8
8
import android .graphics .Bitmap ;
9
9
import android .graphics .BitmapFactory ;
10
10
import android .net .Uri ;
11
+ import android .os .Build ;
11
12
import android .os .Bundle ;
12
13
import android .speech .RecognizerIntent ;
13
14
import android .support .annotation .Nullable ;
32
33
import com .atomjack .shared .Logger ;
33
34
import com .atomjack .shared .PlayerState ;
34
35
import com .atomjack .shared .Preferences ;
35
- import com .atomjack .shared .SendToDataLayerThread ;
36
36
import com .atomjack .shared .WearConstants ;
37
- import com .atomjack .shared .model .Timeline ;
38
37
import com .atomjack .vcfp .Feedback ;
39
- import com .atomjack .vcfp .PlexHeaders ;
40
38
import com .atomjack .vcfp .R ;
41
- import com .atomjack .vcfp .Utils ;
42
39
import com .atomjack .vcfp .VoiceControlForPlexApplication ;
43
40
import com .atomjack .vcfp .activities .MainActivity ;
44
- import com .atomjack .vcfp .activities .VCFPActivity ;
45
41
import com .atomjack .vcfp .adapters .StreamAdapter ;
46
42
import com .atomjack .vcfp .interfaces .ActiveConnectionHandler ;
47
43
import com .atomjack .vcfp .interfaces .ActivityListener ;
48
- import com .atomjack .vcfp .interfaces .BitmapHandler ;
49
44
import com .atomjack .vcfp .interfaces .InputStreamHandler ;
50
- import com .atomjack .vcfp .interfaces .PlayerFragmentListener ;
51
45
import com .atomjack .vcfp .interfaces .PlexSubscriptionListener ;
52
46
import com .atomjack .vcfp .model .Connection ;
53
- import com .atomjack .vcfp .model .MediaContainer ;
54
47
import com .atomjack .vcfp .model .PlexClient ;
55
48
import com .atomjack .vcfp .model .PlexMedia ;
56
- import com .atomjack .vcfp .model .PlexServer ;
57
49
import com .atomjack .vcfp .model .PlexTrack ;
58
50
import com .atomjack .vcfp .model .PlexVideo ;
59
51
import com .atomjack .vcfp .model .Stream ;
60
52
import com .atomjack .vcfp .net .PlexHttpClient ;
61
- import com .atomjack .vcfp .net .PlexHttpMediaContainerHandler ;
62
53
import com .atomjack .vcfp .services .PlexSearchService ;
63
- import com .google .android .gms .wearable .DataMap ;
64
54
65
55
import org .apache .commons .io .IOUtils ;
66
56
75
65
76
66
public abstract class PlayerFragment extends Fragment
77
67
implements SeekBar .OnSeekBarChangeListener {
78
- protected PlayerFragmentListener playerFragmentListener ;
79
68
protected PlexMedia nowPlayingMedia ;
80
69
protected PlexClient client ;
81
70
@@ -100,6 +89,8 @@ public abstract class PlayerFragment extends Fragment
100
89
protected TextView durationDisplay ;
101
90
protected ImageView nowPlayingPoster ;
102
91
92
+ protected boolean fromWear = false ;
93
+
103
94
protected GestureDetectorCompat mDetector ;
104
95
105
96
protected Dialog mediaOptionsDialog ;
@@ -118,6 +109,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
118
109
if (savedInstanceState != null ) {
119
110
Logger .d ("[PlayerFragment] onSavedInstanceState is not null" );
120
111
nowPlayingMedia = savedInstanceState .getParcelable (Intent .EXTRA_MEDIA );
112
+ fromWear = savedInstanceState .getBoolean (WearConstants .FROM_WEAR , false );
121
113
layout = savedInstanceState .getInt (Intent .EXTRA_LAYOUT );
122
114
client = savedInstanceState .getParcelable (Intent .EXTRA_CLIENT );
123
115
}
@@ -156,10 +148,11 @@ public PlayerFragment() {
156
148
simpleDiskCache = VoiceControlForPlexApplication .getInstance ().mSimpleDiskCache ;
157
149
}
158
150
159
- public void init (int layout , PlexClient client , PlexMedia media , PlexSubscriptionListener plexSubscriptionListener ) {
151
+ public void init (int layout , PlexClient client , PlexMedia media , boolean fromWear , PlexSubscriptionListener plexSubscriptionListener ) {
160
152
this .layout = layout ;
161
153
this .client = client ;
162
154
nowPlayingMedia = media ;
155
+ this .fromWear = fromWear ;
163
156
this .plexSubscriptionListener = plexSubscriptionListener ;
164
157
}
165
158
@@ -290,7 +283,8 @@ public void showNowPlaying(boolean setView) {
290
283
vto .addOnGlobalLayoutListener (new ViewTreeObserver .OnGlobalLayoutListener () {
291
284
@ Override
292
285
public void onGlobalLayout () {
293
- nowPlayingPosterContainer .getViewTreeObserver ().removeOnGlobalLayoutListener (this );
286
+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .JELLY_BEAN )
287
+ nowPlayingPosterContainer .getViewTreeObserver ().removeOnGlobalLayoutListener (this );
294
288
int height = nowPlayingPosterContainer .getMeasuredHeight ();
295
289
int width = nowPlayingPosterContainer .getMeasuredWidth ();
296
290
Logger .d ("Found dimensions: %d/%d" , width , height );
@@ -556,7 +550,7 @@ protected void doMic() {
556
550
557
551
SecureRandom random = new SecureRandom ();
558
552
serviceIntent .setData (Uri .parse (new BigInteger (130 , random ).toString (32 )));
559
- PendingIntent resultsPendingIntent = PendingIntent .getService (getActivity (), 0 , serviceIntent , android . content . Intent . FLAG_ACTIVITY_NEW_TASK );
553
+ PendingIntent resultsPendingIntent = PendingIntent .getService (getActivity (), 0 , serviceIntent , PendingIntent . FLAG_ONE_SHOT );
560
554
561
555
android .content .Intent listenerIntent = new android .content .Intent (RecognizerIntent .ACTION_RECOGNIZE_SPEECH );
562
556
listenerIntent .putExtra (RecognizerIntent .EXTRA_LANGUAGE_MODEL , RecognizerIntent .LANGUAGE_MODEL_FREE_FORM );
@@ -637,7 +631,6 @@ public void onNothingSelected(AdapterView<?> parent) {
637
631
}
638
632
639
633
builder .setView (layout );
640
- builder .setTitle (getResources ().getString (R .string .stream_selection ));
641
634
mediaOptionsDialog = builder .create ();
642
635
mediaOptionsDialog .show ();
643
636
}
0 commit comments