Disable selection mode for purchases. Check additional cases for displaying unsupported content message.

This commit is contained in:
Akinwale Ariwodola 2020-05-25 05:38:25 +01:00
parent 613634adcf
commit d1167e4d2b
3 changed files with 44 additions and 24 deletions

View file

@ -480,7 +480,11 @@ public class FileViewFragment extends BaseFragment implements
if (files.size() > 0) { if (files.size() > 0) {
claim.setFile(files.get(0)); claim.setFile(files.get(0));
checkIsFileComplete(); checkIsFileComplete();
if (!claim.isPlayable() && !claim.isViewable()) {
showUnsupportedView();
}
} }
initialFileLoadDone = true; initialFileLoadDone = true;
} }
@ -1241,24 +1245,33 @@ public class FileViewFragment extends BaseFragment implements
} else { } else {
mainActionButton.setText(R.string.download); mainActionButton.setText(R.string.download);
} }
}
if (claim.isFree()) { if (claim.isFree()) {
if (claim.isPlayable()) { if (claim.isPlayable()) {
if (MainActivity.nowPlayingClaim != null && MainActivity.nowPlayingClaim.getClaimId().equalsIgnoreCase(claim.getClaimId())) { if (MainActivity.nowPlayingClaim != null && MainActivity.nowPlayingClaim.getClaimId().equalsIgnoreCase(claim.getClaimId())) {
// claim already playing // claim already playing
showExoplayerView(); showExoplayerView();
playMedia(); playMedia();
} else { } else {
onMainActionButtonClicked();
}
} else if (claim.isViewable() && Lbry.SDK_READY) {
onMainActionButtonClicked(); onMainActionButtonClicked();
} else if (!Lbry.SDK_READY) {
restoreMainActionButton();
} }
} else { } else if (claim.isViewable() && Lbry.SDK_READY) {
onMainActionButtonClicked();
} else if (!Lbry.SDK_READY) {
restoreMainActionButton(); restoreMainActionButton();
} }
} else {
restoreMainActionButton();
}
if (Lbry.SDK_READY && !claim.isPlayable() && !claim.isViewable()) {
if (claim.getFile() == null) {
loadFile();
} else {
// file already loaded, but it's unsupported
showUnsupportedView();
}
} }
checkRewardsDriver(); checkRewardsDriver();
@ -1276,15 +1289,18 @@ public class FileViewFragment extends BaseFragment implements
} }
private void showUnsupportedView() { private void showUnsupportedView() {
getView().findViewById(R.id.file_view_exoplayer_container).setVisibility(View.GONE); View root = getView();
getView().findViewById(R.id.file_view_unsupported_container).setVisibility(View.VISIBLE); if (root != null) {
String fileNameString = ""; root.findViewById(R.id.file_view_exoplayer_container).setVisibility(View.GONE);
if (claim.getFile() != null) { root.findViewById(R.id.file_view_unsupported_container).setVisibility(View.VISIBLE);
LbryFile lbryFile = claim.getFile(); String fileNameString = "";
File file = new File(lbryFile.getDownloadPath()); if (claim.getFile() != null) {
fileNameString = String.format("\"%s\" ", file.getName()); LbryFile lbryFile = claim.getFile();
File file = new File(lbryFile.getDownloadPath());
fileNameString = String.format("\"%s\" ", file.getName());
}
((TextView) root.findViewById(R.id.file_view_unsupported_text)).setText(getString(R.string.unsupported_content_desc, fileNameString));
} }
((TextView) getView().findViewById(R.id.file_view_unsupported_text)).setText(getString(R.string.unsupported_content_desc, fileNameString));
} }
private void showExoplayerView() { private void showExoplayerView() {
@ -1504,6 +1520,7 @@ public class FileViewFragment extends BaseFragment implements
private void tryOpenFileOrFileGet() { private void tryOpenFileOrFileGet() {
if (claim != null) { if (claim != null) {
android.util.Log.d("#HELP", "TryOpenOrGetFile?");
String claimId = claim.getClaimId(); String claimId = claim.getClaimId();
FileListTask task = new FileListTask(claimId, null, new FileListTask.FileListResultHandler() { FileListTask task = new FileListTask(claimId, null, new FileListTask.FileListResultHandler() {
@Override @Override
@ -1615,6 +1632,7 @@ public class FileViewFragment extends BaseFragment implements
private void playOrViewMedia() { private void playOrViewMedia() {
boolean handled = false; boolean handled = false;
String mediaType = claim.getMediaType(); String mediaType = claim.getMediaType();
android.util.Log.d("#HELP", "mediaType=" + mediaType);
if (!Helper.isNullOrEmpty(mediaType)) { if (!Helper.isNullOrEmpty(mediaType)) {
if (claim.isPlayable()) { if (claim.isPlayable()) {
startTimeMillis = System.currentTimeMillis(); startTimeMillis = System.currentTimeMillis();
@ -1667,7 +1685,9 @@ public class FileViewFragment extends BaseFragment implements
} }
} }
android.util.Log.d("#HELP", "handled=" + handled);
if (!handled) { if (!handled) {
android.util.Log.d("#HELP", "showing unsupported view?");
showUnsupportedView(); showUnsupportedView();
} }
} }

View file

@ -314,7 +314,7 @@ public class LibraryFragment extends BaseFragment implements
if (contentListAdapter != null) { if (contentListAdapter != null) {
contentListAdapter.setHideFee(true); contentListAdapter.setHideFee(true);
contentListAdapter.clearItems(); contentListAdapter.clearItems();
contentListAdapter.setCanEnterSelectionMode(true); contentListAdapter.setCanEnterSelectionMode(false);
} }
listReachedEnd = false; listReachedEnd = false;
@ -353,7 +353,7 @@ public class LibraryFragment extends BaseFragment implements
private void initContentListAdapter(List<Claim> claims) { private void initContentListAdapter(List<Claim> claims) {
contentListAdapter = new ClaimListAdapter(claims, getContext()); contentListAdapter = new ClaimListAdapter(claims, getContext());
contentListAdapter.setCanEnterSelectionMode(true); contentListAdapter.setCanEnterSelectionMode(currentFilter == FILTER_DOWNLOADS);
contentListAdapter.setSelectionModeListener(this); contentListAdapter.setSelectionModeListener(this);
contentListAdapter.setHideFee(currentFilter != FILTER_PURCHASES); contentListAdapter.setHideFee(currentFilter != FILTER_PURCHASES);
contentListAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() { contentListAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() {

View file

@ -322,7 +322,7 @@ public final class Helper {
} }
public static String getValue(CharSequence cs) { public static String getValue(CharSequence cs) {
return cs != null ? cs.toString() : ""; return cs != null ? cs.toString().trim() : "";
} }
public static List<String> buildContentSortOrder(int sortBy) { public static List<String> buildContentSortOrder(int sortBy) {