private void swapSuggestions(final List<? extends SearchSuggestion> newSearchSuggestions, final boolean withAnim) { mSuggestionsList.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { Util.removeGlobalLayoutObserver(mSuggestionsList, this); boolean isSuggestionItemsFillRecyclerView = updateSuggestionsSectionHeight(newSearchSuggestions, withAnim); //we only need to employ the reverse layout technique if the items don't fill up the RecyclerView LinearLayoutManager suggestionsListLm = (LinearLayoutManager) mSuggestionsList.getLayoutManager(); if (isSuggestionItemsFillRecyclerView) { suggestionsListLm.setReverseLayout(false); } else { mSuggestionsAdapter.reverseList(); suggestionsListLm.setReverseLayout(true); } mSuggestionsList.setAlpha(1); } }); mSuggestionsList.setAdapter(mSuggestionsAdapter);//workaround to avoid list retaining scroll pos mSuggestionsList.setAlpha(0); mSuggestionsAdapter.swapData(newSearchSuggestions); mDivider.setVisibility(!newSearchSuggestions.isEmpty() ? View.VISIBLE : View.GONE); }
@Override public void onGlobalLayout() { Util.removeGlobalLayoutObserver(mSuggestionsList, this); boolean isSuggestionItemsFillRecyclerView = updateSuggestionsSectionHeight(newSearchSuggestions, withAnim); //we only need to employ the reverse layout technique if the items don't fill up the RecyclerView LinearLayoutManager suggestionsListLm = (LinearLayoutManager) mSuggestionsList.getLayoutManager(); if (isSuggestionItemsFillRecyclerView) { suggestionsListLm.setReverseLayout(false); } else { mSuggestionsAdapter.reverseList(); suggestionsListLm.setReverseLayout(true); } mSuggestionsList.setAlpha(1); } });
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView); mViewPager = (ViewPager) findViewById(R.id.viewpager); mZoomHeader = (ZoomHeaderView) findViewById(R.id.zoomHeader); mViewPager.setAdapter(new Adapter()); mViewPager.setOffscreenPageLimit(4); CtrlLinearLayoutManager layoutManager = new CtrlLinearLayoutManager(this); //未展开禁止滑动 layoutManager.setScrollEnabled(false); mRecyclerView.setLayoutManager(layoutManager); mRecyclerView.setAdapter(new ListAdapter()); mRecyclerView.setAlpha(0); mBottomView = (RelativeLayout) findViewById(R.id.rv_bottom); }
mediumRecyclerView.setAlpha(0);
@Override public boolean onScale(@NonNull ScaleGestureDetector detector) { if (gestureTolerance(detector)) { //small scaleFactor *= detector.getScaleFactor(); scaleFactor = Math.max(1f, Math.min(scaleFactor, SMALL_MAX_SCALE_FACTOR)); isInProgress = scaleFactor > 1; smallRecyclerView.setScaleX(scaleFactor); smallRecyclerView.setScaleY(scaleFactor); //medium scaleFactorMedium *= detector.getScaleFactor(); scaleFactorMedium = Math.max(0.8f, Math.min(scaleFactorMedium, 1f)); mediumRecyclerView.setScaleX(scaleFactorMedium); mediumRecyclerView.setScaleY(scaleFactorMedium); //alpha mediumRecyclerView.setAlpha((scaleFactor - 1) / (0.25f)); smallRecyclerView.setAlpha(1 - (scaleFactor - 1) / (0.25f)); } return true; }
@Override public void finishSelf(boolean backPressed) { recyclerView.setAlpha(0f); if (!browsablePresenter.isBrowsable() && photoListManagePresenter.getCurrentIndex() == getIntent().getIntExtra(KEY_PHOTO_ACTIVITY_2_PHOTO_CURRENT_INDEX, -1) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { finishAfterTransition(); } else { finish(); if (backPressed) { overridePendingTransition(R.anim.none, R.anim.activity_slide_out); } else { overridePendingTransition(R.anim.none, R.anim.activity_fade_out); } } }
mIconsGrid.setAlpha(0.0f); mActionBar.hide();
private void setState(int stateTo) { if(state == stateTo) { return; } recyclerView.clearAnimation(); progressView.clearAnimation(); switch (stateTo) { case STATE_SHOWING: if (state == STATE_LOADING) { recyclerView.setVisibility(View.VISIBLE); ShowAnimation show = new ShowAnimation(recyclerView); show.setDuration(150); recyclerView.startAnimation(show); HideAnimation hide = new HideAnimation(progressView); hide.setDuration(150); progressView.startAnimation(hide); } break; case STATE_LOADING: if (state == STATE_SHOWING) { recyclerView.setAlpha(0); progressView.setAlpha(1); recyclerView.setVisibility(View.GONE); } break; } state = stateTo; }
/** * 在positionView的位置显示popupWindow; * 显示的时候 首先获取到背景View;然后将其设置为背景图片 */ public void showAtLocation(View parentView, View positionView) { int[] contentPosition = PopupWindowUtils.calculatePopupWindowPos(mContentView, positionView, mTrianleHeight, getWidth()); int[] centerPosition = PopupWindowUtils.getPositionViewCenterPos(positionView); mRecyclerView.setBackground(null); mRecyclerView.setAlpha(1.0f); mPopouBackView = new PopouBackView(mContext); mPopouBackView.setContentPosition(contentPosition); mPopouBackView.setPosCenterPosition(centerPosition); mPopouBackView.setRadius(mRadius); mPopouBackView.setPosViewHeight(positionView.getMeasuredHeight()); mPopouBackView.setViewWidth(getWidth());//注意这里传入的参数为popop的宽度 mPopouBackView.setViewHeight(mContentView.getMeasuredHeight()); mPopouBackView.setShowDown(PopupWindowUtils.isShowDown(mContentView, positionView, mTrianleHeight)); mPopouBackView.setTranWidth(mTriangleWidth); mPopouBackView.setTranHeight(mTrianleHeight); mPopouBackView.setBackColor(mBackgroundColor); Bitmap bitmap = mPopouBackView.convertViewToBitmap(); Drawable drawable = new BitmapDrawable(null, bitmap); update(); setBackgroundDrawable(drawable); darkenBackground(mDarkBackgroundDegree);//设置背景框为灰色 showAtLocation(parentView, Gravity.TOP | Gravity.START, contentPosition[0], contentPosition[1]); }