-
Notifications
You must be signed in to change notification settings - Fork 14
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
6 changed files
with
140 additions
and
29 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
36 changes: 36 additions & 0 deletions
36
.../main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/RaiseFromCenterTransformer.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,36 @@ | ||
package it.dhd.oxygencustomizer.xposed.utils.viewpager; | ||
|
||
import android.view.View; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
public class RaiseFromCenterTransformer extends ABaseTransformer { | ||
|
||
protected void onTransform(@NonNull View page, float position) { | ||
int width = page.getWidth(), height = page.getHeight(); | ||
|
||
if (position < -1) { | ||
page.setTranslationX(0); | ||
} else if (position < 0) { | ||
|
||
float scale = 1 + position; | ||
page.setPivotX(width/2); | ||
page.setPivotY(height/2); | ||
page.setScaleY(scale); | ||
page.setScaleX(scale); | ||
// Counteract the default motion | ||
page.setTranslationX(-position*width); | ||
} else if (position < 1) { | ||
float scale = 1 - position; | ||
page.setPivotX(width/2); | ||
page.setPivotY(height/2); | ||
page.setScaleY(scale); | ||
page.setScaleX(scale); | ||
// Counteract the default motion | ||
page.setTranslationX(-width * position); | ||
|
||
} else { | ||
page.setTranslationX(0); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...ain/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/RotateAboutBottomTransformer.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,12 @@ | ||
package it.dhd.oxygencustomizer.xposed.utils.viewpager; | ||
|
||
import android.view.View; | ||
|
||
public class RotateAboutBottomTransformer extends ABaseTransformer { | ||
protected void onTransform(View view, float position) { | ||
final float width = view.getWidth(), height = view.getHeight(); | ||
view.setPivotX(width / 2); | ||
view.setPivotY(height); | ||
view.setRotation(position * 20); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...src/main/java/it/dhd/oxygencustomizer/xposed/utils/viewpager/TranslationYTransformer.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 it.dhd.oxygencustomizer.xposed.utils.viewpager; | ||
|
||
import android.view.View; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
public class TranslationYTransformer extends ABaseTransformer { | ||
public static final int TOP_TO_BOTTOM = 1, BOTTOM_TO_TOP = 2; | ||
public int ANIMATE_TYPE = 2; | ||
|
||
public TranslationYTransformer(){ | ||
|
||
} | ||
|
||
public TranslationYTransformer(int ANIMATE_TYPE) { | ||
this.ANIMATE_TYPE = ANIMATE_TYPE; | ||
} | ||
|
||
protected void onTransform(@NonNull View page, float position) { | ||
|
||
int width = page.getWidth(), height = page.getHeight(); | ||
|
||
if (position <= 0) { | ||
// This page is way off-screen to the left. | ||
page.setTranslationX(0); | ||
} else if (position <= 1) { | ||
// Log.d("POSITION", position * height + "!!"); | ||
if (ANIMATE_TYPE == TOP_TO_BOTTOM) { | ||
page.setTranslationY(-position * (height)); | ||
} else if (ANIMATE_TYPE == BOTTOM_TO_TOP) { | ||
page.setTranslationY(position * (height)); | ||
} | ||
} else { | ||
// This page is way off-screen to the right. | ||
page.setTranslationX(0); | ||
|
||
} | ||
} | ||
} |
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