Search in sources :

Example 16 with LbryFile

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

the class LibraryFragment method updateStats.

private void updateStats() {
    totalBytes = 0;
    totalVideoBytes = 0;
    totalAudioBytes = 0;
    totalImageBytes = 0;
    totalOtherBytes = 0;
    if (currentFiles != null) {
        for (LbryFile file : currentFiles) {
            long writtenBytes = file.getWrittenBytes();
            String mime = file.getMimeType();
            if (mime != null) {
                if (mime.startsWith("video/")) {
                    totalVideoBytes += writtenBytes;
                } else if (mime.startsWith("audio/")) {
                    totalAudioBytes += writtenBytes;
                } else if (mime.startsWith("image/")) {
                    totalImageBytes += writtenBytes;
                } else {
                    totalOtherBytes += writtenBytes;
                }
            }
            totalBytes += writtenBytes;
        }
    }
    renderStats();
}
Also used : LbryFile(com.odysee.app.model.LbryFile)

Example 17 with LbryFile

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

the class FileViewFragment method onRelatedDownloadAction.

private void onRelatedDownloadAction(String downloadAction, String uri, String outpoint, String fileInfoJson, double progress) {
    if ("abort".equals(downloadAction)) {
        if (relatedContentAdapter != null) {
            relatedContentAdapter.clearFileForClaimOrUrl(outpoint, uri);
        }
        return;
    }
    try {
        JSONObject fileInfo = new JSONObject(fileInfoJson);
        LbryFile claimFile = LbryFile.fromJSONObject(fileInfo);
        String claimId = claimFile.getClaimId();
        if (relatedContentAdapter != null) {
            relatedContentAdapter.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)

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