From 232d81baa8c51b92e07022a1fbd7c3034a7123df Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Thu, 29 Aug 2019 12:15:31 -0500 Subject: [PATCH] Stay at top in the Nodes Dialog. - Add a method to the Nodes Dialog in the Settings, so that the list of nodes always stays at the top and shows the best nodes. --- .../fragments/ImportBrainkeyFragment.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ImportBrainkeyFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ImportBrainkeyFragment.kt index d443d86..28e4b88 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ImportBrainkeyFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/ImportBrainkeyFragment.kt @@ -10,9 +10,11 @@ import android.view.View import android.view.ViewGroup import androidx.appcompat.widget.Toolbar import androidx.navigation.Navigation +import androidx.recyclerview.widget.LinearLayoutManager import com.afollestad.materialdialogs.MaterialDialog import com.afollestad.materialdialogs.callbacks.onDismiss import com.afollestad.materialdialogs.list.customListAdapter +import com.afollestad.materialdialogs.list.getRecyclerView import com.afollestad.materialdialogs.list.listItemsSingleChoice import com.crashlytics.android.Crashlytics import com.jakewharton.rxbinding3.widget.textChanges @@ -66,6 +68,9 @@ class ImportBrainkeyFragment : BaseAccountFragment() { /** Adapter that holds the FullNode list used in the Bitshares nodes modal */ private var nodesAdapter: FullNodesAdapter? = null + // NodesDialog's RecyclerView LayoutManager used to always keep showing the first node of the list. + private var mNodesDialogLinearLayoutManager: LinearLayoutManager? = null + /** Handler that will be used to make recurrent calls to get the latest BitShares block number*/ private val mHandler = Handler() @@ -144,6 +149,8 @@ class ImportBrainkeyFragment : BaseAccountFragment() { .observeOn(AndroidSchedulers.mainThread()) .subscribe( { fullNode -> + mNodesDialogLinearLayoutManager?.scrollToPositionWithOffset(0, 0) + if (!fullNode.isRemoved) nodesAdapter?.add(fullNode) else @@ -164,6 +171,8 @@ class ImportBrainkeyFragment : BaseAccountFragment() { } } + mNodesDialogLinearLayoutManager = (mNodesDialog?.getRecyclerView()?.layoutManager as LinearLayoutManager) + // Registering a recurrent task used to poll for dynamic global properties requests mHandler.post(mRequestDynamicGlobalPropertiesTask) }