-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support swipe gesture to switch between tabs (#308)
* Support swipe gesture to switch between tabs * Use tab layout for tab indicators
- Loading branch information
Showing
14 changed files
with
178 additions
and
140 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...android/pikettassist/ui/FragmentName.java → ...oid/pikettassist/ui/FragmentPosition.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
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
39 changes: 39 additions & 0 deletions
39
app/src/main/java/com/github/frimtec/android/pikettassist/ui/common/ViewPager2Helper.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,39 @@ | ||
package com.github.frimtec.android.pikettassist.ui.common; | ||
|
||
import android.util.Log; | ||
|
||
import androidx.recyclerview.widget.RecyclerView; | ||
import androidx.viewpager2.widget.ViewPager2; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
public class ViewPager2Helper { | ||
|
||
private static final String TAG = "ViewPager2Helper"; | ||
|
||
public static void reduceDragSensitivity(ViewPager2 viewPager, int sensitivity) { | ||
try { | ||
RecyclerView recyclerView = (RecyclerView) getRecyclerViewField().get(viewPager); | ||
|
||
Field touchSlopField = getTouchSlopField(); | ||
//noinspection ConstantConditions | ||
int touchSlop = (int) touchSlopField.get(recyclerView); | ||
touchSlopField.set(recyclerView, touchSlop * sensitivity); | ||
} catch (NoSuchFieldException|IllegalAccessException e) { | ||
Log.e(TAG, "Cannot change drag sensibility", e); | ||
} | ||
} | ||
|
||
static Field getRecyclerViewField() throws NoSuchFieldException { | ||
Field field = ViewPager2.class.getDeclaredField("mRecyclerView"); | ||
field.setAccessible(true); | ||
return field; | ||
} | ||
|
||
static Field getTouchSlopField() throws NoSuchFieldException { | ||
Field field = RecyclerView.class.getDeclaredField("mTouchSlop"); | ||
field.setAccessible(true); | ||
return field; | ||
} | ||
|
||
} |
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
Oops, something went wrong.