com.chad.library.adapter.base.listener.OnItemClickListener Java Examples

The following examples show how to use com.chad.library.adapter.base.listener.OnItemClickListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScheduleCollectionFragment.java    From AcgClub with MIT License 6 votes vote down vote up
@Override
protected void initData() {
  mAdapter = new ScheduleCollectionAdapter(getMAppComponent().imageLoader());
  rcvScheduleCollection.setLayoutManager(new GridLayoutManager(getContext(), 3));
  rcvScheduleCollection.setAdapter(mAdapter);
  mAdapter.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
      ScheduleCache item = (ScheduleCache) adapter.getItem(position);
      RouterUtils.getInstance()
          .build(RouterConstants.PATH_SCHEDULE_DETAIL)
          .withString(IntentConstant.SCHEDULE_DETAIL_URL, item.getScheduleUrl())
          .navigation();
    }
  });
  getScheduleCollections();
}
 
Example #2
Source File: ScheduleNewActivity.java    From AcgClub with MIT License 6 votes vote down vote up
@Override
protected void initData() {
  setToolBar(toolbar, "动漫周排行");

  mAdapter = new ScheduleNewAdapter(mAppComponent.imageLoader());
  mAdapter.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(BaseQuickAdapter adapter, android.view.View view, int position) {
      ScheduleNewItem scheduleNewItem = (ScheduleNewItem) adapter.getData().get(position);
      Intent intent = new Intent(getBaseContext(), ScheduleDetailActivity.class);
      intent.putExtra(IntentConstant.SCHEDULE_DETAIL_URL, scheduleNewItem.getAnimeLink());
      startActivity(intent);
    }
  });

  LinearLayoutManager layoutManager = new LinearLayoutManager(getBaseContext());
  layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
  rcvScheduleNew.addItemDecoration(new CommonItemDecoration(2, CommonItemDecoration.UNIT_DP));
  rcvScheduleNew.setLayoutManager(layoutManager);
  rcvScheduleNew.setAdapter(mAdapter);

  mPresenter.getScheduleWeekRank();
}
 
Example #3
Source File: AccountFragment.java    From AccountBook with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 初始化 Adapter
 */
private void initAdapter() {
    mRecyclerView.setLayoutManager(new GridLayoutManager(mContext, 5));
    mTypeAdapter = new AccountTypeAdapter(R.layout.item_account_type, mCostTypes);
    mRecyclerView.setAdapter(mTypeAdapter);
    mRecyclerView.addOnItemTouchListener(new OnItemClickListener() {
        @Override
        public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
            if(position == adapter.getData().size() - 1){// 自定义
                Intent intent = new Intent(mContext, TypeEditActivity.class);
                intent.putExtra(AppConstants.EXTRA_ACCOUNT_TYPE, mAccount.getType());
                startActivityForResult(intent, REQUEST_CODE_TYPE);
            }else{
                setAccountType(position);
            }
        }
    });
}
 
Example #4
Source File: HomeFragment.java    From POCenter with MIT License 5 votes vote down vote up
/**
 * set listeners
 */
private void initEvent() {
    // refresh listener
    bind.vContent.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            loadData(true);
        }
    });
    // load more listener
    homeAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
        @Override
        public void onLoadMoreRequested() {
            bind.rv.post(new Runnable() {
                @Override
                public void run() {
                    loadMore();
                }
            });
        }
    });

    // item click listener
    bind.rv.addOnItemTouchListener(new OnItemClickListener() {
        @Override
        public void SimpleOnItemClick(BaseQuickAdapter baseQuickAdapter, View view, int i) {
            // get item url
            ProjectBean project = (ProjectBean) baseQuickAdapter.getItem(i);
            // start detail activity
            Intent intent = new Intent(getContext(), DetailActivity.class);
            intent.putExtra(DetailActivity.EXTRA_URL, project.url);
            intent.putExtra(DetailActivity.EXTRA_TITLE, project.title);
            intent.putExtra(DetailActivity.EXTRA_DESCRIPTION, project.description);
            startActivity(intent);
        }
    });
}
 
