Open dialog immediately at activity oncreate, can't open it after asynctask (potential illegalstateexception)
This commit is contained in:
parent
68e1495ef2
commit
394a549f7e
2 changed files with 13 additions and 10 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue