mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
Fix updating
This commit is contained in:
parent
ded709a58b
commit
4bfb51e6e2
@ -87,7 +87,7 @@ private class CreatePrivateChatActivityAdapter(val activity: CreatePrivateChatAc
|
|||||||
|
|
||||||
override fun getPageTitle(index: Int): CharSequence? {
|
override fun getPageTitle(index: Int): CharSequence? {
|
||||||
return when (index) {
|
return when (index) {
|
||||||
0 -> "Enter Public Key"
|
0 -> "Enter Session ID"
|
||||||
1 -> "Scan QR Code"
|
1 -> "Scan QR Code"
|
||||||
else -> throw IllegalStateException()
|
else -> throw IllegalStateException()
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,10 @@ package org.thoughtcrime.securesms.loki.redesign.activities
|
|||||||
|
|
||||||
import android.arch.lifecycle.Observer
|
import android.arch.lifecycle.Observer
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.database.Cursor
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.support.v4.app.LoaderManager
|
||||||
|
import android.support.v4.content.Loader
|
||||||
import android.support.v7.widget.LinearLayoutManager
|
import android.support.v7.widget.LinearLayoutManager
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
@ -40,15 +43,27 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
homeAdapter.conversationClickListener = this
|
homeAdapter.conversationClickListener = this
|
||||||
recyclerView.adapter = homeAdapter
|
recyclerView.adapter = homeAdapter
|
||||||
recyclerView.layoutManager = LinearLayoutManager(this)
|
recyclerView.layoutManager = LinearLayoutManager(this)
|
||||||
|
// This is a workaround for the fact that CursorRecyclerViewAdapter doesn't actually auto-update (even though it says it will)
|
||||||
|
LoaderManager.getInstance(this).restartLoader(0, null, object : LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
|
override fun onCreateLoader(id: Int, bundle: Bundle?): Loader<Cursor> {
|
||||||
|
return HomeLoader(this@HomeActivity)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLoadFinished(loader: Loader<Cursor>, cursor: Cursor?) {
|
||||||
|
homeAdapter.changeCursor(cursor)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLoaderReset(cursor: Loader<Cursor>) {
|
||||||
|
homeAdapter.changeCursor(null)
|
||||||
|
}
|
||||||
|
})
|
||||||
// Set up new conversation button
|
// Set up new conversation button
|
||||||
newConversationButton.setOnClickListener { createPrivateChat() }
|
newConversationButton.setOnClickListener { createPrivateChat() }
|
||||||
// Set up typing observer
|
// Set up typing observer
|
||||||
ApplicationContext.getInstance(this).typingStatusRepository.typingThreads.observe(this, object : Observer<Set<Long>> {
|
ApplicationContext.getInstance(this).typingStatusRepository.typingThreads.observe(this, Observer<Set<Long>> { threadIDs ->
|
||||||
|
|
||||||
override fun onChanged(threadIDs: Set<Long>?) {
|
|
||||||
val adapter = recyclerView.adapter as HomeAdapter
|
val adapter = recyclerView.adapter as HomeAdapter
|
||||||
adapter.typingThreadIDs = threadIDs ?: setOf()
|
adapter.typingThreadIDs = threadIDs ?: setOf()
|
||||||
}
|
|
||||||
})
|
})
|
||||||
// Set up public chats and RSS feeds if needed
|
// Set up public chats and RSS feeds if needed
|
||||||
if (TextSecurePreferences.getLocalNumber(this) != null) {
|
if (TextSecurePreferences.getLocalNumber(this) != null) {
|
||||||
@ -68,7 +83,7 @@ class HomeActivity : PassphraseRequiredActionBarActivity, ConversationClickListe
|
|||||||
|
|
||||||
// region Interaction
|
// region Interaction
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
val id = item.getItemId()
|
val id = item.itemId
|
||||||
when (id) {
|
when (id) {
|
||||||
R.id.joinPublicChatItem -> joinPublicChat()
|
R.id.joinPublicChatItem -> joinPublicChat()
|
||||||
else -> { /* Do nothing */ }
|
else -> { /* Do nothing */ }
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package org.thoughtcrime.securesms.loki.redesign.activities
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.database.Cursor
|
||||||
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
|
import org.thoughtcrime.securesms.util.AbstractCursorLoader
|
||||||
|
|
||||||
|
class HomeLoader(context: Context) : AbstractCursorLoader(context) {
|
||||||
|
|
||||||
|
override fun getCursor(): Cursor {
|
||||||
|
return DatabaseFactory.getThreadDatabase(context).conversationList
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user