160 lines
5.4 KiB
Java
160 lines
5.4 KiB
Java
package com.bottle.hp.album;
|
|
|
|
import android.content.ContentResolver;
|
|
import android.content.Context;
|
|
import android.database.Cursor;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.BitmapFactory;
|
|
import android.provider.MediaStore;
|
|
import android.text.TextUtils;
|
|
import android.text.format.Time;
|
|
import android.util.DisplayMetrics;
|
|
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
import java.util.regex.Pattern;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class Utils {
|
|
public static String a() {
|
|
Time time = new Time();
|
|
time.setToNow();
|
|
return "" + time.year + time.month + time.monthDay + "_" + time.hour + time.minute + time.second;
|
|
}
|
|
|
|
public static int b(Context context) {
|
|
new DisplayMetrics();
|
|
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
|
if (displayMetrics == null) {
|
|
return 0;
|
|
}
|
|
return displayMetrics.widthPixels;
|
|
}
|
|
|
|
public static boolean b(String str) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
return false;
|
|
}
|
|
try {
|
|
return Pattern.compile("[0-9]{1,}").matcher(str).matches();
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static String a(long j) {
|
|
long j2 = j / 1000;
|
|
long j3 = j2 % 60;
|
|
long j4 = (j2 / 60) % 60;
|
|
long j5 = j2 / 3600;
|
|
return j5 > 0 ? String.format("%d:%02d:%02d", Long.valueOf(j5), Long.valueOf(j4), Long.valueOf(j3)) : String.format("%02d:%02d", Long.valueOf(j4), Long.valueOf(j3));
|
|
}
|
|
|
|
public static int a(Context context, float f) {
|
|
return (int) ((f * context.getResources().getDisplayMetrics().density) + 0.5f);
|
|
}
|
|
|
|
public static int a(Context context) {
|
|
new DisplayMetrics();
|
|
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
|
|
if (displayMetrics == null) {
|
|
return 0;
|
|
}
|
|
return displayMetrics.heightPixels;
|
|
}
|
|
|
|
public static Bitmap a(ContentResolver contentResolver, String str, int i) {
|
|
Cursor cursor;
|
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
|
options.inDither = false;
|
|
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
|
|
try {
|
|
cursor = contentResolver.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, new String[]{FileDownloadModel.ID}, "_data='" + str.replace("'", "''") + "'", null, null);
|
|
} catch (Throwable th) {
|
|
th.printStackTrace();
|
|
cursor = null;
|
|
}
|
|
if (cursor == null || cursor.getCount() == 0) {
|
|
return null;
|
|
}
|
|
cursor.moveToFirst();
|
|
String string = cursor.getString(cursor.getColumnIndex(FileDownloadModel.ID));
|
|
if (string == null) {
|
|
return null;
|
|
}
|
|
cursor.close();
|
|
return MediaStore.Video.Thumbnails.getThumbnail(contentResolver, Long.parseLong(string), i, options);
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:13:0x001b, code lost:
|
|
|
|
if (r1 == null) goto L15;
|
|
*/
|
|
/* JADX WARN: Removed duplicated region for block: B:17:0x0022 */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
|
*/
|
|
public static android.graphics.Bitmap a(java.lang.String r2) {
|
|
/*
|
|
r0 = 0
|
|
android.media.MediaMetadataRetriever r1 = new android.media.MediaMetadataRetriever // Catch: java.lang.Throwable -> L13 java.lang.Exception -> L16
|
|
r1.<init>() // Catch: java.lang.Throwable -> L13 java.lang.Exception -> L16
|
|
r1.setDataSource(r2) // Catch: java.lang.Exception -> L11 java.lang.Throwable -> L1f
|
|
android.graphics.Bitmap r0 = r1.getFrameAtTime() // Catch: java.lang.Exception -> L11 java.lang.Throwable -> L1f
|
|
Ld:
|
|
r1.release()
|
|
goto L1e
|
|
L11:
|
|
r2 = move-exception
|
|
goto L18
|
|
L13:
|
|
r2 = move-exception
|
|
r1 = r0
|
|
goto L20
|
|
L16:
|
|
r2 = move-exception
|
|
r1 = r0
|
|
L18:
|
|
r2.printStackTrace() // Catch: java.lang.Throwable -> L1f
|
|
if (r1 == 0) goto L1e
|
|
goto Ld
|
|
L1e:
|
|
return r0
|
|
L1f:
|
|
r2 = move-exception
|
|
L20:
|
|
if (r1 == 0) goto L25
|
|
r1.release()
|
|
L25:
|
|
throw r2
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.bottle.hp.album.Utils.a(java.lang.String):android.graphics.Bitmap");
|
|
}
|
|
|
|
public static long a(File file) throws Exception {
|
|
if (file.exists()) {
|
|
FileInputStream fileInputStream = new FileInputStream(file);
|
|
try {
|
|
long available = fileInputStream.available();
|
|
fileInputStream.close();
|
|
return available;
|
|
} catch (Throwable th) {
|
|
try {
|
|
throw th;
|
|
} catch (Throwable th2) {
|
|
try {
|
|
fileInputStream.close();
|
|
} catch (Throwable th3) {
|
|
th.addSuppressed(th3);
|
|
}
|
|
throw th2;
|
|
}
|
|
}
|
|
}
|
|
System.out.println("文件不存在");
|
|
return 0L;
|
|
}
|
|
}
|