Java Code Examples for org.telegram.messenger.DownloadController

The following examples show how to use org.telegram.messenger.DownloadController. These examples are extracted from open source projects. 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
private void updatePresetChoseView(SlideChooseView slideChooseView) {
    String[] presetsStr = new String[presets.size()];
    for (int i = 0; i < presets.size(); i++) {
        DownloadController.Preset preset = presets.get(i);
        if (preset == lowPreset) {
            presetsStr[i] = LocaleController.getString("AutoDownloadLow", R.string.AutoDownloadLow);
        } else if (preset == mediumPreset) {
            presetsStr[i] = LocaleController.getString("AutoDownloadMedium", R.string.AutoDownloadMedium);
        } else if (preset == highPreset) {
            presetsStr[i] = LocaleController.getString("AutoDownloadHigh", R.string.AutoDownloadHigh);
        } else {
            presetsStr[i] = LocaleController.getString("AutoDownloadCustom", R.string.AutoDownloadCustom);
        }

    }
    slideChooseView.setOptions(selectedPreset, presetsStr);
}
 
Example 2
public SharedAudioCell(Context context) {
    super(context);
    setFocusable(true);

    radialProgress = new RadialProgress2(this);
    radialProgress.setColors(Theme.key_chat_inLoader, Theme.key_chat_inLoaderSelected, Theme.key_chat_inMediaIcon, Theme.key_chat_inMediaIconSelected);

    TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
    setWillNotDraw(false);

    checkBox = new CheckBox2(context, 21);
    checkBox.setVisibility(INVISIBLE);
    checkBox.setColor(null, Theme.key_windowBackgroundWhite, Theme.key_checkboxCheck);
    checkBox.setDrawUnchecked(false);
    checkBox.setDrawBackgroundAsArc(3);
    addView(checkBox, LayoutHelper.createFrame(24, 24, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 38, 32, LocaleController.isRTL ? 39 : 0, 0));
}
 
Example 3
public ContextLinkCell(Context context, boolean needsCheckBox) {
    super(context);

    linkImageView = new ImageReceiver(this);
    linkImageView.setLayerNum(1);
    linkImageView.setUseSharedAnimationQueue(true);
    letterDrawable = new LetterDrawable();
    radialProgress = new RadialProgress2(this);
    TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
    setFocusable(true);

    if (needsCheckBox) {
        backgroundPaint = new Paint();
        backgroundPaint.setColor(Theme.getColor(Theme.key_sharedMedia_photoPlaceholder));

        checkBox = new CheckBox2(context, 21);
        checkBox.setVisibility(INVISIBLE);
        checkBox.setColor(null, Theme.key_sharedMedia_photoPlaceholder, Theme.key_checkboxCheck);
        checkBox.setDrawUnchecked(false);
        checkBox.setDrawBackgroundAsArc(1);
        addView(checkBox, LayoutHelper.createFrame(24, 24, Gravity.RIGHT | Gravity.TOP, 0, 1, 1, 0));
    }
    setWillNotDraw(false);
}
 
Example 4
Source Project: Telegram-FOSS   Source File: VoIPHelper.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static int getDataSavingDefault() {
	boolean low = DownloadController.getInstance(0).lowPreset.lessCallData,
			medium = DownloadController.getInstance(0).mediumPreset.lessCallData,
			high = DownloadController.getInstance(0).highPreset.lessCallData;
	if (!low && !medium && !high) {
		return TgVoip.DATA_SAVING_NEVER;
	} else if (low && !medium && !high) {
		return TgVoip.DATA_SAVING_ROAMING;
	} else if (low && medium && !high) {
		return TgVoip.DATA_SAVING_MOBILE;
	} else if (low && medium && high) {
		return TgVoip.DATA_SAVING_ALWAYS;
	}
	if (BuildVars.LOGS_ENABLED)
		FileLog.w("Invalid call data saving preset configuration: " + low + "/" + medium + "/" + high);
	return TgVoip.DATA_SAVING_NEVER;
}
 
Example 5
Source Project: Telegram   Source File: VoIPHelper.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static int getDataSavingDefault() {
	boolean low = DownloadController.getInstance(0).lowPreset.lessCallData,
			medium = DownloadController.getInstance(0).mediumPreset.lessCallData,
			high = DownloadController.getInstance(0).highPreset.lessCallData;
	if (!low && !medium && !high) {
		return TgVoip.DATA_SAVING_NEVER;
	} else if (low && !medium && !high) {
		return TgVoip.DATA_SAVING_ROAMING;
	} else if (low && medium && !high) {
		return TgVoip.DATA_SAVING_MOBILE;
	} else if (low && medium && high) {
		return TgVoip.DATA_SAVING_ALWAYS;
	}
	if (BuildVars.LOGS_ENABLED)
		FileLog.w("Invalid call data saving preset configuration: " + low + "/" + medium + "/" + high);
	return TgVoip.DATA_SAVING_NEVER;
}
 
Example 6
private void updatePresetChoseView(SlideChooseView slideChooseView) {
    String[] presetsStr = new String[presets.size()];
    for (int i = 0; i < presets.size(); i++) {
        DownloadController.Preset preset = presets.get(i);
        if (preset == lowPreset) {
            presetsStr[i] = LocaleController.getString("AutoDownloadLow", R.string.AutoDownloadLow);
        } else if (preset == mediumPreset) {
            presetsStr[i] = LocaleController.getString("AutoDownloadMedium", R.string.AutoDownloadMedium);
        } else if (preset == highPreset) {
            presetsStr[i] = LocaleController.getString("AutoDownloadHigh", R.string.AutoDownloadHigh);
        } else {
            presetsStr[i] = LocaleController.getString("AutoDownloadCustom", R.string.AutoDownloadCustom);
        }

    }
    slideChooseView.setOptions(selectedPreset, presetsStr);
}
 
Example 7
Source Project: Telegram   Source File: SharedAudioCell.java    License: GNU General Public License v2.0 6 votes vote down vote up
public SharedAudioCell(Context context) {
    super(context);
    setFocusable(true);

    radialProgress = new RadialProgress2(this);
    radialProgress.setColors(Theme.key_chat_inLoader, Theme.key_chat_inLoaderSelected, Theme.key_chat_inMediaIcon, Theme.key_chat_inMediaIconSelected);

    TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
    setWillNotDraw(false);

    checkBox = new CheckBox2(context, 21);
    checkBox.setVisibility(INVISIBLE);
    checkBox.setColor(null, Theme.key_windowBackgroundWhite, Theme.key_checkboxCheck);
    checkBox.setDrawUnchecked(false);
    checkBox.setDrawBackgroundAsArc(3);
    addView(checkBox, LayoutHelper.createFrame(24, 24, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 38, 32, LocaleController.isRTL ? 39 : 0, 0));
}
 
Example 8
public DataAutoDownloadActivity(int type)
{
    super();
    currentType = type;

    if (currentType == DownloadController.AUTODOWNLOAD_MASK_VIDEOMESSAGE)
    {
        maxSize = 8 * 1024 * 1024;
    }
    else if (currentType == DownloadController.AUTODOWNLOAD_MASK_GIF)
    {
        maxSize = 10 * 1024 * 1024;
    }
    else
    {
        maxSize = 1536 * 1024 * 1024;
    }

    mobileDataDownloadMask = DownloadController.getInstance(currentAccount).mobileDataDownloadMask[0];
    mobileDataPrivateDownloadMask = DownloadController.getInstance(currentAccount).mobileDataDownloadMask[1];
    mobileDataGroupDownloadMask = DownloadController.getInstance(currentAccount).mobileDataDownloadMask[2];
    mobileDataChannelDownloadMask = DownloadController.getInstance(currentAccount).mobileDataDownloadMask[3];
    wifiDownloadMask = DownloadController.getInstance(currentAccount).wifiDownloadMask[0];
    wifiPrivateDownloadMask = DownloadController.getInstance(currentAccount).wifiDownloadMask[1];
    wifiGroupDownloadMask = DownloadController.getInstance(currentAccount).wifiDownloadMask[2];
    wifiChannelDownloadMask = DownloadController.getInstance(currentAccount).wifiDownloadMask[3];
    roamingDownloadMask = DownloadController.getInstance(currentAccount).roamingDownloadMask[0];
    roamingPrivateDownloadMask = DownloadController.getInstance(currentAccount).roamingDownloadMask[1];
    roamingGroupDownloadMask = DownloadController.getInstance(currentAccount).roamingDownloadMask[2];
    roamingChannelDownloadMask = DownloadController.getInstance(currentAccount).roamingDownloadMask[2];

    mobileMaxSize = DownloadController.getInstance(currentAccount).mobileMaxFileSize[DownloadController.maskToIndex(currentType)];
    wifiMaxSize = DownloadController.getInstance(currentAccount).wifiMaxFileSize[DownloadController.maskToIndex(currentType)];
    roamingMaxSize = DownloadController.getInstance(currentAccount).roamingMaxFileSize[DownloadController.maskToIndex(currentType)];
}
 
Example 9
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder)
{
    int position = holder.getAdapterPosition();
    if (position == photosRow || position == voiceMessagesRow || position == videoMessagesRow || position == videosRow || position == filesRow || position == musicRow || position == gifsRow)
    {
        return DownloadController.getInstance(currentAccount).globalAutodownloadEnabled;
    }
    return position == storageUsageRow || position == useLessDataForCallsRow || position == mobileUsageRow || position == roamingUsageRow || position == wifiUsageRow || position == proxyRow ||
            position == resetDownloadRow || position == autoDownloadMediaRow || position == enableCacheStreamRow || position == enableStreamRow || position == enableAllStreamRow || position == quickRepliesRow;
}
 
Example 10
Source Project: Telegram   Source File: PopupAudioView.java    License: 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 11
public SharedAudioCell(Context context) {
    super(context);

    radialProgress = new RadialProgress(this);
    TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
    setWillNotDraw(false);

    checkBox = new CheckBox(context, R.drawable.round_check2);
    checkBox.setVisibility(INVISIBLE);
    checkBox.setColor(Theme.getColor(Theme.key_checkbox), Theme.getColor(Theme.key_checkboxCheck));
    addView(checkBox, LayoutHelper.createFrame(20, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 40, 34, LocaleController.isRTL ? 40 : 0, 0));
}
 
Example 12
public ContextLinkCell(Context context) {
    super(context);

    linkImageView = new ImageReceiver(this);
    letterDrawable = new LetterDrawable();
    radialProgress = new RadialProgress(this);
    TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
}
 
Example 13
@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    if (drawLinkImageView) {
        linkImageView.onDetachedFromWindow();
    }
    DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
}
 
Example 14
@Override
public void dismiss() {
    super.dismiss();
    NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagePlayingDidReset);
    NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagePlayingPlayStateChanged);
    NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagePlayingDidStarted);
    NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.messagePlayingProgressDidChanged);
    NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.musicDidLoaded);
    DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
}
 
Example 15
public PopupAudioView(Context context) {
    super(context);
    timePaint = new TextPaint(TextPaint.ANTI_ALIAS_FLAG);
    timePaint.setTextSize(AndroidUtilities.dp(16));

    TAG = DownloadController.getInstance(currentAccount).generateObserverTag();

    seekBar = new SeekBar(getContext());
    seekBar.setDelegate(this);
    progressView = new ProgressView();
}
 
