当前位置: 首页>>代码示例>>Java>>正文


Java SwipeMenuRecyclerView类代码示例

本文整理汇总了Java中com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView的典型用法代码示例。如果您正苦于以下问题:Java SwipeMenuRecyclerView类的具体用法?Java SwipeMenuRecyclerView怎么用?Java SwipeMenuRecyclerView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SwipeMenuRecyclerView类属于com.yanzhenjie.recyclerview.swipe包,在下文中一共展示了SwipeMenuRecyclerView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onItemClick

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
/**
 * Item的菜单被点击的时候调用。
 *
 * @param closeable       closeable. 用来关闭菜单。
 * @param adapterPosition adapterPosition. 这个菜单所在的item在Adapter中position。
 * @param menuPosition    menuPosition. 这个菜单的position。比如你为某个Item创建了2个MenuItem,那么这个position可能是是 0、1,
 * @param direction       如果是左侧菜单,值是:SwipeMenuRecyclerView#LEFT_DIRECTION,如果是右侧菜单,值是:SwipeMenuRecyclerView
 *                        #RIGHT_DIRECTION.
 */
@Override
public void onItemClick(Closeable closeable, int adapterPosition, int menuPosition, int direction) {
    closeable.smoothCloseMenu();// 关闭被点击的菜单。
    if (direction == SwipeMenuRecyclerView.RIGHT_DIRECTION) {
        Toast.makeText(getApplicationContext(), "删除成功", Toast.LENGTH_SHORT).show();
    }
    // TODO 如果是删除:推荐调用Adapter.notifyItemRemoved(position),不推荐Adapter.notifyDataSetChanged();
    if (menuPosition == 0) {// 删除按钮被点击。
        Post noteOne = noteList.get(adapterPosition);
        ContentValues cv = new ContentValues();
        cv.put(NoteDB.ID, noteOne.getId());
        cv.put(NoteDB.TITLE, noteOne.getTitle());
        cv.put(NoteDB.CONTENT, noteOne.getContent());
        cv.put(NoteDB.TIME, System.currentTimeMillis());
        mDatabase.insert(NoteDB.RECYCLE_TABLE, null, cv);
        mDatabase.delete(NoteDB.TABLE_NAME, "id=?", new String[]{noteOne.getId() + ""});
        noteList.remove(adapterPosition);
        noteAdapter.notifyItemRemoved(adapterPosition);
    }
}
 
开发者ID:weimin96,项目名称:shareNote,代码行数:30,代码来源:NoteActivity.java

示例2: onCreate

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_positions);
    show_positions_add= (TextView) findViewById(R.id.show_positions_add);
    show_positions_menu_recy_view= (SwipeMenuRecyclerView) findViewById(R.id.show_positions_menu_recy_view);
    SharedPreferences prefs=getSharedPreferences("user", Context.MODE_PRIVATE);
    username=prefs.getString("username",null);
    xutils=Xutils.getInstance();
    width = getResources().getDimensionPixelSize(R.dimen.item_height);
    show_positions_add.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            Intent intent =new Intent(ShowPositionsActivity.this,WritePositionActivity.class);
            startActivity(intent);
            ShowPositionsActivity.this.finish();

        }
    });
    getcollect();
}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:23,代码来源:ShowPositionsActivity.java

示例3: onItemClick

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
/**
 * Item的菜单被点击的时候调用。
 * @param closeable       closeable. 用来关闭菜单。
 * @param adapterPosition adapterPosition. 这个菜单所在的item在Adapter中position。
 * @param menuPosition    menuPosition. 这个菜单的position。比如你为某个Item创建了2个MenuItem,那么这个position可能是是 0、1,
 * @param direction       如果是左侧菜单,值是:SwipeMenuRecyclerView#LEFT_DIRECTION,如果是右侧菜单,值是:SwipeMenuRecyclerView#RIGHT_DIRECTION.
 */
@Override
public void onItemClick(Closeable closeable, int adapterPosition, int menuPosition, int direction) {
    closeable.smoothCloseMenu();// 关闭被点击的菜单。

    if (direction == SwipeMenuRecyclerView.RIGHT_DIRECTION) {
        Toast.makeText(mContext, "list第" + adapterPosition + "; 右侧菜单第" + menuPosition, Toast.LENGTH_SHORT).show();
    } else if (direction == SwipeMenuRecyclerView.LEFT_DIRECTION) {
        Toast.makeText(mContext, "list第" + adapterPosition + "; 左侧菜单第" + menuPosition, Toast.LENGTH_SHORT).show();
    }

    // TODO 推荐调用Adapter.notifyItemRemoved(position),也可以Adapter.notifyDataSetChanged();
    if (menuPosition == 0) {// 删除按钮被点击。
        mStrings.remove(adapterPosition);
        mMenuAdapter.notifyItemRemoved(adapterPosition);
    }
}
 
