Java Code Examples for org.telegram.messenger.FileLoader#getPathToMessage()

The following examples show how to use org.telegram.messenger.FileLoader#getPathToMessage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PopupAudioView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void updateButtonState() {
    String fileName = currentMessageObject.getFileName();
    File cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
    if (cacheFile.exists()) {
        DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
        boolean playing = MediaController.getInstance().isPlayingMessage(currentMessageObject);
        if (!playing || playing && MediaController.getInstance().isMessagePaused()) {
            buttonState = 0;
        } else {
            buttonState = 1;
        }
        progressView.setProgress(0);
    } else {
        DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, this);
        if (!FileLoader.getInstance(currentAccount).isLoadingFile(fileName)) {
            buttonState = 2;
            progressView.setProgress(0);
        } else {
            buttonState = 3;
            Float progress = ImageLoader.getInstance().getFileProgress(fileName);
            if (progress != null) {
                progressView.setProgress(progress);
            } else {
                progressView.setProgress(0);
            }
        }
    }
    updateProgress();
}
 
Example 2
Source File: PopupAudioView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void updateButtonState() {
    String fileName = currentMessageObject.getFileName();
    File cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
    if (cacheFile.exists()) {
        DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
        boolean playing = MediaController.getInstance().isPlayingMessage(currentMessageObject);
        if (!playing || playing && MediaController.getInstance().isMessagePaused()) {
            buttonState = 0;
        } else {
            buttonState = 1;
        }
        progressView.setProgress(0);
    } else {
        DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, this);
        if (!FileLoader.getInstance(currentAccount).isLoadingFile(fileName)) {
            buttonState = 2;
            progressView.setProgress(0);
        } else {
            buttonState = 3;
            Float progress = ImageLoader.getInstance().getFileProgress(fileName);
            if (progress != null) {
                progressView.setProgress(progress);
            } else {
                progressView.setProgress(0);
            }
        }
    }
    updateProgress();
}
 
Example 3
Source File: PopupAudioView.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void updateButtonState() {
    String fileName = currentMessageObject.getFileName();
    File cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
    if (cacheFile.exists()) {
        DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
        boolean playing = MediaController.getInstance().isPlayingMessage(currentMessageObject);
        if (!playing || playing && MediaController.getInstance().isMessagePaused()) {
            buttonState = 0;
        } else {
            buttonState = 1;
        }
        progressView.setProgress(0);
    } else {
        DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, this);
        if (!FileLoader.getInstance(currentAccount).isLoadingFile(fileName)) {
            buttonState = 2;
            progressView.setProgress(0);
        } else {
            buttonState = 3;
            Float progress = ImageLoader.getInstance().getFileProgress(fileName);
            if (progress != null) {
                progressView.setProgress(progress);
            } else {
                progressView.setProgress(0);
            }
        }
    }
    updateProgress();
}
 
Example 4
Source File: OtherDocumentPlaceholderDrawable.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void checkFileExist() {
    if (parentMessageObject != null && parentMessageObject.messageOwner.media != null) {
        String fileName = null;
        File cacheFile;
        if (TextUtils.isEmpty(parentMessageObject.messageOwner.attachPath) || !(new File(parentMessageObject.messageOwner.attachPath).exists())) {
            cacheFile = FileLoader.getPathToMessage(parentMessageObject.messageOwner);
            if (!cacheFile.exists()) {
                fileName = FileLoader.getAttachFileName(parentMessageObject.getDocument());
            }
        }
        loaded = false;
        if (fileName == null) {
            progressVisible = false;
            loading = false;
            loaded = true;
            DownloadController.getInstance(parentMessageObject.currentAccount).removeLoadingFileObserver(this);
        } else {
            DownloadController.getInstance(parentMessageObject.currentAccount).addLoadingFileObserver(fileName, this);
            loading = FileLoader.getInstance(parentMessageObject.currentAccount).isLoadingFile(fileName);
            if (loading) {
                progressVisible = true;
                Float progress = ImageLoader.getInstance().getFileProgress(fileName);
                if (progress == null) {
                    progress = 0.0f;
                }
                setProgress(progress, false);
            } else {
                progressVisible = false;
            }
        }
    } else {
        loading = false;
        loaded = true;
        progressVisible = false;
        setProgress(0, false);
        DownloadController.getInstance(parentMessageObject.currentAccount).removeLoadingFileObserver(this);
    }
    parentView.invalidate();
}
 
Example 5
Source File: PopupAudioView.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void updateButtonState() {
    String fileName = currentMessageObject.getFileName();
    File cacheFile = FileLoader.getPathToMessage(currentMessageObject.messageOwner);
    if (cacheFile.exists()) {
        DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
        boolean playing = MediaController.getInstance().isPlayingMessage(currentMessageObject);
        if (!playing || playing && MediaController.getInstance().isMessagePaused()) {
            buttonState = 0;
        } else {
            buttonState = 1;
        }
        progressView.setProgress(0);
    } else {
        DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, this);
        if (!FileLoader.getInstance(currentAccount).isLoadingFile(fileName)) {
            buttonState = 2;
            progressView.setProgress(0);
        } else {
            buttonState = 3;
            Float progress = ImageLoader.getInstance().getFileProgress(fileName);
            if (progress != null) {
                progressView.setProgress(progress);
            } else {
                progressView.setProgress(0);
            }
        }
    }
    updateProgress();
}
 
