Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Relex committed Nov 6, 2018
1 parent debf79e commit 3d6554d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public FragmentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int view
}

/**
* Attach Fragment && Fragment setUserVisibleHint true
* Attach Fragment and Fragment setUserVisibleHint true
*/
@Override public void onViewAttachedToWindow(@NonNull FragmentViewHolder holder) {
super.onViewAttachedToWindow(holder);
Expand All @@ -60,24 +60,26 @@ public FragmentViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int view

fragmentTransaction.commitNowAllowingStateLoss();

if (holder.currentFragment != null) {
if (holder.currentFragment != null && holder.currentFragment.getUserVisibleHint()) {
holder.currentFragment.setMenuVisibility(false);
holder.currentFragment.setUserVisibleHint(false);
}

holder.currentFragment = fragment;
}

fragment.setMenuVisibility(true);
fragment.setUserVisibleHint(true);

if (!fragment.getUserVisibleHint()) {
fragment.setMenuVisibility(true);
fragment.setUserVisibleHint(true);
}
}

/**
* Fragment setUserVisibleHint false
*/
@Override public void onViewDetachedFromWindow(@NonNull FragmentViewHolder holder) {
super.onViewDetachedFromWindow(holder);
if (holder.currentFragment != null) {
if (holder.currentFragment != null && holder.currentFragment.getUserVisibleHint()) {
holder.currentFragment.setMenuVisibility(false);
holder.currentFragment.setUserVisibleHint(false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.relex.recyclerpager;

import android.support.annotation.CallSuper;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SnapHelper;
Expand Down Expand Up @@ -82,8 +83,8 @@ public SnapPageScrollListener(SnapHelper snapHelper) {
onPageScrolled(targetPosition, targetPositionOffset, targetPositionOffsetPixels);
}

@Override
public final void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
@CallSuper @Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (currentPosition == RecyclerView.NO_POSITION) {
return;
Expand Down

0 comments on commit 3d6554d

Please sign in to comment.