예제 #1
0
 @Override
 protected void initData() {
   mImageLoader = new ImageLoader(Volley.newRequestQueue(this), new BitmapCache());
   mSelectedMonth = (Calendar.getInstance().get(Calendar.MONTH) + 1);
   mSelectedDay = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
   mDataList = new ArrayList<>();
   mListAdapter = new HistoryTodayListAdapter(this);
   mListAdapter.setBeanList(mDataList);
   mRecyclerView.setHasFixedSize(true);
   mRecyclerView.setAdapter(mListAdapter);
   mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
   mRecyclerView.setItemAnimator(new DefaultItemAnimator());
   mFbInAnim = AnimationUtils.loadAnimation(HistoryTodayActivity.this, R.anim.in_south);
   mFbOutAnim = AnimationUtils.loadAnimation(HistoryTodayActivity.this, R.anim.out_south);
 }
예제 #2
0
  @Override
  protected void initListener() {
    mSelectFb.setOnClickListener(this);
    mScrollToTopFb.setOnClickListener(this);
    mListAdapter.setOnItemClickListener(
        new HistoryTodayListAdapter.OnItemClickListener() {
          @Override
          public void onItemClick(View view, int position) {
            loadImage(mTopAreaIv, mListAdapter.getBeanList().get(position).getPic());
            mTopDesTv.setText(
                StringUtil.addBeginSpace(mListAdapter.getBeanList().get(position).getDes(), 4));
          }

          @Override
          public void onItemLongClick(View view, final int position) {}
        });

    mRecyclerView.setOnScrollListener(
        new RecyclerView.OnScrollListener() {
          private int currRecyclerState; // 静止、滚动

          @Override
          public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);

            currRecyclerState = newState;
          }

          @Override
          public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            super.onScrolled(recyclerView, dx, dy);

            if (currRecyclerState == RecyclerView.SCROLL_STATE_DRAGGING) {
              if (dy > 0) {
                // 上拉下滚
                hideFb();
              } else if (dy < 0) {
                // 下拉上滚
                showFb();
              }
            }
          }
        });
  }