Example 6
Source File: OtherDocumentPlaceholderDrawable.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void checkFileExist() {
    if (parentMessageObject != null && parentMessageObject.messageOwner.media != null) {
        String fileName = null;
        File cacheFile;
        if (TextUtils.isEmpty(parentMessageObject.messageOwner.attachPath) || !(new File(parentMessageObject.messageOwner.attachPath).exists())) {
            cacheFile = FileLoader.getPathToMessage(parentMessageObject.messageOwner);
            if (!cacheFile.exists()) {
                fileName = FileLoader.getAttachFileName(parentMessageObject.getDocument());
            }
        }
        loaded = false;
        if (fileName == null) {
            progressVisible = false;
            loading = false;
            loaded = true;
            DownloadController.getInstance(parentMessageObject.currentAccount).removeLoadingFileObserver(this);
        } else {
            DownloadController.getInstance(parentMessageObject.currentAccount).addLoadingFileObserver(fileName, this);
            loading = FileLoader.getInstance(parentMessageObject.currentAccount).isLoadingFile(fileName);
            if (loading) {
                progressVisible = true;
                Float progress = ImageLoader.getInstance().getFileProgress(fileName);
                if (progress == null) {
                    progress = 0.0f;
                }
                setProgress(progress, false);
            } else {
                progressVisible = false;
            }
        }
    } else {
        loading = false;
        loaded = true;
        progressVisible = false;
        setProgress(0, false);
        DownloadController.getInstance(parentMessageObject.currentAccount).removeLoadingFileObserver(this);
    }
    parentView.invalidate();
}
 
Example 7
Source File: SharedDocumentCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void updateFileExistIcon() {
    if (message != null && message.messageOwner.media != null) {
        String fileName = null;
        File cacheFile;
        if (message.messageOwner.attachPath == null || message.messageOwner.attachPath.length() == 0 || !(new File(message.messageOwner.attachPath).exists())) {
            cacheFile = FileLoader.getPathToMessage(message.messageOwner);
            if (!cacheFile.exists()) {
                fileName = FileLoader.getAttachFileName(message.getDocument());
            }
        }
        loaded = false;
        if (fileName == null) {
            statusImageView.setVisibility(INVISIBLE);
            progressView.setVisibility(INVISIBLE);
            dateTextView.setPadding(0, 0, 0, 0);
            loading = false;
            loaded = true;
            DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
        } else {
            DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, this);
            loading = FileLoader.getInstance(currentAccount).isLoadingFile(fileName);
            statusImageView.setVisibility(VISIBLE);
            statusImageView.setImageResource(loading ? R.drawable.media_doc_pause : R.drawable.media_doc_load);
            dateTextView.setPadding(LocaleController.isRTL ? 0 : AndroidUtilities.dp(14), 0, LocaleController.isRTL ? AndroidUtilities.dp(14) : 0, 0);
            if (loading) {
                progressView.setVisibility(VISIBLE);
                Float progress = ImageLoader.getInstance().getFileProgress(fileName);
                if (progress == null) {
                    progress = 0.0f;
                }
                progressView.setProgress(progress, false);
            } else {
                progressView.setVisibility(INVISIBLE);
            }
        }
    } else {
        loading = false;
        loaded = true;
        progressView.setVisibility(INVISIBLE);
        progressView.setProgress(0, false);
        statusImageView.setVisibility(INVISIBLE);
        dateTextView.setPadding(0, 0, 0, 0);
        DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
    }
}
 
Example 8
Source File: SharedDocumentCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void updateFileExistIcon() {
    if (message != null && message.messageOwner.media != null) {
        String fileName = null;
        File cacheFile;
        if (message.messageOwner.attachPath == null || message.messageOwner.attachPath.length() == 0 || !(new File(message.messageOwner.attachPath).exists())) {
            cacheFile = FileLoader.getPathToMessage(message.messageOwner);
            if (!cacheFile.exists()) {
                fileName = FileLoader.getAttachFileName(message.getDocument());
            }
        }
        loaded = false;
        if (fileName == null) {
            statusImageView.setVisibility(INVISIBLE);
            progressView.setVisibility(INVISIBLE);
            dateTextView.setPadding(0, 0, 0, 0);
            loading = false;
            loaded = true;
            DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
        } else {
            DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, this);
            loading = FileLoader.getInstance(currentAccount).isLoadingFile(fileName);
            statusImageView.setVisibility(VISIBLE);
            statusImageView.setImageResource(loading ? R.drawable.media_doc_pause : R.drawable.media_doc_load);
            dateTextView.setPadding(LocaleController.isRTL ? 0 : AndroidUtilities.dp(14), 0, LocaleController.isRTL ? AndroidUtilities.dp(14) : 0, 0);
            if (loading) {
                progressView.setVisibility(VISIBLE);
                Float progress = ImageLoader.getInstance().getFileProgress(fileName);
                if (progress == null) {
                    progress = 0.0f;
                }
                progressView.setProgress(progress, false);
            } else {
                progressView.setVisibility(INVISIBLE);
            }
        }
    } else {
        loading = false;
        loaded = true;
        progressView.setVisibility(INVISIBLE);
        progressView.setProgress(0, false);
        statusImageView.setVisibility(INVISIBLE);
        dateTextView.setPadding(0, 0, 0, 0);
        DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
    }
}