开发者ID:liuhui19991,项目名称:CloudMusicLH,代码行数:24,代码来源:RefreshLoadMoreActivity.java

示例4: drawHorizontal

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
public void drawHorizontal(Canvas c, RecyclerView parent) {
    c.save();
    int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        int childPosition = parent.getChildAdapterPosition(child);
        if (childPosition < 0) continue;
        if (mViewTypeList.contains(parent.getAdapter().getItemViewType(childPosition))) continue;
        if (child instanceof SwipeMenuRecyclerView.LoadMoreView) continue;
        final int left = child.getLeft();
        final int top = child.getBottom();
        final int right = child.getRight();
        final int bottom = top + mDividerHeight;
        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
    c.restore();
}
 
开发者ID:yanzhenjie,项目名称:SwipeRecyclerView,代码行数:19,代码来源:DefaultItemDecoration.java

示例5: drawVertical

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
public void drawVertical(Canvas c, RecyclerView parent) {
    c.save();
    final int childCount = parent.getChildCount();
    for (int i = 0; i < childCount; i++) {
        final View child = parent.getChildAt(i);
        int childPosition = parent.getChildAdapterPosition(child);
        if (childPosition < 0) continue;
        if (mViewTypeList.contains(parent.getAdapter().getItemViewType(childPosition))) continue;
        if (child instanceof SwipeMenuRecyclerView.LoadMoreView) continue;
        final int left = child.getRight();
        final int top = child.getTop();
        final int right = left + mDividerWidth;
        final int bottom = child.getBottom();

        mDivider.setBounds(left, top, right, bottom);
        mDivider.draw(c);
    }
    c.restore();
}
 
开发者ID:yanzhenjie,项目名称:SwipeRecyclerView,代码行数:20,代码来源:DefaultItemDecoration.java

示例6: onCreate

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getContentView());

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);


    setSupportActionBar(mToolbar);
    mActionBar = getSupportActionBar();
    if (displayHomeAsUpEnabled()) {
        mActionBar.setDisplayHomeAsUpEnabled(true);
    }

    mLayoutManager = createLayoutManager();
    mItemDecoration = createItemDecoration();
    mDataList = createDataList();
    mAdapter = createAdapter();

    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.addItemDecoration(mItemDecoration);
    mRecyclerView.setSwipeItemClickListener(this);
}
 
开发者ID:yanzhenjie,项目名称:SwipeRecyclerView,代码行数:25,代码来源:BaseActivity.java

示例7: onCreate

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_share_app_manager);
    StatusBarCompat.setupStatusBarView(this, (ViewGroup) getWindow().getDecorView(), true, R.color.primary_dark);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mRV = (SwipeMenuRecyclerView) findViewById(R.id.rv);
    mRV.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
    Adapter.AppInfoAdapter appsAdapter = new Adapter.AppInfoAdapter(mResultAppInfo);
    mRV.setAdapter(appsAdapter);
    new LoadAppInfoClass().execute();
    mRV.setHasFixedSize(true);// 如果Item够简单,高度是确定的,打开FixSize将提高性能。
    mRV.setItemAnimator(new DefaultItemAnimator());// 设置Item默认动画,加也行,不加也行。
    mRV.setLongPressDragEnabled(true);// 开启拖拽,就这么简单一句话。
    mRV.setOnItemMoveListener(new OnItemMoveListener() {
        @Override
        public boolean onItemMove(int fromPosition, int toPosition) {
            // 当Item被拖拽的时候。
            Collections.swap(mResultAppInfo, fromPosition, toPosition);
            if (resolveInfoWraps != null) {
                Collections.swap(resolveInfoWraps, fromPosition, toPosition);
            }
            appsAdapter.notifyItemMoved(fromPosition, toPosition);


            return true;// 返回true表示处理了,返回false表示你没有处理。
        }

        @Override
        public void onItemDismiss(int position) {

        }
    });
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:37,代码来源:ShareAppManagerActivity.java

示例8: initView

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
protected void initView() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolBar);
    mMenuRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycle_view);
    mContext = this;
    initToolbar(toolbar);
    mDatabase = new NoteDB(this).getReadableDatabase();
}
 
开发者ID:weimin96,项目名称:shareNote,代码行数:8,代码来源:NoteActivity.java