Example #5
Source File: DeviceListFragment.java    From AndroidSDK with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View contentView = inflater.inflate(R.layout.fragment_device_list, container, false);
    mRecyclerView = (RecyclerView) contentView.findViewById(R.id.recyler_view);
    mSwipeRefreshLayout = (SwipeRefreshLayout) contentView.findViewById(R.id.swipe_refresh_layout);
    mFabAddDevice = (FloatingActionButton) contentView.findViewById(R.id.fab_add_device);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    mAdapter = new DeviceListAdapter();
    mAdapter.setOnLoadMoreListener(mLoadMoreListener, mRecyclerView);
    mRecyclerView.addOnItemTouchListener(new OnItemClickListener() {
        @Override
        public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
            DeviceActivity.actionDevice(getContext(), mDeviceItems.get(position));
        }
    });
    mRecyclerView.setAdapter(mAdapter);
    mSwipeRefreshLayout.setColorSchemeColors(0xFFDA4336);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    getDevices(false);
    mSwipeRefreshLayout.setRefreshing(true);

    mFabAddDevice.setOnClickListener(this);
    LocalBroadcastManager.getInstance(getContext()).registerReceiver(mUpdateApiKeyReceiver, new IntentFilter(IntentActions.ACTION_UPDATE_APIKEY));
    LocalBroadcastManager.getInstance(getContext()).registerReceiver(mUpdateDeviceListReceiver, new IntentFilter(IntentActions.ACTION_UPDATE_DEVICE_LIST));
    return contentView;
}
 
Example #6
Source File: SearchBookActivity.java    From SmallGdufe-Android with GNU General Public License v3.0 5 votes vote down vote up
private void initAdapter() {
    mAdapter = new SearchBookAdapter(R.layout.search_book_item);
    mAdapter.openLoadAnimation();
    mAdapter.setEmptyView(R.layout.layout_empty_data, (ViewGroup) mRecyclerView.getParent());
    mAdapter.isUseEmpty(false); //避免一开始就出现空页面
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));

    searchView.setIconifiedByDefault(false);//是否自动缩小为图标
    searchView.setSubmitButtonEnabled(true);
    searchView.setQueryHint("书名");

    mRecyclerView.addOnItemTouchListener(new OnItemClickListener( ){

        @Override
        public void onSimpleItemClick(BaseQuickAdapter adapter, final View view, final int position) {

            SearchBook bean = mAdapter.getItem(position);
            if(bean.getNumAll().equals("0")){
                Toast.makeText(SearchBookActivity.this, "此书刊可能正在订购中或者处理中", Toast.LENGTH_SHORT).show();
                return;
            }
            Intent intent = new Intent(SearchBookActivity.this,SearchBookStoreActivity.class);
            intent.putExtra(SearchBookStoreActivity.intentBookName,bean.getName());
            intent.putExtra(SearchBookStoreActivity.intentBookMacNo,bean.getMacno());
            startActivity(intent);
        }
    });
}
 
Example #7
Source File: DrawerHelper.java    From UIWidget with Apache License 2.0 5 votes vote down vote up
public void initRecyclerView(final Activity mContext, RecyclerView mRecyclerViewDrawer, List<DrawerEntity> list) {
    final BaseQuickAdapter mAdapterDrawer = new DrawerAdapter(mContext);
    mRecyclerViewDrawer.setLayoutManager(new LinearLayoutManager(mContext));
    mRecyclerViewDrawer.setAdapter(mAdapterDrawer);
    mRecyclerViewDrawer.addOnItemTouchListener(new OnItemClickListener() {
        @Override
        public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
            DrawerEntity entity = (DrawerEntity) mAdapterDrawer.getItem(position);
            WebViewActivity.start(mContext,entity.url);
        }
    });
    mAdapterDrawer.setNewData(list);
}
 
Example #8
Source File: BaseRecycleActivity.java    From UIWidget with Apache License 2.0 5 votes vote down vote up
protected void initRecyclerView() {
    mRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mRecyclerView.setLayoutManager(initLayoutManager());
    mRecyclerView.setAdapter(initAdapter());
    if (!setItemClickable()) {
        return;
    }
    mRecyclerView.addOnItemTouchListener(new OnItemClickListener() {
        @Override
        public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
            onItemClicked(adapter, view, position);
        }

    });
}
 
Example #9
Source File: DrawerHelper.java    From TitleBarView with Apache License 2.0 5 votes vote down vote up
public void initRecyclerView(final Activity mContext, RecyclerView mRecyclerViewDrawer, List<DrawerEntity> list) {
    final BaseQuickAdapter mAdapterDrawer = new DrawerAdapter(mContext);
    mRecyclerViewDrawer.setLayoutManager(new LinearLayoutManager(mContext));
    mRecyclerViewDrawer.setAdapter(mAdapterDrawer);
    mRecyclerViewDrawer.addOnItemTouchListener(new OnItemClickListener() {
        @Override
        public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
            DrawerEntity entity = (DrawerEntity) mAdapterDrawer.getItem(position);
            WebViewActivity.start(mContext, entity.url);
        }
    });
    mAdapterDrawer.setNewData(list);
}
 
Example #10
Source File: BaseRecycleActivity.java    From TitleBarView with Apache License 2.0 5 votes vote down vote up
protected void initRecyclerView() {
    mRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mRecyclerView.setLayoutManager(initLayoutManager());
    mRecyclerView.setAdapter(initAdapter());
    if (!setItemClickable()) {
        return;
    }
    mRecyclerView.addOnItemTouchListener(new OnItemClickListener() {
        @Override
        public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
            onItemClicked(adapter, view, position);
        }

    });
}
 
Example #11
Source File: ZeroFiveNewsFragment.java    From AcgClub with MIT License 5 votes vote down vote up
@Override
protected void initData() {
  mAdapter = new ZeroFiveNewsItemAdapter(getMAppComponent().imageLoader());
  mAdapter.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(BaseQuickAdapter adapter, android.view.View view, int position) {
      ZeroFiveNews zeroFiveNews = (ZeroFiveNews) adapter.getData().get(position);
      Intent intent = new Intent(getContext(), ZeroFiveNewsDetailActivity.class);
      intent.putExtra(IntentConstant.ZERO_FIVE_NEWS_ITEM, zeroFiveNews);
      startActivity(intent);
    }
  });

  LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
  layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
  rcvNewsItem.addItemDecoration(new CommonItemDecoration(2, CommonItemDecoration.UNIT_DP));
  rcvNewsItem.setLayoutManager(layoutManager);
  mAdapter.getLoadMoreModule().setOnLoadMoreListener(new OnLoadMoreListener() {
    @Override
    public void onLoadMore() {

      mPresenter.getMoreAcgNewsList();
    }
  });
  rcvNewsItem.setAdapter(mAdapter);

  swipeRefresh.setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh() {
      mPresenter.getAcgNewsList();
    }
  });
  setSwipeRefreshLayout(swipeRefresh);
  mPresenter.getAcgNewsList();
}
 
Example #12
Source File: BookcasePresenter.java    From FriendBook with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start() {
    super.start();
    if (isViewAttached()) {
        getView().addOnItemTouchListener(new OnItemClickListener() {
            @Override
            public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
                BookcaseAdapter bookcaseAdapter = (BookcaseAdapter) adapter;
                if (bookcaseAdapter.isEditing()) {
                    bookcaseAdapter.selectedItem(position);
                } else {
                    BookTb bookTb = (BookTb) adapter.getItem(position);
                    AppRouter.showReadActivity(view.getContext(), bookTb);
                }
            }
        });
    }

    Subscription subscribe = RxBus
            .getDefault()
            .toObservable(AddBook2BookcaseEvent.class)
            .subscribe(new SimpleSubscriber<AddBook2BookcaseEvent>() {
                @Override
                public void onNext(AddBook2BookcaseEvent addBook2BookcaseEvent) {
                    mAdapter.addData(addBook2BookcaseEvent.bookTb);
                }
            });
    addSubscription2Destroy(subscribe);
    addSubscription2Destroy(
            RxBus
                    .getDefault()
                    .toObservable(BookcaseRefreshEvent.class)
                    .subscribe(new SimpleSubscriber<BookcaseRefreshEvent>() {
                        @Override
                        public void onNext(BookcaseRefreshEvent event) {
                            loadData(true);
                        }
                    })
    );
}
 
Example #13
Source File: SearchBookPresenter.java    From FriendBook with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start() {
    super.start();
    if (isViewAttached()) {
        getView().addOnItemTouchListener(new OnItemClickListener() {
            @Override
            public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
               /* Book book = (Book) adapter.getItem(position);
                AppRouter.showReadActivity(view.getContext(), book.getId(), book.getName(), 0);*/
                AppRouter.showBookDetailActivity(view.getContext(), ((Book) adapter.getItem(position)));
            }
        });
    }
}
 
Example #14
Source File: BookPresenter.java    From FriendBook with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start() {
    super.start();
    if (isViewAttached()) {
        getView().addOnItemTouchListener(new OnItemClickListener() {
            @Override
            public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
                AppRouter.showBookDetailActivity(view.getContext(), ((Book) adapter.getItem(position)));
            }
        });
    }
}
 
Example #15
Source File: BookRankingPresenter.java    From FriendBook with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void start() {
    super.start();
    if (isViewAttached()) {
        getView().addOnItemTouchListener(new OnItemClickListener() {
            @Override
            public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
                AppRouter.showBookDetailActivity(view.getContext(), ((Book) adapter.getItem(position)));
            }
        });
    }
}
 
