aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Wong <wongma7@outlook.com>2015-09-15 23:54:17 -0400
committerMatthew Wong <wongma7@outlook.com>2015-09-15 23:54:17 -0400
commit394a549f7e8aa5b656ba847a03938a34fccc54dd (patch)
tree3a810a9a707a2bfa28f625bfdcd5a22dea94f585
parent68e1495ef26645750e111cb7a7299c2b9efd2be3 (diff)
Open dialog immediately at activity oncreate, can't open it after asynctask (potential illegalstateexception)
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java8
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java15
2 files changed, 13 insertions, 10 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java
index e708c19d..5d342f4a 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillFragment.java
@@ -98,11 +98,11 @@ public class AutofillFragment extends DialogFragment {
editor.putString(packageName, path);
}
editor.apply();
- int position = getArguments().getInt("position");
- callingActivity.recyclerAdapter.notifyItemChanged(position);
- if (getArguments().getBoolean("finish")) {
- callingActivity.finish();
+ // if recyclerAdapter has not loaded yet, there is no need to notifyItemChanged
+ if (callingActivity.recyclerAdapter != null) {
+ int position = callingActivity.recyclerAdapter.getPosition(packageName);
+ callingActivity.recyclerAdapter.notifyItemChanged(position);
}
}
});
diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
index 16867bcd..adfce0b1 100644
--- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
+++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillPreferenceActivity.java
@@ -32,7 +32,7 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
private PackageManager pm;
- private boolean recreate;
+ private boolean recreate; // flag for action on up press; origin autofill dialog? different act
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -49,6 +49,14 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
new populateTask().execute();
+ recreate = false;
+ Bundle extras = getIntent().getExtras();
+ if (extras != null) {
+ recreate = true;
+
+ showDialog(extras.getString("packageName"), extras.getString("appName"));
+ }
+
setTitle("Autofill Apps");
}
@@ -79,13 +87,9 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
findViewById(R.id.progress_bar).setVisibility(View.GONE);
recyclerView.setAdapter(recyclerAdapter);
-
- recreate = false;
Bundle extras = getIntent().getExtras();
if (extras != null) {
- recreate = true;
recyclerView.scrollToPosition(recyclerAdapter.getPosition(extras.getString("packageName")));
- showDialog(extras.getString("packageName"), extras.getString("appName"));
}
}
}
@@ -139,7 +143,6 @@ public class AutofillPreferenceActivity extends AppCompatActivity {
Bundle args = new Bundle();
args.putString("packageName", packageName);
args.putString("appName", appName);
- args.putInt("position", recyclerAdapter.getPosition(packageName));
df.setArguments(args);
df.show(getFragmentManager(), "autofill_dialog");
}