diff --git a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java index d82de0ad..515dabed 100644 --- a/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/findcontent/FileViewFragment.java @@ -480,7 +480,11 @@ public class FileViewFragment extends BaseFragment implements if (files.size() > 0) { claim.setFile(files.get(0)); checkIsFileComplete(); + if (!claim.isPlayable() && !claim.isViewable()) { + showUnsupportedView(); + } } + initialFileLoadDone = true; } @@ -1241,24 +1245,33 @@ public class FileViewFragment extends BaseFragment implements } else { mainActionButton.setText(R.string.download); } + } - if (claim.isFree()) { - if (claim.isPlayable()) { - if (MainActivity.nowPlayingClaim != null && MainActivity.nowPlayingClaim.getClaimId().equalsIgnoreCase(claim.getClaimId())) { - // claim already playing - showExoplayerView(); - playMedia(); - } else { - onMainActionButtonClicked(); - } - } else if (claim.isViewable() && Lbry.SDK_READY) { + if (claim.isFree()) { + if (claim.isPlayable()) { + if (MainActivity.nowPlayingClaim != null && MainActivity.nowPlayingClaim.getClaimId().equalsIgnoreCase(claim.getClaimId())) { + // claim already playing + showExoplayerView(); + playMedia(); + } else { onMainActionButtonClicked(); - } else if (!Lbry.SDK_READY) { - restoreMainActionButton(); } - } else { + } else if (claim.isViewable() && Lbry.SDK_READY) { + onMainActionButtonClicked(); + } else if (!Lbry.SDK_READY) { 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(); @@ -1276,15 +1289,18 @@ public class FileViewFragment extends BaseFragment implements } private void showUnsupportedView() { - getView().findViewById(R.id.file_view_exoplayer_container).setVisibility(View.GONE); - getView().findViewById(R.id.file_view_unsupported_container).setVisibility(View.VISIBLE); - String fileNameString = ""; - if (claim.getFile() != null) { - LbryFile lbryFile = claim.getFile(); - File file = new File(lbryFile.getDownloadPath()); - fileNameString = String.format("\"%s\" ", file.getName()); + View root = getView(); + if (root != null) { + root.findViewById(R.id.file_view_exoplayer_container).setVisibility(View.GONE); + root.findViewById(R.id.file_view_unsupported_container).setVisibility(View.VISIBLE); + String fileNameString = ""; + if (claim.getFile() != null) { + 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() { @@ -1504,6 +1520,7 @@ public class FileViewFragment extends BaseFragment implements private void tryOpenFileOrFileGet() { if (claim != null) { + android.util.Log.d("#HELP", "TryOpenOrGetFile?"); String claimId = claim.getClaimId(); FileListTask task = new FileListTask(claimId, null, new FileListTask.FileListResultHandler() { @Override @@ -1615,6 +1632,7 @@ public class FileViewFragment extends BaseFragment implements private void playOrViewMedia() { boolean handled = false; String mediaType = claim.getMediaType(); + android.util.Log.d("#HELP", "mediaType=" + mediaType); if (!Helper.isNullOrEmpty(mediaType)) { if (claim.isPlayable()) { startTimeMillis = System.currentTimeMillis(); @@ -1667,7 +1685,9 @@ public class FileViewFragment extends BaseFragment implements } } + android.util.Log.d("#HELP", "handled=" + handled); if (!handled) { + android.util.Log.d("#HELP", "showing unsupported view?"); showUnsupportedView(); } } diff --git a/app/src/main/java/io/lbry/browser/ui/library/LibraryFragment.java b/app/src/main/java/io/lbry/browser/ui/library/LibraryFragment.java index f6d7f8b9..efad17ac 100644 --- a/app/src/main/java/io/lbry/browser/ui/library/LibraryFragment.java +++ b/app/src/main/java/io/lbry/browser/ui/library/LibraryFragment.java @@ -314,7 +314,7 @@ public class LibraryFragment extends BaseFragment implements if (contentListAdapter != null) { contentListAdapter.setHideFee(true); contentListAdapter.clearItems(); - contentListAdapter.setCanEnterSelectionMode(true); + contentListAdapter.setCanEnterSelectionMode(false); } listReachedEnd = false; @@ -353,7 +353,7 @@ public class LibraryFragment extends BaseFragment implements private void initContentListAdapter(List claims) { contentListAdapter = new ClaimListAdapter(claims, getContext()); - contentListAdapter.setCanEnterSelectionMode(true); + contentListAdapter.setCanEnterSelectionMode(currentFilter == FILTER_DOWNLOADS); contentListAdapter.setSelectionModeListener(this); contentListAdapter.setHideFee(currentFilter != FILTER_PURCHASES); contentListAdapter.setListener(new ClaimListAdapter.ClaimListItemListener() { diff --git a/app/src/main/java/io/lbry/browser/utils/Helper.java b/app/src/main/java/io/lbry/browser/utils/Helper.java index 01aec06b..0535eb5a 100644 --- a/app/src/main/java/io/lbry/browser/utils/Helper.java +++ b/app/src/main/java/io/lbry/browser/utils/Helper.java @@ -322,7 +322,7 @@ public final class Helper { } public static String getValue(CharSequence cs) { - return cs != null ? cs.toString() : ""; + return cs != null ? cs.toString().trim() : ""; } public static List buildContentSortOrder(int sortBy) {