Skip to content

Commit

Permalink
Clean code after Benoit's review #2
Browse files Browse the repository at this point in the history
  • Loading branch information
ganfra committed Jan 15, 2020
1 parent 7c0f2d6 commit b44ddcf
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
8 changes: 7 additions & 1 deletion vector/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -38,7 +38,7 @@ fun EpoxyController.buildProfileAction(
divider: Boolean = true,
action: () -> Unit
) {
profileItemAction {
profileActionItem {
iconRes(icon)
id("action_$id")
subtitle(subtitle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ class RoomListQuickActionsEpoxyController @Inject constructor(private val avatar
id("leave_separator")
}
RoomListQuickActionsSharedAction.Leave(roomSummary.roomId).toBottomSheetItem(5)

// Leave
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*
*/

@file:Suppress("DEPRECATION")

package im.vector.riotx.features.roommemberprofile

import android.os.Bundle
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit b44ddcf

Please sign in to comment.