Search in sources :

Example 41 with StaggeredGridLayoutManager

use of android.support.v7.widget.StaggeredGridLayoutManager in project VirtualApp by asLody.

the class ListAppFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    mRecyclerView = (DragSelectRecyclerView) view.findViewById(R.id.select_app_recycler_view);
    mProgressBar = (ProgressBar) view.findViewById(R.id.select_app_progress_bar);
    mInstallButton = (Button) view.findViewById(R.id.select_app_install_btn);
    mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, OrientationHelper.VERTICAL));
    mRecyclerView.addItemDecoration(new ItemOffsetDecoration(VUiKit.dpToPx(getContext(), 2)));
    mAdapter = new CloneAppListAdapter(getActivity());
    mRecyclerView.setAdapter(mAdapter);
    mAdapter.setOnItemClickListener(new CloneAppListAdapter.ItemEventListener() {

        @Override
        public void onItemClick(AppInfo info, int position) {
            int count = mAdapter.getSelectedCount();
            if (!mAdapter.isIndexSelected(position)) {
                if (count >= 9) {
                    Toast.makeText(getContext(), "No more then 9 apps can be chosen at a time!", Toast.LENGTH_SHORT).show();
                    return;
                }
            }
            mAdapter.toggleSelected(position);
        }

        @Override
        public boolean isSelectable(int position) {
            return mAdapter.isIndexSelected(position) || mAdapter.getSelectedCount() < 9;
        }
    });
    mAdapter.setSelectionListener(count -> {
        mInstallButton.setEnabled(count > 0);
        mInstallButton.setText(String.format(Locale.ENGLISH, "Install to SandBox (%d)", count));
    });
    mInstallButton.setOnClickListener(v -> {
        Integer[] selectedIndices = mAdapter.getSelectedIndices();
        ArrayList<AppInfoLite> dataList = new ArrayList<AppInfoLite>(selectedIndices.length);
        for (int index : selectedIndices) {
            AppInfo info = mAdapter.getItem(index);
            dataList.add(new AppInfoLite(info.packageName, info.path, info.fastOpen));
        }
        Intent data = new Intent();
        data.putParcelableArrayListExtra(VCommends.EXTRA_APP_INFO_LIST, dataList);
        getActivity().setResult(Activity.RESULT_OK, data);
        getActivity().finish();
    });
    new ListAppPresenterImpl(getActivity(), this, getSelectFrom()).start();
}
Also used : ArrayList(java.util.ArrayList) AppInfoLite(io.virtualapp.home.models.AppInfoLite) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) Intent(android.content.Intent) ItemOffsetDecoration(io.virtualapp.home.adapters.decorations.ItemOffsetDecoration) AppInfo(io.virtualapp.home.models.AppInfo) CloneAppListAdapter(io.virtualapp.home.adapters.CloneAppListAdapter)

Example 42 with StaggeredGridLayoutManager

use of android.support.v7.widget.StaggeredGridLayoutManager in project VirtualApp by asLody.

the class SmartRecyclerAdapter method onCreateViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = null;
    if (viewType == TYPE_HEADER) {
        itemView = headerView;
    } else if (viewType == TYPE_FOOTER) {
        itemView = footerView;
    }
    if (itemView != null) {
        //set StaggeredGridLayoutManager header & footer view
        if (layoutManager instanceof StaggeredGridLayoutManager) {
            ViewGroup.LayoutParams targetParams = itemView.getLayoutParams();
            StaggeredGridLayoutManager.LayoutParams StaggerLayoutParams;
            if (targetParams != null) {
                StaggerLayoutParams = new StaggeredGridLayoutManager.LayoutParams(targetParams.width, targetParams.height);
            } else {
                StaggerLayoutParams = new StaggeredGridLayoutManager.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            }
            StaggerLayoutParams.setFullSpan(true);
            itemView.setLayoutParams(StaggerLayoutParams);
        }
        return new RecyclerView.ViewHolder(itemView) {
        };
    }
    return super.onCreateViewHolder(parent, viewType);
}
Also used : ViewGroup(android.view.ViewGroup) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 43 with StaggeredGridLayoutManager

use of android.support.v7.widget.StaggeredGridLayoutManager in project Meizhi by drakeet.

the class MainActivity method setupRecyclerView.

