TransportMediator.java
7.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
package android.support.v4.media;
import android.app.Activity;
import android.content.Context;
import android.media.AudioManager;
import android.media.RemoteControlClient;
import android.os.Build.VERSION;
import android.view.KeyEvent;
import android.view.KeyEvent.Callback;
import android.view.KeyEvent.DispatcherState;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.Window;
import di;
import dj;
import java.util.ArrayList;
public class TransportMediator
extends TransportController
{
public static final int FLAG_KEY_MEDIA_FAST_FORWARD = 64;
public static final int FLAG_KEY_MEDIA_NEXT = 128;
public static final int FLAG_KEY_MEDIA_PAUSE = 16;
public static final int FLAG_KEY_MEDIA_PLAY = 4;
public static final int FLAG_KEY_MEDIA_PLAY_PAUSE = 8;
public static final int FLAG_KEY_MEDIA_PREVIOUS = 1;
public static final int FLAG_KEY_MEDIA_REWIND = 2;
public static final int FLAG_KEY_MEDIA_STOP = 32;
public static final int KEYCODE_MEDIA_PAUSE = 127;
public static final int KEYCODE_MEDIA_PLAY = 126;
public static final int KEYCODE_MEDIA_RECORD = 130;
final Context a;
final TransportPerformer b;
final AudioManager c;
final View d;
final Object e;
final dj f;
final ArrayList<TransportStateListener> g = new ArrayList();
final di h = new di()
{
public final long a()
{
return TransportMediator.this.b.onGetCurrentPosition();
}
public final void a(int paramAnonymousInt)
{
TransportMediator.this.b.onAudioFocusChange(paramAnonymousInt);
}
public final void a(long paramAnonymousLong)
{
TransportMediator.this.b.onSeekTo(paramAnonymousLong);
}
public final void a(KeyEvent paramAnonymousKeyEvent)
{
paramAnonymousKeyEvent.dispatch(TransportMediator.this.i);
}
};
final KeyEvent.Callback i = new KeyEvent.Callback()
{
public final boolean onKeyDown(int paramAnonymousInt, KeyEvent paramAnonymousKeyEvent)
{
if (TransportMediator.a(paramAnonymousInt)) {
return TransportMediator.this.b.onMediaButtonDown(paramAnonymousInt, paramAnonymousKeyEvent);
}
return false;
}
public final boolean onKeyLongPress(int paramAnonymousInt, KeyEvent paramAnonymousKeyEvent)
{
return false;
}
public final boolean onKeyMultiple(int paramAnonymousInt1, int paramAnonymousInt2, KeyEvent paramAnonymousKeyEvent)
{
return false;
}
public final boolean onKeyUp(int paramAnonymousInt, KeyEvent paramAnonymousKeyEvent)
{
if (TransportMediator.a(paramAnonymousInt)) {
return TransportMediator.this.b.onMediaButtonUp(paramAnonymousInt, paramAnonymousKeyEvent);
}
return false;
}
};
public TransportMediator(Activity paramActivity, TransportPerformer paramTransportPerformer)
{
this(paramActivity, null, paramTransportPerformer);
}
private TransportMediator(Activity paramActivity, View paramView, TransportPerformer paramTransportPerformer)
{
if (paramActivity != null) {}
for (Object localObject = paramActivity;; localObject = paramView.getContext())
{
this.a = ((Context)localObject);
this.b = paramTransportPerformer;
this.c = ((AudioManager)this.a.getSystemService("audio"));
if (paramActivity != null) {
paramView = paramActivity.getWindow().getDecorView();
}
this.d = paramView;
this.e = this.d.getKeyDispatcherState();
if (Build.VERSION.SDK_INT < 18) {
break;
}
this.f = new dj(this.a, this.c, this.d, this.h);
return;
}
this.f = null;
}
public TransportMediator(View paramView, TransportPerformer paramTransportPerformer)
{
this(null, paramView, paramTransportPerformer);
}
static boolean a(int paramInt)
{
switch (paramInt)
{
default:
return false;
}
return true;
}
private TransportStateListener[] a()
{
if (this.g.size() <= 0) {
return null;
}
TransportStateListener[] arrayOfTransportStateListener = new TransportStateListener[this.g.size()];
this.g.toArray(arrayOfTransportStateListener);
return arrayOfTransportStateListener;
}
private void b()
{
TransportStateListener[] arrayOfTransportStateListener = a();
if (arrayOfTransportStateListener != null)
{
int k = arrayOfTransportStateListener.length;
int j = 0;
while (j < k)
{
arrayOfTransportStateListener[j].onPlayingChanged(this);
j += 1;
}
}
}
private void c()
{
dj localdj;
long l;
int k;
RemoteControlClient localRemoteControlClient;
int j;
if (this.f != null)
{
localdj = this.f;
boolean bool = this.b.onIsPlaying();
l = this.b.onGetCurrentPosition();
k = this.b.onGetTransportControlFlags();
if (localdj.o != null)
{
localRemoteControlClient = localdj.o;
if (!bool) {
break label87;
}
j = 3;
if (!bool) {
break label92;
}
}
}
label87:
label92:
for (float f1 = 1.0F;; f1 = 0.0F)
{
localRemoteControlClient.setPlaybackState(j, l, f1);
localdj.o.setTransportControlFlags(k);
return;
j = 1;
break;
}
}
public void destroy()
{
dj localdj = this.f;
localdj.d();
localdj.c.getViewTreeObserver().removeOnWindowAttachListener(localdj.h);
localdj.c.getViewTreeObserver().removeOnWindowFocusChangeListener(localdj.i);
}
public boolean dispatchKeyEvent(KeyEvent paramKeyEvent)
{
return paramKeyEvent.dispatch(this.i, (KeyEvent.DispatcherState)this.e, this);
}
public int getBufferPercentage()
{
return this.b.onGetBufferPercentage();
}
public long getCurrentPosition()
{
return this.b.onGetCurrentPosition();
}
public long getDuration()
{
return this.b.onGetDuration();
}
public Object getRemoteControlClient()
{
if (this.f != null) {
return this.f.o;
}
return null;
}
public int getTransportControlFlags()
{
return this.b.onGetTransportControlFlags();
}
public boolean isPlaying()
{
return this.b.onIsPlaying();
}
public void pausePlaying()
{
if (this.f != null)
{
dj localdj = this.f;
if (localdj.q == 3)
{
localdj.q = 2;
localdj.o.setPlaybackState(2);
}
localdj.b();
}
this.b.onPause();
c();
b();
}
public void refreshState()
{
c();
b();
TransportStateListener[] arrayOfTransportStateListener = a();
if (arrayOfTransportStateListener != null)
{
int k = arrayOfTransportStateListener.length;
int j = 0;
while (j < k)
{
arrayOfTransportStateListener[j].onTransportControlsChanged(this);
j += 1;
}
}
}
public void registerStateListener(TransportStateListener paramTransportStateListener)
{
this.g.add(paramTransportStateListener);
}
public void seekTo(long paramLong)
{
this.b.onSeekTo(paramLong);
}
public void startPlaying()
{
if (this.f != null)
{
dj localdj = this.f;
if (localdj.q != 3)
{
localdj.q = 3;
localdj.o.setPlaybackState(3);
}
if (localdj.p) {
localdj.a();
}
}
this.b.onStart();
c();
b();
}
public void stopPlaying()
{
if (this.f != null)
{
dj localdj = this.f;
if (localdj.q != 1)
{
localdj.q = 1;
localdj.o.setPlaybackState(1);
}
localdj.b();
}
this.b.onStop();
c();
b();
}
public void unregisterStateListener(TransportStateListener paramTransportStateListener)
{
this.g.remove(paramTransportStateListener);
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/media/TransportMediator.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/