org.telegram.messenger.FileLoader Java Examples
The following examples show how to use
org.telegram.messenger.FileLoader.
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: AudioPlayerCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void didPressedMiniButton(boolean animated) { if (miniButtonState == 0) { miniButtonState = 1; radialProgress.setProgress(0, false); FileLoader.getInstance(currentAccount).loadFile(currentMessageObject.getDocument(), true, 0); radialProgress.setMiniBackground(getMiniDrawableForCurrentState(), true, false); invalidate(); } else if (miniButtonState == 1) { if (MediaController.getInstance().isPlayingMessage(currentMessageObject)) { MediaController.getInstance().cleanupPlayer(true, true); } miniButtonState = 0; FileLoader.getInstance(currentAccount).cancelLoadFile(currentMessageObject.getDocument()); radialProgress.setMiniBackground(getMiniDrawableForCurrentState(), true, false); invalidate(); } }
Example #2
Source File: StickersAdapter.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private boolean checkStickerFilesExistAndDownload() { if (stickers == null) { return false; } stickersToLoad.clear(); int size = Math.min(6, stickers.size()); for (int a = 0; a < size; a++) { StickerResult result = stickers.get(a); TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(result.sticker.thumbs, 90); if (thumb instanceof TLRPC.TL_photoSize) { File f = FileLoader.getPathToAttach(thumb, "webp", true); if (!f.exists()) { stickersToLoad.add(FileLoader.getAttachFileName(thumb, "webp")); FileLoader.getInstance(currentAccount).loadFile(ImageLocation.getForDocument(thumb, result.sticker), result.parent, "webp", 1, 1); } } } return stickersToLoad.isEmpty(); }
Example #3
Source File: SharedAudioCell.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void setMessageObject(MessageObject messageObject, boolean divider) { needDivider = divider; currentMessageObject = messageObject; TLRPC.Document document = messageObject.getDocument(); TLRPC.PhotoSize thumb = document != null ? FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 240) : null; if (thumb instanceof TLRPC.TL_photoSize) { radialProgress.setImageOverlay(thumb, document, messageObject); } else { String artworkUrl = messageObject.getArtworkUrl(true); if (!TextUtils.isEmpty(artworkUrl)) { radialProgress.setImageOverlay(artworkUrl); } else { radialProgress.setImageOverlay(null, null, null); } } updateButtonState(false, false); requestLayout(); }
Example #4
Source File: SharedAudioCell.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private void didPressedMiniButton(boolean animated) { if (miniButtonState == 0) { miniButtonState = 1; radialProgress.setProgress(0, false); FileLoader.getInstance(currentAccount).loadFile(currentMessageObject.getDocument(), currentMessageObject, 1, 0); radialProgress.setMiniIcon(getMiniIconForCurrentState(), false, true); invalidate(); } else if (miniButtonState == 1) { if (MediaController.getInstance().isPlayingMessage(currentMessageObject)) { MediaController.getInstance().cleanupPlayer(true, true); } miniButtonState = 0; FileLoader.getInstance(currentAccount).cancelLoadFile(currentMessageObject.getDocument()); radialProgress.setMiniIcon(getMiniIconForCurrentState(), false, true); invalidate(); } }
Example #5
Source File: StickersAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private boolean checkStickerFilesExistAndDownload() { if (stickers == null) { return false; } stickersToLoad.clear(); int size = Math.min(10, stickers.size()); for (int a = 0; a < size; a++) { TLRPC.Document document = stickers.get(a); File f = FileLoader.getPathToAttach(document.thumb, "webp", true); if (!f.exists()) { stickersToLoad.add(FileLoader.getAttachFileName(document.thumb, "webp")); FileLoader.getInstance(currentAccount).loadFile(document.thumb.location, "webp", 0, 1); } } return stickersToLoad.isEmpty(); }
Example #6
Source File: AudioPlayerCell.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void setMessageObject(MessageObject messageObject) { currentMessageObject = messageObject; TLRPC.Document document = messageObject.getDocument(); TLRPC.PhotoSize thumb = document != null ? FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90) : null; if (thumb instanceof TLRPC.TL_photoSize) { radialProgress.setImageOverlay(thumb, document, messageObject); } else { String artworkUrl = messageObject.getArtworkUrl(true); if (!TextUtils.isEmpty(artworkUrl)) { radialProgress.setImageOverlay(artworkUrl); } else { radialProgress.setImageOverlay(null, null, null); } } requestLayout(); updateButtonState(false, false); }
Example #7
Source File: StatisticPostInfoCell.java From Telegram with GNU General Public License v2.0 | 6 votes |
public void setData(StatisticActivity.RecentPostInfo postInfo) { MessageObject messageObject = postInfo.message; if (messageObject.photoThumbs != null) { TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize()); TLRPC.PhotoSize thumbSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs,50); imageView.setImage( ImageLocation.getForObject(size, messageObject.photoThumbsObject), "50_50", ImageLocation.getForObject(thumbSize, messageObject.photoThumbsObject), "b1", 0, messageObject); imageView.setRoundRadius(AndroidUtilities.dp(4)); } else if (chat.chat_photo.sizes.size() > 0) { imageView.setImage(ImageLocation.getForPhoto(chat.chat_photo.sizes.get(0), chat.chat_photo), "50_50", null, null, chat); imageView.setRoundRadius(AndroidUtilities.dp(46) >> 1); } String text; if (messageObject.isMusic()) { text = String.format("%s, %s", messageObject.getMusicTitle().trim(), messageObject.getMusicAuthor().trim()); } else { text = messageObject.caption != null ? messageObject.caption.toString() : messageObject.messageText.toString(); } message.setText(text.replace("\n", " ").trim()); views.setText(String.format(LocaleController.getPluralString("Views", postInfo.counters.views), AndroidUtilities.formatCount(postInfo.counters.views))); date.setText(LocaleController.formatDateAudio(postInfo.message.messageOwner.date, false)); shares.setText(String.format(LocaleController.getPluralString("Shares", postInfo.counters.forwards), AndroidUtilities.formatCount(postInfo.counters.forwards))); }
Example #8
Source File: ConnectionsManager.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public void init(int version, int layer, int apiId, String deviceModel, String systemVersion, String appVersion, String langCode, String systemLangCode, String configPath, String logPath, int userId, boolean enablePushConnection) { native_init(currentAccount, version, layer, apiId, deviceModel, systemVersion, appVersion, langCode, systemLangCode, configPath, logPath, userId, enablePushConnection, isNetworkOnline(), getCurrentNetworkType()); checkConnection(); BroadcastReceiver networkStateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { checkConnection(); FileLoader.getInstance(currentAccount).onNetworkChanged(isConnectionSlow()); } }; IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION); ApplicationLoader.applicationContext.registerReceiver(networkStateReceiver, filter); }
Example #9
Source File: WallpaperUpdater.java From Telegram with GNU General Public License v2.0 | 6 votes |
private void didSelectPhotos(ArrayList<SendMessagesHelper.SendingMediaInfo> photos) { try { if (!photos.isEmpty()) { SendMessagesHelper.SendingMediaInfo info = photos.get(0); if (info.path != null) { currentWallpaperPath = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE), Utilities.random.nextInt() + ".jpg"); Point screenSize = AndroidUtilities.getRealScreenSize(); Bitmap bitmap = ImageLoader.loadBitmap(info.path, null, screenSize.x, screenSize.y, true); FileOutputStream stream = new FileOutputStream(currentWallpaperPath); bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream); delegate.didSelectWallpaper(currentWallpaperPath, bitmap, true); } } } catch (Throwable e) { FileLog.e(e); } }
Example #10
Source File: StatisticPostInfoCell.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public void setData(StatisticActivity.RecentPostInfo postInfo) { MessageObject messageObject = postInfo.message; if (messageObject.photoThumbs != null) { TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs, AndroidUtilities.getPhotoSize()); TLRPC.PhotoSize thumbSize = FileLoader.getClosestPhotoSizeWithSize(messageObject.photoThumbs,50); imageView.setImage( ImageLocation.getForObject(size, messageObject.photoThumbsObject), "50_50", ImageLocation.getForObject(thumbSize, messageObject.photoThumbsObject), "b1", 0, messageObject); imageView.setRoundRadius(AndroidUtilities.dp(4)); } else if (chat.chat_photo.sizes.size() > 0) { imageView.setImage(ImageLocation.getForPhoto(chat.chat_photo.sizes.get(0), chat.chat_photo), "50_50", null, null, chat); imageView.setRoundRadius(AndroidUtilities.dp(46) >> 1); } String text; if (messageObject.isMusic()) { text = String.format("%s, %s", messageObject.getMusicTitle().trim(), messageObject.getMusicAuthor().trim()); } else { text = messageObject.caption != null ? messageObject.caption.toString() : messageObject.messageText.toString(); } message.setText(text.replace("\n", " ").trim()); views.setText(String.format(LocaleController.getPluralString("Views", postInfo.counters.views), AndroidUtilities.formatCount(postInfo.counters.views))); date.setText(LocaleController.formatDateAudio(postInfo.message.messageOwner.date, false)); shares.setText(String.format(LocaleController.getPluralString("Shares", postInfo.counters.forwards), AndroidUtilities.formatCount(postInfo.counters.forwards))); }
Example #11
Source File: SharedAudioCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void didPressedMiniButton(boolean animated) { if (miniButtonState == 0) { miniButtonState = 1; radialProgress.setProgress(0, false); FileLoader.getInstance(currentAccount).loadFile(currentMessageObject.getDocument(), true, 0); radialProgress.setMiniBackground(getMiniDrawableForCurrentState(), true, false); invalidate(); } else if (miniButtonState == 1) { if (MediaController.getInstance().isPlayingMessage(currentMessageObject)) { MediaController.getInstance().cleanupPlayer(true, true); } miniButtonState = 0; FileLoader.getInstance(currentAccount).cancelLoadFile(currentMessageObject.getDocument()); radialProgress.setMiniBackground(getMiniDrawableForCurrentState(), true, false); invalidate(); } }
Example #12
Source File: SharedAudioCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void didPressedMiniButton(boolean animated) { if (miniButtonState == 0) { miniButtonState = 1; radialProgress.setProgress(0, false); FileLoader.getInstance(currentAccount).loadFile(currentMessageObject.getDocument(), true, 0); radialProgress.setMiniBackground(getMiniDrawableForCurrentState(), true, false); invalidate(); } else if (miniButtonState == 1) { if (MediaController.getInstance().isPlayingMessage(currentMessageObject)) { MediaController.getInstance().cleanupPlayer(true, true); } miniButtonState = 0; FileLoader.getInstance(currentAccount).cancelLoadFile(currentMessageObject.getDocument()); radialProgress.setMiniBackground(getMiniDrawableForCurrentState(), true, false); invalidate(); } }
Example #13
Source File: AudioPlayerCell.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void didPressedMiniButton(boolean animated) { if (miniButtonState == 0) { miniButtonState = 1; radialProgress.setProgress(0, false); FileLoader.getInstance(currentAccount).loadFile(currentMessageObject.getDocument(), true, 0); radialProgress.setMiniBackground(getMiniDrawableForCurrentState(), true, false); invalidate(); } else if (miniButtonState == 1) { if (MediaController.getInstance().isPlayingMessage(currentMessageObject)) { MediaController.getInstance().cleanupPlayer(true, true); } miniButtonState = 0; FileLoader.getInstance(currentAccount).cancelLoadFile(currentMessageObject.getDocument()); radialProgress.setMiniBackground(getMiniDrawableForCurrentState(), true, false); invalidate(); } }
Example #14
Source File: StickersAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private boolean checkStickerFilesExistAndDownload() { if (stickers == null) { return false; } stickersToLoad.clear(); int size = Math.min(10, stickers.size()); for (int a = 0; a < size; a++) { TLRPC.Document document = stickers.get(a); File f = FileLoader.getPathToAttach(document.thumb, "webp", true); if (!f.exists()) { stickersToLoad.add(FileLoader.getAttachFileName(document.thumb, "webp")); FileLoader.getInstance(currentAccount).loadFile(document.thumb.location, "webp", 0, 1); } } return stickersToLoad.isEmpty(); }
Example #15
Source File: StickersAdapter.java From Telegram with GNU General Public License v2.0 | 6 votes |
private boolean checkStickerFilesExistAndDownload() { if (stickers == null) { return false; } stickersToLoad.clear(); int size = Math.min(6, stickers.size()); for (int a = 0; a < size; a++) { StickerResult result = stickers.get(a); TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(result.sticker.thumbs, 90); if (thumb instanceof TLRPC.TL_photoSize) { File f = FileLoader.getPathToAttach(thumb, "webp", true); if (!f.exists()) { stickersToLoad.add(FileLoader.getAttachFileName(thumb, "webp")); FileLoader.getInstance(currentAccount).loadFile(ImageLocation.getForDocument(thumb, result.sticker), result.parent, "webp", 1, 1); } } } return stickersToLoad.isEmpty(); }
Example #16
Source File: EncryptedFileDataSource.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public long open(DataSpec dataSpec) throws EncryptedFileDataSourceException { try { uri = dataSpec.uri; File path = new File(dataSpec.uri.getPath()); String name = path.getName(); File keyPath = new File(FileLoader.getInternalCacheDir(), name + ".key"); RandomAccessFile keyFile = new RandomAccessFile(keyPath, "r"); keyFile.read(key); keyFile.read(iv); keyFile.close(); file = new RandomAccessFile(path, "r"); file.seek(dataSpec.position); fileOffset = (int) dataSpec.position; bytesRemaining = dataSpec.length == C.LENGTH_UNSET ? file.length() - dataSpec.position : dataSpec.length; if (bytesRemaining < 0) { throw new EOFException(); } } catch (IOException e) { throw new EncryptedFileDataSourceException(e); } opened = true; transferStarted(dataSpec); return bytesRemaining; }
Example #17
Source File: ChatActionCell.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void setMessageObject(MessageObject messageObject) { if (currentMessageObject == messageObject && (hasReplyMessage || messageObject.replyMessageObject == null)) { return; } currentMessageObject = messageObject; hasReplyMessage = messageObject.replyMessageObject != null; previousWidth = 0; if (currentMessageObject.type == 11) { int id = 0; if (messageObject.messageOwner.to_id != null) { if (messageObject.messageOwner.to_id.chat_id != 0) { id = messageObject.messageOwner.to_id.chat_id; } else if (messageObject.messageOwner.to_id.channel_id != 0) { id = messageObject.messageOwner.to_id.channel_id; } else { id = messageObject.messageOwner.to_id.user_id; if (id == UserConfig.getInstance(currentAccount).getClientUserId()) { id = messageObject.messageOwner.from_id; } } } avatarDrawable.setInfo(id, null, null); if (currentMessageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserUpdatedPhoto) { imageReceiver.setImage(null, null, avatarDrawable, null, currentMessageObject, 0); } else { TLRPC.PhotoSize photo = FileLoader.getClosestPhotoSizeWithSize(currentMessageObject.photoThumbs, AndroidUtilities.dp(64)); if (photo != null) { imageReceiver.setImage(ImageLocation.getForObject(photo, currentMessageObject.photoThumbsObject), "50_50", avatarDrawable, null, currentMessageObject, 0); } else { imageReceiver.setImageBitmap(avatarDrawable); } } imageReceiver.setVisible(!PhotoViewer.isShowingImage(currentMessageObject), false); } else { imageReceiver.setImageBitmap((Bitmap) null); } requestLayout(); }
Example #18
Source File: PopupAudioView.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void downloadAudioIfNeed() { if (buttonState == 2) { FileLoader.getInstance(currentAccount).loadFile(currentMessageObject.getDocument(), currentMessageObject, 1, 0); buttonState = 3; invalidate(); } }
Example #19
Source File: InstantCameraView.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void didWriteData(File file, long availableSize, boolean last) { if (videoConvertFirstWrite) { FileLoader.getInstance(currentAccount).uploadFile(file.toString(), isSecretChat, false, 1, ConnectionsManager.FileTypeVideo); videoConvertFirstWrite = false; if (last) { FileLoader.getInstance(currentAccount).checkUploadNewDataAvailable(file.toString(), isSecretChat, availableSize, last ? file.length() : 0); } } else { FileLoader.getInstance(currentAccount).checkUploadNewDataAvailable(file.toString(), isSecretChat, availableSize, last ? file.length() : 0); } }
Example #20
Source File: SharedAudioCell.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void didPressedButton() { if (buttonState == 0) { if (miniButtonState == 0) { FileLoader.getInstance(currentAccount).loadFile(currentMessageObject.getDocument(), currentMessageObject, 1, 0); } if (needPlayMessage(currentMessageObject)) { if (hasMiniProgress == 2 && miniButtonState != 1) { miniButtonState = 1; radialProgress.setProgress(0, false); radialProgress.setMiniIcon(getMiniIconForCurrentState(), false, true); } buttonState = 1; radialProgress.setIcon(getIconForCurrentState(), false, true); invalidate(); } } else if (buttonState == 1) { boolean result = MediaController.getInstance().pauseMessage(currentMessageObject); if (result) { buttonState = 0; radialProgress.setIcon(getIconForCurrentState(), false, true); invalidate(); } } else if (buttonState == 2) { radialProgress.setProgress(0, false); FileLoader.getInstance(currentAccount).loadFile(currentMessageObject.getDocument(), currentMessageObject, 1, 0); buttonState = 4; radialProgress.setIcon(getIconForCurrentState(), false, true); invalidate(); } else if (buttonState == 4) { FileLoader.getInstance(currentAccount).cancelLoadFile(currentMessageObject.getDocument()); buttonState = 2; radialProgress.setIcon(getIconForCurrentState(), false, true); invalidate(); } }
Example #21
Source File: ThemesHorizontalListCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); Theme.ThemeInfo t = currentType == ThemeActivity.THEME_TYPE_NIGHT ? Theme.getCurrentNightTheme() : Theme.getCurrentTheme(); button.setChecked(themeInfo == t, false); if (themeInfo != null && themeInfo.info != null && !themeInfo.themeLoaded) { String name = FileLoader.getAttachFileName(themeInfo.info.document); if (!loadingThemes.containsKey(name) && !loadingWallpapers.containsKey(themeInfo)) { themeInfo.themeLoaded = true; placeholderAlpha = 0.0f; parseTheme(); applyTheme(); } } }
Example #22
Source File: PopupAudioView.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
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 #23
Source File: StickerCell.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void setSticker(TLRPC.Document document, Object parent, int side) { parentObject = parent; if (document != null) { TLRPC.PhotoSize thumb = FileLoader.getClosestPhotoSizeWithSize(document.thumbs, 90); if (MessageObject.canAutoplayAnimatedSticker(document)) { if (thumb != null) { imageView.setImage(ImageLocation.getForDocument(document), "80_80", ImageLocation.getForDocument(thumb, document), null, 0, parentObject); } else { imageView.setImage(ImageLocation.getForDocument(document), "80_80", null, null, parentObject); } } else { imageView.setImage(ImageLocation.getForDocument(thumb, document), null, "webp", null, parentObject); } } sticker = document; if (side == -1) { setBackgroundResource(R.drawable.stickers_back_left); setPadding(AndroidUtilities.dp(7), 0, 0, 0); } else if (side == 0) { setBackgroundResource(R.drawable.stickers_back_center); setPadding(0, 0, 0, 0); } else if (side == 1) { setBackgroundResource(R.drawable.stickers_back_right); setPadding(0, 0, AndroidUtilities.dp(7), 0); } else if (side == 2) { setBackgroundResource(R.drawable.stickers_back_all); setPadding(AndroidUtilities.dp(3), 0, AndroidUtilities.dp(3), 0); } Drawable background = getBackground(); if (background != null) { background.setAlpha(230); background.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_stickersHintPanel), PorterDuff.Mode.MULTIPLY)); } }
Example #24
Source File: OtherDocumentPlaceholderDrawable.java From Telegram with GNU General Public License v2.0 | 5 votes |
public OtherDocumentPlaceholderDrawable(Context context, View view, MessageObject messageObject) { docPaint.setTextSize(AndroidUtilities.dp(14)); namePaint.setTextSize(AndroidUtilities.dp(19)); sizePaint.setTextSize(AndroidUtilities.dp(15)); buttonPaint.setTextSize(AndroidUtilities.dp(15)); percentPaint.setTextSize(AndroidUtilities.dp(15)); openPaint.setTextSize(AndroidUtilities.dp(15)); progressPaint.setStrokeWidth(AndroidUtilities.dp(2)); parentView = view; parentMessageObject = messageObject; TAG = DownloadController.getInstance(messageObject.currentAccount).generateObserverTag(); TLRPC.Document document = messageObject.getDocument(); if (document != null) { fileName = FileLoader.getDocumentFileName(messageObject.getDocument()); if (TextUtils.isEmpty(fileName)) { fileName = "name"; } int idx; ext = (idx = fileName.lastIndexOf('.')) == -1 ? "" : fileName.substring(idx + 1).toUpperCase(); int w = (int) Math.ceil(docPaint.measureText(ext)); if (w > AndroidUtilities.dp(40)) { ext = TextUtils.ellipsize(ext, docPaint, AndroidUtilities.dp(40), TextUtils.TruncateAt.END).toString(); } thumbDrawable = context.getResources().getDrawable(AndroidUtilities.getThumbForNameOrMime(fileName, messageObject.getDocument().mime_type, true)).mutate(); fileSize = AndroidUtilities.formatFileSize(document.size); w = (int) Math.ceil(namePaint.measureText(fileName)); if (w > AndroidUtilities.dp(320)) { fileName = TextUtils.ellipsize(fileName, namePaint, AndroidUtilities.dp(320), TextUtils.TruncateAt.END).toString(); } } checkFileExist(); }
Example #25
Source File: PhotoObject.java From Yahala-Messenger with MIT License | 5 votes |
public PhotoObject(TLRPC.PhotoSize photo) { photoOwner = photo; if (photo instanceof TLRPC.TL_photoCachedSize) { BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inPreferredConfig = Bitmap.Config.RGB_565; opts.inDither = false; opts.outWidth = photo.w; opts.outHeight = photo.h; image = BitmapFactory.decodeByteArray(photoOwner.bytes, 0, photoOwner.bytes.length, opts); if (image != null && FileLoader.getInstance().runtimeHack != null) { FileLoader.getInstance().runtimeHack.trackFree(image.getRowBytes() * image.getHeight()); } } }
Example #26
Source File: ImageUpdater.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void processBitmap(Bitmap bitmap) { if (bitmap == null) { return; } if (encryptedDocument) { bigPhoto = ImageLoader.scaleAndSaveImage(bitmap, 2048, 2048, 89, false, 320, 320); if (delegate != null) { TLRPC.TL_secureFile secureFile = new TLRPC.TL_secureFile(); secureFile.dc_id = (int) bigPhoto.location.volume_id; secureFile.id = bigPhoto.location.local_id; secureFile.date = (int) (System.currentTimeMillis() / 1000); delegate.didUploadedPhoto(null, null, null, secureFile); } SharedConfig.saveConfig(); } else { smallPhoto = ImageLoader.scaleAndSaveImage(bitmap, 100, 100, 80, false); bigPhoto = ImageLoader.scaleAndSaveImage(bitmap, 800, 800, 80, false, 320, 320); bitmap.recycle(); if (bigPhoto != null && smallPhoto != null) { if (returnOnly) { if (delegate != null) { delegate.didUploadedPhoto(null, smallPhoto, bigPhoto, null); } } else { UserConfig.getInstance(currentAccount).saveConfig(false); uploadingImage = FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE) + "/" + bigPhoto.location.volume_id + "_" + bigPhoto.location.local_id + ".jpg"; NotificationCenter.getInstance(currentAccount).addObserver(ImageUpdater.this, NotificationCenter.FileDidUpload); NotificationCenter.getInstance(currentAccount).addObserver(ImageUpdater.this, NotificationCenter.FileDidFailUpload); FileLoader.getInstance(currentAccount).uploadFile(uploadingImage, false, true, ConnectionsManager.FileTypePhoto); } } } }
Example #27
Source File: AudioPlayerCell.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void didPressedButton() { if (buttonState == 0) { if (miniButtonState == 0) { FileLoader.getInstance(currentAccount).loadFile(currentMessageObject.getDocument(), currentMessageObject, 1, 0); } if (MediaController.getInstance().findMessageInPlaylistAndPlay(currentMessageObject)) { if (hasMiniProgress == 2 && miniButtonState != 1) { miniButtonState = 1; radialProgress.setProgress(0, false); radialProgress.setMiniIcon(getMiniIconForCurrentState(), false, true); } buttonState = 1; radialProgress.setIcon(getIconForCurrentState(), false, true); invalidate(); } } else if (buttonState == 1) { boolean result = MediaController.getInstance().pauseMessage(currentMessageObject); if (result) { buttonState = 0; radialProgress.setIcon(getIconForCurrentState(), false, true); invalidate(); } } else if (buttonState == 2) { radialProgress.setProgress(0, false); FileLoader.getInstance(currentAccount).loadFile(currentMessageObject.getDocument(), currentMessageObject, 1, 0); buttonState = 4; radialProgress.setIcon(getIconForCurrentState(), false, true); invalidate(); } else if (buttonState == 4) { FileLoader.getInstance(currentAccount).cancelLoadFile(currentMessageObject.getDocument()); buttonState = 2; radialProgress.setIcon(getIconForCurrentState(), false, true); invalidate(); } }
Example #28
Source File: PopupAudioView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void downloadAudioIfNeed() { if (buttonState == 2) { FileLoader.getInstance(currentAccount).loadFile(currentMessageObject.getDocument(), true, 0); buttonState = 3; invalidate(); } }
Example #29
Source File: InstantCameraView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void didWriteData(File file, boolean last) { if (videoConvertFirstWrite) { FileLoader.getInstance(currentAccount).uploadFile(file.toString(), isSecretChat, false, 1, ConnectionsManager.FileTypeVideo); videoConvertFirstWrite = false; if (last) { FileLoader.getInstance(currentAccount).checkUploadNewDataAvailable(file.toString(), isSecretChat, file.length(), last ? file.length() : 0); } } else { FileLoader.getInstance(currentAccount).checkUploadNewDataAvailable(file.toString(), isSecretChat, file.length(), last ? file.length() : 0); } }
Example #30
Source File: ExtendedDefaultDataSource.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public long open(DataSpec dataSpec) throws IOException { Assertions.checkState(dataSource == null); // Choose the correct source for the scheme. String scheme = dataSpec.uri.getScheme(); if (Util.isLocalFileUri(dataSpec.uri)) { if (dataSpec.uri.getPath().startsWith("/android_asset/")) { dataSource = assetDataSource; } else { if (dataSpec.uri.getPath().endsWith(".enc")) { dataSource = encryptedFileDataSource; } else { dataSource = fileDataSource; } } } else if ("tg".equals(scheme)) { dataSource = FileLoader.getStreamLoadOperation(listener); } else if (SCHEME_ASSET.equals(scheme)) { dataSource = assetDataSource; } else if (SCHEME_CONTENT.equals(scheme)) { dataSource = contentDataSource; } else { dataSource = baseDataSource; } // Open the source and return. return dataSource.open(dataSpec); }