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