Example #16
Source File: ISHNewsFragment.java    From AcgClub with MIT License 5 votes vote down vote up
@Override
protected void initData() {
  mAdapter = new ISHNewsItemAdapter(getMAppComponent().imageLoader());
  mAdapter.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(BaseQuickAdapter adapter, android.view.View view, int position) {
      SHPostItem shPostItem = (SHPostItem) adapter.getData().get(position);
      Intent intent = new Intent(getContext(), ISHNewsDetailActivity.class);
      intent.putExtra(IntentConstant.ISH_NEWS_ITEM, shPostItem);
      startActivity(intent);
    }
  });

  LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
  layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
  rcvNewsItem.addItemDecoration(new CommonItemDecoration(2, CommonItemDecoration.UNIT_DP));
  rcvNewsItem.setLayoutManager(layoutManager);
  mAdapter.getLoadMoreModule().setOnLoadMoreListener(new OnLoadMoreListener() {
    @Override
    public void onLoadMore() {
      mPresenter.getMoreAcgNewsList();
    }

  });
  rcvNewsItem.setAdapter(mAdapter);

  swipeRefresh.setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh() {
      mPresenter.getAcgNewsList();
    }
  });
  setSwipeRefreshLayout(swipeRefresh);
  mPresenter.getAcgNewsList();
}
 
Example #17
Source File: SearchActivity.java    From POCenter with MIT License 4 votes vote down vote up
/**
 * set listeners
 */
private void initEvent() {
    // refresh listener
    bind.vContent.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            loadData(true);
        }
    });
    // load more listener
    searchAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
        @Override
        public void onLoadMoreRequested() {
            bind.rv.post(new Runnable() {
                @Override
                public void run() {
                    loadMore();
                }
            });
        }
    });

    // item click listener
    bind.rv.addOnItemTouchListener(new OnItemClickListener() {
        @Override
        public void SimpleOnItemClick(BaseQuickAdapter baseQuickAdapter, View view, int i) {
            // get item url
            ProjectBean project = (ProjectBean) baseQuickAdapter.getItem(i);
            // start detail activity
            Intent intent = new Intent(SearchActivity.this, DetailActivity.class);
            intent.putExtra(DetailActivity.EXTRA_URL, project.url);
            intent.putExtra(DetailActivity.EXTRA_TITLE, project.title);
            intent.putExtra(DetailActivity.EXTRA_DESCRIPTION, project.description);
            startActivity(intent);
        }
    });

    // search listener
    bind.fsv.setOnSearchListener(new FloatingSearchView.OnSearchListener() {
        @Override
        public void onSuggestionClicked(SearchSuggestion searchSuggestion) {

        }

        @Override
        public void onSearchAction(String currentQuery) {
            if (!TextUtils.isEmpty(currentQuery)) {
                presenter.setSearchString(currentQuery);
                loadData(false);
            }
        }
    });
}
 
Example #18
Source File: ScheduleOtherActivity.java    From AcgClub with MIT License 4 votes vote down vote up
@Override
protected void initData() {
  setToolBar(toolbar, "");

  String scheduleOtherUrl = getIntent().getStringExtra(IntentConstant.SCHEDULE_DETAIL_URL);
  if (TextUtils.isEmpty(scheduleOtherUrl)) {
    showError(R.string.msg_error_url_null);
    return;
  }

  mAdapter = new ScheduleOtherAdapter(mAppComponent.imageLoader());
  mAdapter.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(BaseQuickAdapter adapter, android.view.View view, int position) {
      ScheduleOtherPage.ScheduleOtherItem scheduleOtherItem = (ScheduleOtherPage.ScheduleOtherItem) adapter
          .getData().get(position);
      Intent intent = new Intent(getBaseContext(), ScheduleVideoActivity.class);
      intent.putExtra(IntentConstant.SCHEDULE_EPISODE_URL, scheduleOtherItem.getVideolLink());
      startActivity(intent);
    }
  });
  mAdapter.getLoadMoreModule().setOnLoadMoreListener(new OnLoadMoreListener() {
    @Override
    public void onLoadMore() {
      mPresenter.getMoreScheduleOther();
    }
  });

  GridLayoutManager layoutManager = new GridLayoutManager(getBaseContext(), 2);
  rcvScheduleOther.addItemDecoration(new CommonItemDecoration(2, CommonItemDecoration.UNIT_DP));
  rcvScheduleOther.setLayoutManager(layoutManager);
  rcvScheduleOther.setAdapter(mAdapter);

  swipeRefresh.setOnRefreshListener(new OnRefreshListener() {
    @Override
    public void onRefresh() {
      mPresenter.getScheduleOther();
    }
  });

  mPresenter.setCurScheduleOtherUrl(scheduleOtherUrl);
  mPresenter.getScheduleOther();
}