- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
47 lines
1.9 KiB
Java
47 lines
1.9 KiB
Java
package com.vungle.ads.internal.util;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.Resources;
|
|
import android.util.DisplayMetrics;
|
|
import android.webkit.WebView;
|
|
import kotlin.Pair;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
|
|
/* loaded from: classes4.dex */
|
|
public final class ViewUtility {
|
|
public static final ViewUtility INSTANCE = new ViewUtility();
|
|
|
|
private ViewUtility() {
|
|
}
|
|
|
|
public final int dpToPixels(Context context, int i) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
return (int) ((i * context.getResources().getDisplayMetrics().density) + 0.5f);
|
|
}
|
|
|
|
public final WebView getWebView(Context context) throws InstantiationException {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
try {
|
|
return new WebView(context);
|
|
} catch (Resources.NotFoundException e) {
|
|
throw new InstantiationException("Cannot instantiate WebView due to Resources.NotFoundException: " + e + ".message");
|
|
} catch (Exception e2) {
|
|
throw new InstantiationException(e2.getMessage());
|
|
}
|
|
}
|
|
|
|
public final Pair getDeviceWidthAndHeightWithOrientation(Context context, int i) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
Resources resources = context.getApplicationContext().getResources();
|
|
DisplayMetrics displayMetrics = resources.getDisplayMetrics();
|
|
int i2 = resources.getConfiguration().orientation;
|
|
if (i == 0) {
|
|
i = i2;
|
|
}
|
|
if (i == i2) {
|
|
return new Pair(Integer.valueOf(Math.round(displayMetrics.widthPixels / displayMetrics.density)), Integer.valueOf(Math.round(displayMetrics.heightPixels / displayMetrics.density)));
|
|
}
|
|
return new Pair(Integer.valueOf(Math.round(displayMetrics.heightPixels / displayMetrics.density)), Integer.valueOf(Math.round(displayMetrics.widthPixels / displayMetrics.density)));
|
|
}
|
|
}
|