Example 16
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 17
public DataAutoDownloadActivity(int type)
{
    super();
    currentType = type;

    if (currentType == DownloadController.AUTODOWNLOAD_MASK_VIDEOMESSAGE)
    {
        maxSize = 8 * 1024 * 1024;
    }
    else if (currentType == DownloadController.AUTODOWNLOAD_MASK_GIF)
    {
        maxSize = 10 * 1024 * 1024;
    }
    else
    {
        maxSize = 1536 * 1024 * 1024;
    }

    mobileDataDownloadMask = DownloadController.getInstance(currentAccount).mobileDataDownloadMask[0];
    mobileDataPrivateDownloadMask = DownloadController.getInstance(currentAccount).mobileDataDownloadMask[1];
    mobileDataGroupDownloadMask = DownloadController.getInstance(currentAccount).mobileDataDownloadMask[2];
    mobileDataChannelDownloadMask = DownloadController.getInstance(currentAccount).mobileDataDownloadMask[3];
    wifiDownloadMask = DownloadController.getInstance(currentAccount).wifiDownloadMask[0];
    wifiPrivateDownloadMask = DownloadController.getInstance(currentAccount).wifiDownloadMask[1];
    wifiGroupDownloadMask = DownloadController.getInstance(currentAccount).wifiDownloadMask[2];
    wifiChannelDownloadMask = DownloadController.getInstance(currentAccount).wifiDownloadMask[3];
    roamingDownloadMask = DownloadController.getInstance(currentAccount).roamingDownloadMask[0];
    roamingPrivateDownloadMask = DownloadController.getInstance(currentAccount).roamingDownloadMask[1];
    roamingGroupDownloadMask = DownloadController.getInstance(currentAccount).roamingDownloadMask[2];
    roamingChannelDownloadMask = DownloadController.getInstance(currentAccount).roamingDownloadMask[2];

    mobileMaxSize = DownloadController.getInstance(currentAccount).mobileMaxFileSize[DownloadController.maskToIndex(currentType)];
    wifiMaxSize = DownloadController.getInstance(currentAccount).wifiMaxFileSize[DownloadController.maskToIndex(currentType)];
    roamingMaxSize = DownloadController.getInstance(currentAccount).roamingMaxFileSize[DownloadController.maskToIndex(currentType)];
}
 
Example 18
@Override
public boolean isEnabled(RecyclerView.ViewHolder holder)
{
    int position = holder.getAdapterPosition();
    if (position == photosRow || position == voiceMessagesRow || position == videoMessagesRow || position == videosRow || position == filesRow || position == musicRow || position == gifsRow)
    {
        return DownloadController.getInstance(currentAccount).globalAutodownloadEnabled;
    }
    return position == storageUsageRow || position == useLessDataForCallsRow || position == mobileUsageRow || position == roamingUsageRow || position == wifiUsageRow || position == proxyRow ||
            position == resetDownloadRow || position == autoDownloadMediaRow || position == enableCacheStreamRow || position == enableStreamRow || position == enableAllStreamRow || position == quickRepliesRow;
}
 
Example 19
public SharedAudioCell(Context context) {
    super(context);

    radialProgress = new RadialProgress(this);
    TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
    setWillNotDraw(false);

    checkBox = new CheckBox(context, R.drawable.round_check2);
    checkBox.setVisibility(INVISIBLE);
    checkBox.setColor(Theme.getColor(Theme.key_checkbox), Theme.getColor(Theme.key_checkboxCheck));
    addView(checkBox, LayoutHelper.createFrame(20, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 0 : 40, 34, LocaleController.isRTL ? 40 : 0, 0));
}
 
Example 20
public ContextLinkCell(Context context) {
    super(context);

    linkImageView = new ImageReceiver(this);
    letterDrawable = new LetterDrawable();
    radialProgress = new RadialProgress(this);
    TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
}
 
Example 21
@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    if (drawLinkImageView) {
        linkImageView.onDetachedFromWindow();
    }
    DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
}
 
Example 22
Source Project: Telegram   Source File: AudioPlayerCell.java    License: GNU General Public License v2.0 5 votes vote down vote up
public AudioPlayerCell(Context context) {
    super(context);

    radialProgress = new RadialProgress2(this);
    radialProgress.setColors(Theme.key_chat_inLoader, Theme.key_chat_inLoaderSelected, Theme.key_chat_inMediaIcon, Theme.key_chat_inMediaIconSelected);
    TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
    setFocusable(true);
}
 
Example 23
Source Project: Telegram   Source File: ContextLinkCell.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    if (drawLinkImageView) {
        linkImageView.onDetachedFromWindow();
    }
    radialProgress.onDetachedFromWindow();
    DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
}
 
