Clean code after Benoit's review #2

This commit is contained in:
ganfra 2020-01-15 14:57:21 +01:00
parent 7c0f2d6e32
commit b44ddcfd61
8 changed files with 28 additions and 22 deletions

View file

@ -38,8 +38,8 @@ internal abstract class ProfileModule {
}
@Binds
abstract fun bindProfileService(userService: DefaultProfileService): ProfileService
abstract fun bindProfileService(service: DefaultProfileService): ProfileService
@Binds
abstract fun bindGetProfileTask(getProfileInfoTask: DefaultGetProfileInfoTask): GetProfileInfoTask
abstract fun bindGetProfileTask(task: DefaultGetProfileInfoTask): GetProfileInfoTask
}

View file

@ -125,7 +125,13 @@
<data android:host="matrix.to" />
</intent-filter>
</activity>
<activity android:name=".features.roommemberprofile.RoomMemberProfileActivity" />
<activity android:name=".features.roommemberprofile.RoomMemberProfileActivity"
android:parentActivityName=".features.home.HomeActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".features.home.HomeActivity" />
</activity>
<!-- Services -->

View file

@ -30,7 +30,7 @@ import im.vector.riotx.core.extensions.setTextOrHide
import im.vector.riotx.features.themes.ThemeUtils
@EpoxyModelClass(layout = R.layout.item_profile_action)
abstract class ProfileItemAction : VectorEpoxyModel<ProfileItemAction.Holder>() {
abstract class ProfileActionItem : VectorEpoxyModel<ProfileActionItem.Holder>() {
@EpoxyAttribute
lateinit var title: String

View file

@ -22,7 +22,7 @@ import com.airbnb.epoxy.EpoxyController
import im.vector.riotx.core.epoxy.DividerItem_
fun EpoxyController.buildProfileSection(title: String) {
profileItemSection {
profileSectionItem {
id("section_$title")
title(title)
}
@ -38,7 +38,7 @@ fun EpoxyController.buildProfileAction(
divider: Boolean = true,
action: () -> Unit
) {
profileItemAction {
profileActionItem {
iconRes(icon)
id("action_$id")
subtitle(subtitle)

View file

@ -24,7 +24,7 @@ import im.vector.riotx.core.epoxy.VectorEpoxyHolder
import im.vector.riotx.core.epoxy.VectorEpoxyModel
@EpoxyModelClass(layout = R.layout.item_profile_section)
abstract class ProfileItemSection: VectorEpoxyModel<ProfileItemSection.Holder>() {
abstract class ProfileSectionItem: VectorEpoxyModel<ProfileSectionItem.Holder>() {
@EpoxyAttribute
lateinit var title: String

View file

@ -64,8 +64,6 @@ class RoomListQuickActionsEpoxyController @Inject constructor(private val avatar
id("leave_separator")
}
RoomListQuickActionsSharedAction.Leave(roomSummary.roomId).toBottomSheetItem(5)
// Leave
}
}

View file

@ -56,16 +56,9 @@ class DefaultNavigator @Inject constructor(
fatalError("Trying to open an unknown room $roomId", vectorPreferences.failFast())
return
}
val args = RoomDetailArgs(roomId, eventId)
val intent = RoomDetailActivity.newIntent(context, args)
if (buildTask) {
val stackBuilder = TaskStackBuilder.create(context)
stackBuilder.addNextIntentWithParentStack(intent)
stackBuilder.startActivities()
} else {
context.startActivity(intent)
}
startActivity(context, intent, buildTask)
}
override fun openNotJoinedRoom(context: Context, roomIdOrAlias: String?, eventId: String?, buildTask: Boolean) {
@ -86,7 +79,8 @@ class DefaultNavigator @Inject constructor(
override fun openRoomMemberProfile(userId: String, roomId: String?, context: Context, buildTask: Boolean) {
val args = RoomMemberProfileArgs(userId = userId, roomId = roomId)
context.startActivity(RoomMemberProfileActivity.newIntent(context, args))
val intent = RoomMemberProfileActivity.newIntent(context, args)
startActivity(context, intent, buildTask)
}
override fun openRoomForSharing(activity: Activity, roomId: String, sharedData: SharedData) {
@ -141,4 +135,14 @@ class DefaultNavigator @Inject constructor(
override fun openRoomProfile(context: Context, roomId: String) {
context.startActivity(RoomProfileActivity.newIntent(context, roomId))
}
private fun startActivity(context: Context, intent: Intent, buildTask: Boolean) {
if (buildTask) {
val stackBuilder = TaskStackBuilder.create(context)
stackBuilder.addNextIntentWithParentStack(intent)
stackBuilder.startActivities()
} else {
context.startActivity(intent)
}
}
}

View file

@ -15,8 +15,6 @@
*
*/
@file:Suppress("DEPRECATION")
package im.vector.riotx.features.roommemberprofile
import android.os.Bundle
@ -80,8 +78,8 @@ class RoomMemberProfileFragment @Inject constructor(
.subscribe {
dismissLoadingDialog()
when (it) {
is RoomMemberProfileViewEvents.Loading -> showLoadingDialog(it.message)
is RoomMemberProfileViewEvents.Failure -> showErrorInSnackbar(it.throwable)
is RoomMemberProfileViewEvents.Loading -> showLoadingDialog(it.message)
is RoomMemberProfileViewEvents.Failure -> showErrorInSnackbar(it.throwable)
}
}
.disposeOnDestroyView()