diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-07-08 03:34:53 +0200 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-07-08 03:34:53 +0200 |
commit | daa1f5cf8ee92bce0d192d46beb9f3057871afbd (patch) | |
tree | 403048104155e9c0f6bcea3d25b221126c41067e /OpenKeychain/src/main/java/org | |
parent | 5adcb7885cf9629b1ef60b26e76a4c9a8b1f7845 (diff) | |
parent | fed11b26472e8fd2045a31facfd6c555f8bc06b9 (diff) | |
download | open-keychain-daa1f5cf8ee92bce0d192d46beb9f3057871afbd.tar.gz open-keychain-daa1f5cf8ee92bce0d192d46beb9f3057871afbd.tar.bz2 open-keychain-daa1f5cf8ee92bce0d192d46beb9f3057871afbd.zip |
Merge branch 'master' of github.com:open-keychain/open-keychain
Diffstat (limited to 'OpenKeychain/src/main/java/org')
2 files changed, 27 insertions, 6 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java index 6bf6b655d..8db48ae3b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResultParcel.java @@ -9,6 +9,8 @@ import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.Log; import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; /** Represent the result of an operation. * @@ -288,7 +290,7 @@ public class OperationResultParcel implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(mResult); - dest.writeTypedList(mLog); + dest.writeTypedList(mLog.toList()); } public static final Creator<OperationResultParcel> CREATOR = new Creator<OperationResultParcel>() { @@ -301,20 +303,22 @@ public class OperationResultParcel implements Parcelable { } }; - public static class OperationLog extends ArrayList<LogEntryParcel> { + public static class OperationLog implements Iterable<LogEntryParcel> { + + private final List<LogEntryParcel> parcels = new ArrayList<LogEntryParcel>(); /// Simple convenience method public void add(LogLevel level, LogType type, int indent, Object... parameters) { Log.d(Constants.TAG, type.toString()); - add(new OperationResultParcel.LogEntryParcel(level, type, indent, parameters)); + parcels.add(new OperationResultParcel.LogEntryParcel(level, type, indent, parameters)); } public void add(LogLevel level, LogType type, int indent) { - add(new OperationResultParcel.LogEntryParcel(level, type, indent, (Object[]) null)); + parcels.add(new OperationResultParcel.LogEntryParcel(level, type, indent, (Object[]) null)); } public boolean containsWarnings() { - for(LogEntryParcel entry : new IterableIterator<LogEntryParcel>(iterator())) { + for(LogEntryParcel entry : new IterableIterator<LogEntryParcel>(parcels.iterator())) { if (entry.mLevel == LogLevel.WARN || entry.mLevel == LogLevel.ERROR) { return true; } @@ -322,6 +326,22 @@ public class OperationResultParcel implements Parcelable { return false; } + public void addAll(List<LogEntryParcel> parcels) { + parcels.addAll(parcels); + } + + public List<LogEntryParcel> toList() { + return parcels; + } + + public boolean isEmpty() { + return parcels.isEmpty(); + } + + @Override + public Iterator<LogEntryParcel> iterator() { + return parcels.iterator(); + } } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java index 67317de6e..75c967c60 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java @@ -43,6 +43,7 @@ import org.sufficientlysecure.keychain.util.Log; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; public class LogDisplayFragment extends ListFragment implements OnTouchListener { @@ -135,7 +136,7 @@ public class LogDisplayFragment extends ListFragment implements OnTouchListener private LayoutInflater mInflater; private int dipFactor; - public LogAdapter(Context context, ArrayList<LogEntryParcel> log, LogLevel level) { + public LogAdapter(Context context, OperationResultParcel.OperationLog log, LogLevel level) { super(context, R.layout.log_display_item); mInflater = LayoutInflater.from(getContext()); dipFactor = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, |