Пример #1
0
  private void init(View view) {
    mNetworkRequest = new NetworkRequestImpl(getContext());
    mRoomIdDB = new RoomIdDatabaseHelper(getContext(), RoomIdDatabaseHelper.HEART_DB_NAME, null, 1);
    mptrClassicFrameLayout = (PtrClassicFrameLayout) view.findViewById(R.id.store_house_ptr_frame);
    mRecyclerView = (RecyclerView) view.findViewById(R.id.store_house_ptr_rv);
    mRoomInfos = new ArrayList<>();
    mAdapter = new RoomInfoAdapter(getContext(), mRoomInfos);
    final GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 2);
    mRecyclerView.setLayoutManager(gridLayoutManager);
    mAdapter.setOnItemClickListener(
        new RoomInfoAdapter.OnItemClickListener() {
          @Override
          public void onItemClick(View view, int position) {
            mNetworkRequest.getStreamUrl(mRoomInfos.get(position).getRoomId(), mStreamUrlListener);
          }

          @Override
          public void onItemLongClick(View view, int position) {
            mDeletePosition = position;
            new AlertDialog.Builder(getContext())
                .setTitle("收藏")
                .setMessage("确认收藏")
                .setNegativeButton("否", null)
                .setPositiveButton("是", mPositiveClickListener)
                .show();
          }
        });
    setAdapter();
    setPtrHandler();
    mptrClassicFrameLayout.autoRefresh(true);
  }
Пример #2
0
 @Override
 public void onClick(DialogInterface dialog, int which) {
   int roomId = mRoomInfos.get(mDeletePosition).getRoomId();
   mRoomIdDB.deleteRoomId(roomId);
   mRoomInfos.remove(mRoomInfos.get(mDeletePosition));
   mAdapter.notifyDataSetChanged();
 }
Пример #3
0
 @Override
 public void onSuccess(RoomInfo roomInfo) {
   mRoomInfos.add(roomInfo);
   mAdapter.notifyDataSetChanged();
 }