Cache activity result if provider isn't ready yet
This commit is contained in:
parent
ec4e704c32
commit
f0c438e2d4
1 changed files with 14 additions and 2 deletions
|
@ -42,6 +42,7 @@ public class OpenPgpKeyPreference extends Preference implements OpenPgpApiManage
|
|||
private long keyId;
|
||||
private String defaultUserId;
|
||||
private OpenPgpApiManager openPgpApiManager;
|
||||
private Intent cachedActivityResultData;
|
||||
|
||||
private PendingIntent pendingIntentSelectKey;
|
||||
private boolean pendingIntentRunImmediately;
|
||||
|
@ -111,7 +112,13 @@ public class OpenPgpKeyPreference extends Preference implements OpenPgpApiManage
|
|||
}
|
||||
|
||||
private void apiRetrievePendingIntentAndKeyInfo() {
|
||||
Intent data = new Intent();
|
||||
Intent data;
|
||||
if (cachedActivityResultData != null) {
|
||||
data = cachedActivityResultData;
|
||||
cachedActivityResultData = null;
|
||||
} else {
|
||||
data = new Intent();
|
||||
}
|
||||
apiRetrievePendingIntentAndKeyInfo(data);
|
||||
}
|
||||
|
||||
|
@ -294,7 +301,12 @@ public class OpenPgpKeyPreference extends Preference implements OpenPgpApiManage
|
|||
return true;
|
||||
case REQUEST_CODE_KEY_PREFERENCE:
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
apiRetrievePendingIntentAndKeyInfo(data);
|
||||
cachedActivityResultData = data;
|
||||
// this might happen early in the lifecycle (e.g. before onResume). if the provider isn't connected
|
||||
// here, apiRetrievePendingIntentAndKeyInfo() will be called as soon as it is.
|
||||
if (openPgpApiManager.getOpenPgpProviderState() == OpenPgpProviderState.OK) {
|
||||
apiRetrievePendingIntentAndKeyInfo();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue