コード例 #1
0
ファイル: RegionView.java プロジェクト: Hi-Mike/EmotionShow
  public void initData(int regionCode) {
    // 一定能选中省
    provinceAdapter.addHeader(
        (provinceHeader =
            new RegionHeaderView(callback, new Region(0, 1, 100000, 100000, "不限"), "不限")));
    ArrayList<Region> arrProvince = RegionModel.getInstance().getProvinceList();
    provinceAdapter.addAll(arrProvince);
    Region provinceRegion = RegionModel.getInstance().findProvince(regionCode);
    if (provinceRegion == null) {
      provinceRegion = arrProvince.get(0);
    }
    province.scrollToPosition(arrProvince.indexOf(provinceRegion) + 1);

    // 一定要选中市
    cityAdapter.addHeader((cityHeader = new RegionHeaderView(callback, provinceRegion, "全部")));
    ArrayList<Region> arrCity = RegionModel.getInstance().getCityList(provinceRegion.getCid());
    cityAdapter.addAll(arrCity);
    Region cityRegion = RegionModel.getInstance().findCity(regionCode);
    if (cityRegion == null) {
      cityRegion = arrCity.get(0);
    }
    city.scrollToPosition(arrCity.indexOf(cityRegion) + 1);

    // 一定要选中区
    regionAdapter.addHeader((regionHeader = new RegionHeaderView(callback, cityRegion, "全部")));
    ArrayList<Region> arrRegion = RegionModel.getInstance().getRegionList(cityRegion.getCid());
    regionAdapter.addAll(arrRegion);
    Region regionRegion = RegionModel.getInstance().findRegion(regionCode);
    if (regionRegion == null) {
      regionRegion = arrRegion.get(0);
    }
    region.scrollToPosition(arrRegion.indexOf(regionRegion) + 1);
  }
コード例 #2
0
  /**
   * 设置headerAndFooterAdapter的FooterView State
   *
   * @param recyclerView recyclerView
   * @param pageSize 分页展示时,recyclerView每一页的数量
   * @param state FooterView State
   * @param errorListener FooterView处于Error状态时的点击事件
   */
  public static void setFooterViewState(
      Context context,
      RecyclerView recyclerView,
      int pageSize,
      LoadingFooter.State state,
      View.OnClickListener errorListener) {

    if (context == null) {
      return;
    }

    RecyclerView.Adapter outerAdapter = recyclerView.getAdapter();

    if (outerAdapter == null || !(outerAdapter instanceof HeaderAndFooterRecyclerViewAdapter)) {
      return;
    }

    HeaderAndFooterRecyclerViewAdapter headerAndFooterAdapter =
        (HeaderAndFooterRecyclerViewAdapter) outerAdapter;

    // 只有一页的时候,就别加什么FooterView了
    if (headerAndFooterAdapter.getInnerAdapter().getItemCount() < pageSize) {
      return;
    }

    LoadingFooter footerView;

    // 已经有footerView了
    if (headerAndFooterAdapter.getFooterViewsCount() > 0) {
      footerView = (LoadingFooter) headerAndFooterAdapter.getFooterView();
      footerView.setState(state);

      if (state == LoadingFooter.State.NetWorkError) {
        footerView.setOnClickListener(errorListener);
      }
      recyclerView.scrollToPosition(headerAndFooterAdapter.getItemCount() - 1);
    } else {
      footerView = new LoadingFooter(context);
      footerView.setState(state);

      if (state == LoadingFooter.State.NetWorkError) {
        footerView.setOnClickListener(errorListener);
      }

      headerAndFooterAdapter.addFooterView(footerView);
      recyclerView.scrollToPosition(headerAndFooterAdapter.getItemCount() - 1);
    }
  }
コード例 #3
0
 /**
  * 更新界面数据 - 刷新
  *
  * @param list
  */
 public void update(List<Video> list) {
   if (mAdapter != null) {
     mRecyclerView.scrollToPosition(0);
     mAdapter.getCollection().update(list);
     mAdapter.notifyDataSetChanged();
   }
 }
コード例 #4
0
 @Override
 public boolean onQueryTextChange(String query) {
   final List<Album> filteredModelList = filter(mAllAlbums, query);
   mAdapter.setAlbums(filteredModelList);
   mResultsView.scrollToPosition(0);
   return true;
 }
コード例 #5
0
ファイル: MediaFragment.java プロジェクト: MEXXIO/impression
 public final void jumpToTop(boolean animateChange) {
   if (animateChange) {
     // stopAnimation();
     mRecyclerView.smoothScrollToPosition(0);
   } else {
     mRecyclerView.scrollToPosition(0);
   }
 }
コード例 #6
0
 // Recherche dynamique
 @Override
 public boolean onQueryTextChange(String query) {
   noms = bdd.getNoms();
   final List<ContenuListe> filteredModelList = filter(noms, query);
   recAdapter.animateTo(filteredModelList);
   listView.scrollToPosition(0);
   return true;
 }
コード例 #7
0
  @Override
  public boolean onQueryTextChange(String query) {

    final List<NoteDetail> filteredModelList = filter(allDatas, query);
    mAdapter.animateTo(filteredModelList);
    mRecyclerView.scrollToPosition(0);
    return true;
  }
コード例 #8
0
 public void addItem(String s) {
   if ((mAdapter.history.size() > 0
           && !mAdapter.history.get(0).split(" = ")[0].equals(s.split(" = ")[0]))
       || mAdapter.history.size() == 0) {
     mAdapter.history.add(0, s);
     mAdapter.notifyItemInserted(0);
     mRecycler.scrollToPosition(0);
   }
 }
コード例 #9
0
  @Override
  void onNext(PostsWrapper data) {
    boolean pullUpToRefresh = isPullUpToRefresh();
    if (pullUpToRefresh) {
      // mRecyclerAdapter.getItemCount() = 0
      // when configuration changes (like orientation changes)
      if (mRecyclerAdapter.getItemCount() != 0) {
        mRecyclerAdapter.hideFooterProgress();
      }
    }

    Posts posts = data.getPosts();
    List<Post> postList = posts.getPostList();
    // if user has logged out, has no permission to access this thread or this thread is invalid
    if (postList.isEmpty()) {
      consumeResult(data.getResult());
    } else {
      super.onNext(data);

      int lastItemCount = mRecyclerAdapter.getItemCount();
      mRecyclerAdapter.setDataSet(postList);
      if (pullUpToRefresh) {
        int newItemCount = mRecyclerAdapter.getItemCount() - lastItemCount;
        if (newItemCount > 0) {
          mRecyclerAdapter.notifyItemRangeInserted(lastItemCount, newItemCount);
        }
      } else {
        mRecyclerAdapter.notifyDataSetChanged();

        String quotePostId = getArguments().getString(ARG_QUOTE_POST_ID);
        if (!TextUtils.isEmpty(quotePostId)) {
          for (int i = 0, length = postList.size(); i < length; i++) {
            if (quotePostId.equals(postList.get(i).getId())) {
              // scroll to quote post
              mRecyclerView.scrollToPosition(i);
              break;
            }
          }
          // clear this argument after redirecting
          getArguments().putString(ARG_QUOTE_POST_ID, null);
        }
      }

      Thread postListInfo = posts.getPostListInfo();
      // we have not title if we open thread link in our app
      if (getActivity().getTitle() == null) {
        mPagerCallback.setThreadTitle(postListInfo.getTitle());
      }
      mPagerCallback.setTotalPageByPosts(postListInfo.getReplies() + 1);
      if (posts.getThreadAttachment() != null) {
        mPagerCallback.setupThreadAttachment(posts.getThreadAttachment());
      }
    }
  }
コード例 #10
0
 public void switchCategory(Article.Category category) {
   PreferencesUtility.saveCategory(getContext(), category);
   currentState = new State();
   recyclerView.scrollToPosition(0);
   if (category == Article.Category.FAVOURITES) {
     mListener.removeOffsetListener();
   } else {
     mListener.restoreOffsetListener();
   }
   launchLoader(currentState.currentPage);
 }
コード例 #11
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    NumberPickerDialog dialog;
    switch (item.getItemId()) {
      case R.id.action_add:
        dialog = new NumberPickerDialog(getActivity());
        dialog.setTitle("Position to Add");
        dialog.setPickerRange(0, mAdapter.getItemCount() - 1);
        dialog.setOnNumberSelectedListener(
            new NumberPickerDialog.OnNumberSelectedListener() {
              @Override
              public void onNumberSelected(int value) {
                mAdapter.addItem(value);
              }
            });
        dialog.show();

        return true;
      case R.id.action_remove:
        dialog = new NumberPickerDialog(getActivity());
        dialog.setTitle("Position to Remove");
        dialog.setPickerRange(0, mAdapter.getItemCount() - 1);
        dialog.setOnNumberSelectedListener(
            new NumberPickerDialog.OnNumberSelectedListener() {
              @Override
              public void onNumberSelected(int value) {
                mAdapter.removeItem(value);
              }
            });
        dialog.show();

        return true;
      case R.id.action_empty:
        mAdapter.setItemCount(0);
        return true;
      case R.id.action_small:
        mAdapter.setItemCount(5);
        return true;
      case R.id.action_medium:
        mAdapter.setItemCount(25);
        return true;
      case R.id.action_large:
        mAdapter.setItemCount(196);
        return true;
      case R.id.action_scroll_zero:
        mRecyclerView.scrollToPosition(0);
        return true;
      case R.id.action_smooth_zero:
        mRecyclerView.smoothScrollToPosition(0);
        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
コード例 #12
0
 public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
   if (mAdapter != null) {
     // Swap the new cursor in.  (The framework will take care of closing the, old cursor once we
     // return.)
     mAdapter.changeCursor(data);
     if (mPosition != 0) {
       mRecyclerView.scrollToPosition(Math.min(mPosition, data.getCount() - 1));
       mPosition = 0;
     }
   }
 }
コード例 #13
0
ファイル: SubmissionsView.java プロジェクト: KonradIT/Slide
 public void forceRefresh() {
   rv.scrollToPosition(0);
   mSwipeRefreshLayout.post(
       new Runnable() {
         @Override
         public void run() {
           mSwipeRefreshLayout.setRefreshing(true);
           refresh();
         }
       });
   mSwipeRefreshLayout.setRefreshing(false);
 }
コード例 #14
0
ファイル: PostFragment.java プロジェクト: Nodebuck/Pr0
  /**
   * Scroll the th given comment
   *
   * @param commentId The comment id to scroll to
   */
  private void scrollToComment(long commentId) {
    Optional<Integer> offset = adapter.getOffset(commentsAdapter);
    if (!offset.isPresent()) return;

    for (int idx = 0; idx < commentsAdapter.getItemCount(); idx++) {
      if (commentsAdapter.getItemId(idx) == commentId) {
        content.scrollToPosition(offset.get() + idx);
        break;
      }
    }

    commentsAdapter.setSelectedCommentId(commentId);
  }
コード例 #15
0
ファイル: NotesFragment.java プロジェクト: foolself/JustNote
 public void updateNote(Note newNote, Note oldNote) {
   for (Note note : notes) {
     if (oldNote.getId().equals(note.getId())) {
       note.setTitle(newNote.getTitle());
       note.setContent(newNote.getContent());
       notes.remove(note);
       notes.add(0, note);
       notesRecyclerView.scrollToPosition(0);
       notesAdapter.notifyDataSetChanged();
       break;
     }
   }
 }
コード例 #16
0
  private boolean validateName() {
    boolean valid =
        editedReference
                .getPlaylistName()
                .trim()
                .equalsIgnoreCase(reference.getPlaylistName().trim())
            || Library.verifyPlaylistName(this, editedReference.getPlaylistName()) == null;

    if (!valid) {
      RecyclerView list = (RecyclerView) findViewById(R.id.list);
      list.scrollToPosition(0);
    }
    return valid;
  }
コード例 #17
0
  /** 重新获取嵌套的内容视图 */
  private void regetNestedContentView() {
    int currentItem = mDirectViewPager.getCurrentItem();
    PagerAdapter adapter = mDirectViewPager.getAdapter();
    if (adapter instanceof FragmentPagerAdapter || adapter instanceof FragmentStatePagerAdapter) {
      Fragment item = (Fragment) adapter.instantiateItem(mDirectViewPager, currentItem);
      mNestedContentView = item.getView();

      // 清空之前的
      mNestedNormalView = null;
      mNestedAbsListView = null;
      mNestedRecyclerView = null;
      mNestedScrollView = null;
      mNestedWebView = null;

      if (mNestedContentView instanceof AbsListView) {
        mNestedAbsListView = (AbsListView) mNestedContentView;
        mNestedAbsListView.setOnScrollListener(mLvOnScrollListener);

        if (!isHeaderViewCompleteInvisible()) {
          mNestedAbsListView.setSelection(0);
        }
      } else if (mNestedContentView instanceof RecyclerView) {
        mNestedRecyclerView = (RecyclerView) mNestedContentView;
        mNestedRecyclerView.removeOnScrollListener(mRvOnScrollListener);
        mNestedRecyclerView.addOnScrollListener(mRvOnScrollListener);

        if (!isHeaderViewCompleteInvisible()) {
          mNestedRecyclerView.scrollToPosition(0);
        }
      } else if (mNestedContentView instanceof ScrollView) {
        mNestedScrollView = (ScrollView) mNestedContentView;

        if (!isHeaderViewCompleteInvisible()) {
          mNestedScrollView.scrollTo(mNestedScrollView.getScrollX(), 0);
        }
      } else if (mNestedContentView instanceof WebView) {
        mNestedWebView = (WebView) mNestedContentView;

        if (!isHeaderViewCompleteInvisible()) {
          mNestedWebView.scrollTo(mNestedWebView.getScrollX(), 0);
        }
      } else {
        mNestedNormalView = mNestedContentView;
      }
    } else {
      throw new IllegalStateException(
          BGAStickyNavLayout.class.getSimpleName()
              + "的第三个子控件为ViewPager时,其adapter必须是FragmentPagerAdapter或者FragmentStatePagerAdapter");
    }
  }
コード例 #18
0
  @AfterViews
  protected void init() {
    getProfileComponent()
        .plusControlsPage(new ActivityModule(this), new ReportModule(reportUri))
        .inject(this);

    initInputControlOptions();
    showInputControlOptions();

    emptyText.setText(getString(R.string.r_search_nothing_to_display));
    mPreviousSelected = getSelectedPosition();
    inputControlsList.scrollToPosition(mPreviousSelected);

    getSupportActionBar().setTitle(mInputControlLabel);
  }
コード例 #19
0
  public void initView() {
    // 初始化刷新控件
    mRefreshLayout.setOnRefreshListener(this);
    mRefreshLayout.setColorSchemeResources(
        android.R.color.holo_blue_bright,
        android.R.color.holo_green_light,
        android.R.color.holo_orange_light,
        android.R.color.holo_red_light);

    mFab.setOnClickListener(
        view -> {
          //                Snackbar.make(view, "Replace with your own action",
          // Snackbar.LENGTH_LONG)
          //                        .setAction("Action", null).show();
          mRecyclerView.scrollToPosition(0);
        });
  }
コード例 #20
0
 private void showResults(String query, ArrayList<Course> listToShow, boolean filter) {
   if (listToShow.isEmpty()) {
     String searchResult;
     if (filter) {
       searchResult = getString(R.string.no_results_for_filter);
       mNoResults.setText(searchResult);
       mNoResults.setVisibility(View.VISIBLE);
     } else if (query != null && !query.isEmpty()) {
       searchResult = String.format(getString(R.string.no_results_for_query), query);
       mNoResults.setText(searchResult);
       mNoResults.setVisibility(View.VISIBLE);
     } else {
       mNoResults.setVisibility(View.GONE);
     }
   } else {
     mNoResults.setVisibility(View.GONE);
   }
   mAdapter.animateTo(listToShow);
   mRecycler.scrollToPosition(0);
 }
コード例 #21
0
ファイル: BroadcastActivity.java プロジェクト: xyhrun/Douya
  private void onSendCommentResponse(boolean successful, Comment result, VolleyError error) {

    if (successful) {
      if (!mCanLoadMoreComments) {
        mCommentAdapter.add(result);
        fixCommentCount();
      } else {
        ToastUtils.show(R.string.broadcast_send_comment_successful, this);
      }
      mBroadcastCommentList.scrollToPosition(mAdapter.getItemCount() - 1);
      mCommentEdit.setText(null);
    } else {
      LogUtils.e(error.toString());
      ToastUtils.show(
          getString(
              R.string.broadcast_send_comment_failed_format, ApiError.getErrorString(error, this)),
          this);
    }

    setSendingComment(false);
  }
コード例 #22
0
ファイル: MiniDrawer.java プロジェクト: linbiqiu/TTT
  /** creates the items for the MiniDrawer */
  public void createItems() {
    mDrawerAdapter.clearDrawerItems();

    if (mAccountHeader != null) {
      IProfile profile = mAccountHeader.getActiveProfile();
      if (profile instanceof IDrawerItem) {
        mDrawerAdapter.addDrawerItem(generateMiniDrawerItem((IDrawerItem) profile));
      }
    }

    if (mDrawer != null) {
      if (getDrawerItems() != null) {
        // migrate to miniDrawerItems
        for (IDrawerItem drawerItem : getDrawerItems()) {
          IDrawerItem miniDrawerItem = generateMiniDrawerItem(drawerItem);
          if (miniDrawerItem != null) {
            mDrawerAdapter.addDrawerItem(miniDrawerItem);
          }
        }
      }
    }

    // listener
    if (mOnMiniDrawerItemClickListener != null) {
      mDrawerAdapter.setOnClickListener(mOnMiniDrawerItemClickListener);
    } else {
      mDrawerAdapter.setOnClickListener(
          new BaseDrawerAdapter.OnClickListener() {
            @Override
            public void onClick(View v, int position, IDrawerItem item) {
              int type = getMiniDrawerType(item);
              if (type == ITEM) {
                // fire the onClickListener also if the specific drawerItem is not Selectable
                if (item.isSelectable()) {
                  // make sure we are on the original drawerItemList
                  if (mAccountHeader != null && mAccountHeader.isSelectionListShown()) {
                    mAccountHeader.toggleSelectionList(v.getContext());
                  }
                  // set the selection
                  mDrawer.setSelection(item, true);
                } else if (mDrawer.getOnDrawerItemClickListener() != null) {
                  // get the original `DrawerItem` from the Drawer as this one will contain all
                  // information
                  mDrawer
                      .getOnDrawerItemClickListener()
                      .onItemClick(
                          v,
                          position,
                          DrawerUtils.getDrawerItem(getDrawerItems(), item.getIdentifier()));
                }
              } else if (type == PROFILE) {
                if (mAccountHeader != null && !mAccountHeader.isSelectionListShown()) {
                  mAccountHeader.toggleSelectionList(v.getContext());
                }
                if (mCrossFader != null) {
                  mCrossFader.crossfade();
                }
              }
            }
          });
    }
    mDrawerAdapter.setOnLongClickListener(mOnMiniDrawerItemLongClickListener);
    mRecyclerView.scrollToPosition(0);
  }
コード例 #23
0
  @Override
  public void onViewStateRestored(Bundle savedInstanceState) {
    super.onViewStateRestored(savedInstanceState);

    rvAdvies.scrollToPosition(0);
  }
コード例 #24
0
 public void resetView() {
   recyclerView.scrollToPosition(0);
 }
コード例 #25
0
 public void notifyItemInserted(int position) {
   getAdapter().notifyItemInserted(position);
   mRecyclerView.scrollToPosition(position);
 }
コード例 #26
0
 private void onFilteringList() {
   emptyText.setVisibility(mSingleSelectIcAdapter.getItemCount() == 0 ? View.VISIBLE : View.GONE);
   inputControlsList.scrollToPosition(0);
 }
コード例 #27
0
 /** It shows the progress bar */
 private void showProgressBar() {
   recyclerView.scrollToPosition(0);
   recyclerView.setVisibility(View.GONE);
   progressBar.setVisibility(View.VISIBLE);
 }
コード例 #28
0
 @Override
 public void setScrollPosition(int position) {
   viewList.scrollToPosition(position);
 }
コード例 #29
0
 private void changeCase(Case theCase) {
   mCaseAdapter.changeCase(theCase);
   mCaseView.scrollToPosition(0);
 }
コード例 #30
0
 private void scrollDown() {
   recyclerView.scrollToPosition(chatMessageAdapter.getItemCount() - 1);
 }