Search in sources :

Example 1 with SmartRecyclerAdapter

use of io.virtualapp.abs.nestedadapter.SmartRecyclerAdapter in project VirtualApp by asLody.

the class HomeActivity method initLaunchpad.

private void initLaunchpad() {
    mLauncherView.setHasFixedSize(true);
    StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, OrientationHelper.VERTICAL);
    mLauncherView.setLayoutManager(layoutManager);
    mLaunchpadAdapter = new LaunchpadAdapter(this);
    SmartRecyclerAdapter wrap = new SmartRecyclerAdapter(mLaunchpadAdapter);
    View footer = new View(this);
    footer.setLayoutParams(new StaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, VUiKit.dpToPx(this, 60)));
    wrap.setFooterView(footer);
    mLauncherView.setAdapter(wrap);
    mLauncherView.addItemDecoration(new ItemOffsetDecoration(this, R.dimen.desktop_divider));
    ItemTouchHelper touchHelper = new ItemTouchHelper(new LauncherTouchCallback());
    touchHelper.attachToRecyclerView(mLauncherView);
    mLaunchpadAdapter.setAppClickListener((pos, data) -> {
        if (!data.isLoading()) {
            if (data instanceof AddAppButton) {
                onAddAppButtonClick();
            }
            mLaunchpadAdapter.notifyItemChanged(pos);
            mPresenter.launchApp(data);
        }
    });
}
Also used : ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) AddAppButton(io.virtualapp.home.models.AddAppButton) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) ItemOffsetDecoration(io.virtualapp.home.adapters.decorations.ItemOffsetDecoration) SmartRecyclerAdapter(io.virtualapp.abs.nestedadapter.SmartRecyclerAdapter) View(android.view.View) TextView(android.widget.TextView) TwoGearsView(io.virtualapp.widgets.TwoGearsView) RecyclerView(android.support.v7.widget.RecyclerView) LaunchpadAdapter(io.virtualapp.home.adapters.LaunchpadAdapter)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)1 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)1 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)1 View (android.view.View)1 TextView (android.widget.TextView)1 SmartRecyclerAdapter (io.virtualapp.abs.nestedadapter.SmartRecyclerAdapter)1 LaunchpadAdapter (io.virtualapp.home.adapters.LaunchpadAdapter)1 ItemOffsetDecoration (io.virtualapp.home.adapters.decorations.ItemOffsetDecoration)1 AddAppButton (io.virtualapp.home.models.AddAppButton)1 TwoGearsView (io.virtualapp.widgets.TwoGearsView)1