2
2
package me .storm .ninegag .view .swipeback ;
3
3
4
4
import android .app .Activity ;
5
+ import android .app .ActivityOptions ;
5
6
import android .graphics .drawable .ColorDrawable ;
7
+ import android .os .Build ;
6
8
import android .view .LayoutInflater ;
7
9
import android .view .View ;
8
10
@@ -90,10 +92,14 @@ public void convertActivityFromTranslucent() {
90
92
* {@link android.R.attr#windowIsTranslucent} back from opaque to
91
93
* translucent following a call to {@link #convertActivityFromTranslucent()}
92
94
* .
93
- * <p/>
95
+ *
96
+
97
+
94
98
* Calling this allows the Activity behind this one to be seen again. Once
95
99
* all such Activities have been redrawn
96
- * <p/>
100
+ *
101
+
102
+
97
103
* This call has no effect on non-translucent activities or on activities
98
104
* with the {@link android.R.attr#windowIsFloating} attribute.
99
105
*/
@@ -102,17 +108,28 @@ public void convertActivityToTranslucent() {
102
108
Class <?>[] classes = Activity .class .getDeclaredClasses ();
103
109
Class <?> translucentConversionListenerClazz = null ;
104
110
for (Class clazz : classes ) {
105
- if (clazz .getSimpleName ().contains ("TranslucentConversionListener" )) {
111
+ if (clazz .getSimpleName ().contains (
112
+ "TranslucentConversionListener" )) {
106
113
translucentConversionListenerClazz = clazz ;
107
114
}
108
115
}
109
- Method method = Activity .class .getDeclaredMethod ("convertToTranslucent" ,
110
- translucentConversionListenerClazz );
111
- method .setAccessible (true );
112
- method .invoke (mActivity , new Object []{
113
- null
114
- });
116
+ Method [] methods = Activity .class .getDeclaredMethods ();
117
+ if (Build .VERSION .SDK_INT < Build .VERSION_CODES .LOLLIPOP ) {
118
+ Method method = Activity .class .getDeclaredMethod (
119
+ "convertToTranslucent" ,
120
+ translucentConversionListenerClazz );
121
+ method .setAccessible (true );
122
+ method .invoke (mActivity , new Object [] { null });
123
+ } else {
124
+ Method method = Activity .class .getDeclaredMethod (
125
+ "convertToTranslucent" ,
126
+ translucentConversionListenerClazz ,
127
+ ActivityOptions .class );
128
+ method .setAccessible (true );
129
+ method .invoke (mActivity , new Object [] { null , null });
130
+ }
115
131
} catch (Throwable t ) {
132
+ t .printStackTrace ();
116
133
}
117
134
}
118
135
}
0 commit comments