diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2012-03-23 21:25:18 +0100 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2012-03-23 21:27:06 +0100 |
commit | 51f56540932d83cb81549b817fccbca495e54c5a (patch) | |
tree | 3e3394890de8565210fb36a6db617034fc7145db /main/src | |
parent | fde480c2098aebc318c433cc4143868f765dafec (diff) | |
download | cgeo-51f56540932d83cb81549b817fccbca495e54c5a.zip cgeo-51f56540932d83cb81549b817fccbca495e54c5a.tar.gz cgeo-51f56540932d83cb81549b817fccbca495e54c5a.tar.bz2 |
Fix #1326: invoke Activity.overridePendingTransitionMethod() dynamically
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/cgeo/geocaching/compatibility/Compatibility.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/compatibility/Compatibility.java b/main/src/cgeo/geocaching/compatibility/Compatibility.java index 409f837..344ff6a 100644 --- a/main/src/cgeo/geocaching/compatibility/Compatibility.java +++ b/main/src/cgeo/geocaching/compatibility/Compatibility.java @@ -14,6 +14,8 @@ import android.view.Display; import android.view.Surface; import android.widget.EditText; +import java.lang.reflect.Method; + public final class Compatibility { private final static int sdkVersion = Integer.parseInt(Build.VERSION.SDK); @@ -23,7 +25,16 @@ public final class Compatibility { private final static AndroidLevel8Interface level8; private final static AndroidLevel11Interface level11; + private static Method overridePendingTransitionMethod = null; + static { + if (isLevel5) { + try { + overridePendingTransitionMethod = Activity.class.getMethod("overridePendingTransition", Integer.TYPE, Integer.TYPE); + } catch (Exception e) { + Log.e(Settings.tag, "cannot get overridePendingTransition", e); + } + } if (isLevel8) { level8 = new AndroidLevel8(); } @@ -89,15 +100,23 @@ public final class Compatibility { } } + private static void overridePendingTransition(final Activity activity, int enterAnim, int exitAnim) { + try { + overridePendingTransitionMethod.invoke(activity, enterAnim, exitAnim); + } catch (Exception e) { + Log.e(Settings.tag, "cannot call overridePendingTransition", e); + } + } + public static void restartActivity(AbstractActivity activity) { final Intent intent = activity.getIntent(); if (isLevel5) { - activity.overridePendingTransition(0, 0); + overridePendingTransition(activity, 0, 0); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); } activity.finish(); if (isLevel5) { - activity.overridePendingTransition(0, 0); + overridePendingTransition(activity, 0, 0); } activity.startActivity(intent); } |