diff options
| author | Harsh Shandilya <msfjarvis@gmail.com> | 2020-06-12 14:58:15 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-12 20:28:15 +0530 |
| commit | d8231e112afb501c43041a6f839ab8285f400f77 (patch) | |
| tree | 6785a8d0c6a70a3017ce5d62fe6b8234d5564f07 /app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt | |
| parent | bf33fb2c88a208931340201e95a524b274d70b31 (diff) | |
| download | HardenedPass-d8231e112afb501c43041a6f839ab8285f400f77.tar.gz HardenedPass-d8231e112afb501c43041a6f839ab8285f400f77.zip | |
Break down PGP Activity into focused sections (#776)
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt')
| -rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt index 3553d431..860d8459 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.kt @@ -16,31 +16,32 @@ import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.SearchView import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView import com.google.android.material.floatingactionbutton.FloatingActionButton import com.zeapo.pwdstore.R +import com.zeapo.pwdstore.databinding.AutofillRecyclerViewBinding +import com.zeapo.pwdstore.utils.viewBinding import me.zhanghai.android.fastscroll.FastScrollerBuilder import java.lang.ref.WeakReference import java.util.ArrayList class AutofillPreferenceActivity : AppCompatActivity() { + private val binding by viewBinding(AutofillRecyclerViewBinding::inflate) internal var recyclerAdapter: AutofillRecyclerAdapter? = null // let fragment have access - private var recyclerView: RecyclerView? = null private var pm: PackageManager? = null private var recreate: Boolean = false // flag for action on up press; origin autofill dialog? different act public override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - - setContentView(R.layout.autofill_recycler_view) - recyclerView = findViewById(R.id.autofill_recycler) + setContentView(binding.root) val layoutManager = LinearLayoutManager(this) - recyclerView!!.layoutManager = layoutManager - recyclerView!!.addItemDecoration(DividerItemDecoration(this, DividerItemDecoration.VERTICAL)) - FastScrollerBuilder(recyclerView!!).build() + with(binding) { + autofillRecycler.layoutManager = layoutManager + autofillRecycler.addItemDecoration(DividerItemDecoration(this@AutofillPreferenceActivity, DividerItemDecoration.VERTICAL)) + FastScrollerBuilder(autofillRecycler).build() + } pm = packageManager @@ -105,7 +106,7 @@ class AutofillPreferenceActivity : AppCompatActivity() { companion object { private class PopulateTask(activity: AutofillPreferenceActivity) : AsyncTask<Void, Void, Void>() { - val weakReference = WeakReference<AutofillPreferenceActivity>(activity) + val weakReference = WeakReference(activity) override fun onPreExecute() { weakReference.get()?.apply { @@ -140,11 +141,13 @@ class AutofillPreferenceActivity : AppCompatActivity() { override fun onPostExecute(ignored: Void?) { weakReference.get()?.apply { runOnUiThread { - findViewById<View>(R.id.progress_bar).visibility = View.GONE - recyclerView!!.adapter = recyclerAdapter - val extras = intent.extras - if (extras != null) { - recyclerView!!.scrollToPosition(recyclerAdapter!!.getPosition(extras.getString("appName")!!)) + with(binding) { + progressBar.visibility = View.GONE + autofillRecycler.adapter = recyclerAdapter + val extras = intent.extras + if (extras != null) { + autofillRecycler.scrollToPosition(recyclerAdapter!!.getPosition(extras.getString("appName")!!)) + } } } } |