示例9: initView

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
@Override
    public void initView() {



        linearLayout_title = findViewById(R.id.titleLayout);
        linearLayout_title.setBackVisisble(true);
        linearLayout_title.setBackText(mRootView.getContext().getString(R.string.myself));
        linearLayout_title.setTitleText(mRootView.getContext().getString(R.string.my_device));


        mRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh_layout);
//        mRefreshLayout.setOnRefreshListener(this); // 刷新监听。
        mRefreshLayout.setEnabled(false);
        mRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(mRootView.getContext()));
        mRecyclerView.addItemDecoration(new DefaultItemDecoration(ContextCompat.getColor(mRootView.getContext(), R.color.divider_color)));
        //点击item监听
        mRecyclerView.setSwipeItemClickListener(this);
        mRecyclerView.setSwipeMenuCreator(swipeMenuCreator);
        mRecyclerView.setSwipeMenuItemClickListener(mMenuItemClickListener);
        // 自定义的核心就是DefineLoadMoreView类。
//        DefineLoadMoreView loadMoreView = new DefineLoadMoreView(mRootView.getContext());
//        mRecyclerView.addFooterView(loadMoreView); // 添加为Footer。
//        mRecyclerView.setLoadMoreView(loadMoreView); // 设置LoadMoreView更新监听。
//        mRecyclerView.setLoadMoreListener(this); // 加载更多的监听。
        mRecyclerView.setItemAnimator(new DefaultItemAnimator());


    }
 
开发者ID:dufangyu1990,项目名称:LeCatApp,代码行数:31,代码来源:MyDeviceView.java

示例10: onItemClick

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
@Override
public void onItemClick(SwipeMenuBridge menuBridge) {
    menuBridge.closeMenu();
    int direction = menuBridge.getDirection(); // 左侧还是右侧菜单。
    int adapterPosition = menuBridge.getAdapterPosition(); // RecyclerView的Item的position。

    if (direction == SwipeMenuRecyclerView.RIGHT_DIRECTION) {

        String deviceId = datalist.get(adapterPosition).getDeviceId();
        deletePos = adapterPosition;
        mPresent.presentCallBack(deviceId,"","");
    }
}
 
开发者ID:dufangyu1990,项目名称:LeCatApp,代码行数:14,代码来源:MyDeviceView.java

示例11: onWaitToLoadMore

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
/**
 * 调用了setAutoLoadMore(false)后,在需要加载更多的时候,这个方法会被调用,并传入加载更多的listener。
 */
@Override
public void onWaitToLoadMore(SwipeMenuRecyclerView.LoadMoreListener loadMoreListener) {
    this.mLoadMoreListener = loadMoreListener;

    setVisibility(VISIBLE);
    mLoadingView.setVisibility(GONE);
    mTvMessage.setVisibility(VISIBLE);
    mTvMessage.setText("点我加载更多");
}
 
开发者ID:dufangyu1990,项目名称:LeCatApp,代码行数:13,代码来源:DefineLoadMoreView.java

示例12: onCreate

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    baseInit();  // 启动页面, 数据库加载, 界面初始化(滑动侧板菜单, 浮动添加事件按钮等)

    Collections.sort(eventList);  // 按evenList每个元素的pos进行排序, 即为显示的顺序

    // 设置RecycleView
    SwipeMenuRecyclerView eventNameRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id
            .event_name_recycler_view);
    LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
    MyAdapter = new EventsAdapter(eventList, eventNameRecyclerView, visibility);
    MyAdapter.setTodoEventSize(eventList.size());

    // 设置侧滑菜单和侧滑菜单监听器
    eventNameRecyclerView.setSwipeMenuCreator(mSwipeMenuCreator); // 创建滑动菜单
    eventNameRecyclerView.setSwipeMenuItemClickListener(mMenuItemClickListener); // 滑动菜单监听器
    eventNameRecyclerView.setOnItemMoveListener(onItemMoveListener);// 监听拖拽,更新UI。

    eventNameRecyclerView.setLayoutManager(layoutManager);  // 设置LayoutManager
    eventNameRecyclerView.setItemAnimator(new DefaultItemAnimator());
    eventNameRecyclerView.setAdapter(MyAdapter);    // 设置adapter

    registerForContextMenu(eventNameRecyclerView); // 长按上下文菜单
}
 
开发者ID:wendyltan,项目名称:EasyTodo,代码行数:28,代码来源:MainActivity.java