Example 24
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 25
public DataAutoDownloadActivity(int type) {
    super();
    currentType = type;

    lowPreset = DownloadController.getInstance(currentAccount).lowPreset;
    mediumPreset = DownloadController.getInstance(currentAccount).mediumPreset;
    highPreset = DownloadController.getInstance(currentAccount).highPreset;

    if (currentType == 0) {
        currentPresetNum = DownloadController.getInstance(currentAccount).currentMobilePreset;
        typePreset = DownloadController.getInstance(currentAccount).mobilePreset;
        defaultPreset = mediumPreset;
        key = "mobilePreset";
        key2 = "currentMobilePreset";
    } else if (currentType == 1) {
        currentPresetNum = DownloadController.getInstance(currentAccount).currentWifiPreset;
        typePreset = DownloadController.getInstance(currentAccount).wifiPreset;
        defaultPreset = highPreset;
        key = "wifiPreset";
        key2 = "currentWifiPreset";
    } else {
        currentPresetNum = DownloadController.getInstance(currentAccount).currentRoamingPreset;
        typePreset = DownloadController.getInstance(currentAccount).roamingPreset;
        defaultPreset = lowPreset;
        key = "roamingPreset";
        key2 = "currentRoamingPreset";
    }
}
 
Example 26
@Override
public void onPause() {
    super.onPause();
    if (wereAnyChanges) {
        DownloadController.getInstance(currentAccount).savePresetToServer(currentType);
        wereAnyChanges = false;
    }
}
 
Example 27
@Override
public boolean onFragmentCreate() {
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad);
    if (screenType == SCREEN_TYPE_ACCENT_COLOR) {
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetNewWallpapper);
    }
    if (screenType != SCREEN_TYPE_PREVIEW || accent != null) {
        if (SharedConfig.getDevicePerfomanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW) {
            int w = Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
            int h = Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y);
            imageFilter = (int) (w / AndroidUtilities.density) + "_" + (int) (h / AndroidUtilities.density) + "_f";
        } else {
            imageFilter = (int) (1080 / AndroidUtilities.density) + "_" + (int) (1920 / AndroidUtilities.density) + "_f";
        }
        maxWallpaperSize = Math.min(1920, Math.max(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y));

        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.wallpapersNeedReload);
        NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.wallpapersDidLoad);
        TAG = DownloadController.getInstance(currentAccount).generateObserverTag();

        if (patterns == null) {
            patterns = new ArrayList<>();
            MessagesStorage.getInstance(currentAccount).getWallpapers();
        }
    } else {
        isMotion = Theme.isWallpaperMotion();
    }

    return super.onFragmentCreate();
}
 
Example 28
Source Project: Telegram-FOSS   Source File: PatternCell.java    License: GNU General Public License v2.0 5 votes vote down vote up
public PatternCell(Context context, int maxSize, PatternCellDelegate patternCellDelegate) {
    super(context);
    setRoundRadius(AndroidUtilities.dp(6));
    maxWallpaperSize = maxSize;
    delegate = patternCellDelegate;

    radialProgress = new RadialProgress2(this);
    radialProgress.setProgressRect(AndroidUtilities.dp(30), AndroidUtilities.dp(30), AndroidUtilities.dp(70), AndroidUtilities.dp(70));

    backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
}
 
Example 29
public void updateFileExistIcon() {
    if (message != null && message.messageOwner.media != null) {
        loaded = false;
        if (message.attachPathExists || message.mediaExists) {
            statusImageView.setVisibility(INVISIBLE);
            progressView.setVisibility(INVISIBLE);
            dateTextView.setPadding(0, 0, 0, 0);
            loading = false;
            loaded = true;
            DownloadController.getInstance(currentAccount).removeLoadingFileObserver(this);
        } else {
            String fileName = FileLoader.getAttachFileName(message.getDocument());
            DownloadController.getInstance(currentAccount).addLoadingFileObserver(fileName, message, 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 30
public AudioPlayerCell(Context context) {
    super(context);

    radialProgress = new RadialProgress2(this);
    radialProgress.setColors(Theme.key_chat_inLoader, Theme.key_chat_inLoaderSelected, Theme.key_chat_inMediaIcon, Theme.key_chat_inMediaIconSelected);
    TAG = DownloadController.getInstance(currentAccount).generateObserverTag();
    setFocusable(true);
}