forked from Krupen/FabulousFilter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
library updated with viewpager support
- Loading branch information
Krupen
committed
Jun 28, 2017
1 parent
0eae80e
commit 7522a56
Showing
13 changed files
with
1,207 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,5 +33,4 @@ dependencies { | |
compile ('com.google.android:flexbox:0.2.7'){ | ||
exclude group: 'com.android.support' | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
fabulousfilter/src/main/java/android/support/v4/view/ViewPagerUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package android.support.v4.view; | ||
|
||
import android.view.View; | ||
|
||
public class ViewPagerUtils { | ||
|
||
public static View getCurrentView(ViewPager viewPager) { | ||
final int currentItem = viewPager.getCurrentItem(); | ||
for (int i = 0; i < viewPager.getChildCount(); i++) { | ||
final View child = viewPager.getChildAt(i); | ||
final ViewPager.LayoutParams layoutParams = (ViewPager.LayoutParams) child.getLayoutParams(); | ||
if (!layoutParams.isDecor && currentItem == layoutParams.position) { | ||
return child; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
.../main/java/com/allattentionhere/fabulousfilter/viewpagerbottomsheet/BottomSheetUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.allattentionhere.fabulousfilter.viewpagerbottomsheet; | ||
|
||
import android.support.design.widget.CoordinatorLayout; | ||
import android.support.v4.view.ViewPager; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.view.ViewParent; | ||
|
||
|
||
public final class BottomSheetUtils { | ||
|
||
public static void setupViewPager(ViewPager viewPager) { | ||
final View bottomSheetParent = findBottomSheetParent(viewPager); | ||
if (bottomSheetParent != null) { | ||
viewPager.addOnPageChangeListener(new BottomSheetViewPagerListener(viewPager, bottomSheetParent)); | ||
} | ||
} | ||
|
||
private static class BottomSheetViewPagerListener extends ViewPager.SimpleOnPageChangeListener { | ||
private final ViewPager viewPager; | ||
private final ViewPagerBottomSheetBehavior<View> behavior; | ||
|
||
private BottomSheetViewPagerListener(ViewPager viewPager, View bottomSheetParent) { | ||
this.viewPager = viewPager; | ||
this.behavior = ViewPagerBottomSheetBehavior.from(bottomSheetParent); | ||
} | ||
|
||
@Override | ||
public void onPageSelected(int position) { | ||
viewPager.post(new Runnable() { | ||
@Override | ||
public void run() { | ||
behavior.invalidateScrollingChild(); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
private static View findBottomSheetParent(final View view) { | ||
View current = view; | ||
while (current != null) { | ||
final ViewGroup.LayoutParams params = current.getLayoutParams(); | ||
if (params instanceof CoordinatorLayout.LayoutParams && ((CoordinatorLayout.LayoutParams) params).getBehavior() instanceof ViewPagerBottomSheetBehavior) { | ||
return current; | ||
} | ||
final ViewParent parent = current.getParent(); | ||
current = parent == null || !(parent instanceof View) ? null : (View) parent; | ||
} | ||
return null; | ||
} | ||
|
||
} |
Oops, something went wrong.