|
|
|
|
@ -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(); |
|
|
|
|
|