DownloadUtils
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
package com.vk.core.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.DownloadManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteException;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.facebook.common.i.MediaUtils;
|
||||
import com.facebook.x.g.EncodedImage;
|
||||
import com.vk.core.concurrent.VkExecutors;
|
||||
import com.vk.imageloader.VKImageLoader;
|
||||
import com.vk.log.L;
|
||||
import com.vk.metrics.eventtracking.VkTracker;
|
||||
import com.vtosters.lite.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.util.HashSet;
|
||||
|
||||
import b.h.g.m.CameraUtils;
|
||||
import b.h.g.m.FileUtils;
|
||||
|
||||
public class DownloadUtils {
|
||||
public static final HashSet<Long> a = new HashSet<>();
|
||||
|
||||
public static void a(Context context, String str, String str2) {
|
||||
a(context, str, str2, false);
|
||||
}
|
||||
|
||||
public static void b(Context context, String str, String str2) {
|
||||
a(context, str, str2, true);
|
||||
}
|
||||
|
||||
private static void a(Context context, String str, String str2, boolean z) {
|
||||
try {
|
||||
b(context, str, str2, z);
|
||||
} catch (Exception e2) {
|
||||
L.d(e2);
|
||||
ToastUtils.a(context.getString(R.string.error) + " [" + e2.getMessage() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
private static void b(final Context context, String str, String str2, boolean z) {
|
||||
if (TextUtils.isEmpty(str2)) {
|
||||
return;
|
||||
}
|
||||
boolean c2 = MediaUtils.c(MediaUtils.b(str2));
|
||||
final File b2 = FileUtils.b(a(str, str2));
|
||||
if (c2) {
|
||||
EncodedImage c3 = VKImageLoader.c(Uri.parse(str2));
|
||||
final InputStream h = c3 == null ? null : c3.h();
|
||||
if (h != null) {
|
||||
try {
|
||||
if (b2.exists() || FileUtils.b(b2)) {
|
||||
VkExecutors.x.a().execute(() -> ToastUtils.a(context.getString(R.string.file_saved, b2.getAbsoluteFile())));
|
||||
}
|
||||
} catch (Exception e2) {
|
||||
L.a(e2);
|
||||
}
|
||||
CameraUtils.a(context, b2, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(str2));
|
||||
request.setDestinationUri(Uri.fromFile(b2));
|
||||
request.setMimeType(FileUtils.f(new File(str)));
|
||||
request.setNotificationVisibility(1);
|
||||
request.allowScanningByMediaScanner();
|
||||
request.setTitle(str);
|
||||
DownloadManager a2 = a(context);
|
||||
if (a2 == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
long enqueue = a2.enqueue(request);
|
||||
if (!z) {
|
||||
return;
|
||||
}
|
||||
a.add(enqueue);
|
||||
} catch (IllegalArgumentException e3) {
|
||||
L.a(e3);
|
||||
b(context);
|
||||
}
|
||||
}
|
||||
|
||||
private static String a(String str, String str2) {
|
||||
String lastPathSegment = Uri.parse(str2).getLastPathSegment();
|
||||
if (!TextUtils.isEmpty(str)) {
|
||||
String replace = str.replace('/', '_');
|
||||
return !replace.contains(".") ? lastPathSegment : replace;
|
||||
}
|
||||
return lastPathSegment;
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("Range")
|
||||
public static boolean a(Context context, Uri uri) {
|
||||
try {
|
||||
Cursor query = a(context).query(new DownloadManager.Query().setFilterByStatus(11));
|
||||
if (query != null && query.moveToFirst()) {
|
||||
while (!uri.toString().equals(query.getString(query.getColumnIndex("uri")))) {
|
||||
if (!query.moveToNext()) {
|
||||
query.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@SuppressLint("Range")
|
||||
int i = query.getInt(query.getColumnIndex("status"));
|
||||
@SuppressLint("Range")
|
||||
String string = query.getString(query.getColumnIndex("local_uri"));
|
||||
query.close();
|
||||
if (i == 1 || i == 2) {
|
||||
ToastUtils.a(R.string.download_is_in_progress);
|
||||
query.close();
|
||||
return true;
|
||||
} else if (i != 8) {
|
||||
query.close();
|
||||
return false;
|
||||
} else {
|
||||
boolean a2 = a(context, string);
|
||||
query.close();
|
||||
return a2;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} catch (SQLiteException e2) {
|
||||
VkTracker.k.b(e2);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void b(Context context) {
|
||||
if (context != null) {
|
||||
try {
|
||||
context.startActivity(new Intent("android.settings.APPLICATION_DETAILS_SETTINGS").setData(Uri.parse("package:com.android.providers.downloads")));
|
||||
} catch (ActivityNotFoundException e2) {
|
||||
L.a(e2);
|
||||
context.startActivity(new Intent("android.settings.MANAGE_APPLICATIONS_SETTINGS"));
|
||||
}
|
||||
ToastUtils.a("Please enable download manager", true);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean a(Context context, String str) {
|
||||
File file;
|
||||
try {
|
||||
try {
|
||||
file = new File(new URI(str));
|
||||
try {
|
||||
if (!file.exists()) {
|
||||
return false;
|
||||
}
|
||||
Intent intent = new Intent("android.intent.action.VIEW");
|
||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
String f2 = FileUtils.f(file);
|
||||
if (!TextUtils.isEmpty(f2)) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.setDataAndType(FileUtils.n(file), f2);
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
throw new ActivityNotFoundException();
|
||||
} catch (ActivityNotFoundException unused) {
|
||||
return a(context, file);
|
||||
}
|
||||
} catch (ActivityNotFoundException unused2) {
|
||||
unused2.printStackTrace();
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
VkTracker.k.b(th);
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean a(Context context, File file) {
|
||||
if (file != null && file.exists()) {
|
||||
Intent intent = new Intent("android.intent.action.VIEW");
|
||||
intent.setDataAndType(Uri.parse(file.getAbsolutePath()), "application/*");
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
return true;
|
||||
} catch (ActivityNotFoundException e2) {
|
||||
L.a(e2);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static DownloadManager a(Context context) {
|
||||
return (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
.class final Lcom/vk/core/util/DownloadUtils$a;
|
||||
.super Lb/h/g/m/FileUtils$a$b;
|
||||
.source "DownloadUtils.java"
|
||||
|
||||
|
||||
# annotations
|
||||
.annotation system Ldalvik/annotation/EnclosingMethod;
|
||||
value = Lcom/vk/core/util/DownloadUtils;->a(Ljava/io/InputStream;Ljava/io/File;Landroid/content/Context;)V
|
||||
.end annotation
|
||||
|
||||
.annotation system Ldalvik/annotation/InnerClass;
|
||||
accessFlags = 0x8
|
||||
name = null
|
||||
.end annotation
|
||||
|
||||
|
||||
# instance fields
|
||||
.field final synthetic a:Landroid/content/Context;
|
||||
|
||||
.field final synthetic b:Ljava/io/File;
|
||||
|
||||
|
||||
# direct methods
|
||||
.method constructor <init>(Landroid/content/Context;Ljava/io/File;)V
|
||||
.locals 0
|
||||
|
||||
.line 1
|
||||
iput-object p1, p0, Lcom/vk/core/util/DownloadUtils$a;->a:Landroid/content/Context;
|
||||
|
||||
iput-object p2, p0, Lcom/vk/core/util/DownloadUtils$a;->b:Ljava/io/File;
|
||||
|
||||
invoke-direct {p0}, Lb/h/g/m/FileUtils$a$b;-><init>()V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
|
||||
# virtual methods
|
||||
.method public b()V
|
||||
.locals 4
|
||||
|
||||
.line 1
|
||||
iget-object v0, p0, Lcom/vk/core/util/DownloadUtils$a;->a:Landroid/content/Context;
|
||||
|
||||
const/4 v1, 0x1
|
||||
|
||||
new-array v1, v1, [Ljava/lang/Object;
|
||||
|
||||
iget-object v2, p0, Lcom/vk/core/util/DownloadUtils$a;->b:Ljava/io/File;
|
||||
|
||||
invoke-virtual {v2}, Ljava/io/File;->getAbsoluteFile()Ljava/io/File;
|
||||
|
||||
move-result-object v2
|
||||
|
||||
const/4 v3, 0x0
|
||||
|
||||
aput-object v2, v1, v3
|
||||
|
||||
const v2, 0x7f120400
|
||||
|
||||
invoke-virtual {v0, v2, v1}, Landroid/content/Context;->getString(I[Ljava/lang/Object;)Ljava/lang/String;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
invoke-static {v0}, Lcom/vk/core/util/ToastUtils;->a(Ljava/lang/CharSequence;)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
@@ -1,810 +0,0 @@
|
||||
.class public Lcom/vk/core/util/DownloadUtils;
|
||||
.super Ljava/lang/Object;
|
||||
.source "DownloadUtils.java"
|
||||
|
||||
|
||||
# static fields
|
||||
.field public static final a:Ljava/util/HashSet;
|
||||
.annotation system Ldalvik/annotation/Signature;
|
||||
value = {
|
||||
"Ljava/util/HashSet<",
|
||||
"Ljava/lang/Long;",
|
||||
">;"
|
||||
}
|
||||
.end annotation
|
||||
.end field
|
||||
|
||||
|
||||
# direct methods
|
||||
.method static constructor <clinit>()V
|
||||
.locals 1
|
||||
|
||||
.line 1
|
||||
new-instance v0, Ljava/util/HashSet;
|
||||
|
||||
invoke-direct {v0}, Ljava/util/HashSet;-><init>()V
|
||||
|
||||
sput-object v0, Lcom/vk/core/util/DownloadUtils;->a:Ljava/util/HashSet;
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method private static a(Landroid/content/Context;)Landroid/app/DownloadManager;
|
||||
.locals 1
|
||||
|
||||
const-string v0, "download"
|
||||
|
||||
.line 49
|
||||
invoke-virtual {p0, v0}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;
|
||||
|
||||
move-result-object p0
|
||||
|
||||
check-cast p0, Landroid/app/DownloadManager;
|
||||
|
||||
return-object p0
|
||||
.end method
|
||||
|
||||
.method private static a(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
||||
.locals 2
|
||||
|
||||
.line 6
|
||||
invoke-static {p1}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
.line 7
|
||||
invoke-virtual {p1}, Landroid/net/Uri;->getLastPathSegment()Ljava/lang/String;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
.line 8
|
||||
invoke-static {p0}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-nez v0, :cond_1
|
||||
|
||||
const/16 v0, 0x2f
|
||||
|
||||
const/16 v1, 0x5f
|
||||
|
||||
.line 9
|
||||
invoke-virtual {p0, v0, v1}, Ljava/lang/String;->replace(CC)Ljava/lang/String;
|
||||
|
||||
move-result-object p0
|
||||
|
||||
const-string v0, "."
|
||||
|
||||
.line 10
|
||||
invoke-virtual {p0, v0}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-nez v0, :cond_0
|
||||
|
||||
return-object p1
|
||||
|
||||
:cond_0
|
||||
return-object p0
|
||||
|
||||
:cond_1
|
||||
return-object p1
|
||||
.end method
|
||||
|
||||
.method public static a(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V
|
||||
.locals 1
|
||||
|
||||
const/4 v0, 0x0
|
||||
|
||||
.line 1
|
||||
invoke-static {p0, p1, p2, v0}, Lcom/vk/core/util/DownloadUtils;->a(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Z)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method private static a(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Z)V
|
||||
.locals 0
|
||||
|
||||
.line 2
|
||||
:try_start_0
|
||||
invoke-static {p0, p1, p2, p3}, Lcom/vk/core/util/DownloadUtils;->b(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Z)V
|
||||
:try_end_0
|
||||
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
|
||||
|
||||
goto :goto_0
|
||||
|
||||
:catch_0
|
||||
move-exception p1
|
||||
|
||||
const/4 p2, 0x0
|
||||
|
||||
new-array p2, p2, [Ljava/lang/Object;
|
||||
|
||||
.line 3
|
||||
invoke-static {p1, p2}, Lcom/vk/log/L;->d(Ljava/lang/Throwable;[Ljava/lang/Object;)V
|
||||
|
||||
.line 4
|
||||
new-instance p2, Ljava/lang/StringBuilder;
|
||||
|
||||
invoke-direct {p2}, Ljava/lang/StringBuilder;-><init>()V
|
||||
|
||||
const p3, 0x7f120369
|
||||
|
||||
invoke-virtual {p0, p3}, Landroid/content/Context;->getString(I)Ljava/lang/String;
|
||||
|
||||
move-result-object p0
|
||||
|
||||
invoke-virtual {p2, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
||||
|
||||
const-string p0, " ["
|
||||
|
||||
invoke-virtual {p2, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
||||
|
||||
invoke-virtual {p1}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;
|
||||
|
||||
move-result-object p0
|
||||
|
||||
invoke-virtual {p2, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
||||
|
||||
const-string p0, "]"
|
||||
|
||||
invoke-virtual {p2, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
||||
|
||||
invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
||||
|
||||
move-result-object p0
|
||||
|
||||
invoke-static {p0}, Lcom/vk/core/util/ToastUtils;->a(Ljava/lang/CharSequence;)V
|
||||
|
||||
:goto_0
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method static synthetic a(Ljava/io/InputStream;Ljava/io/File;Landroid/content/Context;)V
|
||||
.locals 1
|
||||
|
||||
.line 5
|
||||
new-instance v0, Lcom/vk/core/util/DownloadUtils$a;
|
||||
|
||||
invoke-direct {v0, p2, p1}, Lcom/vk/core/util/DownloadUtils$a;-><init>(Landroid/content/Context;Ljava/io/File;)V
|
||||
|
||||
invoke-static {p0, p1, v0}, Lb/h/g/m/FileUtils$a;->a(Ljava/io/InputStream;Ljava/io/File;Lb/h/g/m/FileUtils$a$a;)Z
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public static a(Landroid/content/Context;Landroid/net/Uri;)Z
|
||||
.locals 5
|
||||
|
||||
.line 11
|
||||
invoke-static {p0}, Lcom/vk/core/util/DownloadUtils;->a(Landroid/content/Context;)Landroid/app/DownloadManager;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
const/4 v1, 0x0
|
||||
|
||||
const/4 v2, 0x0
|
||||
|
||||
.line 12
|
||||
:try_start_0
|
||||
new-instance v3, Landroid/app/DownloadManager$Query;
|
||||
|
||||
invoke-direct {v3}, Landroid/app/DownloadManager$Query;-><init>()V
|
||||
|
||||
const/16 v4, 0xb
|
||||
|
||||
.line 13
|
||||
invoke-virtual {v3, v4}, Landroid/app/DownloadManager$Query;->setFilterByStatus(I)Landroid/app/DownloadManager$Query;
|
||||
|
||||
move-result-object v3
|
||||
|
||||
.line 14
|
||||
invoke-virtual {v0, v3}, Landroid/app/DownloadManager;->query(Landroid/app/DownloadManager$Query;)Landroid/database/Cursor;
|
||||
|
||||
move-result-object v2
|
||||
|
||||
if-eqz v2, :cond_8
|
||||
|
||||
.line 15
|
||||
invoke-interface {v2}, Landroid/database/Cursor;->moveToFirst()Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-nez v0, :cond_0
|
||||
|
||||
goto :goto_0
|
||||
|
||||
:cond_0
|
||||
const-string v0, "uri"
|
||||
|
||||
.line 16
|
||||
invoke-interface {v2, v0}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I
|
||||
|
||||
move-result v0
|
||||
|
||||
invoke-interface {v2, v0}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
.line 17
|
||||
invoke-virtual {p1}, Landroid/net/Uri;->toString()Ljava/lang/String;
|
||||
|
||||
move-result-object v3
|
||||
|
||||
invoke-virtual {v3, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-eqz v0, :cond_6
|
||||
|
||||
const-string p1, "status"
|
||||
|
||||
.line 18
|
||||
invoke-interface {v2, p1}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I
|
||||
|
||||
move-result p1
|
||||
|
||||
invoke-interface {v2, p1}, Landroid/database/Cursor;->getInt(I)I
|
||||
|
||||
move-result p1
|
||||
|
||||
const-string v0, "local_uri"
|
||||
|
||||
.line 19
|
||||
invoke-interface {v2, v0}, Landroid/database/Cursor;->getColumnIndex(Ljava/lang/String;)I
|
||||
|
||||
move-result v0
|
||||
|
||||
invoke-interface {v2, v0}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
.line 20
|
||||
invoke-interface {v2}, Landroid/database/Cursor;->close()V
|
||||
:try_end_0
|
||||
.catch Landroid/database/sqlite/SQLiteException; {:try_start_0 .. :try_end_0} :catch_0
|
||||
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
||||
|
||||
const/4 v3, 0x1
|
||||
|
||||
if-eq p1, v3, :cond_4
|
||||
|
||||
const/4 v4, 0x2
|
||||
|
||||
if-eq p1, v4, :cond_4
|
||||
|
||||
const/16 v3, 0x8
|
||||
|
||||
if-eq p1, v3, :cond_2
|
||||
|
||||
if-eqz v2, :cond_1
|
||||
|
||||
.line 21
|
||||
invoke-interface {v2}, Landroid/database/Cursor;->close()V
|
||||
|
||||
:cond_1
|
||||
return v1
|
||||
|
||||
.line 22
|
||||
:cond_2
|
||||
:try_start_1
|
||||
invoke-static {p0, v0}, Lcom/vk/core/util/DownloadUtils;->a(Landroid/content/Context;Ljava/lang/String;)Z
|
||||
|
||||
move-result p0
|
||||
:try_end_1
|
||||
.catch Landroid/database/sqlite/SQLiteException; {:try_start_1 .. :try_end_1} :catch_0
|
||||
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
||||
|
||||
if-eqz v2, :cond_3
|
||||
|
||||
.line 23
|
||||
invoke-interface {v2}, Landroid/database/Cursor;->close()V
|
||||
|
||||
:cond_3
|
||||
return p0
|
||||
|
||||
:cond_4
|
||||
const p0, 0x7f12032f
|
||||
|
||||
.line 24
|
||||
:try_start_2
|
||||
invoke-static {p0}, Lcom/vk/core/util/ToastUtils;->a(I)V
|
||||
:try_end_2
|
||||
.catch Landroid/database/sqlite/SQLiteException; {:try_start_2 .. :try_end_2} :catch_0
|
||||
.catchall {:try_start_2 .. :try_end_2} :catchall_0
|
||||
|
||||
if-eqz v2, :cond_5
|
||||
|
||||
.line 25
|
||||
invoke-interface {v2}, Landroid/database/Cursor;->close()V
|
||||
|
||||
:cond_5
|
||||
return v3
|
||||
|
||||
.line 26
|
||||
:cond_6
|
||||
:try_start_3
|
||||
invoke-interface {v2}, Landroid/database/Cursor;->moveToNext()Z
|
||||
|
||||
move-result v0
|
||||
:try_end_3
|
||||
.catch Landroid/database/sqlite/SQLiteException; {:try_start_3 .. :try_end_3} :catch_0
|
||||
.catchall {:try_start_3 .. :try_end_3} :catchall_0
|
||||
|
||||
if-nez v0, :cond_0
|
||||
|
||||
if-eqz v2, :cond_7
|
||||
|
||||
.line 27
|
||||
invoke-interface {v2}, Landroid/database/Cursor;->close()V
|
||||
|
||||
:cond_7
|
||||
return v1
|
||||
|
||||
:cond_8
|
||||
:goto_0
|
||||
if-eqz v2, :cond_9
|
||||
|
||||
invoke-interface {v2}, Landroid/database/Cursor;->close()V
|
||||
|
||||
:cond_9
|
||||
return v1
|
||||
|
||||
:catchall_0
|
||||
move-exception p0
|
||||
|
||||
goto :goto_1
|
||||
|
||||
:catch_0
|
||||
move-exception p0
|
||||
|
||||
.line 28
|
||||
:try_start_4
|
||||
sget-object p1, Lcom/vk/metrics/eventtracking/VkTracker;->k:Lcom/vk/metrics/eventtracking/VkTracker;
|
||||
|
||||
invoke-virtual {p1, p0}, Lcom/vk/metrics/eventtracking/VkTracker;->b(Ljava/lang/Throwable;)V
|
||||
:try_end_4
|
||||
.catchall {:try_start_4 .. :try_end_4} :catchall_0
|
||||
|
||||
if-eqz v2, :cond_a
|
||||
|
||||
.line 29
|
||||
invoke-interface {v2}, Landroid/database/Cursor;->close()V
|
||||
|
||||
:cond_a
|
||||
return v1
|
||||
|
||||
:goto_1
|
||||
if-eqz v2, :cond_b
|
||||
|
||||
invoke-interface {v2}, Landroid/database/Cursor;->close()V
|
||||
|
||||
.line 30
|
||||
:cond_b
|
||||
throw p0
|
||||
.end method
|
||||
|
||||
.method private static a(Landroid/content/Context;Ljava/io/File;)Z
|
||||
.locals 3
|
||||
|
||||
const/4 v0, 0x0
|
||||
|
||||
if-eqz p1, :cond_1
|
||||
|
||||
.line 43
|
||||
invoke-virtual {p1}, Ljava/io/File;->exists()Z
|
||||
|
||||
move-result v1
|
||||
|
||||
if-nez v1, :cond_0
|
||||
|
||||
goto :goto_0
|
||||
|
||||
.line 44
|
||||
:cond_0
|
||||
new-instance v1, Landroid/content/Intent;
|
||||
|
||||
const-string v2, "android.intent.action.VIEW"
|
||||
|
||||
invoke-direct {v1, v2}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
|
||||
|
||||
.line 45
|
||||
invoke-virtual {p1}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
invoke-static {p1}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
const-string v2, "application/*"
|
||||
|
||||
invoke-virtual {v1, p1, v2}, Landroid/content/Intent;->setDataAndType(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;
|
||||
|
||||
const/high16 p1, 0x10000000
|
||||
|
||||
.line 46
|
||||
invoke-virtual {v1, p1}, Landroid/content/Intent;->addFlags(I)Landroid/content/Intent;
|
||||
|
||||
.line 47
|
||||
:try_start_0
|
||||
invoke-virtual {p0, v1}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
|
||||
:try_end_0
|
||||
.catch Landroid/content/ActivityNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
|
||||
|
||||
const/4 p0, 0x1
|
||||
|
||||
return p0
|
||||
|
||||
:catch_0
|
||||
move-exception p0
|
||||
|
||||
.line 48
|
||||
invoke-static {p0}, Lcom/vk/log/L;->a(Ljava/lang/Throwable;)V
|
||||
|
||||
:cond_1
|
||||
:goto_0
|
||||
return v0
|
||||
.end method
|
||||
|
||||
.method public static a(Landroid/content/Context;Ljava/lang/String;)Z
|
||||
.locals 5
|
||||
|
||||
const/4 v0, 0x0
|
||||
|
||||
const/4 v1, 0x0
|
||||
|
||||
.line 31
|
||||
:try_start_0
|
||||
new-instance v2, Ljava/io/File;
|
||||
|
||||
new-instance v3, Ljava/net/URI;
|
||||
|
||||
invoke-direct {v3, p1}, Ljava/net/URI;-><init>(Ljava/lang/String;)V
|
||||
|
||||
invoke-direct {v2, v3}, Ljava/io/File;-><init>(Ljava/net/URI;)V
|
||||
:try_end_0
|
||||
.catch Landroid/content/ActivityNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
|
||||
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
||||
|
||||
.line 32
|
||||
:try_start_1
|
||||
invoke-virtual {v2}, Ljava/io/File;->exists()Z
|
||||
|
||||
move-result p1
|
||||
|
||||
if-nez p1, :cond_0
|
||||
|
||||
return v0
|
||||
|
||||
.line 33
|
||||
:cond_0
|
||||
new-instance p1, Landroid/content/Intent;
|
||||
|
||||
const-string v1, "android.intent.action.VIEW"
|
||||
|
||||
invoke-direct {p1, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
|
||||
|
||||
const/4 v1, 0x1
|
||||
|
||||
.line 34
|
||||
invoke-virtual {p1, v1}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;
|
||||
|
||||
.line 35
|
||||
invoke-static {v2}, Lb/h/g/m/FileUtils;->f(Ljava/io/File;)Ljava/lang/String;
|
||||
|
||||
move-result-object v3
|
||||
|
||||
.line 36
|
||||
invoke-static {v3}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
|
||||
|
||||
move-result v4
|
||||
|
||||
if-nez v4, :cond_1
|
||||
|
||||
const/high16 v4, 0x10000000
|
||||
|
||||
.line 37
|
||||
invoke-virtual {p1, v4}, Landroid/content/Intent;->addFlags(I)Landroid/content/Intent;
|
||||
|
||||
.line 38
|
||||
invoke-static {v2}, Lb/h/g/m/FileUtils;->uriFromFile(Ljava/io/File;)Landroid/net/Uri;
|
||||
|
||||
move-result-object v4
|
||||
|
||||
invoke-virtual {p1, v4, v3}, Landroid/content/Intent;->setDataAndType(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;
|
||||
|
||||
.line 39
|
||||
invoke-virtual {p0, p1}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
|
||||
|
||||
return v1
|
||||
|
||||
.line 40
|
||||
:cond_1
|
||||
new-instance p1, Landroid/content/ActivityNotFoundException;
|
||||
|
||||
invoke-direct {p1}, Landroid/content/ActivityNotFoundException;-><init>()V
|
||||
|
||||
throw p1
|
||||
:try_end_1
|
||||
.catch Landroid/content/ActivityNotFoundException; {:try_start_1 .. :try_end_1} :catch_1
|
||||
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
||||
|
||||
:catchall_0
|
||||
move-exception p0
|
||||
|
||||
.line 41
|
||||
sget-object p1, Lcom/vk/metrics/eventtracking/VkTracker;->k:Lcom/vk/metrics/eventtracking/VkTracker;
|
||||
|
||||
invoke-virtual {p1, p0}, Lcom/vk/metrics/eventtracking/VkTracker;->b(Ljava/lang/Throwable;)V
|
||||
|
||||
return v0
|
||||
|
||||
:catch_0
|
||||
move-object v2, v1
|
||||
|
||||
.line 42
|
||||
:catch_1
|
||||
invoke-static {p0, v2}, Lcom/vk/core/util/DownloadUtils;->a(Landroid/content/Context;Ljava/io/File;)Z
|
||||
|
||||
move-result p0
|
||||
|
||||
return p0
|
||||
.end method
|
||||
|
||||
.method private static b(Landroid/content/Context;)V
|
||||
.locals 2
|
||||
|
||||
if-eqz p0, :cond_0
|
||||
|
||||
.line 25
|
||||
:try_start_0
|
||||
new-instance v0, Landroid/content/Intent;
|
||||
|
||||
const-string v1, "android.settings.APPLICATION_DETAILS_SETTINGS"
|
||||
|
||||
invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
|
||||
|
||||
const-string v1, "package:com.android.providers.downloads"
|
||||
|
||||
.line 26
|
||||
invoke-static {v1}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;
|
||||
|
||||
move-result-object v1
|
||||
|
||||
invoke-virtual {v0, v1}, Landroid/content/Intent;->setData(Landroid/net/Uri;)Landroid/content/Intent;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
.line 27
|
||||
invoke-virtual {p0, v0}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
|
||||
:try_end_0
|
||||
.catch Landroid/content/ActivityNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
|
||||
|
||||
goto :goto_0
|
||||
|
||||
:catch_0
|
||||
move-exception v0
|
||||
|
||||
.line 28
|
||||
invoke-static {v0}, Lcom/vk/log/L;->a(Ljava/lang/Throwable;)V
|
||||
|
||||
.line 29
|
||||
new-instance v0, Landroid/content/Intent;
|
||||
|
||||
const-string v1, "android.settings.MANAGE_APPLICATIONS_SETTINGS"
|
||||
|
||||
invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V
|
||||
|
||||
invoke-virtual {p0, v0}, Landroid/content/Context;->startActivity(Landroid/content/Intent;)V
|
||||
|
||||
:goto_0
|
||||
const/4 p0, 0x1
|
||||
|
||||
const-string v0, "Please enable download manager"
|
||||
|
||||
.line 30
|
||||
invoke-static {v0, p0}, Lcom/vk/core/util/ToastUtils;->a(Ljava/lang/CharSequence;Z)V
|
||||
|
||||
:cond_0
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method public static b(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V
|
||||
.locals 1
|
||||
|
||||
const/4 v0, 0x1
|
||||
|
||||
.line 1
|
||||
invoke-static {p0, p1, p2, v0}, Lcom/vk/core/util/DownloadUtils;->a(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Z)V
|
||||
|
||||
return-void
|
||||
.end method
|
||||
|
||||
.method private static b(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Z)V
|
||||
.locals 3
|
||||
|
||||
.line 2
|
||||
invoke-static {p2}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z
|
||||
|
||||
move-result v0
|
||||
|
||||
if-eqz v0, :cond_0
|
||||
|
||||
return-void
|
||||
|
||||
.line 3
|
||||
:cond_0
|
||||
invoke-static {p2}, Lcom/facebook/common/i/MediaUtils;->b(Ljava/lang/String;)Ljava/lang/String;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
.line 4
|
||||
invoke-static {v0}, Lcom/facebook/common/i/MediaUtils;->c(Ljava/lang/String;)Z
|
||||
|
||||
move-result v0
|
||||
|
||||
.line 5
|
||||
invoke-static {p1, p2}, Lcom/vk/core/util/DownloadUtils;->a(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
|
||||
|
||||
move-result-object v1
|
||||
|
||||
.line 6
|
||||
invoke-static {v1}, Lb/h/g/m/FileUtils;->b(Ljava/lang/String;)Ljava/io/File;
|
||||
|
||||
move-result-object v1
|
||||
|
||||
if-eqz v0, :cond_4
|
||||
|
||||
.line 7
|
||||
invoke-static {p2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
invoke-static {v0}, Lcom/vk/imageloader/VKImageLoader;->c(Landroid/net/Uri;)Lcom/facebook/x/g/EncodedImage;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
const/4 v2, 0x0
|
||||
|
||||
if-nez v0, :cond_1
|
||||
|
||||
move-object v0, v2
|
||||
|
||||
goto :goto_0
|
||||
|
||||
.line 8
|
||||
:cond_1
|
||||
invoke-virtual {v0}, Lcom/facebook/x/g/EncodedImage;->h()Ljava/io/InputStream;
|
||||
|
||||
move-result-object v0
|
||||
|
||||
:goto_0
|
||||
if-eqz v0, :cond_4
|
||||
|
||||
.line 9
|
||||
:try_start_0
|
||||
invoke-virtual {v1}, Ljava/io/File;->exists()Z
|
||||
|
||||
move-result p1
|
||||
|
||||
if-nez p1, :cond_2
|
||||
|
||||
invoke-static {v1}, Lb/h/g/m/FileUtils;->b(Ljava/io/File;)Z
|
||||
|
||||
move-result p1
|
||||
|
||||
if-eqz p1, :cond_3
|
||||
|
||||
.line 10
|
||||
:cond_2
|
||||
sget-object p1, Lcom/vk/core/concurrent/VkExecutors;->x:Lcom/vk/core/concurrent/VkExecutors;
|
||||
|
||||
invoke-virtual {p1}, Lcom/vk/core/concurrent/VkExecutors;->a()Ljava/util/concurrent/ExecutorService;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
new-instance p2, Lcom/vk/core/util/a;
|
||||
|
||||
invoke-direct {p2, v0, v1, p0}, Lcom/vk/core/util/a;-><init>(Ljava/io/InputStream;Ljava/io/File;Landroid/content/Context;)V
|
||||
|
||||
invoke-interface {p1, p2}, Ljava/util/concurrent/ExecutorService;->execute(Ljava/lang/Runnable;)V
|
||||
:try_end_0
|
||||
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
|
||||
|
||||
goto :goto_1
|
||||
|
||||
:catch_0
|
||||
move-exception p1
|
||||
|
||||
.line 11
|
||||
invoke-static {p1}, Lcom/vk/log/L;->a(Ljava/lang/Throwable;)V
|
||||
|
||||
.line 12
|
||||
:cond_3
|
||||
:goto_1
|
||||
invoke-static {p0, v1, v2}, Lb/h/g/m/CameraUtils;->a(Landroid/content/Context;Ljava/io/File;Landroid/media/MediaScannerConnection$OnScanCompletedListener;)V
|
||||
|
||||
return-void
|
||||
|
||||
.line 13
|
||||
:cond_4
|
||||
invoke-static {p2}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;
|
||||
|
||||
move-result-object p2
|
||||
|
||||
.line 14
|
||||
new-instance v0, Landroid/app/DownloadManager$Request;
|
||||
|
||||
invoke-direct {v0, p2}, Landroid/app/DownloadManager$Request;-><init>(Landroid/net/Uri;)V
|
||||
|
||||
.line 15
|
||||
invoke-static {v1}, Landroid/net/Uri;->fromFile(Ljava/io/File;)Landroid/net/Uri;
|
||||
|
||||
move-result-object p2
|
||||
|
||||
invoke-virtual {v0, p2}, Landroid/app/DownloadManager$Request;->setDestinationUri(Landroid/net/Uri;)Landroid/app/DownloadManager$Request;
|
||||
|
||||
.line 16
|
||||
new-instance p2, Ljava/io/File;
|
||||
|
||||
invoke-direct {p2, p1}, Ljava/io/File;-><init>(Ljava/lang/String;)V
|
||||
|
||||
invoke-static {p2}, Lb/h/g/m/FileUtils;->f(Ljava/io/File;)Ljava/lang/String;
|
||||
|
||||
move-result-object p2
|
||||
|
||||
invoke-virtual {v0, p2}, Landroid/app/DownloadManager$Request;->setMimeType(Ljava/lang/String;)Landroid/app/DownloadManager$Request;
|
||||
|
||||
const/4 p2, 0x1
|
||||
|
||||
.line 17
|
||||
invoke-virtual {v0, p2}, Landroid/app/DownloadManager$Request;->setNotificationVisibility(I)Landroid/app/DownloadManager$Request;
|
||||
|
||||
.line 18
|
||||
invoke-virtual {v0}, Landroid/app/DownloadManager$Request;->allowScanningByMediaScanner()V
|
||||
|
||||
.line 19
|
||||
invoke-virtual {v0, p1}, Landroid/app/DownloadManager$Request;->setTitle(Ljava/lang/CharSequence;)Landroid/app/DownloadManager$Request;
|
||||
|
||||
.line 20
|
||||
invoke-static {p0}, Lcom/vk/core/util/DownloadUtils;->a(Landroid/content/Context;)Landroid/app/DownloadManager;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
if-eqz p1, :cond_5
|
||||
|
||||
.line 21
|
||||
:try_start_1
|
||||
invoke-virtual {p1, v0}, Landroid/app/DownloadManager;->enqueue(Landroid/app/DownloadManager$Request;)J
|
||||
|
||||
move-result-wide p1
|
||||
|
||||
if-eqz p3, :cond_5
|
||||
|
||||
.line 22
|
||||
sget-object p3, Lcom/vk/core/util/DownloadUtils;->a:Ljava/util/HashSet;
|
||||
|
||||
invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;
|
||||
|
||||
move-result-object p1
|
||||
|
||||
invoke-virtual {p3, p1}, Ljava/util/HashSet;->add(Ljava/lang/Object;)Z
|
||||
:try_end_1
|
||||
.catch Ljava/lang/IllegalArgumentException; {:try_start_1 .. :try_end_1} :catch_1
|
||||
|
||||
goto :goto_2
|
||||
|
||||
:catch_1
|
||||
move-exception p1
|
||||
|
||||
.line 23
|
||||
invoke-static {p1}, Lcom/vk/log/L;->a(Ljava/lang/Throwable;)V
|
||||
|
||||
.line 24
|
||||
invoke-static {p0}, Lcom/vk/core/util/DownloadUtils;->b(Landroid/content/Context;)V
|
||||
|
||||
:cond_5
|
||||
:goto_2
|
||||
return-void
|
||||
.end method
|
||||
Reference in New Issue
Block a user