Search in sources :

Example 11 with LbryFile

use of com.odysee.app.model.LbryFile in project odysee-android by OdyseeTeam.

the class FileViewFragment method showUnsupportedView.

private void showUnsupportedView() {
    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 = "";
        Claim actualClaim = collectionClaimItem != null ? collectionClaimItem : fileClaim;
        if (actualClaim.getFile() != null && !Helper.isNullOrEmpty(actualClaim.getFile().getDownloadPath())) {
            LbryFile lbryFile = actualClaim.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));
    }
}
Also used : LbryFile(com.odysee.app.model.LbryFile) TextView(android.widget.TextView) SolidIconView(com.odysee.app.ui.controls.SolidIconView) PlayerView(com.google.android.exoplayer2.ui.PlayerView) NestedScrollView(androidx.core.widget.NestedScrollView) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) File(java.io.File) LbryFile(com.odysee.app.model.LbryFile) Claim(com.odysee.app.model.Claim)

Example 12 with LbryFile

use of com.odysee.app.model.LbryFile in project odysee-android by OdyseeTeam.

the class FollowingFragment method onDownloadAction.

public void onDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress) {
    if ("abort".equals(downloadAction)) {
        if (contentListAdapter != null) {
            contentListAdapter.clearFileForClaimOrUrl(outpoint, uri);
        }
        return;
    }
    try {
        JSONObject fileInfo = new JSONObject(fileInfoJson);
        LbryFile claimFile = LbryFile.fromJSONObject(fileInfo);
        String claimId = claimFile.getClaimId();
        if (contentListAdapter != null) {
            contentListAdapter.updateFileForClaimByIdOrUrl(claimFile, claimId, uri);
        }
    } catch (JSONException ex) {
    // invalid file info for download
    }
}
Also used : JSONObject(org.json.JSONObject) LbryFile(com.odysee.app.model.LbryFile) JSONException(org.json.JSONException)

Example 13 with LbryFile

use of com.odysee.app.model.LbryFile in project odysee-android by OdyseeTeam.

the class Lbry method get.

public static LbryFile get(boolean saveFile) throws ApiCallException {
    LbryFile file = null;
    Map<String, Object> params = new HashMap<>();
    params.put("save_file", saveFile);
    try {
        JSONObject result = (JSONObject) parseResponse(apiCall(METHOD_GET, params));
        file = LbryFile.fromJSONObject(result);
        if (file != null) {
            String fileClaimId = file.getClaimId();
            if (!Helper.isNullOrEmpty(fileClaimId)) {
                ClaimCacheKey key = new ClaimCacheKey();
                key.setClaimId(fileClaimId);
                if (claimCache.containsKey(key)) {
                    claimCache.get(key).setFile(file);
                }
            }
        }
    } catch (LbryRequestException | LbryResponseException ex) {
        throw new ApiCallException("Could not execute resolve call", ex);
    }
    return file;
}
Also used : ClaimCacheKey(com.odysee.app.model.ClaimCacheKey) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ApiCallException(com.odysee.app.exceptions.ApiCallException) LbryFile(com.odysee.app.model.LbryFile) JSONObject(org.json.JSONObject) LbryResponseException(com.odysee.app.exceptions.LbryResponseException) LbryRequestException(com.odysee.app.exceptions.LbryRequestException)

Example 14 with LbryFile

use of com.odysee.app.model.LbryFile in project odysee-android by OdyseeTeam.

the class SearchFragment method onDownloadAction.

public void onDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress) {
    if ("abort".equals(downloadAction)) {
        if (resultListAdapter != null) {
            resultListAdapter.clearFileForClaimOrUrl(outpoint, uri);
        }
        return;
    }
    try {
        JSONObject fileInfo = new JSONObject(fileInfoJson);
        LbryFile claimFile = LbryFile.fromJSONObject(fileInfo);
        String claimId = claimFile.getClaimId();
        if (resultListAdapter != null) {
            resultListAdapter.updateFileForClaimByIdOrUrl(claimFile, claimId, uri);
        }
    } catch (JSONException ex) {
    // invalid file info for download
    }
}
Also used : JSONObject(org.json.JSONObject) LbryFile(com.odysee.app.model.LbryFile) JSONException(org.json.JSONException)

Example 15 with LbryFile

use of com.odysee.app.model.LbryFile in project odysee-android by OdyseeTeam.

the class LibraryFragment method onDownloadAction.

public void onDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress) {
    if ("abort".equals(downloadAction)) {
        if (contentListAdapter != null) {
            contentListAdapter.clearFileForClaimOrUrl(outpoint, uri, currentFilter == FILTER_DOWNLOADS);
        }
        return;
    }
    try {
        JSONObject fileInfo = new JSONObject(fileInfoJson);
        LbryFile claimFile = LbryFile.fromJSONObject(fileInfo);
        String claimId = claimFile.getClaimId();
        if (contentListAdapter != null) {
            contentListAdapter.updateFileForClaimByIdOrUrl(claimFile, claimId, uri, true);
        }
    } catch (JSONException ex) {
    // invalid file info for download
    }
}
Also used : JSONObject(org.json.JSONObject) LbryFile(com.odysee.app.model.LbryFile) JSONException(org.json.JSONException)

Aggregations

LbryFile (com.odysee.app.model.LbryFile)17 JSONException (org.json.JSONException)11 JSONObject (org.json.JSONObject)9 ApiCallException (com.odysee.app.exceptions.ApiCallException)7 Claim (com.odysee.app.model.Claim)6 LbryRequestException (com.odysee.app.exceptions.LbryRequestException)5 LbryResponseException (com.odysee.app.exceptions.LbryResponseException)5 View (android.view.View)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 RecyclerView (androidx.recyclerview.widget.RecyclerView)3 LbryUriException (com.odysee.app.exceptions.LbryUriException)3 LbryioRequestException (com.odysee.app.exceptions.LbryioRequestException)3 LbryioResponseException (com.odysee.app.exceptions.LbryioResponseException)3 FileListTask (com.odysee.app.tasks.file.FileListTask)3 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 ExecutionException (java.util.concurrent.ExecutionException)3 WebView (android.webkit.WebView)2 AdapterView (android.widget.AdapterView)2