示例13: onCreateView

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    rootview = inflater.inflate(R.layout.collect_fragment, container, false);
    menu_recy_view= (SwipeMenuRecyclerView) rootview.findViewById(R.id.menu_recy_view);
    collect_fragment_load_layout= (LoadingLayout) rootview.findViewById(R.id.collect_fragment_load_layout);
    collect_headview= (CircleImageView) rootview.findViewById(R.id.collect_headview);
    collect_username= (TextView) rootview.findViewById(R.id.collect_username);
    xutils=Xutils.getInstance();

    SharedPreferences prefs=getActivity().getSharedPreferences("user", Context.MODE_PRIVATE);
    final SharedPreferences.Editor editor=prefs.edit();
    username=prefs.getString("username",null);
    collect_fragment_load_layout.setStatus(LoadingLayout.Loading);
    String url="http://www.shmilyz.com/headimage/"+username+".jpg";

    Glide.with(getActivity())
            .load(url)
            .diskCacheStrategy( DiskCacheStrategy.NONE )
            .into(collect_headview);
    collect_username.setText(username);
    width = getResources().getDimensionPixelSize(R.dimen.item_height);

    getcollect();
    return rootview;

}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:28,代码来源:AlreadyBuyFragment.java

示例14: onCreateView

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater,  ViewGroup container,  Bundle savedInstanceState) {

    rootview = inflater.inflate(R.layout.collect_fragment, container, false);
    menu_recy_view= (SwipeMenuRecyclerView) rootview.findViewById(R.id.menu_recy_view);
    collect_fragment_load_layout= (LoadingLayout) rootview.findViewById(R.id.collect_fragment_load_layout);
    collect_headview= (CircleImageView) rootview.findViewById(R.id.collect_headview);
    collect_username= (TextView) rootview.findViewById(R.id.collect_username);
    xutils=Xutils.getInstance();

    SharedPreferences prefs=getActivity().getSharedPreferences("user", Context.MODE_PRIVATE);
    final SharedPreferences.Editor editor=prefs.edit();
    username=prefs.getString("username",null);
    collect_fragment_load_layout.setStatus(LoadingLayout.Loading);
    String url="http://www.shmilyz.com/headimage/"+username+".jpg";

    Glide.with(getActivity())
            .load(url)
            .diskCacheStrategy( DiskCacheStrategy.NONE )
            .into(collect_headview);
    collect_username.setText(username);
    width = getResources().getDimensionPixelSize(R.dimen.item_height);

    getcollect();
    return rootview;

}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:28,代码来源:CollectFragment.java

示例15: initViews

import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView; //导入依赖的package包/类
@Override
public void initViews() {
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_layout);
    mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_light, android.R.color.holo_red_light, android.R.color.holo_orange_light, android.R.color.holo_green_light);
    mSwipeRefreshLayout.setOnRefreshListener(mOnRefreshListener);

    mStrings = new ArrayList<>();
    for (int i = 0; i < 20; i++) {
        mStrings.add("我是第" + i + "个。");
    }
    mSwipeMenuRecyclerView = (SwipeMenuRecyclerView) findViewById(R.id.recycler_view);
    mSwipeMenuRecyclerView.setLayoutManager(new LinearLayoutManager(this));// 布局管理器。
    mSwipeMenuRecyclerView.setHasFixedSize(true);// 如果Item够简单,高度是确定的,打开FixSize将提高性能。
    mSwipeMenuRecyclerView.setItemAnimator(new DefaultItemAnimator());// 设置Item默认动画,加也行,不加也行。
    mSwipeMenuRecyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL_LIST));// 添加分割线。
    // 添加滚动监听。
    mSwipeMenuRecyclerView.addOnScrollListener(mOnScrollListener);

    // 为SwipeRecyclerView的Item创建菜单就两句话,不错就是这么简单:
    // 设置菜单创建器。
    mSwipeMenuRecyclerView.setSwipeMenuCreator(swipeMenuCreator);
    // 设置菜单Item点击监听。
    mSwipeMenuRecyclerView.setSwipeMenuItemClickListener(menuItemClickListener);

    //这两句话注掉也可以
    mSwipeMenuRecyclerView.smoothOpenLeftMenu(0);
    mSwipeMenuRecyclerView.smoothOpenRightMenu(0);

    mMenuAdapter = new MenuAdapter(mStrings);
    mMenuAdapter.setOnItemClickListener(onItemClickListener);
    mSwipeMenuRecyclerView.setAdapter(mMenuAdapter);
}
 
开发者ID:liuhui19991,项目名称:CloudMusicLH,代码行数:33,代码来源:RefreshLoadMoreActivity.java


注:本文中的com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。