Merge pull request #374 from okcaptain/dev

Dev
pull/375/head^2
okcaptain 2 years ago committed by GitHub
commit dfbf55bc22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      app/build.gradle
  2. 12
      app/src/leanback/java/com/fongmi/android/tv/ui/dialog/MenuDialog.java
  3. 12
      app/src/leanback/java/com/fongmi/android/tv/ui/dialog/MenuKeyDialog.java
  4. 13
      app/src/main/java/com/fongmi/android/tv/ui/custom/CustomWebView.java

@ -10,8 +10,8 @@ android {
applicationId "com.fongmi.android.tv"
minSdk 21
targetSdk 28
versionCode 231
versionName "0329"
versionCode 232
versionName "2.3.2"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]

@ -50,6 +50,14 @@ public class MenuDialog implements MenuAdapter.OnClickListener {
initView();
}
private int getCount() {
return 2;
}
private float getWidth() {
return 0.4f + (getCount() - 1) * 0.2f;
}
private void initView() {
setRecyclerView();
setDialog();
@ -61,14 +69,14 @@ public class MenuDialog implements MenuAdapter.OnClickListener {
binding.recycler.setHasFixedSize(true);
binding.recycler.setItemAnimator(null);
binding.recycler.addItemDecoration(new SpaceItemDecoration(1, 16));
binding.recycler.setLayoutManager(new GridLayoutManager(dialog.getContext(), 1));
binding.recycler.setLayoutManager(new GridLayoutManager(dialog.getContext(), getCount()));
binding.recycler.post(() -> binding.recycler.scrollToPosition(0));
}
private void setDialog() {
WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
params.width = (int) (ResUtil.getScreenWidth() * 0.4f);
params.width = (int) (ResUtil.getScreenWidth() * getWidth());
dialog.getWindow().setAttributes(params);
dialog.getWindow().setDimAmount(0);
dialog.show();

@ -45,6 +45,14 @@ public class MenuKeyDialog implements MenuAdapter.OnClickListener {
initView();
}
private int getCount() {
return 3;
}
private float getWidth() {
return 0.4f + (getCount() - 1) * 0.2f;
}
private void initView() {
setRecyclerView();
setDialog();
@ -55,14 +63,14 @@ public class MenuKeyDialog implements MenuAdapter.OnClickListener {
binding.recycler.setHasFixedSize(true);
binding.recycler.setItemAnimator(null);
binding.recycler.addItemDecoration(new SpaceItemDecoration(1, 16));
binding.recycler.setLayoutManager(new GridLayoutManager(dialog.getContext(), 1));
binding.recycler.setLayoutManager(new GridLayoutManager(dialog.getContext(), getCount()));
binding.recycler.post(() -> binding.recycler.scrollToPosition(Setting.getHomeMenuKey()));
}
private void setDialog() {
WindowManager.LayoutParams params = dialog.getWindow().getAttributes();
params.width = (int) (ResUtil.getScreenWidth() * 0.4f);
params.width = (int) (ResUtil.getScreenWidth() * getWidth());
dialog.getWindow().setAttributes(params);
dialog.getWindow().setDimAmount(0);
dialog.show();

@ -77,6 +77,11 @@ public class CustomWebView extends WebView {
setWebViewClient(webViewClient());
}
private void addView() {
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(1, 1);
if (App.activity() != null) App.activity().addContentView(this, params);
}
public CustomWebView start(String key, String from, Map<String, String> headers, String url, String click, ParseCallback callback, boolean detect) {
App.post(timer, Constant.TIMEOUT_PARSE_WEB);
this.callback = callback;
@ -84,6 +89,7 @@ public class CustomWebView extends WebView {
this.click = click;
this.from = from;
this.key = key;
addView();
start(url, headers);
return this;
}
@ -142,7 +148,7 @@ public class CustomWebView extends WebView {
private void showDialog() {
if (dialog != null || App.activity() == null) return;
if (getParent() != null) ((ViewGroup) getParent()).removeView(this);
removeView();
dialog = new AlertDialog.Builder(App.activity()).setView(this).show();
}
@ -200,8 +206,13 @@ public class CustomWebView extends WebView {
callback = null;
}
private void removeView() {
if (getParent() != null) ((ViewGroup) getParent()).removeView(this);
}
public void stop(boolean error) {
hideDialog();
removeView();
stopLoading();
loadUrl(BLANK);
App.removeCallbacks(timer);

Loading…
Cancel
Save