Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
moezbhatti committed Jan 12, 2020
1 parent 57ce854 commit be741c0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ class ActiveConversationManagerImpl @Inject constructor() : ActiveConversationMa
return threadId
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ interface ActiveConversationManager {

fun getActiveConversation(): Long?

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.moez.QKSMS.common.Navigator
import com.moez.QKSMS.common.base.QkViewModel
import com.moez.QKSMS.common.util.BillingManager
import com.moez.QKSMS.common.util.ClipboardUtils
import com.moez.QKSMS.common.util.Colors
import com.moez.QKSMS.common.util.MessageDetailsFormatter
import com.moez.QKSMS.common.util.extensions.makeToast
import com.moez.QKSMS.compat.SubscriptionManagerCompat
Expand Down Expand Up @@ -78,7 +77,6 @@ class ComposeViewModel @Inject constructor(
@Named("addresses") private val addresses: List<String>,
@Named("text") private val sharedText: String,
@Named("attachments") private val sharedAttachments: Attachments,
private val colors: Colors,
private val contactRepo: ContactRepository,
private val context: Context,
private val activeConversationManager: ActiveConversationManager,
Expand Down Expand Up @@ -449,21 +447,22 @@ class ComposeViewModel @Inject constructor(
.subscribe { message -> cancelMessage.execute(message.id) }

// Set the current conversation
Observables.combineLatest(
view.activityVisibleIntent.distinctUntilChanged(),
conversation.mapNotNull { conversation ->
conversation.takeIf { it.isValid }?.id
}.distinctUntilChanged())
{ visible, threadId ->
when (visible) {
true -> {
activeConversationManager.setActiveConversation(threadId)
markRead.execute(listOf(threadId))
}
Observables
.combineLatest(
view.activityVisibleIntent.distinctUntilChanged(),
conversation.mapNotNull { conversation ->
conversation.takeIf { it.isValid }?.id
}.distinctUntilChanged())
{ visible, threadId ->
when (visible) {
true -> {
activeConversationManager.setActiveConversation(threadId)
markRead.execute(listOf(threadId))
}

false -> activeConversationManager.setActiveConversation(null)
}
}
false -> activeConversationManager.setActiveConversation(null)
}
}
.autoDisposable(view.scope())
.subscribe()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ class ConversationsAdapter @Inject constructor(
private val phoneNumberUtils: PhoneNumberUtils
) : QkRealmAdapter<Conversation>() {

init {
setHasStableIds(true)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QkViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)
val view = layoutInflater.inflate(R.layout.conversation_list_item, parent, false)
Expand Down Expand Up @@ -113,10 +109,6 @@ class ConversationsAdapter @Inject constructor(
holder.unread.setTint(colors.theme(recipient).theme)
}

override fun getItemId(index: Int): Long {
return getItem(index)!!.id
}

override fun getItemViewType(position: Int): Int {
return if (getItem(position)?.unread == false) 0 else 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.snackbar.Snackbar
import com.jakewharton.rxbinding2.view.clicks
import com.jakewharton.rxbinding2.widget.textChanges
Expand Down Expand Up @@ -150,8 +149,8 @@ class MainActivity : QkThemedActivity(), MainView {
homeIntent.onNext(Unit)
}

recyclerView.setHasFixedSize(true)
recyclerView.layoutManager = LinearLayoutManager(this)
itemTouchCallback.adapter = conversationsAdapter
conversationsAdapter.autoScrollToStart(recyclerView)

// Don't allow clicks to pass through the drawer layout
drawer.clicks().autoDisposable(scope()).subscribe()
Expand All @@ -161,8 +160,10 @@ class MainActivity : QkThemedActivity(), MainView {
.autoDisposable(scope())
.subscribe { theme ->
// Set the color for the drawer icons
val states = arrayOf(intArrayOf(android.R.attr.state_activated),
val states = arrayOf(
intArrayOf(android.R.attr.state_activated),
intArrayOf(-android.R.attr.state_activated))

resolveThemeColor(android.R.attr.textColorSecondary)
.let { textSecondary -> ColorStateList(states, intArrayOf(theme.theme, textSecondary)) }
.let { tintList ->
Expand All @@ -185,9 +186,6 @@ class MainActivity : QkThemedActivity(), MainView {
compose.setTint(theme.textPrimary)
}

itemTouchCallback.adapter = conversationsAdapter
conversationsAdapter.autoScrollToStart(recyclerView)

// These theme attributes don't apply themselves on API 21
if (Build.VERSION.SDK_INT <= 22) {
toolbarSearch.setBackgroundTint(resolveThemeColor(R.attr.bubbleColor))
Expand Down Expand Up @@ -286,10 +284,11 @@ class MainActivity : QkThemedActivity(), MainView {
inbox.isActivated = state.page is Inbox
archived.isActivated = state.page is Archived

if (drawerLayout.isDrawerOpen(GravityCompat.START) && !state.drawerOpen) drawerLayout.closeDrawer(
GravityCompat.START)
else if (!drawerLayout.isDrawerVisible(GravityCompat.START) && state.drawerOpen) drawerLayout.openDrawer(
GravityCompat.START)
if (drawerLayout.isDrawerOpen(GravityCompat.START) && !state.drawerOpen) {
drawerLayout.closeDrawer(GravityCompat.START)
} else if (!drawerLayout.isDrawerVisible(GravityCompat.START) && state.drawerOpen) {
drawerLayout.openDrawer(GravityCompat.START)
}

when (state.syncing) {
is SyncRepository.SyncProgress.Idle -> {
Expand Down
1 change: 1 addition & 0 deletions presentation/src/main/res/layout/main_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
android:clipToPadding="false"
android:paddingTop="8dp"
android:paddingBottom="8dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toTopOf="@id/bottom"
app:layout_constraintTop_toBottomOf="@id/toolbar"
tools:listitem="@layout/conversation_list_item" />
Expand Down

0 comments on commit be741c0

Please sign in to comment.