private void setupRecyclerView() { ArrayList<MenuEntity> list = new ArrayList<>(); // 添加假数据 MenuEntity menuEntity1 = new MenuEntity(); menuEntity1.iconId = R.drawable.recommend; menuEntity1.title = "最新推荐"; MenuEntity menuEntity2 = new MenuEntity(); menuEntity2.iconId = R.drawable.seven; menuEntity2.title = "本周更新"; MenuEntity menuEntity3 = new MenuEntity(); menuEntity3.iconId = R.drawable.mouse; menuEntity3.title = "所有漫画"; list.add(menuEntity1); list.add(menuEntity2); list.add(menuEntity3); // SweetSheet 控件,根据 rl 确认位置 mSweetSheet = new SweetSheet(fl_home); // 设置数据源 (数据源支持设置 list 数组,也支持从菜单中获取) mSweetSheet.setMenuList(list); // 根据设置不同的 Delegate 来显示不同的风格. mSweetSheet.setDelegate(new RecyclerViewDelegate(false)); // 根据设置不同Effect 来显示背景效果BlurEffect:模糊效果.DimEffect 变暗效果 mSweetSheet.setBackgroundEffect(new BlurEffect(8)); // 设置点击事件 mSweetSheet.setOnMenuItemClickListener( new SweetSheet.OnMenuItemClickListener() { @Override public boolean onItemClick(int position, MenuEntity menuEntity1) { showFab(); // //根据返回值, true 会关闭 SweetSheet ,false 则不会. // Toast.makeText(HomeActivity.this, menuEntity1.title + " " + position, // Toast.LENGTH_SHORT).show(); handClick(position); return true; } }); mSweetSheet.setBgListener( new Delegate.BgListener() { @Override public void onClick() { closeMenu(); } }); fab.setOnClickListener(this); }
public void closeMenu() { if (mSweetSheet.isShow()) { showFab(); mSweetSheet.dismiss(); } }
public void menuAndBtnAnim() { mSweetSheet.toggle(); if (mSweetSheet.isShow()) { hideFab(); } }