fix: crash bugs

This commit is contained in:
Akinwale Ariwodola 2020-06-25 20:23:24 +01:00
parent a2b6d4e570
commit 07630ca97b
2 changed files with 23 additions and 6 deletions

View file

@ -60,7 +60,13 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
public ClaimListAdapter(List<Claim> items, Context context) {
this.context = context;
this.items = new ArrayList<>(items);
this.items = new ArrayList<>();
for (Claim item : items) {
if (item != null) {
items.add(item);
}
}
this.selectedItems = new ArrayList<>();
quickClaimIdMap = new HashMap<>();
quickClaimUrlMap = new HashMap<>();
@ -139,7 +145,7 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
public void addItems(List<Claim> claims) {
for (Claim claim : claims) {
if (!items.contains(claim)) {
if (claim != null && !items.contains(claim)) {
items.add(claim);
}
}
@ -149,7 +155,12 @@ public class ClaimListAdapter extends RecyclerView.Adapter<ClaimListAdapter.View
notifyDataSetChanged();
}
public void setItems(List<Claim> claims) {
items = new ArrayList<>(claims);
items = new ArrayList<>();
for (Claim claim : claims) {
if (claim != null) {
items.add(claim);
}
}
notifyDataSetChanged();
}

View file

@ -1678,15 +1678,21 @@ public class FileViewFragment extends BaseFragment implements
}
if (claim.getFile() == null && !claim.isFree()) {
if (!Lbry.SDK_READY) {
Snackbar.make(getView().findViewById(R.id.file_view_global_layout), R.string.sdk_initializing_functionality, Snackbar.LENGTH_LONG).show();
if (root != null) {
Snackbar.make(root.findViewById(R.id.file_view_global_layout),
R.string.sdk_initializing_functionality, Snackbar.LENGTH_LONG).show();
}
restoreMainActionButton();
return;
}
checkAndConfirmPurchaseUrl();
} else {
if (!claim.isPlayable() && !Lbry.SDK_READY) {
Snackbar.make(getView().findViewById(R.id.file_view_global_layout), R.string.sdk_initializing_functionality, Snackbar.LENGTH_LONG).show();
if (claim != null && !claim.isPlayable() && !Lbry.SDK_READY) {
if (root != null) {
Snackbar.make(root.findViewById(R.id.file_view_global_layout),
R.string.sdk_initializing_functionality, Snackbar.LENGTH_LONG).show();
}
restoreMainActionButton();
return;
}