aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BaseOperation.java
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-10-10 19:59:25 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-10-10 19:59:25 +0200
commitfe981e54989c47ae252a4dfdc2aa41aab295cc7e (patch)
treea1d1400b6f57154b2df596ef9afc37dae0486d8d /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BaseOperation.java
parentee00894e271a8f86d1710e7585eea13857533019 (diff)
downloadopen-keychain-fe981e54989c47ae252a4dfdc2aa41aab295cc7e.tar.gz
open-keychain-fe981e54989c47ae252a4dfdc2aa41aab295cc7e.tar.bz2
open-keychain-fe981e54989c47ae252a4dfdc2aa41aab295cc7e.zip
move around package structure a bit
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BaseOperation.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BaseOperation.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BaseOperation.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BaseOperation.java
new file mode 100644
index 000000000..01889ed82
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/BaseOperation.java
@@ -0,0 +1,55 @@
+package org.sufficientlysecure.keychain.operations;
+
+import android.content.Context;
+
+import org.sufficientlysecure.keychain.pgp.Progressable;
+import org.sufficientlysecure.keychain.provider.ProviderHelper;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+public class BaseOperation {
+
+ final public Context mContext;
+ final public Progressable mProgressable;
+ final public AtomicBoolean mCancelled;
+
+ final public ProviderHelper mProviderHelper;
+
+ // TODO do we really need the context in these operations?
+ public BaseOperation(Context context, ProviderHelper providerHelper, Progressable progressable) {
+ this.mContext = context;
+ this.mProgressable = progressable;
+ this.mProviderHelper = providerHelper;
+ mCancelled = null;
+ }
+
+ public BaseOperation(Context context, ProviderHelper providerHelper, Progressable progressable, AtomicBoolean cancelled) {
+ mContext = context;
+ mProgressable = progressable;
+ mProviderHelper = providerHelper;
+ mCancelled = cancelled;
+ }
+
+ public void updateProgress(int message, int current, int total) {
+ if (mProgressable != null) {
+ mProgressable.setProgress(message, current, total);
+ }
+ }
+
+ public void updateProgress(String message, int current, int total) {
+ if (mProgressable != null) {
+ mProgressable.setProgress(message, current, total);
+ }
+ }
+
+ public void updateProgress(int current, int total) {
+ if (mProgressable != null) {
+ mProgressable.setProgress(current, total);
+ }
+ }
+
+ protected boolean checkCancelled() {
+ return mCancelled != null && mCancelled.get();
+ }
+
+}