private void setupRecyclerView() {
    final StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
    mRecyclerView.setLayoutManager(layoutManager);
    mMeizhiListAdapter = new MeizhiListAdapter(this, mMeizhiList);
    mRecyclerView.setAdapter(mMeizhiListAdapter);
    new Once(this).show("tip_guide_6", () -> {
        Snackbar.make(mRecyclerView, getString(R.string.tip_guide), Snackbar.LENGTH_INDEFINITE).setAction(R.string.i_know, v -> {
        }).show();
    });
    mRecyclerView.addOnScrollListener(getOnBottomListener(layoutManager));
    mMeizhiListAdapter.setOnMeizhiTouchListener(getOnMeizhiTouchListener());
}
Also used : Bundle(android.os.Bundle) ButterKnife(butterknife.ButterKnife) me.drakeet.meizhi.data.休息视频Data(me.drakeet.meizhi.data.休息视频Data) Date(java.util.Date) Toasts(me.drakeet.meizhi.util.Toasts) AndroidSchedulers(rx.android.schedulers.AndroidSchedulers) Intent(android.content.Intent) OnClick(butterknife.OnClick) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) Observable(rx.Observable) Picasso(com.squareup.picasso.Picasso) Meizhi(me.drakeet.meizhi.data.entity.Meizhi) OnMeizhiTouchListener(me.drakeet.meizhi.func.OnMeizhiTouchListener) Dates(me.drakeet.meizhi.util.Dates) Handler(android.os.Handler) Menu(android.view.Menu) View(android.view.View) Bind(butterknife.Bind) R(me.drakeet.meizhi.R) Gank(me.drakeet.meizhi.data.entity.Gank) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) SwipeRefreshBaseActivity(me.drakeet.meizhi.ui.base.SwipeRefreshBaseActivity) ConflictAlgorithm(com.litesuits.orm.db.model.ConflictAlgorithm) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) UmengUpdateAgent(com.umeng.update.UmengUpdateAgent) ActivityCompat(android.support.v4.app.ActivityCompat) MeizhiData(me.drakeet.meizhi.data.MeizhiData) App(me.drakeet.meizhi.App) RecyclerView(android.support.v7.widget.RecyclerView) List(java.util.List) QueryBuilder(com.litesuits.orm.db.assit.QueryBuilder) Once(me.drakeet.meizhi.util.Once) MobclickAgent(com.umeng.analytics.MobclickAgent) PreferencesLoader(me.drakeet.meizhi.util.PreferencesLoader) Callback(com.squareup.picasso.Callback) Snackbar(android.support.design.widget.Snackbar) MeizhiListAdapter(me.drakeet.meizhi.ui.adapter.MeizhiListAdapter) AlarmManagers(me.drakeet.meizhi.util.AlarmManagers) Subscription(rx.Subscription) Once(me.drakeet.meizhi.util.Once) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) MeizhiListAdapter(me.drakeet.meizhi.ui.adapter.MeizhiListAdapter)

Example 44 with StaggeredGridLayoutManager

use of android.support.v7.widget.StaggeredGridLayoutManager in project InstaMaterial by frogermcs.

the class UserProfileActivity method setupUserProfileGrid.

private void setupUserProfileGrid() {
    final StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
    rvUserProfile.setLayoutManager(layoutManager);
    rvUserProfile.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            userPhotosAdapter.setLockedAnimations(true);
        }
    });
}
Also used : StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView)

Example 45 with StaggeredGridLayoutManager

use of android.support.v7.widget.StaggeredGridLayoutManager in project android-advancedrecyclerview by h6ah4i.

the class DraggableStaggeredGridExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    //noinspection ConstantConditions
    mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view);
    mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
    // drag & drop manager
    mRecyclerViewDragDropManager = new RecyclerViewDragDropManager();
    mRecyclerViewDragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z3));
    // Start dragging after long press
    mRecyclerViewDragDropManager.setInitiateOnLongPress(true);
    mRecyclerViewDragDropManager.setInitiateOnMove(false);
    mRecyclerViewDragDropManager.setLongPressTimeout(750);
    //adapter
    final DraggableStaggeredGridExampleAdapter myItemAdapter = new DraggableStaggeredGridExampleAdapter(getDataProvider());
    mAdapter = myItemAdapter;
    // wrap for dragging
    mWrappedAdapter = mRecyclerViewDragDropManager.createWrappedAdapter(myItemAdapter);
    final GeneralItemAnimator animator = new DraggableItemAnimator();
    mRecyclerView.setLayoutManager(mLayoutManager);
    // requires *wrapped* adapter
    mRecyclerView.setAdapter(mWrappedAdapter);
    mRecyclerView.setItemAnimator(animator);
    mRecyclerView.setHasFixedSize(false);
    //noinspection StatementWithEmptyBody
    if (supportsViewElevation()) {
    // Lollipop or later has native drop shadow feature. ItemShadowDecorator is not required.
    } else {
        mRecyclerView.addItemDecoration(new ItemShadowDecorator((NinePatchDrawable) ContextCompat.getDrawable(getContext(), R.drawable.material_shadow_z1)));
    }
    mRecyclerViewDragDropManager.attachRecyclerView(mRecyclerView);
// for debugging
//        animator.setDebug(true);
//        animator.setMoveDuration(2000);
}
Also used : ItemShadowDecorator(com.h6ah4i.android.widget.advrecyclerview.decoration.ItemShadowDecorator) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) DraggableItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable)

Aggregations

StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)78 RecyclerView (android.support.v7.widget.RecyclerView)52 View (android.view.View)37 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)32 GridLayoutManager (android.support.v7.widget.GridLayoutManager)26 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)9 Handler (android.os.Handler)7 Toolbar (android.support.v7.widget.Toolbar)7 TextView (android.widget.TextView)7 Nullable (android.support.annotation.Nullable)5 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)5 ViewGroup (android.view.ViewGroup)5 AbsListView (android.widget.AbsListView)5 ScrollView (android.widget.ScrollView)5 BindView (butterknife.BindView)5 ArrayList (java.util.ArrayList)5 Intent (android.content.Intent)4 WebView (android.webkit.WebView)4 Bundle (android.os.Bundle)3 FloatingActionButton (android.support.design.widget.FloatingActionButton)3