mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-08-01 03:30:34 +00:00
Update party invitation to show more detail
Show avatar, buttons, group name and group leader name. Avatar and leader name are slow to load, still needs work. WIP
This commit is contained in:
parent
bde4af1b9e
commit
aa40347e32
3 changed files with 68 additions and 4 deletions
|
|
@ -67,6 +67,16 @@ class NoPartyFragmentFragment : BaseMainFragment() {
|
|||
socialRepository.rejectGroupInvite(it).subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
|
||||
invitations_view.setLeader = { leader ->
|
||||
compositeSubscription.add(
|
||||
socialRepository.getMember(leader)
|
||||
.subscribe(Consumer {
|
||||
invitations_view.avatarView.setAvatar(it)
|
||||
invitations_view.textView.text = getString(R.string.invitation_title,it.displayName,invitations_view.groupName)
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
)
|
||||
}
|
||||
|
||||
username_textview.setOnClickListener {
|
||||
val clipboard = context?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||
val clip = ClipData.newPlainText(context?.getString(R.string.username), user?.username)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.habitrpg.android.habitica.models.members.Member
|
|||
import com.habitrpg.android.habitica.models.social.Group
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.modules.AppModule
|
||||
import com.habitrpg.android.habitica.ui.AvatarView
|
||||
import com.habitrpg.android.habitica.ui.activities.FullProfileActivity
|
||||
import com.habitrpg.android.habitica.ui.activities.MainActivity
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseFragment
|
||||
|
|
@ -43,7 +44,7 @@ import kotlinx.coroutines.launch
|
|||
import net.pherth.android.emoji_library.EmojiEditText
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Named
|
||||
|
||||
import kotlinx.android.synthetic.main.fragment_party_detail.invitations_view
|
||||
|
||||
class PartyDetailFragment : BaseFragment() {
|
||||
|
||||
|
|
@ -61,6 +62,8 @@ class PartyDetailFragment : BaseFragment() {
|
|||
private val refreshLayout: androidx.swiperefreshlayout.widget.SwipeRefreshLayout? by bindView(R.id.refreshLayout)
|
||||
private val partyInvitationWrapper: ViewGroup? by bindView(R.id.party_invitation_wrapper)
|
||||
private val invitationsView: InvitationsView? by bindView(R.id.invitations_view)
|
||||
private val inviteLeaderAvatarView: AvatarView? by bindView(R.id.groupleader_avatar_view)
|
||||
private val inviteLeaderTextView: TextView? by bindView(R.id.groupleader_text_view)
|
||||
private val titleView: TextView? by bindView(R.id.title_view)
|
||||
private val descriptionView: TextView? by bindView(R.id.description_view)
|
||||
private val newQuestButton: Button? by bindView(R.id.new_quest_button)
|
||||
|
|
@ -104,6 +107,19 @@ class PartyDetailFragment : BaseFragment() {
|
|||
questDetailButton?.setOnClickListener { questDetailButtonClicked() }
|
||||
leaveButton?.setOnClickListener { leaveParty() }
|
||||
|
||||
invitationsView?.setLeader = null
|
||||
|
||||
// this attempt flickers to show populated views, then goes back to placeholders
|
||||
// invitations_view.setLeader = {
|
||||
// compositeSubscription.add(
|
||||
// socialRepository.getMember(it)
|
||||
// .subscribe(Consumer {
|
||||
// inviteLeaderAvatarView?.setAvatar(it)
|
||||
// inviteLeaderTextView?.text = getString(R.string.invitation_title,it.displayName, invitationsView?.groupName)
|
||||
// }, RxErrorHandler.handleEmptyError())
|
||||
// )
|
||||
// }
|
||||
|
||||
invitationsView?.acceptCall = {
|
||||
viewModel?.joinGroup(it) {
|
||||
compositeSubscription.add(userRepository.retrieveUser(false)
|
||||
|
|
@ -187,7 +203,30 @@ class PartyDetailFragment : BaseFragment() {
|
|||
|
||||
if ((user.invitations?.parties?.count() ?: 0) > 0) {
|
||||
partyInvitationWrapper?.visibility = View.VISIBLE
|
||||
user.invitations?.parties?.let { invitationsView?.setInvitations(it) }
|
||||
user.invitations?.parties?.let {
|
||||
for (invitation in it){
|
||||
val leaderID = invitation.inviter
|
||||
val groupName = invitation.name
|
||||
|
||||
leaderID.let {
|
||||
compositeSubscription.add(
|
||||
socialRepository.getMember(it)
|
||||
.subscribe(Consumer {
|
||||
inviteLeaderAvatarView?.setAvatar(it)
|
||||
inviteLeaderTextView?.text = getString(R.string.invitation_title,it.displayName,groupName)
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
)
|
||||
}
|
||||
|
||||
view?.findViewById<Button>(R.id.accept_button)?.setOnClickListener {
|
||||
invitation.id?.let { it1 -> invitations_view.acceptCall?.invoke(it1) }
|
||||
}
|
||||
|
||||
view?.findViewById<Button>(R.id.reject_button)?.setOnClickListener {
|
||||
invitation.id?.let { it1 -> invitations_view.rejectCall?.invoke(it1) }
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
partyInvitationWrapper?.visibility = View.GONE
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import android.widget.TextView
|
|||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.extensions.inflate
|
||||
import com.habitrpg.android.habitica.models.invitations.GenericInvitation
|
||||
import com.habitrpg.android.habitica.ui.AvatarView
|
||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
|
||||
class InvitationsView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||
|
|
@ -15,6 +17,13 @@ class InvitationsView @JvmOverloads constructor(
|
|||
|
||||
var acceptCall: ((String) -> Unit)? = null
|
||||
var rejectCall: ((String) -> Unit)? = null
|
||||
var setLeader: ((String) -> Unit)? = null
|
||||
val avatarView: AvatarView by bindView(R.id.groupleader_avatar_view)
|
||||
val textView: TextView by bindView(R.id.groupleader_text_view)
|
||||
var leaderID: String? = null
|
||||
var groupName: String? = null
|
||||
var leaderName: String? = null
|
||||
val view = inflate(R.layout.view_invitation, true)
|
||||
|
||||
init {
|
||||
orientation = VERTICAL
|
||||
|
|
@ -23,9 +32,15 @@ class InvitationsView @JvmOverloads constructor(
|
|||
fun setInvitations(invitations: List<GenericInvitation>) {
|
||||
removeAllViews()
|
||||
for (invitation in invitations) {
|
||||
leaderID = invitation.inviter
|
||||
groupName = invitation.name
|
||||
val view = inflate(R.layout.view_invitation, true)
|
||||
val textView = view.findViewById<TextView>(R.id.text_view)
|
||||
textView.text = context.getString(R.string.invitation_title, context.getString(R.string.someone), invitation.name)
|
||||
|
||||
leaderID?.let {
|
||||
setLeader?.invoke(it)
|
||||
invalidate()
|
||||
}
|
||||
|
||||
view.findViewById<Button>(R.id.accept_button).setOnClickListener {
|
||||
invitation.id?.let { it1 -> acceptCall?.invoke(it1) }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue