Search in sources :

Example 16 with DividerItemDecoration

use of androidx.recyclerview.widget.DividerItemDecoration in project MyJapanese by 54wall.

the class LessonsFragment method setData.

@Override
public void setData(List<Book> data) {
    // 来自initAdapter
    mBookList = data;
    leftAdapter = new LeftMenuAdapter(getActivity(), data);
    rightAdapter = new RightMenuAdapter(getActivity(), data);
    rightAdapter.setOnItemClickListener(new RightMenuAdapter.OnItemClickListener() {

        @Override
        public void onClick(Lesson item) {
            Log.e(TAG, "lesson:" + item.getTitle());
            SharedPreferenceManager.getInstance().putString(Constants.CURRENT_LESSON, item.getTitle());
            SharedPreferenceManager.getInstance().putInt(Constants.CURRENT_LESSON_ID, item.getId());
            ((MainActivity) getActivity()).switchWords(item.getTitle(), false);
        }
    });
    mRightMenu.setAdapter(rightAdapter);
    mRightMenu.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
    mLeftMenu.setAdapter(leftAdapter);
    leftAdapter.addItemSelectedListener(this);
    // 设置初始滚动位置
    Log.e(TAG, "CURRENT_LESSON_ID:" + SharedPreferenceManager.getInstance().getInt(Constants.CURRENT_LESSON_ID, Constants.DEFAULT_LESSON_ID));
    mRightMenu.scrollToPosition(SharedPreferenceManager.getInstance().getInt(Constants.CURRENT_LESSON_ID, Constants.DEFAULT_LESSON_ID));
    initHeadView();
}
Also used : RightMenuAdapter(pri.weiqiang.liyujapanese.ui.adapter.RightMenuAdapter) LeftMenuAdapter(pri.weiqiang.liyujapanese.ui.adapter.LeftMenuAdapter) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) Lesson(pri.weiqiang.liyujapanese.mvp.bean.dic.Lesson)

Example 17 with DividerItemDecoration

use of androidx.recyclerview.widget.DividerItemDecoration in project LiYuJapanese by 54wall.

the class LessonsFragment method setData.

@Override
public void setData(List<Book> data) {
    // 来自initAdapter
    mBookList = data;
    leftAdapter = new LeftMenuAdapter(getActivity(), data);
    rightAdapter = new RightMenuAdapter(getActivity(), data);
    rightAdapter.setOnItemClickListener(new RightMenuAdapter.OnItemClickListener() {

        @Override
        public void onClick(Lesson item) {
            Log.e(TAG, "lesson:" + item.getTitle());
            SharedPreferenceManager.getInstance().putString(Constants.CURRENT_LESSON, item.getTitle());
            SharedPreferenceManager.getInstance().putInt(Constants.CURRENT_LESSON_ID, item.getId());
            ((MainActivity) getActivity()).switchWords(item.getTitle(), false);
        }
    });
    mRightMenu.setAdapter(rightAdapter);
    mRightMenu.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
    mLeftMenu.setAdapter(leftAdapter);
    leftAdapter.addItemSelectedListener(this);
    // 设置初始滚动位置
    Log.e(TAG, "CURRENT_LESSON_ID:" + SharedPreferenceManager.getInstance().getInt(Constants.CURRENT_LESSON_ID, Constants.DEFAULT_LESSON_ID));
    mRightMenu.scrollToPosition(SharedPreferenceManager.getInstance().getInt(Constants.CURRENT_LESSON_ID, Constants.DEFAULT_LESSON_ID));
    initHeadView();
}
Also used : RightMenuAdapter(pri.weiqiang.liyujapanese.ui.adapter.RightMenuAdapter) LeftMenuAdapter(pri.weiqiang.liyujapanese.ui.adapter.LeftMenuAdapter) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) Lesson(pri.weiqiang.liyujapanese.mvp.bean.dic.Lesson)

Example 18 with DividerItemDecoration

use of androidx.recyclerview.widget.DividerItemDecoration in project EhViewer by seven332.

the class FavoritesScene method onCreateDrawerView.

@Override
public View onCreateDrawerView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.drawer_list_rv, container, false);
    final Context context = getContext2();
    Toolbar toolbar = (Toolbar) ViewUtils.$$(view, R.id.toolbar);
    AssertUtils.assertNotNull(context);
    toolbar.setTitle(R.string.collections);
    toolbar.inflateMenu(R.menu.drawer_favorites);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem item) {
            int id = item.getItemId();
            switch(id) {
                case R.id.action_default_favorites_slot:
                    String[] items = new String[12];
                    items[0] = getString(R.string.let_me_select);
                    items[1] = getString(R.string.local_favorites);
                    String[] favCat = Settings.getFavCat();
                    System.arraycopy(favCat, 0, items, 2, 10);
                    new AlertDialog.Builder(context).setTitle(R.string.default_favorites_collection).setItems(items, new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Settings.putDefaultFavSlot(which - 2);
                        }
                    }).show();
                    return true;
            }
            return false;
        }
    });
    EasyRecyclerView recyclerView = (EasyRecyclerView) view.findViewById(R.id.recycler_view_drawer);
    recyclerView.setLayoutManager(new LinearLayoutManager(context));
    recyclerView.addItemDecoration(new DividerItemDecoration(context, DividerItemDecoration.VERTICAL));
    mDrawerAdapter = new FavDrawerAdapter(inflater);
    recyclerView.setAdapter(mDrawerAdapter);
    recyclerView.setOnItemClickListener(this);
    return view;
}
Also used : Context(android.content.Context) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) DialogInterface(android.content.DialogInterface) EditTextDialogBuilder(com.hippo.app.EditTextDialogBuilder) SpannableStringBuilder(android.text.SpannableStringBuilder) FavListUrlBuilder(com.hippo.ehviewer.client.data.FavListUrlBuilder) MenuItem(android.view.MenuItem) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) Toolbar(androidx.appcompat.widget.Toolbar)

Example 19 with DividerItemDecoration

use of androidx.recyclerview.widget.DividerItemDecoration in project ToyShark by LipiLee.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.packet_list);
    final RecyclerView recyclerView = findViewById(R.id.packet_list_recycler_view);
    recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    final PacketListAdapter adapter = new PacketListAdapter(PacketManager.INSTANCE.getList());
    PacketManager.INSTANCE.setAdapter(adapter);
    recyclerView.setAdapter(adapter);
    checkRuntimePermission();
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 20 with DividerItemDecoration

use of androidx.recyclerview.widget.DividerItemDecoration in project collect by opendatakit.

the class ChoicesRecyclerView method enableDivider.

private void enableDivider() {
    DividerItemDecoration divider = new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL);
    Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.inset_divider_64dp);
    if (android.os.Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
        DrawableCompat.setTint(DrawableCompat.wrap(drawable), new ThemeUtils(getContext()).getColorOnSurface());
    }
    divider.setDrawable(drawable);
    addItemDecoration(divider);
}
Also used : Drawable(android.graphics.drawable.Drawable) ThemeUtils(org.odk.collect.android.utilities.ThemeUtils) DividerItemDecoration(androidx.recyclerview.widget.DividerItemDecoration)

Aggregations

DividerItemDecoration (androidx.recyclerview.widget.DividerItemDecoration)26 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)20 RecyclerView (androidx.recyclerview.widget.RecyclerView)15 View (android.view.View)12 TextView (android.widget.TextView)7 Button (android.widget.Button)6 Context (android.content.Context)5 ArrayList (java.util.ArrayList)5 Activity (android.app.Activity)4 Bundle (android.os.Bundle)4 ProgressBar (android.widget.ProgressBar)4 Nullable (androidx.annotation.Nullable)4 List (java.util.List)4 SuppressLint (android.annotation.SuppressLint)3 Log (android.util.Log)3 LayoutInflater (android.view.LayoutInflater)3 MenuItem (android.view.MenuItem)3 ViewGroup (android.view.ViewGroup)3 RelativeLayout (android.widget.RelativeLayout)3 NonNull (androidx.annotation.NonNull)3