-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
658 additions
and
4 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
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
52 changes: 52 additions & 0 deletions
52
app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/ABaseTransformer.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 it.dhd.oxygencustomizer.xposed.utils.viewpager; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.viewpager.widget.ViewPager; | ||
import android.view.View; | ||
|
||
public abstract class ABaseTransformer implements ViewPager.PageTransformer { | ||
protected abstract void onTransform(View view, float f); | ||
|
||
public void transformPage(@NonNull View page, float position) { | ||
onPreTransform(page, position); | ||
onTransform(page, position); | ||
onPostTransform(page, position); | ||
} | ||
|
||
protected boolean hideOffscreenPages() { | ||
return true; | ||
} | ||
|
||
protected boolean isPagingEnabled() { | ||
return false; | ||
} | ||
|
||
protected void onPreTransform(View page, float position) { | ||
float f = 0.0f; | ||
float width = (float) page.getWidth(); | ||
page.setRotationX(0.0f); | ||
page.setRotationY(0.0f); | ||
page.setRotation(0.0f); | ||
page.setScaleX(1.0f); | ||
page.setScaleY(1.0f); | ||
page.setPivotX(0.0f); | ||
page.setPivotY(0.0f); | ||
page.setTranslationY(0.0f); | ||
page.setTranslationX(isPagingEnabled() ? 0.0f : (-width) * position); | ||
if (hideOffscreenPages()) { | ||
if (position > -1.0f && position < 1.0f) { | ||
f = 1.0f; | ||
} | ||
page.setAlpha(f); | ||
return; | ||
} | ||
page.setAlpha(1.0f); | ||
} | ||
|
||
protected void onPostTransform(View page, float position) { | ||
} | ||
|
||
protected static float min(float val, float min) { | ||
return Math.max(val, min); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/AccordionTransformer.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,10 @@ | ||
package it.dhd.oxygencustomizer.xposed.utils.viewpager; | ||
|
||
import android.view.View; | ||
|
||
public class AccordionTransformer extends ABaseTransformer { | ||
protected void onTransform(View view, float position) { | ||
view.setPivotX((float) (position < 0.0f ? 0 : view.getWidth())); | ||
view.setScaleX(position < 0.0f ? 1.0f + position : 1.0f - position); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ava/it/dhd/oxygencustomizer/xposed/utils/viewpager/BackgroundToForegroundTransformer.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,21 @@ | ||
package it.dhd.oxygencustomizer.xposed.utils.viewpager; | ||
|
||
|
||
import android.view.View; | ||
|
||
public class BackgroundToForegroundTransformer extends ABaseTransformer { | ||
protected void onTransform(View view, float position) { | ||
float f = 1.0f; | ||
float height = (float) view.getHeight(); | ||
float width = (float) view.getWidth(); | ||
if (position >= 0.0f) { | ||
f = Math.abs(1.0f - position); | ||
} | ||
float scale = min(f, 0.5f); | ||
view.setScaleX(scale); | ||
view.setScaleY(scale); | ||
view.setPivotX(width * 0.5f); | ||
view.setPivotY(height * 0.5f); | ||
view.setTranslationX(position < 0.0f ? width * position : (-width) * position * 0.25f); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
app/src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/CubeInTransformer.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,15 @@ | ||
package it.dhd.oxygencustomizer.xposed.utils.viewpager; | ||
|
||
import android.view.View; | ||
|
||
public class CubeInTransformer extends ABaseTransformer { | ||
protected void onTransform(View view, float position) { | ||
view.setPivotX((float) (position > 0.0f ? 0 : view.getWidth())); | ||
view.setPivotY(0.0f); | ||
view.setRotationY(-90.0f * position); | ||
} | ||
|
||
public boolean isPagingEnabled() { | ||
return true; | ||
} | ||
} |
Oops, something went wrong.