allow progress message to be set later

This commit is contained in:
Adithya Abraham Philip 2015-06-23 20:20:13 +05:30
parent 90848a2af7
commit be53c3e564
2 changed files with 14 additions and 5 deletions

View File

@ -63,6 +63,11 @@ public abstract class CryptoOperationFragment<T extends Parcelable, S extends Op
mOperationHelper = new CryptoOperationHelper<>(this, callback);
}
public void setProgressMessageResource(int id) {
mOperationHelper.setProgressMessageResource(id);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
mOperationHelper.handleActivityResult(requestCode, resultCode, data);

View File

@ -67,7 +67,7 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
// otherwise all CryptoOperationHandlers may respond to the same onActivityResult
private int mRequestedCode = -1;
private int mProgressMessageString;
private int mProgressMessageResource;
private FragmentActivity mActivity;
private Fragment mFragment;
@ -84,7 +84,7 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
mActivity = activity;
mUseFragment = false;
mCallback = callback;
mProgressMessageString = progressMessageString;
mProgressMessageResource = progressMessageString;
}
/**
@ -95,7 +95,7 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
public CryptoOperationHelper(Fragment fragment, Callback<T, S> callback, int progressMessageString) {
mFragment = fragment;
mUseFragment = true;
mProgressMessageString = progressMessageString;
mProgressMessageResource = progressMessageString;
mCallback = callback;
}
@ -107,10 +107,14 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
public CryptoOperationHelper(Fragment fragment, Callback<T, S> callback) {
mFragment = fragment;
mUseFragment = true;
mProgressMessageString = R.string.progress_building_key;
mProgressMessageResource = R.string.progress_building_key;
mCallback = callback;
}
public void setProgressMessageResource(int id) {
mProgressMessageResource = id;
}
private void initiateInputActivity(RequiredInputParcel requiredInput) {
Activity activity = mUseFragment ? mFragment.getActivity() : mActivity;
@ -254,7 +258,7 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
};
saveHandler.showProgressDialog(
activity.getString(mProgressMessageString),
activity.getString(mProgressMessageResource),
ProgressDialog.STYLE_HORIZONTAL, false);
// Create a new Messenger for the communication back