release
jhengazuki 7 months ago
parent 315f71e80c
commit 55505fb3c7
  1. 16
      app/src/mobile/java/com/fongmi/android/tv/Product.java

@ -1,6 +1,8 @@
package com.fongmi.android.tv;
import android.content.Context;
import android.os.Build;
import android.view.DisplayCutout;
import com.fongmi.android.tv.bean.Style;
import com.fongmi.android.tv.utils.ResUtil;
@ -27,14 +29,11 @@ public class Product {
public static int[] getSpec(Context context, Style style) {
int column = getColumn(context, style);
int space = ResUtil.dp2px(32) + ResUtil.dp2px(16 * (column - 1));
int space = ResUtil.dp2px(32) + ResUtil.dp2px(16 * (column - 1)) + getCutout(context);
if (style.isOval()) space += ResUtil.dp2px(column * 16);
return getSpec(context, space, column, style);
}
public static int[] getSpec(Context context, int space, int column) {
return getSpec(context, space, column, Style.rect());
}
private static int[] getSpec(Context context, int space, int column, Style style) {
int base = ResUtil.getScreenWidth(context) - space;
@ -42,4 +41,13 @@ public class Product {
int height = (int) (width / style.getRatio());
return new int[]{width, height};
}
private static int getCutout(Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return 0;
DisplayCutout cutout = ResUtil.getDisplay(context).getCutout();
if (cutout == null) return 0;
int left = cutout.getSafeInsetLeft();
int right = cutout.getSafeInsetRight();
return left | right;
}
}

Loading…
Cancel
Save