ImportKeys: Fix Recyclerview coherence with data
This commit is contained in:
@@ -69,6 +69,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
|
|
||||||
private LoaderState mLoaderState;
|
private LoaderState mLoaderState;
|
||||||
private List<ImportKeysListEntry> mData;
|
private List<ImportKeysListEntry> mData;
|
||||||
|
private boolean[] mDownloaded;
|
||||||
|
|
||||||
public ImportKeysAdapter(FragmentActivity activity, ImportKeysListener listener, boolean mNonInteractive) {
|
public ImportKeysAdapter(FragmentActivity activity, ImportKeysListener listener, boolean mNonInteractive) {
|
||||||
this.mActivity = activity;
|
this.mActivity = activity;
|
||||||
@@ -82,11 +83,13 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
|
|
||||||
public void setData(List<ImportKeysListEntry> data) {
|
public void setData(List<ImportKeysListEntry> data) {
|
||||||
this.mData = data;
|
this.mData = data;
|
||||||
|
this.mDownloaded = new boolean[data.size()];
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearData() {
|
public void clearData() {
|
||||||
mData = null;
|
mData = null;
|
||||||
|
mDownloaded = null;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,11 +178,11 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
b.expand.setOnClickListener(new View.OnClickListener() {
|
b.expand.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
boolean hidden = b.extraContainer.getVisibility() == View.GONE;
|
boolean downloaded = mDownloaded[position] = !mDownloaded[position];
|
||||||
b.extraContainer.setVisibility(hidden ? View.VISIBLE : View.GONE);
|
b.extraContainer.setVisibility(downloaded ? View.VISIBLE : View.GONE);
|
||||||
b.expand.animate().rotation(hidden ? 180 : 0).start();
|
b.expand.animate().rotation(downloaded ? 180 : 0).start();
|
||||||
|
|
||||||
if (hidden) {
|
if (downloaded) {
|
||||||
if (mLoaderState instanceof BytesLoaderState) {
|
if (mLoaderState instanceof BytesLoaderState) {
|
||||||
getKey(new ParcelableKeyRing(entry.getEncodedRing()));
|
getKey(new ParcelableKeyRing(entry.getEncodedRing()));
|
||||||
} else if (mLoaderState instanceof CloudLoaderState) {
|
} else if (mLoaderState instanceof CloudLoaderState) {
|
||||||
@@ -190,6 +193,9 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
b.extraContainer.setVisibility(mDownloaded[position] ? View.VISIBLE : View.GONE);
|
||||||
|
b.expand.setRotation(mDownloaded[position] ? 180 : 0);
|
||||||
|
|
||||||
b.userIdsList.setVisibility(entry.getUserIds().size() == 1 ? View.GONE : View.VISIBLE);
|
b.userIdsList.setVisibility(entry.getUserIds().size() == 1 ? View.GONE : View.VISIBLE);
|
||||||
// destroyLoader view from holder
|
// destroyLoader view from holder
|
||||||
b.userIdsList.removeAllViews();
|
b.userIdsList.removeAllViews();
|
||||||
@@ -302,7 +308,7 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleResult(ImportKeyResult result) {
|
public void handleResult(ImportKeyResult result) {
|
||||||
boolean resultStatus = result.isOkBoth();
|
boolean resultStatus = result.success();
|
||||||
Log.e(Constants.TAG, "getKey result: " + resultStatus);
|
Log.e(Constants.TAG, "getKey result: " + resultStatus);
|
||||||
if (resultStatus) {
|
if (resultStatus) {
|
||||||
ArrayList<CanonicalizedKeyRing> canKeyRings = result.mCanonicalizedKeyRings;
|
ArrayList<CanonicalizedKeyRing> canKeyRings = result.mCanonicalizedKeyRings;
|
||||||
|
|||||||
@@ -87,7 +87,8 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_centerVertical="true" />
|
android:layout_centerVertical="true"
|
||||||
|
android:visibility="@{revoked || expired ? View.VISIBLE : View.GONE}" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user