forked from rizwan09/LanModeledProgramGeneartion-master
-
Notifications
You must be signed in to change notification settings - Fork 0
/
new_test.data
3658 lines (3658 loc) · 948 KB
/
new_test.data
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
public static void show ( AppCompatActivity activity , ObaArrivalInfo arrival ) { show ( activity , arrival , null ) ; }
@ Override protected int getLayoutId ( ) { return R . layout . report_trip_problem ; }
@ Override public void onViewCreated ( View view , Bundle savedInstanceState ) { Bundle args = getArguments ( ) ; final TextView tripHeadsign = ( TextView ) view . findViewById ( R . id . report_problem_headsign ) ; tripHeadsign . setText ( UIUtils . formatDisplayText ( args . getString ( TRIP_HEADSIGN ) ) ) ; final int tripArray = R . array . report_trip_problem_code_bus ; mCodeView = ( Spinner ) view . findViewById ( R . id . report_problem_code ) ; ArrayAdapter < ? > adapter = ArrayAdapter . createFromResource ( getActivity ( ) , tripArray , android . R . layout . simple_spinner_item ) ; adapter . setDropDownViewResource ( android . R . layout . simple_spinner_dropdown_item ) ; mCodeView . setAdapter ( adapter ) ; mUserComment = ( TextView ) view . findViewById ( R . id . report_problem_comment ) ; mUserOnVehicle = ( CheckBox ) view . findViewById ( R . id . report_problem_onvehicle ) ; mUserVehicle = ( EditText ) view . findViewById ( R . id . report_problem_uservehicle ) ; mUserVehicle . setEnabled ( false ) ; mUserOnVehicle . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { boolean checked = mUserOnVehicle . isChecked ( ) ; mUserVehicle . setEnabled ( checked ) ; } } ) ; if ( savedInstanceState != null ) { int position = savedInstanceState . getInt ( CODE ) ; mCodeView . setSelection ( position ) ; CharSequence comment = savedInstanceState . getCharSequence ( USER_COMMENT ) ; mUserComment . setText ( comment ) ; boolean onVehicle = savedInstanceState . getBoolean ( USER_ON_VEHICLE ) ; mUserOnVehicle . setChecked ( onVehicle ) ; CharSequence num = savedInstanceState . getCharSequence ( USER_VEHICLE_NUM ) ; mUserVehicle . setText ( num ) ; mUserVehicle . setEnabled ( onVehicle ) ; } SPINNER_TO_CODE = new String [] { null , ObaReportProblemWithTripRequest . VEHICLE_NEVER_CAME , ObaReportProblemWithTripRequest . VEHICLE_CAME_EARLY , ObaReportProblemWithTripRequest . VEHICLE_CAME_LATE , ObaReportProblemWithTripRequest . WRONG_HEADSIGN , ObaReportProblemWithTripRequest . VEHICLE_DOES_NOT_STOP_HERE , ObaReportProblemWithTripRequest . OTHER } ; setupIconColors ( ) ; }
@ Override public void onClick ( View v ) { boolean checked = mUserOnVehicle . isChecked ( ) ; mUserVehicle . setEnabled ( checked ) ; }
private void setupIconColors ( ) { ( ( ImageView ) getActivity ( ) . findViewById ( R . id . ic_category ) ) . setColorFilter ( getResources ( ) . getColor ( R . color . material_gray ) ) ; ( ( ImageView ) getActivity ( ) . findViewById ( R . id . ic_trip_info ) ) . setColorFilter ( getResources ( ) . getColor ( R . color . material_gray ) ) ; ( ( ImageView ) getActivity ( ) . findViewById ( R . id . ic_headsign_info ) ) . setColorFilter ( getResources ( ) . getColor ( R . color . material_gray ) ) ; }
@ Override public void onSaveInstanceState ( Bundle outState ) { super. onSaveInstanceState ( outState ) ; outState . putInt ( CODE , mCodeView . getSelectedItemPosition ( ) ) ; outState . putCharSequence ( USER_COMMENT , mUserComment . getText ( ) ) ; outState . putBoolean ( USER_ON_VEHICLE , mUserOnVehicle . isChecked ( ) ) ; outState . putCharSequence ( USER_VEHICLE_NUM , mUserVehicle . getText ( ) ) ; }
@ Override protected void sendReport ( ) { InputMethodManager imm = ( InputMethodManager ) getActivity ( ) . getSystemService ( Context . INPUT_METHOD_SERVICE ) ; imm . hideSoftInputFromWindow ( mUserComment . getWindowToken ( ) , 0 ) ; if ( isReportArgumentsValid ( ) ) { ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . SUBMIT . toString ( ) , getString ( R . string . analytics_action_problem ) , getString ( R . string . analytics_label_report_trip_problem ) ) ; super. sendReport ( ) ; } else { Toast . makeText ( getActivity ( ) , getString ( R . string . report_problem_invalid_argument ) , Toast . LENGTH_LONG ) . show ( ) ; } }
@ Override protected ReportLoader createLoader ( Bundle args ) { String tripId = args . getString ( TRIP_ID ) ; ObaReportProblemWithTripRequest . Builder builder = new ObaReportProblemWithTripRequest . Builder ( getActivity ( ) , tripId ) ; builder . setStopId ( args . getString ( STOP_ID ) ) ; builder . setVehicleId ( args . getString ( TRIP_VEHICLE_ID ) ) ; builder . setServiceDate ( args . getLong ( TRIP_SERVICE_DATE ) ) ; String code = SPINNER_TO_CODE [ mCodeView . getSelectedItemPosition ( ) ] ; if ( code != null ) { builder . setCode ( code ) ; } CharSequence comment = mUserComment . getText ( ) ; if ( ! TextUtils . isEmpty ( comment ) ) { builder . setUserComment ( comment . toString ( ) ) ; } Location location = Application . getLastKnownLocation ( getActivity ( ) , mGoogleApiClient ) ; if ( location != null ) { builder . setUserLocation ( location . getLatitude ( ) , location . getLongitude ( ) ) ; if ( location . hasAccuracy ( ) ) { builder . setUserLocationAccuracy ( ( int ) location . getAccuracy ( ) ) ; } } builder . setUserOnVehicle ( mUserOnVehicle . isChecked ( ) ) ; CharSequence vehicleNum = mUserVehicle . getText ( ) ; if ( ! TextUtils . isEmpty ( vehicleNum ) ) { builder . setUserVehicleNumber ( vehicleNum . toString ( ) ) ; } return new ReportLoader ( getActivity ( ) , builder . build ( ) ) ; }
public GPUImageRenderer ( final GPUImageFilter filter ) { mFilter = filter ; mRunOnDraw = new LinkedList < Runnable > ( ) ; mRunOnDrawEnd = new LinkedList < Runnable > ( ) ; mGLCubeBuffer = ByteBuffer . allocateDirect ( CUBE . length * 4 ) . order ( ByteOrder . nativeOrder ( ) ) . asFloatBuffer ( ) ; mGLCubeBuffer . put ( CUBE ) . position ( 0 ) ; mGLTextureBuffer = ByteBuffer . allocateDirect ( TEXTURE_NO_ROTATION . length * 4 ) . order ( ByteOrder . nativeOrder ( ) ) . asFloatBuffer ( ) ; setRotation ( Rotation . NORMAL , false , false ) ; }
@ Override public void onSurfaceCreated ( final GL10 unused , final EGLConfig config ) { GLES20 . glClearColor ( mBackgroundRed , mBackgroundGreen , mBackgroundBlue , 1 ) ; GLES20 . glDisable ( GLES20 . GL_DEPTH_TEST ) ; mFilter . init ( ) ; }
@ Override public void onSurfaceChanged ( final GL10 gl , final int width , final int height ) { mOutputWidth = width ; mOutputHeight = height ; GLES20 . glViewport ( 0 , 0 , width , height ) ; GLES20 . glUseProgram ( mFilter . getProgram ( ) ) ; mFilter . onOutputSizeChanged ( width , height ) ; adjustImageScaling ( ) ; synchronized ( mSurfaceChangedWaiter ) { mSurfaceChangedWaiter . notifyAll ( ) ; } }
@ Override public void onDrawFrame ( final GL10 gl ) { GLES20 . glClear ( GLES20 . GL_COLOR_BUFFER_BIT | GLES20 . GL_DEPTH_BUFFER_BIT ) ; runAll ( mRunOnDraw ) ; mFilter . onDraw ( mGLTextureId , mGLCubeBuffer , mGLTextureBuffer ) ; runAll ( mRunOnDrawEnd ) ; if ( mSurfaceTexture != null ) { mSurfaceTexture . updateTexImage ( ) ; } }
public void setBackgroundColor ( float red , float green , float blue ) { mBackgroundRed = red ; mBackgroundGreen = green ; mBackgroundBlue = blue ; }
private void runAll ( Queue < Runnable > queue ) { synchronized ( queue ) { while ( ! queue . isEmpty ( ) ) { queue . poll ( ) . run ( ) ; } } }
@ Override public void onPreviewFrame ( final byte [] data , final Camera camera ) { final Size previewSize = camera . getParameters ( ) . getPreviewSize ( ) ; if ( mGLRgbBuffer == null ) { mGLRgbBuffer = IntBuffer . allocate ( previewSize . width * previewSize . height ) ; } if ( mRunOnDraw . isEmpty ( ) ) { runOnDraw ( new Runnable ( ) { @ Override public void run ( ) { GPUImageNativeLibrary . YUVtoRBGA ( data , previewSize . width , previewSize . height , mGLRgbBuffer . array ( ) ) ; mGLTextureId = OpenGlUtils . loadTexture ( mGLRgbBuffer , previewSize , mGLTextureId ) ; camera . addCallbackBuffer ( data ) ; if ( mImageWidth != previewSize . width ) { mImageWidth = previewSize . width ; mImageHeight = previewSize . height ; adjustImageScaling ( ) ; } } } ) ; } }
@ Override public void run ( ) { GPUImageNativeLibrary . YUVtoRBGA ( data , previewSize . width , previewSize . height , mGLRgbBuffer . array ( ) ) ; mGLTextureId = OpenGlUtils . loadTexture ( mGLRgbBuffer , previewSize , mGLTextureId ) ; camera . addCallbackBuffer ( data ) ; if ( mImageWidth != previewSize . width ) { mImageWidth = previewSize . width ; mImageHeight = previewSize . height ; adjustImageScaling ( ) ; } }
public void setUpSurfaceTexture ( final Camera camera ) { runOnDraw ( new Runnable ( ) { @ Override public void run ( ) { int [] textures = new int [ 1 ] ; GLES20 . glGenTextures ( 1 , textures , 0 ) ; mSurfaceTexture = new SurfaceTexture ( textures [ 0 ] ) ; try { camera . setPreviewTexture ( mSurfaceTexture ) ; camera . setPreviewCallback ( GPUImageRenderer .this ) ; camera . startPreview ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } } ) ; }
@ Override public void run ( ) { int [] textures = new int [ 1 ] ; GLES20 . glGenTextures ( 1 , textures , 0 ) ; mSurfaceTexture = new SurfaceTexture ( textures [ 0 ] ) ; try { camera . setPreviewTexture ( mSurfaceTexture ) ; camera . setPreviewCallback ( GPUImageRenderer .this ) ; camera . startPreview ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } }
public void setFilter ( final GPUImageFilter filter ) { runOnDraw ( new Runnable ( ) { @ Override public void run ( ) { final GPUImageFilter oldFilter = mFilter ; mFilter = filter ; if ( oldFilter != null ) { oldFilter . destroy ( ) ; } mFilter . init ( ) ; GLES20 . glUseProgram ( mFilter . getProgram ( ) ) ; mFilter . onOutputSizeChanged ( mOutputWidth , mOutputHeight ) ; } } ) ; }
@ Override public void run ( ) { final GPUImageFilter oldFilter = mFilter ; mFilter = filter ; if ( oldFilter != null ) { oldFilter . destroy ( ) ; } mFilter . init ( ) ; GLES20 . glUseProgram ( mFilter . getProgram ( ) ) ; mFilter . onOutputSizeChanged ( mOutputWidth , mOutputHeight ) ; }
public void deleteImage ( ) { runOnDraw ( new Runnable ( ) { @ Override public void run ( ) { GLES20 . glDeleteTextures ( 1 , new int [] { mGLTextureId } , 0 ) ; mGLTextureId = NO_IMAGE ; } } ) ; }
@ Override public void run ( ) { GLES20 . glDeleteTextures ( 1 , new int [] { mGLTextureId } , 0 ) ; mGLTextureId = NO_IMAGE ; }
public void setImageBitmap ( final Bitmap bitmap ) { setImageBitmap ( bitmap , true ) ; }
public void setImageBitmap ( final Bitmap bitmap , final boolean recycle ) { if ( bitmap == null ) { return; } runOnDraw ( new Runnable ( ) { @ Override public void run ( ) { Bitmap resizedBitmap = null ; if ( bitmap . getWidth ( ) % 2 == 1 ) { resizedBitmap = Bitmap . createBitmap ( bitmap . getWidth ( ) + 1 , bitmap . getHeight ( ) , Bitmap . Config . ARGB_8888 ) ; Canvas can = new Canvas ( resizedBitmap ) ; can . drawARGB ( 0x00 , 0x00 , 0x00 , 0x00 ) ; can . drawBitmap ( bitmap , 0 , 0 , null ) ; mAddedPadding = 1 ; } else { mAddedPadding = 0 ; } mGLTextureId = OpenGlUtils . loadTexture ( resizedBitmap != null ? resizedBitmap : bitmap , mGLTextureId , recycle ) ; if ( resizedBitmap != null ) { resizedBitmap . recycle ( ) ; } mImageWidth = bitmap . getWidth ( ) ; mImageHeight = bitmap . getHeight ( ) ; adjustImageScaling ( ) ; } } ) ; }
@ Override public void run ( ) { Bitmap resizedBitmap = null ; if ( bitmap . getWidth ( ) % 2 == 1 ) { resizedBitmap = Bitmap . createBitmap ( bitmap . getWidth ( ) + 1 , bitmap . getHeight ( ) , Bitmap . Config . ARGB_8888 ) ; Canvas can = new Canvas ( resizedBitmap ) ; can . drawARGB ( 0x00 , 0x00 , 0x00 , 0x00 ) ; can . drawBitmap ( bitmap , 0 , 0 , null ) ; mAddedPadding = 1 ; } else { mAddedPadding = 0 ; } mGLTextureId = OpenGlUtils . loadTexture ( resizedBitmap != null ? resizedBitmap : bitmap , mGLTextureId , recycle ) ; if ( resizedBitmap != null ) { resizedBitmap . recycle ( ) ; } mImageWidth = bitmap . getWidth ( ) ; mImageHeight = bitmap . getHeight ( ) ; adjustImageScaling ( ) ; }
public void setScaleType ( GPUImage . ScaleType scaleType ) { mScaleType = scaleType ; }
protected int getFrameWidth ( ) { return mOutputWidth ; }
protected int getFrameHeight ( ) { return mOutputHeight ; }
private void adjustImageScaling ( ) { float outputWidth = mOutputWidth ; float outputHeight = mOutputHeight ; if ( mRotation == Rotation . ROTATION_270 || mRotation == Rotation . ROTATION_90 ) { outputWidth = mOutputHeight ; outputHeight = mOutputWidth ; } float ratio1 = outputWidth / mImageWidth ; float ratio2 = outputHeight / mImageHeight ; float ratioMax = Math . max ( ratio1 , ratio2 ) ; int imageWidthNew = Math . round ( mImageWidth * ratioMax ) ; int imageHeightNew = Math . round ( mImageHeight * ratioMax ) ; float ratioWidth = imageWidthNew / outputWidth ; float ratioHeight = imageHeightNew / outputHeight ; float [] cube = CUBE ; float [] textureCords = TextureRotationUtil . getRotation ( mRotation , mFlipHorizontal , mFlipVertical ) ; if ( mScaleType == GPUImage . ScaleType . CENTER_CROP ) { float distHorizontal = ( 1 - 1 / ratioWidth ) / 2 ; float distVertical = ( 1 - 1 / ratioHeight ) / 2 ; textureCords = new float [] { addDistance ( textureCords [ 0 ] , distHorizontal ) , addDistance ( textureCords [ 1 ] , distVertical ) , addDistance ( textureCords [ 2 ] , distHorizontal ) , addDistance ( textureCords [ 3 ] , distVertical ) , addDistance ( textureCords [ 4 ] , distHorizontal ) , addDistance ( textureCords [ 5 ] , distVertical ) , addDistance ( textureCords [ 6 ] , distHorizontal ) , addDistance ( textureCords [ 7 ] , distVertical ) , } ; } else { cube = new float [] { CUBE [ 0 ] / ratioHeight , CUBE [ 1 ] / ratioWidth , CUBE [ 2 ] / ratioHeight , CUBE [ 3 ] / ratioWidth , CUBE [ 4 ] / ratioHeight , CUBE [ 5 ] / ratioWidth , CUBE [ 6 ] / ratioHeight , CUBE [ 7 ] / ratioWidth , } ; } mGLCubeBuffer . clear ( ) ; mGLCubeBuffer . put ( cube ) . position ( 0 ) ; mGLTextureBuffer . clear ( ) ; mGLTextureBuffer . put ( textureCords ) . position ( 0 ) ; }
private float addDistance ( float coordinate , float distance ) { return coordinate == 0.0f ? distance : 1 - distance ; }
public void setRotationCamera ( final Rotation rotation , final boolean flipHorizontal , final boolean flipVertical ) { setRotation ( rotation , flipVertical , flipHorizontal ) ; }
public void setRotation ( final Rotation rotation ) { mRotation = rotation ; adjustImageScaling ( ) ; }
public void setRotation ( final Rotation rotation , final boolean flipHorizontal , final boolean flipVertical ) { mFlipHorizontal = flipHorizontal ; mFlipVertical = flipVertical ; setRotation ( rotation ) ; }
public Rotation getRotation ( ) { return mRotation ; }
public boolean isFlippedHorizontally ( ) { return mFlipHorizontal ; }
public boolean isFlippedVertically ( ) { return mFlipVertical ; }
protected void runOnDraw ( final Runnable runnable ) { synchronized ( mRunOnDraw ) { mRunOnDraw . add ( runnable ) ; } }
protected void runOnDrawEnd ( final Runnable runnable ) { synchronized ( mRunOnDrawEnd ) { mRunOnDrawEnd . add ( runnable ) ; } }
void setPanelHeightPixels ( int heightInPixels );
int getPanelHeightPixels ( )
public static void start ( Context context , String focusId , double lat , double lon ) { context . startActivity ( makeIntent ( context , focusId , lat , lon ) ) ; }
public static void start ( Context context , ObaStop stop ) { context . startActivity ( makeIntent ( context , stop ) ) ; }
public static void start ( Context context , String routeId ) { context . startActivity ( makeIntent ( context , routeId ) ) ; }
public static Intent makeIntent ( Context context , String focusId , double lat , double lon ) { Intent myIntent = new Intent ( context , HomeActivity .class ) ; myIntent . putExtra ( MapParams . STOP_ID , focusId ) ; myIntent . putExtra ( MapParams . CENTER_LAT , lat ) ; myIntent . putExtra ( MapParams . CENTER_LON , lon ) ; return myIntent ; }
public static Intent makeIntent ( Context context , ObaStop stop ) { Intent myIntent = new Intent ( context , HomeActivity .class ) ; myIntent . putExtra ( MapParams . STOP_ID , stop . getId ( ) ) ; myIntent . putExtra ( MapParams . STOP_NAME , stop . getName ( ) ) ; myIntent . putExtra ( MapParams . STOP_CODE , stop . getStopCode ( ) ) ; myIntent . putExtra ( MapParams . CENTER_LAT , stop . getLatitude ( ) ) ; myIntent . putExtra ( MapParams . CENTER_LON , stop . getLongitude ( ) ) ; return myIntent ; }
public static Intent makeIntent ( Context context , String routeId ) { Intent myIntent = new Intent ( context , HomeActivity .class ) ; myIntent . putExtra ( MapParams . MODE , MapParams . MODE_ROUTE ) ; myIntent . putExtra ( MapParams . ZOOM_TO_ROUTE , true ) ; myIntent . putExtra ( MapParams . ROUTE_ID , routeId ) ; return myIntent ; }
@ Override public void onCreate ( Bundle savedInstanceState ) { requestWindowFeature ( Window . FEATURE_INDETERMINATE_PROGRESS ) ; super. onCreate ( savedInstanceState ) ; setContentView ( R . layout . main ) ; mContext = this ; setupNavigationDrawer ( ) ; setupSlidingPanel ( ) ; setupMapState ( savedInstanceState ) ; setupMyLocationButton ( ) ; setupGooglePlayServices ( ) ; UIUtils . setupActionBar ( this ) ; checkRegionStatus ( ) ; Bundle b = getIntent ( ) . getExtras ( ) ; if ( b != null ) { if ( b . getBoolean ( ShowcaseViewUtils . TUTORIAL_WELCOME ) ) { ShowcaseViewUtils . showTutorial ( ShowcaseViewUtils . TUTORIAL_WELCOME , this , null ) ; } } }
@ Override public void onStart ( ) { super. onStart ( ) ; if ( mGoogleApiClient != null && ! mGoogleApiClient . isConnected ( ) ) { mGoogleApiClient . connect ( ) ; } ObaAnalytics . reportActivityStart ( this ) ; if ( Build . VERSION . SDK_INT >= 14 ) { AccessibilityManager am = ( AccessibilityManager ) getSystemService ( ACCESSIBILITY_SERVICE ) ; Boolean isTalkBackEnabled = am . isTouchExplorationEnabled ( ) ; if ( isTalkBackEnabled ) { ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . ACCESSIBILITY . toString ( ) , getString ( R . string . analytics_action_touch_exploration ) , getString ( R . string . analytics_label_talkback ) + getClass ( ) . getSimpleName ( ) + " using TalkBack" ) ; } } }
@ Override public void onResume ( ) { super. onResume ( ) ; if ( mArrivalsListHeader != null && mSlidingPanel != null ) { mArrivalsListHeader . setSlidingPanelCollapsed ( isSlidingPanelCollapsed ( ) ) ; } checkLeftHandMode ( ) ; mFabMyLocation . requestLayout ( ) ; }
@ Override protected void onPause ( ) { ShowcaseViewUtils . hideShowcaseView ( ) ; super. onPause ( ) ; }
@ Override public void onStop ( ) { if ( mGoogleApiClient != null && mGoogleApiClient . isConnected ( ) ) { mGoogleApiClient . disconnect ( ) ; } super. onStop ( ) ; }
@ Override protected void onSaveInstanceState ( Bundle outState ) { super. onSaveInstanceState ( outState ) ; if ( mFocusedStopId != null ) { outState . putString ( MapParams . STOP_ID , mFocusedStopId ) ; if ( mFocusedStop != null ) { outState . putString ( MapParams . STOP_CODE , mFocusedStop . getStopCode ( ) ) ; outState . putString ( MapParams . STOP_NAME , mFocusedStop . getName ( ) ) ; } } }
@ Override public void onNavigationDrawerItemSelected ( int position ) { goToNavDrawerItem ( position ) ; }
private void goToNavDrawerItem ( int item ) { switch ( item ) { case NAVDRAWER_ITEM_STARRED_STOPS : if ( mCurrentNavDrawerPosition != NAVDRAWER_ITEM_STARRED_STOPS ) { showStarredStopsFragment ( ) ; mCurrentNavDrawerPosition = item ; ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_button_press ) , getString ( R . string . analytics_label_button_press_star ) ) ; } break; case NAVDRAWER_ITEM_NEARBY : if ( mCurrentNavDrawerPosition != NAVDRAWER_ITEM_NEARBY ) { showMapFragment ( ) ; mCurrentNavDrawerPosition = item ; ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_button_press ) , getString ( R . string . analytics_label_button_press_nearby ) ) ; } break; case NAVDRAWER_ITEM_MY_REMINDERS : if ( mCurrentNavDrawerPosition != NAVDRAWER_ITEM_MY_REMINDERS ) { showMyRemindersFragment ( ) ; mCurrentNavDrawerPosition = item ; ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_button_press ) , getString ( R . string . analytics_label_button_press_reminders ) ) ; } break; case NAVDRAWER_ITEM_PLAN_TRIP : Intent planTrip = new Intent ( HomeActivity .this , TripPlanActivity .class ) ; startActivity ( planTrip ) ; ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_button_press ) , getString ( R . string . analytics_label_button_press_trip_plan ) ) ; break; case NAVDRAWER_ITEM_SETTINGS : Intent preferences = new Intent ( HomeActivity .this , PreferencesActivity .class ) ; startActivity ( preferences ) ; ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_button_press ) , getString ( R . string . analytics_label_button_press_settings ) ) ; break; case NAVDRAWER_ITEM_HELP : showDialog ( HELP_DIALOG ) ; ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_button_press ) , getString ( R . string . analytics_label_button_press_help ) ) ; break; case NAVDRAWER_ITEM_SEND_FEEDBACK : ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_button_press ) , getString ( R . string . analytics_label_button_press_feedback ) ) ; goToSendFeedBack ( ) ; break; } invalidateOptionsMenu ( ) ; }
private void hideMapFragment ( ) { FragmentManager fm = getSupportFragmentManager ( ) ; mMapFragment = ( BaseMapFragment ) fm . findFragmentByTag ( BaseMapFragment . TAG ) ; if ( mMapFragment != null && ! mMapFragment . isHidden ( ) ) { fm . beginTransaction ( ) . hide ( mMapFragment ) . commit ( ) ; } }
private void hideStarredStopsFragment ( ) { FragmentManager fm = getSupportFragmentManager ( ) ; mMyStarredStopsFragment = ( MyStarredStopsFragment ) fm . findFragmentByTag ( MyStarredStopsFragment . TAG ) ; if ( mMyStarredStopsFragment != null && ! mMyStarredStopsFragment . isHidden ( ) ) { fm . beginTransaction ( ) . hide ( mMyStarredStopsFragment ) . commit ( ) ; } }
private void hideReminderFragment ( ) { FragmentManager fm = getSupportFragmentManager ( ) ; mMyRemindersFragment = ( MyRemindersFragment ) fm . findFragmentByTag ( MyRemindersFragment . TAG ) ; if ( mMyRemindersFragment != null && ! mMyRemindersFragment . isHidden ( ) ) { fm . beginTransaction ( ) . hide ( mMyRemindersFragment ) . commit ( ) ; } }
private void hideSlidingPanel ( ) { if ( mSlidingPanel != null ) { mSlidingPanel . setPanelState ( SlidingUpPanelLayout . PanelState . HIDDEN ) ; } }
@ Override public boolean onCreateOptionsMenu ( Menu menu ) { getMenuInflater ( ) . inflate ( R . menu . main_options , menu ) ; UIUtils . setupSearch ( this , menu ) ; setupOptionsMenu ( menu ) ; return super. onCreateOptionsMenu ( menu ) ; }
@ Override public boolean onPrepareOptionsMenu ( Menu menu ) { super. onPrepareOptionsMenu ( menu ) ; setupOptionsMenu ( menu ) ; return true ; }
private void setupOptionsMenu ( Menu menu ) { menu . setGroupVisible ( R . id . main_options_menu_group , true ) ; menu . setGroupVisible ( R . id . arrival_list_menu_group , mShowArrivalsMenu ) ; menu . setGroupVisible ( R . id . starred_stop_menu_group , mShowStarredStopsMenu ) ; }
@ Override @ SuppressWarnings ( "deprecation" ) public boolean onOptionsItemSelected ( MenuItem item ) { Log . d ( TAG , "onOptionsItemSelected" ) ; final int id = item . getItemId ( ) ; if ( id == R . id . search ) { onSearchRequested ( ) ; ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_button_press ) , getString ( R . string . analytics_label_button_press_search_box ) ) ; return true ; } else if ( id == R . id . recent_stops_routes ) { ShowcaseViewUtils . doNotShowTutorial ( ShowcaseViewUtils . TUTORIAL_RECENT_STOPS_ROUTES ) ; Intent myIntent = new Intent ( this , MyRecentStopsAndRoutesActivity .class ) ; startActivity ( myIntent ) ; return true ; } return super. onOptionsItemSelected ( item ) ; }
@ Override protected Dialog onCreateDialog ( int id ) { switch ( id ) { case HELP_DIALOG : return createHelpDialog ( ) ; case WHATSNEW_DIALOG : return createWhatsNewDialog ( ) ; case LEGEND_DIALOG : return createLegendDialog ( ) ; } return super. onCreateDialog ( id ) ; }
@ SuppressWarnings ( "deprecation" ) private Dialog createHelpDialog ( ) { AlertDialog . Builder builder = new AlertDialog . Builder ( this ) ; builder . setTitle ( R . string . main_help_title ) ; int options ; if ( TextUtils . isEmpty ( Application . get ( ) . getCustomApiUrl ( ) ) ) { options = R . array . main_help_options ; } else { options = R . array . main_help_options_no_contact_us ; } builder . setItems ( options , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { switch ( which ) { case 0 : ShowcaseViewUtils . resetAllTutorials ( HomeActivity .this ) ; NavHelp . goHome ( HomeActivity .this , true ) ; break; case 1 : showDialog ( LEGEND_DIALOG ) ; break; case 2 : showDialog ( WHATSNEW_DIALOG ) ; break; case 3 : AgenciesActivity . start ( HomeActivity .this ) ; break; case 4 : String twitterUrl = TWITTER_URL ; if ( Application . get ( ) . getCurrentRegion ( ) != null && ! TextUtils . isEmpty ( Application . get ( ) . getCurrentRegion ( ) . getTwitterUrl ( ) ) ) { twitterUrl = Application . get ( ) . getCurrentRegion ( ) . getTwitterUrl ( ) ; } UIUtils . goToUrl ( HomeActivity .this , twitterUrl ) ; ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_switch ) , getString ( R . string . analytics_label_app_switch ) ) ; break; case 5 : goToSendFeedBack ( ) ; break; } } } ) ; return builder . create ( ) ; }
public void onClick ( DialogInterface dialog , int which ) { switch ( which ) { case 0 : ShowcaseViewUtils . resetAllTutorials ( HomeActivity .this ) ; NavHelp . goHome ( HomeActivity .this , true ) ; break; case 1 : showDialog ( LEGEND_DIALOG ) ; break; case 2 : showDialog ( WHATSNEW_DIALOG ) ; break; case 3 : AgenciesActivity . start ( HomeActivity .this ) ; break; case 4 : String twitterUrl = TWITTER_URL ; if ( Application . get ( ) . getCurrentRegion ( ) != null && ! TextUtils . isEmpty ( Application . get ( ) . getCurrentRegion ( ) . getTwitterUrl ( ) ) ) { twitterUrl = Application . get ( ) . getCurrentRegion ( ) . getTwitterUrl ( ) ; } UIUtils . goToUrl ( HomeActivity .this , twitterUrl ) ; ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_switch ) , getString ( R . string . analytics_label_app_switch ) ) ; break; case 5 : goToSendFeedBack ( ) ; break; } }
@ SuppressWarnings ( "deprecation" ) private Dialog createWhatsNewDialog ( ) { TextView textView = ( TextView ) getLayoutInflater ( ) . inflate ( R . layout . whats_new_dialog , null ) ; textView . setText ( R . string . main_help_whatsnew ) ; AlertDialog . Builder builder = new AlertDialog . Builder ( this ) ; builder . setTitle ( R . string . main_help_whatsnew_title ) ; builder . setIcon ( R . mipmap . ic_launcher ) ; builder . setView ( textView ) ; builder . setNeutralButton ( R . string . main_help_close , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { dismissDialog ( WHATSNEW_DIALOG ) ; } } ) ; builder . setOnDismissListener ( new DialogInterface . OnDismissListener ( ) { @ Override public void onDismiss ( DialogInterface dialog ) { boolean showOptOut = Application . getPrefs ( ) . getBoolean ( ShowcaseViewUtils . TUTORIAL_OPT_OUT_DIALOG , true ) ; if ( showOptOut ) { ShowcaseViewUtils . showOptOutDialog ( HomeActivity .this ) ; } } } ) ; return builder . create ( ) ; }
public void onClick ( DialogInterface dialog , int which ) { dismissDialog ( WHATSNEW_DIALOG ) ; }
@ Override public void onDismiss ( DialogInterface dialog ) { boolean showOptOut = Application . getPrefs ( ) . getBoolean ( ShowcaseViewUtils . TUTORIAL_OPT_OUT_DIALOG , true ) ; if ( showOptOut ) { ShowcaseViewUtils . showOptOutDialog ( HomeActivity .this ) ; } }
@ SuppressWarnings ( "deprecation" ) private Dialog createLegendDialog ( ) { AlertDialog . Builder builder = new AlertDialog . Builder ( this ) ; builder . setTitle ( R . string . main_help_legend_title ) ; Resources resources = getResources ( ) ; LayoutInflater inflater = LayoutInflater . from ( getApplicationContext ( ) ) ; View legendDialogView = inflater . inflate ( R . layout . legend_dialog , null ) ; final float etaTextFontSize = 30 ; View etaAndMin = legendDialogView . findViewById ( R . id . eta_view_ontime ) ; GradientDrawable d1 = ( GradientDrawable ) etaAndMin . getBackground ( ) ; d1 . setColor ( resources . getColor ( R . color . stop_info_ontime ) ) ; etaAndMin . findViewById ( R . id . eta_realtime_indicator ) . setVisibility ( View . VISIBLE ) ; TextView etaTextView = ( ( TextView ) etaAndMin . findViewById ( R . id . eta ) ) ; etaTextView . setTextSize ( etaTextFontSize ) ; etaTextView . setText ( "5" ) ; etaAndMin = legendDialogView . findViewById ( R . id . eta_view_early ) ; d1 = ( GradientDrawable ) etaAndMin . getBackground ( ) ; d1 . setColor ( resources . getColor ( R . color . stop_info_early ) ) ; etaAndMin . findViewById ( R . id . eta_realtime_indicator ) . setVisibility ( View . VISIBLE ) ; etaTextView = ( ( TextView ) etaAndMin . findViewById ( R . id . eta ) ) ; etaTextView . setTextSize ( etaTextFontSize ) ; etaTextView . setText ( "5" ) ; etaAndMin = legendDialogView . findViewById ( R . id . eta_view_delayed ) ; d1 = ( GradientDrawable ) etaAndMin . getBackground ( ) ; d1 . setColor ( resources . getColor ( R . color . stop_info_delayed ) ) ; etaAndMin . findViewById ( R . id . eta_realtime_indicator ) . setVisibility ( View . VISIBLE ) ; etaTextView = ( ( TextView ) etaAndMin . findViewById ( R . id . eta ) ) ; etaTextView . setTextSize ( etaTextFontSize ) ; etaTextView . setText ( "5" ) ; etaAndMin = legendDialogView . findViewById ( R . id . eta_view_scheduled ) ; d1 = ( GradientDrawable ) etaAndMin . getBackground ( ) ; d1 . setColor ( resources . getColor ( R . color . stop_info_scheduled_time ) ) ; etaAndMin . findViewById ( R . id . eta_realtime_indicator ) . setVisibility ( View . INVISIBLE ) ; etaTextView = ( ( TextView ) etaAndMin . findViewById ( R . id . eta ) ) ; etaTextView . setTextSize ( etaTextFontSize ) ; etaTextView . setText ( "5" ) ; builder . setView ( legendDialogView ) ; builder . setNeutralButton ( R . string . main_help_close , new DialogInterface . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { dismissDialog ( LEGEND_DIALOG ) ; } } ) ; return builder . create ( ) ; }
public void onClick ( DialogInterface dialog , int which ) { dismissDialog ( LEGEND_DIALOG ) ; }
@ SuppressWarnings ( "deprecation" ) private boolean autoShowWhatsNew ( ) { SharedPreferences settings = Application . getPrefs ( ) ; PackageManager pm = getPackageManager ( ) ; PackageInfo appInfo = null ; try { appInfo = pm . getPackageInfo ( getPackageName ( ) , PackageManager . GET_META_DATA ) ; } catch ( NameNotFoundException e ) { return false ; } final int oldVer = settings . getInt ( WHATS_NEW_VER , 0 ) ; final int newVer = appInfo . versionCode ; if ( oldVer < newVer ) { showDialog ( WHATSNEW_DIALOG ) ; TripService . scheduleAll ( this ) ; PreferenceUtils . saveInt ( WHATS_NEW_VER , appInfo . versionCode ) ; return true ; } return false ; }
@ Override public void onFocusChanged ( ObaStop stop , HashMap < String , ObaRoute > routes , Location location ) { if ( mFocusedStopId != null && stop != null && mFocusedStopId . equalsIgnoreCase ( stop . getId ( ) ) ) { return; } mFocusedStop = stop ; if ( stop != null ) { mFocusedStopId = stop . getId ( ) ; updateArrivalListFragment ( stop . getId ( ) , stop . getName ( ) , stop . getStopCode ( ) , stop , routes ) ; ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_button_press ) , getString ( R . string . analytics_label_button_press_map_icon ) ) ; } else { mFocusedStopId = null ; moveMyLocationButton ( ) ; mSlidingPanel . setPanelState ( SlidingUpPanelLayout . PanelState . HIDDEN ) ; if ( mArrivalsListFragment != null ) { FragmentManager fm = getSupportFragmentManager ( ) ; fm . beginTransaction ( ) . remove ( mArrivalsListFragment ) . commit ( ) ; } mShowArrivalsMenu = false ; } }
@ Override public void onProgressBarChanged ( boolean showProgressBar ) { mLastMapProgressBarState = showProgressBar ; if ( showProgressBar ) { showMapProgressBar ( ) ; } else { hideMapProgressBar ( ) ; } }
@ Override public void onListViewCreated ( ListView listView ) { mSlidingPanel . setScrollableView ( listView ) ; }
@ Override public void onArrivalTimesUpdated ( ObaArrivalInfoResponse response ) { if ( response == null || response . getStop ( ) == null ) { return; } if ( mFocusedStopId == null ) { mFocusedStopId = response . getStop ( ) . getId ( ) ; } if ( mFocusedStop == null ) { mFocusedStop = response . getStop ( ) ; if ( mMapFragment != null && mSlidingPanel != null ) { mMapFragment . setMapCenter ( mFocusedStop . getLocation ( ) , false , mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . ANCHORED ) ; } if ( mMapFragment != null ) { mMapFragment . setFocusStop ( mFocusedStop , response . getRoutes ( ) ) ; } } moveMyLocationButton ( ) ; showArrivalInfoTutorials ( response ) ; }
private void showArrivalInfoTutorials ( ObaArrivalInfoResponse response ) { if ( ShowcaseViewUtils . isShowcaseViewShowing ( ) ) { return; } if ( mMapFragment . isHidden ( ) || ! mMapFragment . isVisible ( ) || mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . HIDDEN ) { return; } ShowcaseViewUtils . showTutorial ( ShowcaseViewUtils . TUTORIAL_ARRIVAL_HEADER_ARRIVAL_INFO , this , response ) ; if ( mSlidingPanel != null && ( isSlidingPanelCollapsed ( ) || mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . ANCHORED || mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . EXPANDED ) ) { ShowcaseViewUtils . showTutorial ( ShowcaseViewUtils . TUTORIAL_ARRIVAL_HEADER_STAR_ROUTE , this , response ) ; } ShowcaseViewUtils . showTutorial ( ShowcaseViewUtils . TUTORIAL_RECENT_STOPS_ROUTES , this , null ) ; }
@ Override public boolean onShowRouteOnMapSelected ( ArrivalInfo arrivalInfo ) { if ( mSlidingPanel != null ) { mSlidingPanel . setPanelState ( SlidingUpPanelLayout . PanelState . COLLAPSED ) ; } Bundle bundle = new Bundle ( ) ; bundle . putBoolean ( MapParams . ZOOM_TO_ROUTE , false ) ; bundle . putBoolean ( MapParams . ZOOM_INCLUDE_CLOSEST_VEHICLE , true ) ; bundle . putString ( MapParams . ROUTE_ID , arrivalInfo . getInfo ( ) . getRouteId ( ) ) ; mMapFragment . setMapMode ( MapParams . MODE_ROUTE , bundle ) ; return true ; }
@ Override public void onSortBySelected ( ) { if ( mSlidingPanel != null ) { if ( isSlidingPanelCollapsed ( ) ) { mSlidingPanel . setPanelState ( SlidingUpPanelLayout . PanelState . ANCHORED ) ; } } }
@ Override public void onBackPressed ( ) { if ( mSlidingPanel != null ) { if ( mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . EXPANDED || mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . ANCHORED ) { mSlidingPanel . setPanelState ( SlidingUpPanelLayout . PanelState . COLLAPSED ) ; return; } if ( mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . COLLAPSED ) { mMapFragment . setFocusStop ( null , null ) ; return; } } super. onBackPressed ( ) ; }
private void redrawNavigationDrawerFragment ( ) { if ( mNavigationDrawerFragment != null ) { mNavigationDrawerFragment . populateNavDrawer ( ) ; } }
private void updateArrivalListFragment ( @ NonNull String stopId , @ NonNull String stopName , @ NonNull String stopCode , ObaStop stop , HashMap < String , ObaRoute > routes ) { FragmentManager fm = getSupportFragmentManager ( ) ; Intent intent ; mArrivalsListFragment = new ArrivalsListFragment ( ) ; mArrivalsListFragment . setListener ( this ) ; mArrivalsListHeader = new ArrivalsListHeader ( this , mArrivalsListFragment , getSupportFragmentManager ( ) ) ; mArrivalsListFragment . setHeader ( mArrivalsListHeader , mArrivalsListHeaderView ) ; mArrivalsListHeader . setSlidingPanelController ( mSlidingPanelController ) ; mArrivalsListHeader . setSlidingPanelCollapsed ( isSlidingPanelCollapsed ( ) ) ; mShowArrivalsMenu = true ; mExpandCollapse = ( ImageView ) mArrivalsListHeaderView . findViewById ( R . id . expand_collapse ) ; if ( stop != null && routes != null ) { intent = new ArrivalsListFragment . IntentBuilder ( this , stop , routes ) . build ( ) ; } else { intent = new ArrivalsListFragment . IntentBuilder ( this , stopId ) . setStopName ( stopName ) . setStopCode ( stopCode ) . build ( ) ; } mArrivalsListFragment . setArguments ( FragmentUtils . getIntentArgs ( intent ) ) ; fm . beginTransaction ( ) . replace ( R . id . slidingFragment , mArrivalsListFragment ) . commit ( ) ; if ( mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . HIDDEN ) { mSlidingPanel . setPanelState ( SlidingUpPanelLayout . PanelState . COLLAPSED ) ; } moveMyLocationButton ( ) ; }
private void goToSendFeedBack ( ) { if ( mFocusedStop != null ) { ReportActivity . start ( this , mFocusedStopId , mFocusedStop . getName ( ) , mFocusedStop . getStopCode ( ) , mFocusedStop . getLatitude ( ) , mFocusedStop . getLongitude ( ) , mGoogleApiClient ) ; } else { Location loc = Application . getLastKnownLocation ( this , mGoogleApiClient ) ; if ( loc != null ) { ReportActivity . start ( this , loc . getLatitude ( ) , loc . getLongitude ( ) , mGoogleApiClient ) ; } else { ReportActivity . start ( this , mGoogleApiClient ) ; } } }
@ Override public void onRegionTaskFinished ( boolean currentRegionChanged ) { boolean update = autoShowWhatsNew ( ) ; if ( currentRegionChanged || update ) { redrawNavigationDrawerFragment ( ) ; } if ( currentRegionChanged && Application . getPrefs ( ) . getBoolean ( getString ( R . string . preference_key_auto_select_region ) , true ) && Application . get ( ) . getCurrentRegion ( ) != null && UIUtils . canManageDialog ( this ) ) { Toast . makeText ( getApplicationContext ( ) , getString ( R . string . region_region_found , Application . get ( ) . getCurrentRegion ( ) . getName ( ) ) , Toast . LENGTH_LONG ) . show ( ) ; } }
private void setupMyLocationButton ( ) { mFabMyLocation = ( FloatingActionButton ) findViewById ( R . id . btnMyLocation ) ; mFabMyLocation . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View arg0 ) { if ( mMapFragment != null ) { PreferenceUtils . saveBoolean ( getString ( R . string . preference_key_never_show_location_dialog ) , false ) ; mMapFragment . setMyLocation ( true , true ) ; ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_button_press ) , getString ( R . string . analytics_label_button_press_location ) ) ; } } } ) ; ViewGroup . MarginLayoutParams p = ( ViewGroup . MarginLayoutParams ) mFabMyLocation . getLayoutParams ( ) ; MY_LOC_DEFAULT_BOTTOM_MARGIN = p . bottomMargin ; checkLeftHandMode ( ) ; if ( mCurrentNavDrawerPosition == NAVDRAWER_ITEM_NEARBY ) { showMyLocationButton ( ) ; showMapProgressBar ( ) ; } else { hideMyLocationButton ( ) ; hideMapProgressBar ( ) ; } }
@ Override public void onClick ( View arg0 ) { if ( mMapFragment != null ) { PreferenceUtils . saveBoolean ( getString ( R . string . preference_key_never_show_location_dialog ) , false ) ; mMapFragment . setMyLocation ( true , true ) ; ObaAnalytics . reportEventWithCategory ( ObaAnalytics . ObaEventCategory . UI_ACTION . toString ( ) , getString ( R . string . analytics_action_button_press ) , getString ( R . string . analytics_label_button_press_location ) ) ; } }
private void checkLeftHandMode ( ) { if ( mFabMyLocation == null ) { return; } RelativeLayout . LayoutParams layoutParams = ( RelativeLayout . LayoutParams ) mFabMyLocation . getLayoutParams ( ) ; boolean leftHandMode = Application . getPrefs ( ) . getBoolean ( getString ( R . string . preference_key_left_hand_mode ) , false ) ; if ( leftHandMode ) { layoutParams . addRule ( RelativeLayout . ALIGN_PARENT_LEFT ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . JELLY_BEAN_MR1 ) { layoutParams . removeRule ( RelativeLayout . ALIGN_PARENT_RIGHT ) ; } } else { layoutParams . addRule ( RelativeLayout . ALIGN_PARENT_RIGHT ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . JELLY_BEAN_MR1 ) { layoutParams . removeRule ( RelativeLayout . ALIGN_PARENT_LEFT ) ; } } }
synchronized private void moveMyLocationButton ( ) { if ( mFabMyLocation == null ) { return; } if ( mMyLocationAnimation != null && ( mMyLocationAnimation . hasStarted ( ) && ! mMyLocationAnimation . hasEnded ( ) ) ) { return; } if ( mMyLocationAnimation != null ) { mMyLocationAnimation . reset ( ) ; } final Handler h = new Handler ( ) ; h . postDelayed ( new Runnable ( ) { @ Override public void run ( ) { final ViewGroup . MarginLayoutParams p = ( ViewGroup . MarginLayoutParams ) mFabMyLocation . getLayoutParams ( ) ; int tempMargin = MY_LOC_DEFAULT_BOTTOM_MARGIN ; if ( mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . COLLAPSED ) { tempMargin += mSlidingPanel . getPanelHeight ( ) ; if ( p . bottomMargin == tempMargin ) { return; } } else { if ( mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . HIDDEN ) { if ( p . bottomMargin == tempMargin ) { return; } } } final int goalMargin = tempMargin ; final int currentMargin = p . bottomMargin ; mMyLocationAnimation = new Animation ( ) { @ Override protected void applyTransformation ( float interpolatedTime , Transformation t ) { int bottom ; if ( goalMargin > currentMargin ) { bottom = currentMargin + ( int ) ( Math . abs ( currentMargin - goalMargin ) * interpolatedTime ) ; } else { bottom = currentMargin - ( int ) ( Math . abs ( currentMargin - goalMargin ) * interpolatedTime ) ; } UIUtils . setMargins ( mFabMyLocation , p . leftMargin , p . topMargin , p . rightMargin , bottom ) ; } } ; mMyLocationAnimation . setDuration ( MY_LOC_BTN_ANIM_DURATION ) ; mFabMyLocation . startAnimation ( mMyLocationAnimation ) ; } } , 100 ) ; }
@ Override public void run ( ) { final ViewGroup . MarginLayoutParams p = ( ViewGroup . MarginLayoutParams ) mFabMyLocation . getLayoutParams ( ) ; int tempMargin = MY_LOC_DEFAULT_BOTTOM_MARGIN ; if ( mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . COLLAPSED ) { tempMargin += mSlidingPanel . getPanelHeight ( ) ; if ( p . bottomMargin == tempMargin ) { return; } } else { if ( mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . HIDDEN ) { if ( p . bottomMargin == tempMargin ) { return; } } } final int goalMargin = tempMargin ; final int currentMargin = p . bottomMargin ; mMyLocationAnimation = new Animation ( ) { @ Override protected void applyTransformation ( float interpolatedTime , Transformation t ) { int bottom ; if ( goalMargin > currentMargin ) { bottom = currentMargin + ( int ) ( Math . abs ( currentMargin - goalMargin ) * interpolatedTime ) ; } else { bottom = currentMargin - ( int ) ( Math . abs ( currentMargin - goalMargin ) * interpolatedTime ) ; } UIUtils . setMargins ( mFabMyLocation , p . leftMargin , p . topMargin , p . rightMargin , bottom ) ; } } ; mMyLocationAnimation . setDuration ( MY_LOC_BTN_ANIM_DURATION ) ; mFabMyLocation . startAnimation ( mMyLocationAnimation ) ; }
@ Override protected void applyTransformation ( float interpolatedTime , Transformation t ) { int bottom ; if ( goalMargin > currentMargin ) { bottom = currentMargin + ( int ) ( Math . abs ( currentMargin - goalMargin ) * interpolatedTime ) ; } else { bottom = currentMargin - ( int ) ( Math . abs ( currentMargin - goalMargin ) * interpolatedTime ) ; } UIUtils . setMargins ( mFabMyLocation , p . leftMargin , p . topMargin , p . rightMargin , bottom ) ; }
private void showMyLocationButton ( ) { if ( mFabMyLocation == null ) { return; } if ( mFabMyLocation . getVisibility ( ) != View . VISIBLE ) { mFabMyLocation . setVisibility ( View . VISIBLE ) ; } }
private void hideMyLocationButton ( ) { if ( mFabMyLocation == null ) { return; } if ( mFabMyLocation . getVisibility ( ) != View . GONE ) { mFabMyLocation . setVisibility ( View . GONE ) ; } }
private void showMapProgressBar ( ) { if ( mMapProgressBar == null ) { return; } if ( mMapProgressBar . getVisibility ( ) != View . VISIBLE ) { mMapProgressBar . setVisibility ( View . VISIBLE ) ; } }
private void hideMapProgressBar ( ) { if ( mMapProgressBar == null ) { return; } if ( mMapProgressBar . getVisibility ( ) != View . GONE ) { mMapProgressBar . setVisibility ( View . GONE ) ; } }
private void setupNavigationDrawer ( ) { mNavigationDrawerFragment = ( NavigationDrawerFragment ) getSupportFragmentManager ( ) . findFragmentById ( R . id . navigation_drawer ) ; mNavigationDrawerFragment . setUp ( R . id . navigation_drawer , ( DrawerLayout ) findViewById ( R . id . nav_drawer_left_pane ) ) ; Bundle bundle = getIntent ( ) . getExtras ( ) ; if ( bundle != null ) { String routeId = bundle . getString ( MapParams . ROUTE_ID ) ; String stopId = bundle . getString ( MapParams . STOP_ID ) ; if ( routeId != null || stopId != null ) { mNavigationDrawerFragment . selectItem ( NAVDRAWER_ITEM_NEARBY ) ; } } }
private void setupGooglePlayServices ( ) { GoogleApiAvailability api = GoogleApiAvailability . getInstance ( ) ; if ( api . isGooglePlayServicesAvailable ( this ) == ConnectionResult . SUCCESS ) { mGoogleApiClient = LocationUtils . getGoogleApiClientWithCallbacks ( this ) ; mGoogleApiClient . connect ( ) ; } }
@ Override public void onPanelStateChanged ( View panel , SlidingUpPanelLayout . PanelState previousState , SlidingUpPanelLayout . PanelState newState ) { if ( previousState == SlidingUpPanelLayout . PanelState . HIDDEN ) { return; } switch( newState ) { case EXPANDED : onPanelExpanded ( panel ) ; break; case COLLAPSED : onPanelCollapsed ( panel ) ; break; case ANCHORED : onPanelAnchored ( panel ) ; break; case HIDDEN : onPanelHidden ( panel ) ; break; } }
public void onPanelExpanded ( View panel ) { Log . d ( TAG , "onPanelExpanded" ) ; if ( mArrivalsListHeader != null ) { mArrivalsListHeader . setSlidingPanelCollapsed ( false ) ; mArrivalsListHeader . refresh ( ) ; } if ( mExpandCollapse != null ) { mExpandCollapse . setContentDescription ( mContext . getResources ( ) . getString ( R . string . stop_header_sliding_panel_open ) ) ; } }
public void onPanelCollapsed ( View panel ) { Log . d ( TAG , "onPanelCollapsed" ) ; if ( mMapFragment != null ) { mMapFragment . getMapView ( ) . setPadding ( null , null , null , mSlidingPanel . getPanelHeight ( ) ) ; } if ( mArrivalsListHeader != null ) { mArrivalsListHeader . setSlidingPanelCollapsed ( true ) ; mArrivalsListHeader . refresh ( ) ; } moveMyLocationButton ( ) ; if ( mExpandCollapse != null ) { mExpandCollapse . setContentDescription ( mContext . getResources ( ) . getString ( R . string . stop_header_sliding_panel_collapsed ) ) ; } }
public void onPanelAnchored ( View panel ) { Log . d ( TAG , "onPanelAnchored" ) ; if ( mMapFragment != null ) { mMapFragment . getMapView ( ) . setPadding ( null , null , null , mSlidingPanel . getPanelHeight ( ) ) ; } if ( mFocusedStop != null && mMapFragment != null ) { mMapFragment . setMapCenter ( mFocusedStop . getLocation ( ) , true , true ) ; } if ( mArrivalsListHeader != null ) { mArrivalsListHeader . setSlidingPanelCollapsed ( false ) ; mArrivalsListHeader . refresh ( ) ; } if ( mExpandCollapse != null ) { mExpandCollapse . setContentDescription ( mContext . getResources ( ) . getString ( R . string . stop_header_sliding_panel_open ) ) ; } }
public void onPanelHidden ( View panel ) { Log . d ( TAG , "onPanelHidden" ) ; if ( mMapFragment != null ) { mMapFragment . getMapView ( ) . setPadding ( null , null , null , 0 ) ; } if ( mExpandCollapse != null ) { mExpandCollapse . setContentDescription ( mContext . getResources ( ) . getString ( R . string . stop_header_sliding_panel_collapsed ) ) ; } }
@ Override public void setPanelHeightPixels ( int heightInPixels ) { if ( mSlidingPanel != null ) { if ( mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . DRAGGING || mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . HIDDEN ) { return; } if ( mSlidingPanel . getPanelHeight ( ) != heightInPixels ) { mSlidingPanel . setPanelHeight ( heightInPixels ) ; mArrivalsListHeaderView . getLayoutParams ( ) . height = heightInPixels ; mArrivalsListHeaderSubView . getLayoutParams ( ) . height = heightInPixels ; } } }
@ Override public int getPanelHeightPixels ( ) { if ( mSlidingPanel != null ) { return mSlidingPanel . getPanelHeight ( ) ; } return - 1 ; }
private void setupMapState ( Bundle savedInstanceState ) { String stopId ; String stopName ; String stopCode ; if ( savedInstanceState != null ) { stopId = savedInstanceState . getString ( MapParams . STOP_ID ) ; stopName = savedInstanceState . getString ( MapParams . STOP_NAME ) ; stopCode = savedInstanceState . getString ( MapParams . STOP_CODE ) ; if ( stopId != null ) { mFocusedStopId = stopId ; updateArrivalListFragment ( stopId , stopName , stopCode , null , null ) ; } } else { Bundle bundle = getIntent ( ) . getExtras ( ) ; if ( bundle != null ) { stopId = bundle . getString ( MapParams . STOP_ID ) ; stopName = bundle . getString ( MapParams . STOP_NAME ) ; stopCode = bundle . getString ( MapParams . STOP_CODE ) ; double lat = bundle . getDouble ( MapParams . CENTER_LAT ) ; double lon = bundle . getDouble ( MapParams . CENTER_LON ) ; if ( stopId != null && lat != 0.0 && lon != 0.0 ) { mFocusedStopId = stopId ; updateArrivalListFragment ( stopId , stopName , stopCode , null , null ) ; } } } mMapProgressBar = ( ProgressBar ) findViewById ( R . id . progress_horizontal ) ; }
private boolean isSlidingPanelCollapsed ( ) { return ! ( mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . EXPANDED || mSlidingPanel . getPanelState ( ) == SlidingUpPanelLayout . PanelState . ANCHORED ) ; }
public ArrivalsListFragment getArrivalsListFragment ( ) { return mArrivalsListFragment ; }
public SampleHelper ( Context context ) { super( context , "MyDatabase" , null , 1 ); }
@ Override public void onCreate ( SQLiteDatabase database , ConnectionSource connectionSource ) { try { TableUtils . createTableIfNotExists ( connectionSource , Account .class ) ; } catch ( SQLException e ) { e . printStackTrace ( ) ; } }
@ Override public void onUpgrade ( SQLiteDatabase database , ConnectionSource connectionSource , int oldVersion , int newVersion ) { try { TableUtils . dropTable ( connectionSource , Account .class , true ) ; TableUtils . createTable ( connectionSource , Account .class ) ; } catch ( SQLException e ) { e . printStackTrace ( ) ; } }
public NavigationDrawerFragment ( ) { }
@ Override public void onActivityCreated ( Bundle savedInstanceState ) { super. onActivityCreated ( savedInstanceState ) ; setHasOptionsMenu ( true ) ; }
@ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { mDrawerItemsListContainer = inflater . inflate ( R . layout . navdrawer_list , container , false ) ; return mDrawerItemsListContainer ; }
public void setUp ( int fragmentId , DrawerLayout drawerLayout ) { int selfItem = mCurrentSelectedPosition ; mFragmentContainerView = getActivity ( ) . findViewById ( fragmentId ) ; mDrawerLayout = drawerLayout ; if ( mDrawerLayout == null ) { return; } mDrawerLayout . setDrawerShadow ( R . drawable . drawer_shadow , GravityCompat . START ) ; ScrimInsetsScrollView navDrawer = ( ScrimInsetsScrollView ) mDrawerLayout . findViewById ( R . id . navdrawer ) ; if ( selfItem == NAVDRAWER_ITEM_INVALID ) { if ( navDrawer != null ) { ( ( ViewGroup ) navDrawer . getParent ( ) ) . removeView ( navDrawer ) ; } mDrawerLayout = null ; return; } populateNavDrawer ( ) ; ActionBar actionBar = getActionBar ( ) ; actionBar . setDisplayHomeAsUpEnabled ( true ) ; actionBar . setHomeButtonEnabled ( true ) ; mDrawerToggle = new android . support . v7 . app . ActionBarDrawerToggle ( getActivity ( ) , mDrawerLayout , R . string . navigation_drawer_open , R . string . navigation_drawer_close ) { @ Override public void onDrawerClosed ( View drawerView ) { super. onDrawerClosed ( drawerView ) ; if ( ! isAdded ( ) ) { return; } getActivity ( ) . supportInvalidateOptionsMenu ( ) ; } @ Override public void onDrawerOpened ( View drawerView ) { super. onDrawerOpened ( drawerView ) ; if ( ! isAdded ( ) ) { return; } getActivity ( ) . supportInvalidateOptionsMenu ( ) ; } } ; mDrawerLayout . post ( new Runnable ( ) { @ Override public void run ( ) { mDrawerToggle . syncState ( ) ; } } ) ; mDrawerLayout . setDrawerListener ( mDrawerToggle ) ; }
@ Override public void onDrawerClosed ( View drawerView ) { super. onDrawerClosed ( drawerView ) ; if ( ! isAdded ( ) ) { return; } getActivity ( ) . supportInvalidateOptionsMenu ( ) ; }
@ Override public void onDrawerOpened ( View drawerView ) { super. onDrawerOpened ( drawerView ) ; if ( ! isAdded ( ) ) { return; } getActivity ( ) . supportInvalidateOptionsMenu ( ) ; }
@ Override public void run ( ) { mDrawerToggle . syncState ( ) ; }
public void selectItem ( int position ) { setSelectedNavDrawerItem ( position ) ; if ( mDrawerLayout != null ) { mDrawerLayout . closeDrawer ( mFragmentContainerView ) ; } if ( mCallbacks != null ) { mCallbacks . onNavigationDrawerItemSelected ( position ) ; } }
private void setSelectedNavDrawerItem ( int itemId ) { if ( ! isNewActivityItem ( itemId ) ) { mCurrentSelectedPosition = itemId ; SharedPreferences sp = PreferenceManager . getDefaultSharedPreferences ( getActivity ( ) ) ; sp . edit ( ) . putInt ( STATE_SELECTED_POSITION , mCurrentSelectedPosition ) . apply ( ) ; } if ( mNavDrawerItemViews != null ) { for ( int i = 0 ; i < mNavDrawerItemViews . length ; i ++ ) { if ( i < mNavDrawerItems . size ( ) ) { int thisItemId = mNavDrawerItems . get ( i ) ; formatNavDrawerItem ( mNavDrawerItemViews [ i ] , thisItemId , itemId == thisItemId ) ; } } } }
@ Override public void onDetach ( ) { super. onDetach ( ) ; mCallbacks = null ; }
@ Override public void onConfigurationChanged ( Configuration newConfig ) { super. onConfigurationChanged ( newConfig ) ; mDrawerToggle . onConfigurationChanged ( newConfig ) ; }
@ Override public boolean onOptionsItemSelected ( MenuItem item ) { if ( mDrawerToggle . onOptionsItemSelected ( item ) ) { return true ; } return super. onOptionsItemSelected ( item ) ; }
private ActionBar getActionBar ( ) { return ( ( AppCompatActivity ) getActivity ( ) ) . getSupportActionBar ( ) ; }
void onNavigationDrawerItemSelected ( int position );
public void populateNavDrawer ( ) { mNavDrawerItems . clear ( ) ; mNavDrawerItems . add ( NAVDRAWER_ITEM_NEARBY ) ; mNavDrawerItems . add ( NAVDRAWER_ITEM_STARRED_STOPS ) ; mNavDrawerItems . add ( NAVDRAWER_ITEM_MY_REMINDERS ) ; if ( ( Application . get ( ) . getCurrentRegion ( ) != null && ! TextUtils . isEmpty ( Application . get ( ) . getCurrentRegion ( ) . getOtpBaseUrl ( ) ) ) || ! TextUtils . isEmpty ( Application . get ( ) . getCustomOtpApiUrl ( ) ) ) { mNavDrawerItems . add ( NAVDRAWER_ITEM_PLAN_TRIP ) ; } mNavDrawerItems . add ( NAVDRAWER_ITEM_SEPARATOR ) ; mNavDrawerItems . add ( NAVDRAWER_ITEM_SETTINGS ) ; mNavDrawerItems . add ( NAVDRAWER_ITEM_HELP ) ; mNavDrawerItems . add ( NAVDRAWER_ITEM_SEND_FEEDBACK ) ; createNavDrawerItems ( ) ; }
private void createNavDrawerItems ( ) { if ( mDrawerItemsListContainer == null || getActivity ( ) == null ) { return; } mNavDrawerItemViews = new View [ mNavDrawerItems . size ( ) ] ; int i = 0 ; LinearLayout containerLayout = ( LinearLayout ) mDrawerItemsListContainer . findViewById ( R . id . navdrawer_items_list ) ; containerLayout . removeAllViews ( ) ; for ( int itemId : mNavDrawerItems ) { mNavDrawerItemViews [ i ] = makeNavDrawerItem ( itemId , containerLayout ) ; containerLayout . addView ( mNavDrawerItemViews [ i ] ) ; ++ i ; } }
private View makeNavDrawerItem ( final int itemId , ViewGroup container ) { boolean selected = mCurrentSelectedPosition == itemId ; int layoutToInflate ; if ( itemId == NAVDRAWER_ITEM_SEPARATOR ) { layoutToInflate = R . layout . navdrawer_separator ; } else if ( itemId == NAVDRAWER_ITEM_SEPARATOR_SPECIAL ) { layoutToInflate = R . layout . navdrawer_separator ; } else { layoutToInflate = R . layout . navdrawer_item ; } View view = getActivity ( ) . getLayoutInflater ( ) . inflate ( layoutToInflate , container , false ) ; if ( isSeparator ( itemId ) ) { UIUtils . setAccessibilityIgnore ( view ) ; return view ; } ImageView iconView = ( ImageView ) view . findViewById ( R . id . icon ) ; TextView titleView = ( TextView ) view . findViewById ( R . id . title ) ; int iconId = itemId >= 0 && itemId < NAVDRAWER_ICON_RES_ID . length ? NAVDRAWER_ICON_RES_ID [ itemId ] : 0 ; int titleId = itemId >= 0 && itemId < NAVDRAWER_TITLE_RES_ID . length ? NAVDRAWER_TITLE_RES_ID [ itemId ] : 0 ; iconView . setVisibility ( iconId > 0 ? View . VISIBLE : View . GONE ) ; if ( iconId > 0 ) { iconView . setImageResource ( iconId ) ; } titleView . setText ( getString ( titleId ) ) ; formatNavDrawerItem ( view , itemId , selected ) ; view . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { selectItem ( itemId ) ; } } ) ; return view ; }
@ Override public void onClick ( View v ) { selectItem ( itemId ) ; }
private void formatNavDrawerItem ( View view , int itemId , boolean selected ) { if ( isSeparator ( itemId ) ) { return; } ImageView iconView = ( ImageView ) view . findViewById ( R . id . icon ) ; TextView titleView = ( TextView ) view . findViewById ( R . id . title ) ; if ( selected ) { if ( isNewActivityItem ( itemId ) ) { return; } else { view . setSelected ( true ) ; titleView . setTextColor ( getResources ( ) . getColor ( R . color . navdrawer_text_color_selected ) ) ; iconView . setColorFilter ( getResources ( ) . getColor ( R . color . navdrawer_icon_tint_selected ) ) ; } } else { if ( itemId != mCurrentSelectedPosition ) { view . setSelected ( false ) ; titleView . setTextColor ( getResources ( ) . getColor ( R . color . navdrawer_text_color ) ) ; iconView . setColorFilter ( getResources ( ) . getColor ( R . color . navdrawer_icon_tint ) ) ; } } }
private boolean isSeparator ( int itemId ) { return itemId == NAVDRAWER_ITEM_SEPARATOR || itemId == NAVDRAWER_ITEM_SEPARATOR_SPECIAL ; }
private boolean isNewActivityItem ( int itemId ) { return itemId == NAVDRAWER_ITEM_SETTINGS || itemId == NAVDRAWER_ITEM_HELP || itemId == NAVDRAWER_ITEM_SEND_FEEDBACK || itemId == NAVDRAWER_ITEM_PLAN_TRIP ; }
public SimpleCursorAdapterAssert ( SimpleCursorAdapter actual ) { super( actual , SimpleCursorAdapterAssert .class ); }
public Builder ( Context context , String stopId ) { mContext = context ; mIntent = new Intent ( context , ArrivalsListActivity .class ) ; mIntent . setData ( Uri . withAppendedPath ( ObaContract . Stops . CONTENT_URI , stopId ) ) ; }
public Builder ( Context context , ObaStop stop , HashMap < String , ObaRoute > routes ) { mContext = context ; mIntent = new Intent ( context , ArrivalsListActivity .class ) ; mIntent . setData ( Uri . withAppendedPath ( ObaContract . Stops . CONTENT_URI , stop . getId ( ) ) ) ; setStopName ( stop . getName ( ) ) ; setStopDirection ( stop . getDirection ( ) ) ; setStopRoutes ( UIUtils . serializeRouteDisplayNames ( stop , routes ) ) ; }
public Builder setStopName ( String stopName ) { mIntent . putExtra ( ArrivalsListFragment . STOP_NAME , stopName ) ; return this ; }
public Builder setStopDirection ( String stopDir ) { mIntent . putExtra ( ArrivalsListFragment . STOP_DIRECTION , stopDir ) ; return this ; }
public Builder setStopRoutes ( String routes ) { mIntent . putExtra ( ArrivalsListFragment . STOP_ROUTES , routes ) ; return this ; }
public Builder setUpMode ( String mode ) { mIntent . putExtra ( NavHelp . UP_MODE , mode ) ; return this ; }
public Intent getIntent ( ) { return mIntent ; }
public void start ( ) { mContext . startActivity ( mIntent ) ; }
public static void start ( Context context , String stopId ) { new Builder ( context , stopId ) . start ( ) ; }
public static void start ( Context context , ObaStop stop , HashMap < String , ObaRoute > routes ) { new Builder ( context , stop , routes ) . start ( ) ; }
@ Override protected void onCreate ( Bundle savedInstanceState ) { requestWindowFeature ( Window . FEATURE_INDETERMINATE_PROGRESS ) ; super. onCreate ( savedInstanceState ) ; UIUtils . setupActionBar ( this ) ; FragmentManager fm = getSupportFragmentManager ( ) ; if ( fm . findFragmentById ( android . R . id . content ) == null ) { ArrivalsListFragment list = new ArrivalsListFragment ( ) ; list . setArguments ( FragmentUtils . getIntentArgs ( getIntent ( ) ) ) ; fm . beginTransaction ( ) . add ( android . R . id . content , list ) . commit ( ) ; } }
@ Override protected void onNewIntent ( Intent intent ) { super. onNewIntent ( intent ) ; setIntent ( intent ) ; mNewFragment = true ; }
@ Override protected void onResume ( ) { super. onResume ( ) ; boolean newFrag = mNewFragment ; mNewFragment = false ; if ( newFrag ) { FragmentManager fm = getSupportFragmentManager ( ) ; ArrivalsListFragment list = new ArrivalsListFragment ( ) ; list . setArguments ( FragmentUtils . getIntentArgs ( getIntent ( ) ) ) ; FragmentTransaction ft = fm . beginTransaction ( ) ; ft . replace ( android . R . id . content , list ) ; if ( fm . getBackStackEntryCount ( ) > 0 ) { ft . addToBackStack ( null ) ; } ft . commit ( ) ; } }
@ Override protected void onPause ( ) { ShowcaseViewUtils . hideShowcaseView ( ) ; super. onPause ( ) ; }
@ Override protected void onStart ( ) { ObaAnalytics . reportActivityStart ( this ) ; super. onStart ( ) ; }
@ Override public boolean onOptionsItemSelected ( MenuItem item ) { if ( item . getItemId ( ) == android . R . id . home ) { NavHelp . goUp ( this ) ; return true ; } return false ; }
public ArrivalsListFragment getArrivalsListFragment ( ) { FragmentManager fm = getSupportFragmentManager ( ) ; return ( ArrivalsListFragment ) fm . findFragmentById ( android . R . id . content ) ; }
@ Override public void onClick ( DialogInterface dialog , int which ) { URLRewriteActivity .this . finish ( ) ; }
public ArrayAdapter ( Context context , int layout ) { super( context , layout ); mLayoutId = layout ; mInflater = ( LayoutInflater ) context . getSystemService ( Context . LAYOUT_INFLATER_SERVICE ) ; }
@ TargetApi ( 11 ) public void setData ( List < T > data ) { setNotifyOnChange ( false ) ; clear ( ) ; if ( data != null ) { if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . HONEYCOMB ) { addAll ( data ) ; } else { for ( T info : data ) { add ( info ) ; } } } notifyDataSetChanged ( ) ; }
@ Override public View getView ( int position , View convertView , ViewGroup parent ) { View view ; if ( convertView == null ) { view = mInflater . inflate ( mLayoutId , parent , false ) ; } else { view = convertView ; } T item = getItem ( position ) ; initView ( view , item ) ; return view ; }
protected LayoutInflater getLayoutInflater ( ) { return mInflater ; }
abstract protected void initView ( View view , T t );
@ Override protected void onCreate ( Bundle savedInstanceState ) { super. onCreate ( savedInstanceState ) ; setContentView ( R . layout . activity_actionbarcontrolscrollview ) ; ObservableScrollView scrollView = ( ObservableScrollView ) findViewById ( R . id . scroll ) ; scrollView . setScrollViewCallbacks ( this ) ; }
@ Override public void onScrollChanged ( int scrollY , boolean firstScroll , boolean dragging ) { }
@ Override public void onDownMotionEvent ( ) { }
@ Override public void onUpOrCancelMotionEvent ( ScrollState scrollState ) { ActionBar ab = getSupportActionBar ( ) ; if ( ab == null ) { return; } if ( scrollState == ScrollState . UP ) { if ( ab . isShowing ( ) ) { ab . hide ( ) ; } } else if ( scrollState == ScrollState . DOWN ) { if ( ! ab . isShowing ( ) ) { ab . show ( ) ; } } }
public Account ( ) { }
public Account ( String name ) { this . id = 0 ; this . name = name ; }
public int getId ( ) { return id ; }
public String getName ( ) { return name ; }
public static Test suite ( ) { return new TestSuiteBuilder ( AllTests .class ) . includeAllPackagesUnderHere ( ) . build ( ) ; }
public BluetoothGattCharacteristicAssert ( BluetoothGattCharacteristic actual ) { super( actual , BluetoothGattCharacteristicAssert .class ); }
public static String writeTypeToString ( @ BluetoothGattCharacteristicWriteType int writeType ) { return buildNamedValueString ( writeType ) . value ( WRITE_TYPE_DEFAULT , "default" ) . value ( WRITE_TYPE_NO_RESPONSE , "no_response" ) . value ( WRITE_TYPE_SIGNED , "signed" ) . get ( ) ; }
public static String permissionsToString ( @ BluetoothGattCharacteristicPermissions int permissions ) { return buildBitMaskString ( permissions ) . flag ( PERMISSION_READ , "read" ) . flag ( PERMISSION_READ_ENCRYPTED , "read_encrypted" ) . flag ( PERMISSION_READ_ENCRYPTED_MITM , "read_encrypted_mitm" ) . flag ( PERMISSION_WRITE , "write" ) . flag ( PERMISSION_WRITE_ENCRYPTED , "write_encrypted" ) . flag ( PERMISSION_WRITE_ENCRYPTED_MITM , "write_encrypted_mitm" ) . flag ( PERMISSION_WRITE_SIGNED , "write_signed" ) . flag ( PERMISSION_WRITE_SIGNED_MITM , "write_signed_mitm" ) . get ( ) ; }
public static String propertiesToString ( @ BluetoothGattCharacteristicProperties int properties ) { return buildBitMaskString ( properties ) . flag ( PROPERTY_BROADCAST , "broadcast" ) . flag ( PROPERTY_EXTENDED_PROPS , "extended_props" ) . flag ( PROPERTY_INDICATE , "indicate" ) . flag ( PROPERTY_NOTIFY , "notify" ) . flag ( PROPERTY_READ , "read" ) . flag ( PROPERTY_SIGNED_WRITE , "signed_write" ) . flag ( PROPERTY_WRITE , "write" ) . flag ( PROPERTY_WRITE_NO_RESPONSE , "write_no_response" ) . get ( ) ; }
private JacksonSerializer ( ) { }
public static ObaApi . SerializationHandler getInstance ( ) { return SingletonHolder . INSTANCE ; }
private static JsonParser getJsonParser ( Reader reader ) throws IOException { TreeTraversingParser parser = new TreeTraversingParser ( mMapper . readTree ( reader ) ) ; parser . setCodec ( mMapper ) ; return parser ; }
public String toJson ( String input ) { TextNode node = JsonNodeFactory . instance . textNode ( input ) ; return node . toString ( ) ; }
@ Override public < T > T createFromError ( Class < T > cls , int code , String error ) { final String jsonErr = toJson ( error ) ; final String json = getErrorJson ( code , jsonErr ) ; try { return mMapper . readValue ( json , cls ) ; } catch ( JsonParseException e ) { Log . e ( TAG , e . toString ( ) ) ; } catch ( JsonMappingException e ) { Log . e ( TAG , e . toString ( ) ) ; } catch ( IOException e ) { Log . e ( TAG , e . toString ( ) ) ; } return null ; }
public < T > T deserializeFromResponse ( String response , Class < T > cls ) { try { return mMapper . readValue ( response , cls ) ; } catch ( JsonParseException e ) { Log . e ( TAG , e . toString ( ) ) ; } catch ( JsonMappingException e ) { Log . e ( TAG , e . toString ( ) ) ; } catch ( IOException e ) { Log . e ( TAG , e . toString ( ) ) ; } return null ; }
public String serialize ( Object obj ) { StringWriter writer = new StringWriter ( ) ; JsonGenerator jsonGenerator ; try { jsonGenerator = new MappingJsonFactory ( ) . createJsonGenerator ( writer ) ; mMapper . writeValue ( jsonGenerator , obj ) ; return writer . toString ( ) ; } catch ( JsonGenerationException e ) { Log . e ( TAG , e . toString ( ) ) ; return getErrorJson ( ObaApi . OBA_INTERNAL_ERROR , e . toString ( ) ) ; } catch ( JsonMappingException e ) { Log . e ( TAG , e . toString ( ) ) ; return getErrorJson ( ObaApi . OBA_INTERNAL_ERROR , e . toString ( ) ) ; } catch ( IOException e ) { Log . e ( TAG , e . toString ( ) ) ; return getErrorJson ( ObaApi . OBA_IO_EXCEPTION , e . toString ( ) ) ; } }
public static void assertOK ( ObaResponse response ) { assertNotNull ( response ) ; assertEquals ( ObaApi . OBA_OK , response . getCode ( ) ) ; }
@ Override protected void setUp ( ) { mContext . setTheme ( R . style . Theme_OneBusAway ) ; mMock = new ObaMock ( getContext ( ) ) ; Application . get ( ) . setCustomApiUrl ( "api.pugetsound.onebusaway.org" ) ; }
@ Override protected void tearDown ( ) { mMock . finish ( ) ; }
void onScrollChanged ( int scrollY , boolean firstScroll , boolean dragging );
void onDownMotionEvent ( )
void onUpOrCancelMotionEvent ( ScrollState scrollState );
@ Test public void checkParent ( ) { Context context = InstrumentationRegistry . getTargetContext ( ) ; ParentStoryTeller teller = new ParentStoryTeller ( context ) ; teller . tellStory ( ) ; }
public GPUImageEmbossFilter ( ) { this( 1.0f ); }
public GPUImageEmbossFilter ( final float intensity ) { super(); mIntensity = intensity ; }
@ Override public void onInit ( ) { super. onInit ( ) ; setIntensity ( mIntensity ) ; }
public void setIntensity ( final float intensity ) { mIntensity = intensity ; setConvolutionKernel ( new float [] { intensity * ( - 2.0f ) , - intensity , 0.0f , - intensity , 1.0f , intensity , 0.0f , intensity , intensity * 2.0f , } ) ; }
public float getIntensity ( ) { return mIntensity ; }
HandlerScheduler ( Handler handler ) { this . handler = handler ; }
@ Override public Worker createWorker ( ) { return new HandlerWorker ( handler ) ; }
HandlerWorker ( Handler handler ) { this . handler = handler ; }
@ Override public void dispose ( ) { disposed = true ; handler . removeCallbacksAndMessages ( this ) ; }
@ Override public boolean isDisposed ( ) { return disposed ; }
ScheduledRunnable ( Handler handler , Runnable delegate ) { this . handler = handler ; this . delegate = delegate ; }
@ Override public void dispose ( ) { disposed = true ; handler . removeCallbacks ( this ) ; }
@ Override public boolean isDisposed ( ) { return disposed ; }
private boolean supportsOpenGLES2 ( final Context context ) { final ActivityManager activityManager = ( ActivityManager ) context . getSystemService ( Context . ACTIVITY_SERVICE ) ; final ConfigurationInfo configurationInfo = activityManager . getDeviceConfigurationInfo ( ) ; return configurationInfo . reqGlEsVersion >= 0x20000 ; }
public void setGLSurfaceView ( final GLSurfaceView view ) { mGlSurfaceView = view ; mGlSurfaceView . setEGLContextClientVersion ( 2 ) ; mGlSurfaceView . setEGLConfigChooser ( 8 , 8 , 8 , 8 , 16 , 0 ) ; mGlSurfaceView . getHolder ( ) . setFormat ( PixelFormat . RGBA_8888 ) ; mGlSurfaceView . setRenderer ( mRenderer ) ; mGlSurfaceView . setRenderMode ( GLSurfaceView . RENDERMODE_WHEN_DIRTY ) ; mGlSurfaceView . requestRender ( ) ; }
public void setBackgroundColor ( float red , float green , float blue ) { mRenderer . setBackgroundColor ( red , green , blue ) ; }
public void requestRender ( ) { if ( mGlSurfaceView != null ) { mGlSurfaceView . requestRender ( ) ; } }
public void setUpCamera ( final Camera camera ) { setUpCamera ( camera , 0 , false , false ) ; }
public void setUpCamera ( final Camera camera , final int degrees , final boolean flipHorizontal , final boolean flipVertical ) { mGlSurfaceView . setRenderMode ( GLSurfaceView . RENDERMODE_CONTINUOUSLY ) ; if ( Build . VERSION . SDK_INT > Build . VERSION_CODES . GINGERBREAD_MR1 ) { setUpCameraGingerbread ( camera ) ; } else { camera . setPreviewCallback ( mRenderer ) ; camera . startPreview ( ) ; } Rotation rotation = Rotation . NORMAL ; switch ( degrees ) { case 90 : rotation = Rotation . ROTATION_90 ; break; case 180 : rotation = Rotation . ROTATION_180 ; break; case 270 : rotation = Rotation . ROTATION_270 ; break; } mRenderer . setRotationCamera ( rotation , flipHorizontal , flipVertical ) ; }
@ TargetApi ( 11 ) private void setUpCameraGingerbread ( final Camera camera ) { mRenderer . setUpSurfaceTexture ( camera ) ; }
public void setFilter ( final GPUImageFilter filter ) { mFilter = filter ; mRenderer . setFilter ( mFilter ) ; requestRender ( ) ; }
public void setImage ( final Bitmap bitmap ) { mCurrentBitmap = bitmap ; mRenderer . setImageBitmap ( bitmap , false ) ; requestRender ( ) ; }
public void setScaleType ( ScaleType scaleType ) { mScaleType = scaleType ; mRenderer . setScaleType ( scaleType ) ; mRenderer . deleteImage ( ) ; mCurrentBitmap = null ; requestRender ( ) ; }
public void setRotation ( Rotation rotation ) { mRenderer . setRotation ( rotation ) ; }
public void setRotation ( Rotation rotation , boolean flipHorizontal , boolean flipVertical ) { mRenderer . setRotation ( rotation , flipHorizontal , flipVertical ) ; }
public void deleteImage ( ) { mRenderer . deleteImage ( ) ; mCurrentBitmap = null ; requestRender ( ) ; }
public void setImage ( final Uri uri ) { new LoadImageUriTask ( this , uri ) . execute ( ) ; }
public void setImage ( final File file ) { new LoadImageFileTask ( this , file ) . execute ( ) ; }
private String getPath ( final Uri uri ) { String [] projection = { MediaStore . Images . Media . DATA , } ; Cursor cursor = mContext . getContentResolver ( ) . query ( uri , projection , null , null , null ) ; int pathIndex = cursor . getColumnIndexOrThrow ( MediaStore . Images . Media . DATA ) ; String path = null ; if ( cursor . moveToFirst ( ) ) { path = cursor . getString ( pathIndex ) ; } cursor . close ( ) ; return path ; }
public Bitmap getBitmapWithFilterApplied ( ) { return getBitmapWithFilterApplied ( mCurrentBitmap ) ; }
public Bitmap getBitmapWithFilterApplied ( final Bitmap bitmap ) { if ( mGlSurfaceView != null ) { mRenderer . deleteImage ( ) ; mRenderer . runOnDraw ( new Runnable ( ) { @ Override public void run ( ) { synchronized( mFilter ) { mFilter . destroy ( ) ; mFilter . notify ( ) ; } } } ) ; synchronized( mFilter ) { requestRender ( ) ; try { mFilter . wait ( ) ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } } } GPUImageRenderer renderer = new GPUImageRenderer ( mFilter ) ; renderer . setRotation ( Rotation . NORMAL , mRenderer . isFlippedHorizontally ( ) , mRenderer . isFlippedVertically ( ) ) ; renderer . setScaleType ( mScaleType ) ; PixelBuffer buffer = new PixelBuffer ( bitmap . getWidth ( ) , bitmap . getHeight ( ) ) ; buffer . setRenderer ( renderer ) ; renderer . setImageBitmap ( bitmap , false ) ; Bitmap result = buffer . getBitmap ( ) ; mFilter . destroy ( ) ; renderer . deleteImage ( ) ; buffer . destroy ( ) ; mRenderer . setFilter ( mFilter ) ; if ( mCurrentBitmap != null ) { mRenderer . setImageBitmap ( mCurrentBitmap , false ) ; } requestRender ( ) ; return result ; }
@ Override public void run ( ) { synchronized( mFilter ) { mFilter . destroy ( ) ; mFilter . notify ( ) ; } }
public static void getBitmapForMultipleFilters ( final Bitmap bitmap , final List < GPUImageFilter > filters , final ResponseListener < Bitmap > listener ) { if ( filters . isEmpty ( ) ) { return; } GPUImageRenderer renderer = new GPUImageRenderer ( filters . get ( 0 ) ) ; renderer . setImageBitmap ( bitmap , false ) ; PixelBuffer buffer = new PixelBuffer ( bitmap . getWidth ( ) , bitmap . getHeight ( ) ) ; buffer . setRenderer ( renderer ) ; for ( GPUImageFilter filter : filters ) { renderer . setFilter ( filter ) ; listener . response ( buffer . getBitmap ( ) ) ; filter . destroy ( ) ; } renderer . deleteImage ( ) ; buffer . destroy ( ) ; }
@ Deprecated public void saveToPictures ( final String folderName , final String fileName , final OnPictureSavedListener listener ) { saveToPictures ( mCurrentBitmap , folderName , fileName , listener ) ; }
@ Deprecated public void saveToPictures ( final Bitmap bitmap , final String folderName , final String fileName , final OnPictureSavedListener listener ) { new SaveTask ( bitmap , folderName , fileName , listener ) . execute ( ) ; }
void runOnGLThread ( Runnable runnable ) { mRenderer . runOnDrawEnd ( runnable ) ; }
private int getOutputWidth ( ) { if ( mRenderer != null && mRenderer . getFrameWidth ( ) != 0 ) { return mRenderer . getFrameWidth ( ) ; } else if ( mCurrentBitmap != null ) { return mCurrentBitmap . getWidth ( ) ; } else { WindowManager windowManager = ( WindowManager ) mContext . getSystemService ( Context . WINDOW_SERVICE ) ; Display display = windowManager . getDefaultDisplay ( ) ; return display . getWidth ( ) ; } }
private int getOutputHeight ( ) { if ( mRenderer != null && mRenderer . getFrameHeight ( ) != 0 ) { return mRenderer . getFrameHeight ( ) ; } else if ( mCurrentBitmap != null ) { return mCurrentBitmap . getHeight ( ) ; } else { WindowManager windowManager = ( WindowManager ) mContext . getSystemService ( Context . WINDOW_SERVICE ) ; Display display = windowManager . getDefaultDisplay ( ) ; return display . getHeight ( ) ; } }
public SaveTask ( final Bitmap bitmap , final String folderName , final String fileName , final OnPictureSavedListener listener ) { mBitmap = bitmap ; mFolderName = folderName ; mFileName = fileName ; mListener = listener ; mHandler = new Handler ( ) ; }
@ Override protected Void doInBackground ( final Void ... params ) { Bitmap result = getBitmapWithFilterApplied ( mBitmap ) ; saveImage ( mFolderName , mFileName , result ) ; return null ; }
private void saveImage ( final String folderName , final String fileName , final Bitmap image ) { File path = Environment . getExternalStoragePublicDirectory ( Environment . DIRECTORY_PICTURES ) ; File file = new File ( path , folderName + "/" + fileName ) ; try { file . getParentFile ( ) . mkdirs ( ) ; image . compress ( CompressFormat . JPEG , 80 , new FileOutputStream ( file ) ) ; MediaScannerConnection . scanFile ( mContext , new String [] { file . toString ( ) } , null , new MediaScannerConnection . OnScanCompletedListener ( ) { @ Override public void onScanCompleted ( final String path , final Uri uri ) { if ( mListener != null ) { mHandler . post ( new Runnable ( ) { @ Override public void run ( ) { mListener . onPictureSaved ( uri ) ; } } ) ; } } } ) ; } catch ( FileNotFoundException e ) { e . printStackTrace ( ) ; } }
@ Override public void onScanCompleted ( final String path , final Uri uri ) { if ( mListener != null ) { mHandler . post ( new Runnable ( ) { @ Override public void run ( ) { mListener . onPictureSaved ( uri ) ; } } ) ; } }
@ Override public void run ( ) { mListener . onPictureSaved ( uri ) ; }
void onPictureSaved ( Uri uri );
public LoadImageUriTask ( GPUImage gpuImage , Uri uri ) { super( gpuImage ); mUri = uri ; }
@ Override protected Bitmap decode ( BitmapFactory . Options options ) { try { InputStream inputStream ; if ( mUri . getScheme ( ) . startsWith ( "http" ) || mUri . getScheme ( ) . startsWith ( "https" ) ) { inputStream = new URL ( mUri . toString ( ) ) . openStream ( ) ; } else { inputStream = mContext . getContentResolver ( ) . openInputStream ( mUri ) ; } return BitmapFactory . decodeStream ( inputStream , null , options ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } return null ; }
@ Override protected int getImageOrientation ( ) IOException { Cursor cursor = mContext . getContentResolver ( ) . query ( mUri , new String [] { MediaStore . Images . ImageColumns . ORIENTATION } , null , null , null ) ; if ( cursor == null || cursor . getCount ( ) != 1 ) { return 0 ; } cursor . moveToFirst ( ) ; int orientation = cursor . getInt ( 0 ) ; cursor . close ( ) ; return orientation ; }
public LoadImageFileTask ( GPUImage gpuImage , File file ) { super( gpuImage ); mImageFile = file ; }
@ Override protected Bitmap decode ( BitmapFactory . Options options ) { return BitmapFactory . decodeFile ( mImageFile . getAbsolutePath ( ) , options ) ; }
@ Override protected int getImageOrientation ( ) IOException { ExifInterface exif = new ExifInterface ( mImageFile . getAbsolutePath ( ) ) ; int orientation = exif . getAttributeInt ( ExifInterface . TAG_ORIENTATION , 1 ) ; switch ( orientation ) { case ExifInterface . ORIENTATION_NORMAL : return 0 ; case ExifInterface . ORIENTATION_ROTATE_90 : return 90 ; case ExifInterface . ORIENTATION_ROTATE_180 : return 180 ; case ExifInterface . ORIENTATION_ROTATE_270 : return 270 ; default: return 0 ; } }
@ SuppressWarnings ( "deprecation" ) public LoadImageTask ( final GPUImage gpuImage ) { mGPUImage = gpuImage ; }
@ Override protected Bitmap doInBackground ( Void ... params ) { if ( mRenderer != null && mRenderer . getFrameWidth ( ) == 0 ) { try { synchronized ( mRenderer . mSurfaceChangedWaiter ) { mRenderer . mSurfaceChangedWaiter . wait ( 3000 ) ; } } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } } mOutputWidth = getOutputWidth ( ) ; mOutputHeight = getOutputHeight ( ) ; return loadResizedImage ( ) ; }
@ Override protected void onPostExecute ( Bitmap bitmap ) { super. onPostExecute ( bitmap ) ; mGPUImage . deleteImage ( ) ; mGPUImage . setImage ( bitmap ) ; }
protected abstract Bitmap decode ( BitmapFactory . Options options );
private Bitmap loadResizedImage ( ) { BitmapFactory . Options options = new BitmapFactory . Options ( ) ; options . inJustDecodeBounds = true ; decode ( options ) ; int scale = 1 ; while ( checkSize ( options . outWidth / scale > mOutputWidth , options . outHeight / scale > mOutputHeight ) ) { scale ++ ; } scale -- ; if ( scale < 1 ) { scale = 1 ; } options = new BitmapFactory . Options ( ) ; options . inSampleSize = scale ; options . inPreferredConfig = Bitmap . Config . RGB_565 ; options . inPurgeable = true ; options . inTempStorage = new byte [ 32 * 1024 ] ; Bitmap bitmap = decode ( options ) ; if ( bitmap == null ) { return null ; } bitmap = rotateImage ( bitmap ) ; bitmap = scaleBitmap ( bitmap ) ; return bitmap ; }
private Bitmap scaleBitmap ( Bitmap bitmap ) { int width = bitmap . getWidth ( ) ; int height = bitmap . getHeight ( ) ; int [] newSize = getScaleSize ( width , height ) ; Bitmap workBitmap = Bitmap . createScaledBitmap ( bitmap , newSize [ 0 ] , newSize [ 1 ] , true ) ; if ( workBitmap != bitmap ) { bitmap . recycle ( ) ; bitmap = workBitmap ; System . gc ( ) ; } if ( mScaleType == ScaleType . CENTER_CROP ) { int diffWidth = newSize [ 0 ] - mOutputWidth ; int diffHeight = newSize [ 1 ] - mOutputHeight ; workBitmap = Bitmap . createBitmap ( bitmap , diffWidth / 2 , diffHeight / 2 , newSize [ 0 ] - diffWidth , newSize [ 1 ] - diffHeight ) ; if ( workBitmap != bitmap ) { bitmap . recycle ( ) ; bitmap = workBitmap ; } } return bitmap ; }
private int [] getScaleSize ( int width , int height ) { float newWidth ; float newHeight ; float withRatio = ( float ) width / mOutputWidth ; float heightRatio = ( float ) height / mOutputHeight ; boolean adjustWidth = mScaleType == ScaleType . CENTER_CROP ? withRatio > heightRatio : withRatio < heightRatio ; if ( adjustWidth ) { newHeight = mOutputHeight ; newWidth = ( newHeight / height ) * width ; } else { newWidth = mOutputWidth ; newHeight = ( newWidth / width ) * height ; } return new int [] { Math . round ( newWidth ) , Math . round ( newHeight ) } ; }
private boolean checkSize ( boolean widthBigger , boolean heightBigger ) { if ( mScaleType == ScaleType . CENTER_CROP ) { return widthBigger && heightBigger ; } else { return widthBigger || heightBigger ; } }
private Bitmap rotateImage ( final Bitmap bitmap ) { if ( bitmap == null ) { return null ; } Bitmap rotatedBitmap = bitmap ; try { int orientation = getImageOrientation ( ) ; if ( orientation != 0 ) { Matrix matrix = new Matrix ( ) ; matrix . postRotate ( orientation ) ; rotatedBitmap = Bitmap . createBitmap ( bitmap , 0 , 0 , bitmap . getWidth ( ) , bitmap . getHeight ( ) , matrix , true ) ; bitmap . recycle ( ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } return rotatedBitmap ; }
protected abstract int getImageOrientation ( ) IOException ;
void response ( T item );
@ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { View view = inflater . inflate ( R . layout . fragment_recyclerview , container , false ) ; Activity parentActivity = getActivity ( ) ; final ObservableRecyclerView recyclerView = ( ObservableRecyclerView ) view . findViewById ( R . id . scroll ) ; recyclerView . setLayoutManager ( new LinearLayoutManager ( parentActivity ) ) ; recyclerView . setHasFixedSize ( false ) ; setDummyData ( recyclerView ) ; recyclerView . setTouchInterceptionViewGroup ( ( ViewGroup ) parentActivity . findViewById ( R . id . container ) ) ; if ( parentActivity instanceof ObservableScrollViewCallbacks ) { recyclerView . setScrollViewCallbacks ( ( ObservableScrollViewCallbacks ) parentActivity ) ; } return view ; }
public RecyclerViewLayoutManagerAssert ( RecyclerView . LayoutManager actual ) { super( actual , RecyclerViewLayoutManagerAssert .class ); }
@ Override public void execute ( ) MojoExecutionException , MojoFailureException { ConfigHandler configHandler = new ConfigHandler ( this , this . session , this . execution ) ; configHandler . parseConfiguration ( ) ; if ( isEnableIntegrationTest ( ) ) { playTests ( ) ; } }
protected boolean isEnableIntegrationTest ( ) { return ! parsedSkip && ! mavenTestSkip && ! mavenSkipTests ; }
protected boolean isIgnoreTestFailures ( ) { return mavenIgnoreTestFailure || mavenTestFailureIgnore ; }
private String getJarFile ( ) { if ( parsedJarFile == null ) { File jarFilePath = new File ( targetDirectory + File . separator + finalName + ".jar" ) ; return jarFilePath . getName ( ) ; } return parsedJarFile ; }
private String [] getTestClassOrMethods ( ) { return parsedTestClassOrMethods ; }
private String getReportSuffix ( ) { return parsedReportSuffix ; }
private String getPropertiesKeyPrefix ( ) { return parsedPropertiesKeyPrefix ; }
public static String join ( List < String > parts ) { StringBuilder builder = new StringBuilder ( ) ; for ( String part : parts ) { if ( builder . length ( ) > 0 ) { builder . append ( "," ) ; } builder . append ( part ) ; } return builder . toString ( ) ; }
private Utils ( ) { }
@ Override public void execute ( ) MojoExecutionException , MojoFailureException { ConfigHandler configHandler = new ConfigHandler ( this , this . session , this . execution ) ; configHandler . parseConfiguration ( ) ; if ( isEnableIntegrationTest ( ) ) { exerciseApp ( ) ; } }
protected boolean isEnableIntegrationTest ( ) { return ! parsedSkip && ! mavenTestSkip && ! mavenSkipTests ; }
protected boolean isIgnoreTestFailures ( ) { return mavenIgnoreTestFailure || mavenTestFailureIgnore ; }
private Long getSeed ( ) { return parsedSeed ; }
private Long getThrottle ( ) { return parsedThrottle ; }
private Integer getPercentTouch ( ) { return parsedPercentTouch ; }
private Integer getPercentMotion ( ) { return parsedPercentMotion ; }
private Integer getPercentTrackball ( ) { return parsedPercentTrackball ; }
private Integer getPercentNav ( ) { return parsedPercentNav ; }
private Integer getPercentMajorNav ( ) { return parsedPercentMajorNav ; }
private Integer getPercentSyskeys ( ) { return parsedPercentSyskeys ; }
private Integer getPercentAppswitch ( ) { return parsedPercentAppswitch ; }
private Integer getPercentAnyevent ( ) { return parsedPercentAnyevent ; }
public String [] getPackages ( ) { return parsedPackages ; }
public String [] getCategories ( ) { return parsedCategories ; }
public AndroidSdk ( File sdkPath , String apiLevel ) { this( sdkPath , apiLevel , null ); }
public AndroidSdk ( File sdkPath , String apiLevel , @ Nullable String buildToolsVersion ) { this . sdkPath = sdkPath ; this . buildToolsVersion = buildToolsVersion ; this . progressIndicator = new ProgressIndicatorImpl ( ) ; if ( sdkPath != null ) { sdkManager = AndroidSdkHandler . getInstance ( sdkPath ) ; platformToolsPath = new File ( sdkPath , SdkConstants . FD_PLATFORM_TOOLS ) ; toolsPath = new File ( sdkPath , SdkConstants . FD_TOOLS ) ; if ( sdkManager == null ) { throw invalidSdkException ( sdkPath , apiLevel ) ; } } loadSDKToolsMajorVersion ( ) ; if ( apiLevel == null ) { apiLevel = DEFAULT_ANDROID_API_LEVEL ; } androidTarget = findPlatformByApiLevel ( apiLevel ) ; if ( androidTarget == null ) { throw invalidSdkException ( sdkPath , apiLevel ) ; } }
public String getAaptPath ( ) { return getPathForBuildTool ( BuildToolInfo . PathId . AAPT ) ; }
public String getAidlPath ( ) { return getPathForBuildTool ( BuildToolInfo . PathId . AIDL ) ; }
public String getDxJarPath ( ) { return getPathForBuildTool ( BuildToolInfo . PathId . DX_JAR ) ; }
public String getAdbPath ( ) { return getPathForPlatformTool ( SdkConstants . FN_ADB ) ; }
public String getZipalignPath ( ) { return getPathForBuildTool ( BuildToolInfo . PathId . ZIP_ALIGN ) ; }
public String getLintPath ( ) { return getPathForTool ( "lint" + ext ( ".bat" , "" ) ) ; }
public String getMonkeyRunnerPath ( ) { return getPathForTool ( "monkeyrunner" + ext ( ".bat" , "" ) ) ; }
public String getApkBuilderPath ( ) { return getPathForTool ( "apkbuilder" + ext ( ".bat" , "" ) ) ; }
public String getAndroidPath ( ) { String cmd = "android" ; String ext = SdkConstants . currentPlatform ( ) == 2 ? ".bat" : "" ; return getPathForTool ( cmd + ext ) ; }
public File getToolsPath ( ) { return toolsPath ; }
private String getPathForBuildTool ( BuildToolInfo . PathId pathId ) { return getBuildToolInfo ( ) . getPath ( pathId ) ; }
private String getPathForPlatformTool ( String tool ) { return new File ( platformToolsPath , tool ) . getAbsolutePath ( ) ; }
private String getPathForTool ( String tool ) { return new File ( toolsPath , tool ) . getAbsolutePath ( ) ; }
private static String ext ( String windowsExtension , String nonWindowsExtension ) { if ( SdkConstants . currentPlatform ( ) == SdkConstants . PLATFORM_WINDOWS ) { return windowsExtension ; } else { return nonWindowsExtension ; } }
public String getPathForFrameworkAidl ( ) { return androidTarget . getPath ( IAndroidTarget . ANDROID_AIDL ) ; }
public File getPlatform ( ) { assertPathIsDirectory ( sdkPath ) ; final File platformsDirectory = new File ( sdkPath , PLATFORMS_FOLDER_NAME ) ; assertPathIsDirectory ( platformsDirectory ) ; final File platformDirectory ; if ( androidTarget == null ) { IAndroidTarget latestTarget = null ; AndroidTargetManager targetManager = sdkManager . getAndroidTargetManager ( progressIndicator ) ; for ( IAndroidTarget target : targetManager . getTargets ( progressIndicator ) ) { if ( target . isPlatform ( ) ) { if ( latestTarget == null || target . getVersion ( ) . getApiLevel ( ) > latestTarget . getVersion ( ) . getApiLevel ( ) ) { latestTarget = target ; } } } platformDirectory = new File ( latestTarget . getLocation ( ) ) ; } else { platformDirectory = new File ( androidTarget . getLocation ( ) ) ; } assertPathIsDirectory ( platformDirectory ) ; return platformDirectory ; }
public int getSdkMajorVersion ( ) { return sdkMajorVersion ; }
@ Override public void onCreate ( Bundle savedInstanceState ) { super. onCreate ( savedInstanceState ) ; UIUtils . setupActionBar ( this ) ; Intent myIntent = getIntent ( ) ; if ( Intent . ACTION_CREATE_SHORTCUT . equals ( myIntent . getAction ( ) ) ) { setResult ( RESULT_OK , getShortcutIntent ( ) ) ; } finish ( ) ; }
private Intent getShortcutIntent ( ) { final Uri uri = MyTabActivityBase . getDefaultTabUri ( MyStarredStopsFragment . TAB_NAME ) ; return UIUtils . makeShortcut ( this , getString ( R . string . starred_stops_shortcut ) , new Intent ( this , MyStopsActivity .class ) . setData ( uri ) ) ; }
@ Override public boolean isValid ( ) { return isValid ( false ) ; }
public Class < ? > getClassType ( ) { return this . classType ; }
public String getName ( ) { return this . name ; }
public ContentUriInfo getDefaultContentUriInfo ( ) { return this . defaultContentUriInfo ; }
public void setDefaultContentUriInfo ( ContentUriInfo defaultContentUriInfo ) { this . defaultContentUriInfo = defaultContentUriInfo ; }
public ContentMimeTypeVndInfo getDefaultContentMimeTypeVndInfo ( ) { return this . defaultContentMimeTypeVndInfo ; }
public void setDefaultContentMimeTypeVndInfo ( ContentMimeTypeVndInfo defaultContentMimeTypeVndInfo ) { this . defaultContentMimeTypeVndInfo = defaultContentMimeTypeVndInfo ; }
public String getDefaultSortOrderString ( ) { return this . defaultSortOrder ; }
public ColumnInfo getIdColumnInfo ( ) { return this . idColumnInfo ; }
public Map < String , String > getProjectionMap ( ) { return this . projectionMap ; }
boolean onQueryTextSubmit ( String query );
boolean onQueryTextChange ( String newText );
public SearchView ( Context context ) { this( context , null ); }
public SearchView ( Context context , AttributeSet attrs ) { super( context , attrs ); LayoutInflater inflater = ( LayoutInflater ) context . getSystemService ( Context . LAYOUT_INFLATER_SERVICE ) ; inflater . inflate ( R . layout . search_box , this , true ) ; mSearchButton = findViewById ( R . id . search_button ) ; mQueryTextView = ( EditText ) findViewById ( R . id . search_text ) ; mSearchButton . setOnClickListener ( mOnClickListener ) ; mQueryTextView . setOnClickListener ( mOnClickListener ) ; mQueryTextView . addTextChangedListener ( mTextWatcher ) ; mQueryTextView . setOnEditorActionListener ( mOnEditorActionListener ) ; mQueryTextView . setOnFocusChangeListener ( new OnFocusChangeListener ( ) { public void onFocusChange ( View v , boolean hasFocus ) { if ( mOnQueryTextFocusChangeListener != null ) { mOnQueryTextFocusChangeListener . onFocusChange ( SearchView .this , hasFocus ) ; } } } ) ; }
public void onFocusChange ( View v , boolean hasFocus ) { if ( mOnQueryTextFocusChangeListener != null ) { mOnQueryTextFocusChangeListener . onFocusChange ( SearchView .this , hasFocus ) ; } }
public void setOnQueryTextListener ( OnQueryTextListener listener ) { mOnQueryChangeListener = listener ; }
public void setOnQueryTextFocusChangeListener ( OnFocusChangeListener listener ) { mOnQueryTextFocusChangeListener = listener ; }
public CharSequence getQuery ( ) { return mQueryTextView . getText ( ) ; }
public void setQuery ( CharSequence query , boolean submit ) { mQueryTextView . setText ( query ) ; if ( query != null ) { mQueryTextView . setSelection ( query . length ( ) ) ; } if ( submit && ! TextUtils . isEmpty ( query ) ) { onSubmitQuery ( ) ; } }
public void setQueryHint ( CharSequence hint ) { mQueryHint = hint ; updateQueryHint ( ) ; }
public void beforeTextChanged ( CharSequence s , int start , int before , int after ) { }
public void onTextChanged ( CharSequence s , int start , int before , int after ) { SearchView .this . onTextChanged ( s ) ; }
public void afterTextChanged ( Editable s ) { }
public boolean onEditorAction ( TextView v , int actionId , KeyEvent event ) { onSubmitQuery ( ) ; return true ; }
private void onTextChanged ( CharSequence newText ) { if ( mOnQueryChangeListener != null && ! TextUtils . equals ( newText , mOldQueryText ) ) { mOnQueryChangeListener . onQueryTextChange ( newText . toString ( ) ) ; } mOldQueryText = newText . toString ( ) ; }
private void onSubmitQuery ( ) { CharSequence query = mQueryTextView . getText ( ) ; if ( query != null && TextUtils . getTrimmedLength ( query ) > 0 ) { if ( mOnQueryChangeListener == null || ! mOnQueryChangeListener . onQueryTextSubmit ( query . toString ( ) ) ) { } } }
public void onClick ( View v ) { }
private CharSequence getDecoratedHint ( CharSequence hintText ) { return hintText ; }
private void updateQueryHint ( ) { if ( mQueryHint != null ) { mQueryTextView . setHint ( getDecoratedHint ( mQueryHint ) ) ; } else { mQueryTextView . setHint ( getDecoratedHint ( "" ) ) ; } }
@ Override protected void onCreate ( Bundle savedInstanceState ) { super. onCreate ( savedInstanceState ) ; setContentView ( R . layout . main_activity ) ; findViewById ( R . id . button_run_scheduler ) . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { onRunSchedulerExampleButtonClicked ( ) ; } } ) ; }
@ Override public void onClick ( View v ) { onRunSchedulerExampleButtonClicked ( ) ; }
@ Override protected void onDestroy ( ) { super. onDestroy ( ) ; disposables . clear ( ) ; }
void onRunSchedulerExampleButtonClicked ( ) { disposables . add ( sampleObservable ( ) . subscribeOn ( Schedulers . io ( ) ) . observeOn ( AndroidSchedulers . mainThread ( ) ) . subscribeWith ( new DisposableObserver < String > ( ) { @ Override public void onComplete ( ) { Log . d ( TAG , "onComplete()" ) ; } @ Override public void onError ( Throwable e ) { Log . e ( TAG , "onError()" , e ) ; } @ Override public void onNext ( String string ) { Log . d ( TAG , "onNext(" + string + ")" ) ; } } ) ) ; }
@ Override public void onComplete ( ) { Log . d ( TAG , "onComplete()" ) ; }
@ Override public void onError ( Throwable e ) { Log . e ( TAG , "onError()" , e ) ; }
@ Override public void onNext ( String string ) { Log . d ( TAG , "onNext(" + string + ")" ) ; }
void onFocusChanged ( ObaStop stop , HashMap < String , ObaRoute > routes , Location location );
public StopOverlay ( Activity activity , GoogleMap map ) { mActivity = activity ; mMap = map ; loadIcons ( ) ; mMap . setOnMarkerClickListener ( this ) ; mMap . setOnMapClickListener ( this ) ; }
public void setOnFocusChangeListener ( OnFocusChangedListener onFocusChangedListener ) { mOnFocusChangedListener = onFocusChangedListener ; }
public synchronized void populateStops ( List < ObaStop > stops , ObaReferences refs ) { populate ( stops , refs . getRoutes ( ) ) ; }
public synchronized void populateStops ( List < ObaStop > stops , List < ObaRoute > routes ) { populate ( stops , routes ) ; }
private void populate ( List < ObaStop > stops , List < ObaRoute > routes ) { setupMarkerData ( ) ; mMarkerData . populate ( stops , routes ) ; }
public synchronized int size ( ) { if ( mMarkerData != null ) { return mMarkerData . size ( ) ; } else { return 0 ; } }
public synchronized void clear ( boolean clearFocusedStop ) { if ( mMarkerData != null ) { mMarkerData . clear ( clearFocusedStop ) ; } }
private static final void loadIcons ( ) { Resources r = Application . get ( ) . getResources ( ) ; mPx = r . getDimensionPixelSize ( R . dimen . map_stop_shadow_size_6 ) ; mArrowWidthPx = mPx / 2f ; mArrowHeightPx = mPx / 3f ; float arrowSpacingReductionPx = mPx / 10f ; mBuffer = mArrowHeightPx - arrowSpacingReductionPx ; mPercentOffset = ( mBuffer / ( mPx + mBuffer ) ) * 0.5f ; mArrowPaintStroke = new Paint ( ) ; mArrowPaintStroke . setColor ( Color . WHITE ) ; mArrowPaintStroke . setStyle ( Paint . Style . STROKE ) ; mArrowPaintStroke . setStrokeWidth ( 1.0f ) ; mArrowPaintStroke . setAntiAlias ( true ) ; bus_stop_icons [ 0 ] = createBusStopIcon ( NORTH ) ; bus_stop_icons [ 1 ] = createBusStopIcon ( NORTH_WEST ) ; bus_stop_icons [ 2 ] = createBusStopIcon ( WEST ) ; bus_stop_icons [ 3 ] = createBusStopIcon ( SOUTH_WEST ) ; bus_stop_icons [ 4 ] = createBusStopIcon ( SOUTH ) ; bus_stop_icons [ 5 ] = createBusStopIcon ( SOUTH_EAST ) ; bus_stop_icons [ 6 ] = createBusStopIcon ( EAST ) ; bus_stop_icons [ 7 ] = createBusStopIcon ( NORTH_EAST ) ; bus_stop_icons [ 8 ] = createBusStopIcon ( NO_DIRECTION ) ; }
private static Bitmap createBusStopIcon ( String direction ) throws NullPointerException { if ( direction == null ) { throw new IllegalArgumentException ( direction ) ; } Resources r = Application . get ( ) . getResources ( ) ; Context context = Application . get ( ) ; Float directionAngle = null ; Bitmap bm ; Canvas c ; Drawable shape ; Float rotationX = null , rotationY = null ; Paint arrowPaintFill = new Paint ( ) ; arrowPaintFill . setStyle ( Paint . Style . FILL ) ; arrowPaintFill . setAntiAlias ( true ) ; if ( direction . equals ( NO_DIRECTION ) ) { bm = Bitmap . createBitmap ( mPx , mPx , Bitmap . Config . ARGB_8888 ) ; c = new Canvas ( bm ) ; shape = ContextCompat . getDrawable ( context , R . drawable . map_stop_icon ) ; shape . setBounds ( 0 , 0 , bm . getWidth ( ) , bm . getHeight ( ) ) ; } else if ( direction . equals ( NORTH ) ) { directionAngle = 0f ; bm = Bitmap . createBitmap ( mPx , ( int ) ( mPx + mBuffer ) , Bitmap . Config . ARGB_8888 ) ; c = new Canvas ( bm ) ; shape = ContextCompat . getDrawable ( context , R . drawable . map_stop_icon ) ; shape . setBounds ( 0 , ( int ) mBuffer , mPx , bm . getHeight ( ) ) ; arrowPaintFill . setShader ( new LinearGradient ( bm . getWidth ( ) / 2 , 0 , bm . getWidth ( ) / 2 , mArrowHeightPx , r . getColor ( R . color . theme_primary ) , r . getColor ( R . color . theme_accent ) , Shader . TileMode . MIRROR ) ) ; rotationX = bm . getWidth ( ) / 2f ; rotationY = bm . getHeight ( ) / 2f ; } else if ( direction . equals ( NORTH_WEST ) ) { directionAngle = 315f ; bm = Bitmap . createBitmap ( ( int ) ( mPx + mBuffer ) , ( int ) ( mPx + mBuffer ) , Bitmap . Config . ARGB_8888 ) ; c = new Canvas ( bm ) ; shape = ContextCompat . getDrawable ( context , R . drawable . map_stop_icon ) ; shape . setBounds ( ( int ) mBuffer , ( int ) mBuffer , bm . getWidth ( ) , bm . getHeight ( ) ) ; arrowPaintFill . setShader ( new LinearGradient ( 0 , 0 , mBuffer , mBuffer , r . getColor ( R . color . theme_primary ) , r . getColor ( R . color . theme_accent ) , Shader . TileMode . MIRROR ) ) ; rotationX = mPx / 2f + mBuffer / 2f ; rotationY = bm . getHeight ( ) / 2f - mBuffer / 2f ; } else if ( direction . equals ( WEST ) ) { directionAngle = 0f ; bm = Bitmap . createBitmap ( ( int ) ( mPx + mBuffer ) , mPx , Bitmap . Config . ARGB_8888 ) ; c = new Canvas ( bm ) ; shape = ContextCompat . getDrawable ( context , R . drawable . map_stop_icon ) ; shape . setBounds ( ( int ) mBuffer , 0 , bm . getWidth ( ) , bm . getHeight ( ) ) ; arrowPaintFill . setShader ( new LinearGradient ( 0 , bm . getHeight ( ) / 2 , mArrowHeightPx , bm . getHeight ( ) / 2 , r . getColor ( R . color . theme_primary ) , r . getColor ( R . color . theme_accent ) , Shader . TileMode . MIRROR ) ) ; rotationX = bm . getHeight ( ) / 2f ; rotationY = bm . getHeight ( ) / 2f ; } else if ( direction . equals ( SOUTH_WEST ) ) { directionAngle = 225f ; bm = Bitmap . createBitmap ( ( int ) ( mPx + mBuffer ) , ( int ) ( mPx + mBuffer ) , Bitmap . Config . ARGB_8888 ) ; c = new Canvas ( bm ) ; shape = ContextCompat . getDrawable ( context , R . drawable . map_stop_icon ) ; shape . setBounds ( ( int ) mBuffer , 0 , bm . getWidth ( ) , mPx ) ; arrowPaintFill . setShader ( new LinearGradient ( 0 , bm . getHeight ( ) , mBuffer , bm . getHeight ( ) - mBuffer , r . getColor ( R . color . theme_primary ) , r . getColor ( R . color . theme_accent ) , Shader . TileMode . MIRROR ) ) ; rotationX = bm . getWidth ( ) / 2f - mBuffer / 4f ; rotationY = mPx / 2f + mBuffer / 4f ; } else if ( direction . equals ( SOUTH ) ) { directionAngle = 180f ; bm = Bitmap . createBitmap ( mPx , ( int ) ( mPx + mBuffer ) , Bitmap . Config . ARGB_8888 ) ; c = new Canvas ( bm ) ; shape = ContextCompat . getDrawable ( context , R . drawable . map_stop_icon ) ; shape . setBounds ( 0 , 0 , bm . getWidth ( ) , ( int ) ( bm . getHeight ( ) - mBuffer ) ) ; arrowPaintFill . setShader ( new LinearGradient ( bm . getWidth ( ) / 2 , bm . getHeight ( ) , bm . getWidth ( ) / 2 , bm . getHeight ( ) - mArrowHeightPx , r . getColor ( R . color . theme_primary ) , r . getColor ( R . color . theme_accent ) , Shader . TileMode . MIRROR ) ) ; rotationX = bm . getWidth ( ) / 2f ; rotationY = bm . getHeight ( ) / 2f ; } else if ( direction . equals ( SOUTH_EAST ) ) { directionAngle = 135f ; bm = Bitmap . createBitmap ( ( int ) ( mPx + mBuffer ) , ( int ) ( mPx + mBuffer ) , Bitmap . Config . ARGB_8888 ) ; c = new Canvas ( bm ) ; shape = ContextCompat . getDrawable ( context , R . drawable . map_stop_icon ) ; shape . setBounds ( 0 , 0 , mPx , mPx ) ; arrowPaintFill . setShader ( new LinearGradient ( bm . getWidth ( ) , bm . getHeight ( ) , bm . getWidth ( ) - mBuffer , bm . getHeight ( ) - mBuffer , r . getColor ( R . color . theme_primary ) , r . getColor ( R . color . theme_accent ) , Shader . TileMode . MIRROR ) ) ; rotationX = ( mPx + mBuffer / 2 ) / 2f ; rotationY = bm . getHeight ( ) / 2f ; } else if ( direction . equals ( EAST ) ) { directionAngle = 180f ; bm = Bitmap . createBitmap ( ( int ) ( mPx + mBuffer ) , mPx , Bitmap . Config . ARGB_8888 ) ; c = new Canvas ( bm ) ; shape = ContextCompat . getDrawable ( context , R . drawable . map_stop_icon ) ; shape . setBounds ( 0 , 0 , mPx , bm . getHeight ( ) ) ; arrowPaintFill . setShader ( new LinearGradient ( bm . getWidth ( ) , bm . getHeight ( ) / 2 , bm . getWidth ( ) - mArrowHeightPx , bm . getHeight ( ) / 2 , r . getColor ( R . color . theme_primary ) , r . getColor ( R . color . theme_accent ) , Shader . TileMode . MIRROR ) ) ; rotationX = bm . getWidth ( ) / 2f ; rotationY = bm . getHeight ( ) / 2f ; } else if ( direction . equals ( NORTH_EAST ) ) { directionAngle = 45f ; bm = Bitmap . createBitmap ( ( int ) ( mPx + mBuffer ) , ( int ) ( mPx + mBuffer ) , Bitmap . Config . ARGB_8888 ) ; c = new Canvas ( bm ) ; shape = ContextCompat . getDrawable ( context , R . drawable . map_stop_icon ) ; shape . setBounds ( 0 , ( int ) mBuffer , mPx , bm . getHeight ( ) ) ; arrowPaintFill . setShader ( new LinearGradient ( bm . getWidth ( ) , 0 , bm . getWidth ( ) - mBuffer , mBuffer , r . getColor ( R . color . theme_primary ) , r . getColor ( R . color . theme_accent ) , Shader . TileMode . MIRROR ) ) ; rotationX = ( float ) mPx / 2 ; rotationY = bm . getHeight ( ) - ( float ) mPx / 2 ; } else { throw new IllegalArgumentException ( direction ) ; } shape . draw ( c ) ; if ( direction . equals ( NO_DIRECTION ) ) { return bm ; } final float CUTOUT_HEIGHT = mPx / 12 ; Path path = new Path ( ) ; float x1 = 0 , y1 = 0 ; float x2 = 0 , y2 = 0 ; float x3 = 0 , y3 = 0 ; float x4 = 0 , y4 = 0 ; if ( direction . equals ( NORTH ) || direction . equals ( SOUTH ) || direction . equals ( NORTH_EAST ) || direction . equals ( SOUTH_EAST ) || direction . equals ( NORTH_WEST ) || direction . equals ( SOUTH_WEST ) ) { x1 = mPx / 2 ; y1 = 0 ; x2 = ( mPx / 2 ) - ( mArrowWidthPx / 2 ) ; y2 = mArrowHeightPx ; x3 = mPx / 2 ; y3 = mArrowHeightPx - CUTOUT_HEIGHT ; x4 = ( mPx / 2 ) + ( mArrowWidthPx / 2 ) ; y4 = mArrowHeightPx ; } else if ( direction . equals ( EAST ) || direction . equals ( WEST ) ) { x1 = 0 ; y1 = mPx / 2 ; x2 = mArrowHeightPx ; y2 = ( mPx / 2 ) - ( mArrowWidthPx / 2 ) ; x3 = mArrowHeightPx - CUTOUT_HEIGHT ; y3 = mPx / 2 ; x4 = mArrowHeightPx ; y4 = ( mPx / 2 ) + ( mArrowWidthPx / 2 ) ; } path . setFillType ( Path . FillType . EVEN_ODD ) ; path . moveTo ( x1 , y1 ) ; path . lineTo ( x2 , y2 ) ; path . lineTo ( x3 , y3 ) ; path . lineTo ( x4 , y4 ) ; path . lineTo ( x1 , y1 ) ; path . close ( ) ; Matrix matrix = new Matrix ( ) ; matrix . postRotate ( directionAngle , rotationX , rotationY ) ; path . transform ( matrix ) ; c . drawPath ( path , arrowPaintFill ) ; c . drawPath ( path , mArrowPaintStroke ) ; return bm ; }
private static float getXPercentOffsetForDirection ( String direction ) { if ( direction . equals ( NORTH ) ) { return 0.5f ; } else if ( direction . equals ( NORTH_WEST ) ) { return 0.5f + mPercentOffset ; } else if ( direction . equals ( WEST ) ) { return 0.5f + mPercentOffset ; } else if ( direction . equals ( SOUTH_WEST ) ) { return 0.5f + mPercentOffset ; } else if ( direction . equals ( SOUTH ) ) { return 0.5f ; } else if ( direction . equals ( SOUTH_EAST ) ) { return 0.5f - mPercentOffset ; } else if ( direction . equals ( EAST ) ) { return 0.5f - mPercentOffset ; } else if ( direction . equals ( NORTH_EAST ) ) { return 0.5f - mPercentOffset ; } else if ( direction . equals ( NO_DIRECTION ) ) { return 0.5f ; } else { return 0.5f ; } }
private static float getYPercentOffsetForDirection ( String direction ) { if ( direction . equals ( NORTH ) ) { return 0.5f + mPercentOffset ; } else if ( direction . equals ( NORTH_WEST ) ) { return 0.5f + mPercentOffset ; } else if ( direction . equals ( WEST ) ) { return 0.5f ; } else if ( direction . equals ( SOUTH_WEST ) ) { return 0.5f - mPercentOffset ; } else if ( direction . equals ( SOUTH ) ) { return 0.5f - mPercentOffset ; } else if ( direction . equals ( SOUTH_EAST ) ) { return 0.5f - mPercentOffset ; } else if ( direction . equals ( EAST ) ) { return 0.5f ; } else if ( direction . equals ( NORTH_EAST ) ) { return 0.5f + mPercentOffset ; } else if ( direction . equals ( NO_DIRECTION ) ) { return 0.5f ; } else { return 0.5f ; } }
private static BitmapDescriptor getBitmapDescriptorForBusStopDirection ( String direction ) { if ( direction . equals ( NORTH ) ) { return BitmapDescriptorFactory . fromBitmap ( bus_stop_icons [ 0 ] ) ; } else if ( direction . equals ( NORTH_WEST ) ) { return BitmapDescriptorFactory . fromBitmap ( bus_stop_icons [ 1 ] ) ; } else if ( direction . equals ( WEST ) ) { return BitmapDescriptorFactory . fromBitmap ( bus_stop_icons [ 2 ] ) ; } else if ( direction . equals ( SOUTH_WEST ) ) { return BitmapDescriptorFactory . fromBitmap ( bus_stop_icons [ 3 ] ) ; } else if ( direction . equals ( SOUTH ) ) { return BitmapDescriptorFactory . fromBitmap ( bus_stop_icons [ 4 ] ) ; } else if ( direction . equals ( SOUTH_EAST ) ) { return BitmapDescriptorFactory . fromBitmap ( bus_stop_icons [ 5 ] ) ; } else if ( direction . equals ( EAST ) ) { return BitmapDescriptorFactory . fromBitmap ( bus_stop_icons [ 6 ] ) ; } else if ( direction . equals ( NORTH_EAST ) ) { return BitmapDescriptorFactory . fromBitmap ( bus_stop_icons [ 7 ] ) ; } else if ( direction . equals ( NO_DIRECTION ) ) { return BitmapDescriptorFactory . fromBitmap ( bus_stop_icons [ 8 ] ) ; } else { return BitmapDescriptorFactory . fromBitmap ( bus_stop_icons [ 8 ] ) ; } }
public ObaStop getFocus ( ) { if ( mMarkerData != null ) { return mMarkerData . getFocus ( ) ; } return null ; }
public void setFocus ( ObaStop stop , List < ObaRoute > routes ) { setupMarkerData ( ) ; if ( stop == null ) { removeFocus ( null ) ; return; } if ( ! mMarkerData . containsStop ( stop ) ) { ArrayList < ObaStop > l = new ArrayList < ObaStop > ( ) ; l . add ( stop ) ; populateStops ( l , routes ) ; } doFocusChange ( stop ) ; }
private void doFocusChange ( ObaStop stop ) { mMarkerData . setFocus ( stop ) ; HashMap < String , ObaRoute > routes = mMarkerData . getCachedRoutes ( ) ; mOnFocusChangedListener . onFocusChanged ( stop , routes , stop . getLocation ( ) ) ; }
private void removeFocus ( LatLng latLng ) { if ( mMarkerData . getFocus ( ) != null ) { mMarkerData . removeFocus ( ) ; } Location location = null ; if ( latLng != null ) { location = MapHelpV2 . makeLocation ( latLng ) ; } mOnFocusChangedListener . onFocusChanged ( null , null , location ) ; }
private void setupMarkerData ( ) { if ( mMarkerData == null ) { mMarkerData = new MarkerData ( ) ; } }
MarkerData ( ) { mStopMarkers = new HashMap < String , Marker > ( ) ; mStops = new HashMap < Marker , ObaStop > ( ) ; mStopRoutes = new HashMap < String , ObaRoute > ( ) ; mFocusedRoutes = new LinkedList < ObaRoute > ( ) ; }
private void addMarkerToMap ( ObaStop stop , List < ObaRoute > routes ) { Marker m = mMap . addMarker ( new MarkerOptions ( ) . position ( MapHelpV2 . makeLatLng ( stop . getLocation ( ) ) ) . icon ( getBitmapDescriptorForBusStopDirection ( stop . getDirection ( ) ) ) . flat ( true ) . anchor ( getXPercentOffsetForDirection ( stop . getDirection ( ) ) , getYPercentOffsetForDirection ( stop . getDirection ( ) ) ) ) ; mStopMarkers . put ( stop . getId ( ) , m ) ; mStops . put ( m , stop ) ; for ( ObaRoute route : routes ) { if ( ! mStopRoutes . containsKey ( route . getId ( ) ) ) { mStopRoutes . put ( route . getId ( ) , route ) ; } } }
synchronized ObaStop getStopFromMarker ( Marker marker ) { return mStops . get ( marker ) ; }
synchronized boolean containsStop ( ObaStop stop ) { if ( stop != null ) { return containsStop ( stop . getId ( ) ) ; } else { return false ; } }
synchronized boolean containsStop ( String stopId ) { if ( mStopMarkers != null ) { return mStopMarkers . containsKey ( stopId ) ; } else { return false ; } }
synchronized HashMap < String , ObaRoute > getCachedRoutes ( ) { return new HashMap < String , ObaRoute > ( mStopRoutes ) ; }
void setFocus ( ObaStop stop ) { if ( mCurrentFocusMarker != null ) { mCurrentFocusMarker . remove ( ) ; } mCurrentFocusStop = stop ; mFocusedRoutes . clear ( ) ; String [] routeIds = stop . getRouteIds ( ) ; for ( int i = 0 ; i < routeIds . length ; i ++ ) { ObaRoute route = mStopRoutes . get ( routeIds [ i ] ) ; if ( route != null ) { mFocusedRoutes . add ( route ) ; } } LatLng latLng = new LatLng ( stop . getLatitude ( ) - 0.000001 , stop . getLongitude ( ) ) ; mCurrentFocusMarker = mMap . addMarker ( new MarkerOptions ( ) . position ( latLng ) ) ; }
private void animateMarker ( final Marker marker ) { final Handler handler = new Handler ( ) ; final long startTime = SystemClock . uptimeMillis ( ) ; final long duration = 300 ; Projection proj = mMap . getProjection ( ) ; final LatLng markerLatLng = marker . getPosition ( ) ; Point startPoint = proj . toScreenLocation ( markerLatLng ) ; startPoint . offset ( 0 , - 10 ) ; final LatLng startLatLng = proj . fromScreenLocation ( startPoint ) ; final Interpolator interpolator = new BounceInterpolator ( ) ; handler . post ( new Runnable ( ) { @ Override public void run ( ) { long elapsed = SystemClock . uptimeMillis ( ) - startTime ; float t = interpolator . getInterpolation ( ( float ) elapsed / duration ) ; double lng = t * markerLatLng . longitude + ( 1 - t ) * startLatLng . longitude ; double lat = t * markerLatLng . latitude + ( 1 - t ) * startLatLng . latitude ; marker . setPosition ( new LatLng ( lat , lng ) ) ; if ( t < 1.0 ) { handler . postDelayed ( this , 16 ) ; } } } ) ; }
@ Override public void run ( ) { long elapsed = SystemClock . uptimeMillis ( ) - startTime ; float t = interpolator . getInterpolation ( ( float ) elapsed / duration ) ; double lng = t * markerLatLng . longitude + ( 1 - t ) * startLatLng . longitude ; double lat = t * markerLatLng . latitude + ( 1 - t ) * startLatLng . latitude ; marker . setPosition ( new LatLng ( lat , lng ) ) ; if ( t < 1.0 ) { handler . postDelayed ( this , 16 ) ; } }
ObaStop getFocus ( ) { return mCurrentFocusStop ; }
void removeFocus ( ) { if ( mCurrentFocusMarker != null ) { mCurrentFocusMarker . remove ( ) ; mCurrentFocusMarker = null ; } mFocusedRoutes . clear ( ) ; mCurrentFocusStop = null ; }
private void removeMarkersFromMap ( ) { for ( Map . Entry < String , Marker > entry : mStopMarkers . entrySet ( ) ) { entry . getValue ( ) . remove ( ) ; } }
synchronized void clear ( boolean clearFocusedStop ) { if ( mStopMarkers != null ) { removeMarkersFromMap ( ) ; mStopMarkers . clear ( ) ; } if ( mStops != null ) { mStops . clear ( ) ; } if ( mStopRoutes != null ) { mStopRoutes . clear ( ) ; } if ( clearFocusedStop ) { removeFocus ( ) ; } else { if ( mCurrentFocusStop != null && mFocusedRoutes != null ) { addMarkerToMap ( mCurrentFocusStop , mFocusedRoutes ) ; } } }
synchronized int size ( ) { return mStopMarkers . size ( ) ; }
@ Override protected void onCreate ( Bundle savedInstanceState ) { super. onCreate ( savedInstanceState ) ; App . component ( ) . inject ( this ) ; if ( getIntent ( ) . getData ( ) == null || getIntent ( ) . getData ( ) . getScheme ( ) == null ) { tracker . trackException ( "invalid_import_uri" , false ) ; finish ( ) ; } else { new ImportAndShowAsyncTask ( this , getIntent ( ) . getData ( ) ) . execute ( ) ; } }
private AccountContract ( ) { }
@ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { View view = inflater . inflate ( R . layout . fragment_scrollview , container , false ) ; final ObservableScrollView scrollView = ( ObservableScrollView ) view . findViewById ( R . id . scroll ) ; Activity parentActivity = getActivity ( ) ; if ( parentActivity instanceof ObservableScrollViewCallbacks ) { Bundle args = getArguments ( ) ; if ( args != null && args . containsKey ( ARG_SCROLL_Y ) ) { final int scrollY = args . getInt ( ARG_SCROLL_Y , 0 ) ; ScrollUtils . addOnGlobalLayoutListener ( scrollView , new Runnable ( ) { @ Override public void run ( ) { scrollView . scrollTo ( 0 , scrollY ) ; } } ) ; } scrollView . setTouchInterceptionViewGroup ( ( ViewGroup ) parentActivity . findViewById ( R . id . root ) ) ; scrollView . setScrollViewCallbacks ( ( ObservableScrollViewCallbacks ) parentActivity ) ; } return view ; }
@ Override public void run ( ) { scrollView . scrollTo ( 0 , scrollY ) ; }
public WrapperListAdapterImpl ( ListAdapter wrapped ) { this . wrapped = wrapped ; }
@ Override public ListAdapter getWrappedAdapter ( ) { return wrapped ; }
@ Override public boolean areAllItemsEnabled ( ) { return wrapped . areAllItemsEnabled ( ) ; }
@ Override public boolean isEnabled ( int i ) { return wrapped . isEnabled ( i ) ; }
@ Override public void registerDataSetObserver ( DataSetObserver dataSetObserver ) { wrapped . registerDataSetObserver ( dataSetObserver ) ; }
@ Override public void unregisterDataSetObserver ( DataSetObserver dataSetObserver ) { wrapped . unregisterDataSetObserver ( dataSetObserver ) ; }
@ Override public int getCount ( ) { return wrapped . getCount ( ) ; }
@ Override public Object getItem ( int i ) { return wrapped . getItem ( i ) ; }
@ Override public long getItemId ( int i ) { return wrapped . getItemId ( i ) ; }
@ Override public boolean hasStableIds ( ) { return wrapped . hasStableIds ( ) ; }
@ Override public View getView ( int position , View view , ViewGroup viewGroup ) { return wrapped . getView ( position , view , viewGroup ) ; }
@ Override public int getItemViewType ( int i ) { return wrapped . getItemViewType ( i ) ; }
@ Override public int getViewTypeCount ( ) { return wrapped . getViewTypeCount ( ) ; }
@ Override public boolean isEmpty ( ) { return wrapped . isEmpty ( ) ; }
public AarActionbarsherlockExampleSampleIT ( MavenRuntimeBuilder builder ) throws Exception { this . mavenRuntime = builder . build ( ) ; }
@ Test public void buildDeployAndRun ( ) Exception { File basedir = resources . getBasedir ( "aar-actionbarsherlock-example" ) ; MavenExecutionResult result = mavenRuntime . forProject ( basedir ) . execute ( "clean" , PluginInfo . getQualifiedGoal ( "undeploy" ) , "install" , PluginInfo . getQualifiedGoal ( "deploy" ) , PluginInfo . getQualifiedGoal ( "run" ) ) ; result . assertErrorFreeLog ( ) ; }
@ Override public boolean onPreferenceClick ( Preference preference ) { Intent intent = new Intent ( callingActivity , PgpHandler .class ) ; intent . putExtra ( "Operation" , "GET_KEY_ID" ) ; startActivityForResult ( intent , IMPORT_PGP_KEY ) ; return true ; }
@ Override public boolean onPreferenceClick ( Preference preference ) { callingActivity . getSshKeyWithPermissions ( ) ; return true ; }
@ Override public boolean onPreferenceClick ( Preference preference ) { callingActivity . makeSshKey ( true ) ; return true ; }
@ Override public boolean onPreferenceClick ( Preference preference ) { DialogFragment df = new SshKeyGen . ShowSshKeyFragment ( ) ; df . show ( getFragmentManager ( ) , "public_key" ) ; return true ; }
@ Override public boolean onPreferenceClick ( Preference preference ) { Intent intent = new Intent ( callingActivity , GitActivity .class ) ; intent . putExtra ( "Operation" , GitActivity . EDIT_SERVER ) ; startActivityForResult ( intent , EDIT_GIT_INFO ) ; return true ; }
@ Override public void onClick ( DialogInterface dialogInterface , int i ) { try { FileUtils . cleanDirectory ( PasswordRepository . getRepositoryDirectory ( callingActivity . getApplicationContext ( ) ) ) ; PasswordRepository . closeRepository ( ) ; } catch ( Exception e ) { } sharedPreferences . edit ( ) . putBoolean ( "repository_initialized" , false ) . apply ( ) ; dialogInterface . cancel ( ) ; callingActivity . finish ( ) ; }
@ Override public void onClick ( DialogInterface dialogInterface , int i ) { { dialogInterface . cancel ( ) ; } }
@ Override public boolean onPreferenceClick ( Preference preference ) { callingActivity . selectExternalGitRepository ( ) ; return true ; }
@ Override public boolean onPreferenceChange ( Preference preference , Object o ) { findPreference ( "git_delete_repo" ) . setEnabled ( ! ( Boolean ) o ) ; PasswordRepository . closeRepository ( ) ; getPreferenceManager ( ) . getSharedPreferences ( ) . edit ( ) . putBoolean ( "repo_changed" , true ) . apply ( ) ; return true ; }
@ Override public boolean onPreferenceClick ( Preference preference ) { Intent intent = new Intent ( callingActivity , AutofillPreferenceActivity .class ) ; startActivity ( intent ) ; return true ; }
@ Override public boolean onPreferenceClick ( Preference preference ) { new AlertDialog . Builder ( callingActivity ) . setTitle ( R . string . pref_autofill_enable_title ) . setView ( R . layout . autofill_instructions ) . setPositiveButton ( R . string . dialog_ok , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { Intent intent = new Intent ( Settings . ACTION_ACCESSIBILITY_SETTINGS ) ; startActivity ( intent ) ; } } ) . setNegativeButton ( R . string . dialog_cancel , null ) . setOnDismissListener ( new DialogInterface . OnDismissListener ( ) { @ Override public void onDismiss ( DialogInterface dialog ) { ( ( CheckBoxPreference ) findPreference ( "autofill_enable" ) ) . setChecked ( ( ( UserPreference ) getActivity ( ) ) . isServiceEnabled ( ) ) ; } } ) . show ( ) ; return true ; }
@ Override public void onClick ( DialogInterface dialog , int which ) { Intent intent = new Intent ( Settings . ACTION_ACCESSIBILITY_SETTINGS ) ; startActivity ( intent ) ; }
@ Override public void onDismiss ( DialogInterface dialog ) { ( ( CheckBoxPreference ) findPreference ( "autofill_enable" ) ) . setChecked ( ( ( UserPreference ) getActivity ( ) ) . isServiceEnabled ( ) ) ; }
@ Override public boolean onPreferenceClick ( Preference preference ) { callingActivity . exportPasswordsWithPermissions ( ) ; return true ; }
@ Override public Object apply ( String input ) { return OpenPgpUtils . convertKeyIdToHex ( Long . valueOf ( input ) ) ; }
@ Override public void onCreate ( Bundle savedInstanceState ) { super. onCreate ( savedInstanceState ) ; if ( getIntent ( ) != null ) { if ( getIntent ( ) . getStringExtra ( "operation" ) != null ) { switch ( getIntent ( ) . getStringExtra ( "operation" ) ) { case "get_ssh_key" : getSshKeyWithPermissions ( ) ; break; case "make_ssh_key" : makeSshKey ( false ) ; break; case "git_external" : selectExternalGitRepository ( ) ; break; } } } prefsFragment = new PrefsFragment ( ) ; getFragmentManager ( ) . beginTransaction ( ) . replace ( android . R . id . content , prefsFragment ) . commit ( ) ; getSupportActionBar ( ) . setDisplayHomeAsUpEnabled ( true ) ; }
@ Override public void onClick ( DialogInterface dialog , int which ) { Intent i = new Intent ( activity . getApplicationContext ( ) , FilePickerActivity .class ) ; i . putExtra ( FilePickerActivity . EXTRA_ALLOW_MULTIPLE , false ) ; i . putExtra ( FilePickerActivity . EXTRA_ALLOW_CREATE_DIR , true ) ; i . putExtra ( FilePickerActivity . EXTRA_MODE , FilePickerActivity . MODE_DIR ) ; i . putExtra ( FilePickerActivity . EXTRA_START_PATH , Environment . getExternalStorageDirectory ( ) . getPath ( ) ) ; startActivityForResult ( i , SELECT_GIT_DIRECTORY ) ; }
@ Override public boolean onOptionsItemSelected ( MenuItem item ) { int id = item . getItemId ( ) ; switch ( id ) { case android . R . id . home : setResult ( RESULT_OK ) ; finish ( ) ; return true ; } return super. onOptionsItemSelected ( item ) ; }
@ Override public void onClick ( View view ) { ActivityCompat . requestPermissions ( activity , new String [] { Manifest . permission . READ_EXTERNAL_STORAGE } , REQUEST_EXTERNAL_STORAGE ) ; }
public void getSshKey ( ) { Intent i = new Intent ( getApplicationContext ( ) , FilePickerActivity .class ) ; i . putExtra ( FilePickerActivity . EXTRA_ALLOW_MULTIPLE , false ) ; i . putExtra ( FilePickerActivity . EXTRA_ALLOW_CREATE_DIR , false ) ; i . putExtra ( FilePickerActivity . EXTRA_MODE , FilePickerActivity . MODE_FILE ) ; i . putExtra ( FilePickerActivity . EXTRA_START_PATH , Environment . getExternalStorageDirectory ( ) . getPath ( ) ) ; startActivityForResult ( i , IMPORT_SSH_KEY ) ; }
@ Override public void onClick ( View view ) { ActivityCompat . requestPermissions ( activity , new String [] { Manifest . permission . WRITE_EXTERNAL_STORAGE } , REQUEST_EXTERNAL_STORAGE ) ; }
public void makeSshKey ( boolean fromPreferences ) { Intent intent = new Intent ( getApplicationContext ( ) , SshKeyGen .class ) ; startActivity ( intent ) ; if ( ! fromPreferences ) { setResult ( RESULT_OK ) ; finish ( ) ; } }
private void copySshKey ( Uri uri ) throws IOException { InputStream sshKey = this . getContentResolver ( ) . openInputStream ( uri ) ; byte [] privateKey = IOUtils . toByteArray ( sshKey ) ; FileUtils . writeByteArrayToFile ( new File ( getFilesDir ( ) + "/.ssh_key" ) , privateKey ) ; sshKey . close ( ) ; }
private boolean isServiceEnabled ( ) { AccessibilityManager am = ( AccessibilityManager ) this . getSystemService ( Context . ACCESSIBILITY_SERVICE ) ; List < AccessibilityServiceInfo > runningServices = am . getEnabledAccessibilityServiceList ( AccessibilityServiceInfo . FEEDBACK_GENERIC ) ; for ( AccessibilityServiceInfo service : runningServices ) { if ( "com.zeapo.pwdstore/.autofill.AutofillService" . equals ( service . getId ( ) ) ) { return true ; } } return false ; }
@ Override public void onClick ( DialogInterface dialogInterface , int i ) { }
@ Override public void onClick ( DialogInterface dialog , int which ) { PreferenceManager . getDefaultSharedPreferences ( getApplicationContext ( ) ) . edit ( ) . putString ( "git_external_repo" , uri . getPath ( ) ) . apply ( ) ; }
@ Override public void onRequestPermissionsResult ( int requestCode , String permissions [] , int [] grantResults ) { switch ( requestCode ) { case REQUEST_EXTERNAL_STORAGE : { if ( grantResults . length > 0 && grantResults [ 0 ] == PackageManager . PERMISSION_GRANTED ) { getSshKey ( ) ; } } } }
protected ObaShapeRequest ( Uri uri ) { super( uri ); }
public Builder ( Context context , String shapeId ) { super( context , getPathWithId ( "/shape/" , shapeId ) ); }
public ObaShapeRequest build ( ) { return new ObaShapeRequest ( buildUri ( ) ) ; }
public static ObaShapeRequest newRequest ( Context context , String shapeId ) { return new Builder ( context , shapeId ) . build ( ) ; }
@ Override public ObaShapeResponse call ( ) { return call ( ObaShapeResponse .class ) ; }
protected AbstractAccessibilityRecordAssert ( A actual , Class < S > selfType ) { super( actual , selfType ); }
public String translate ( String key ) { if ( containsKey ( key ) ) { return get ( key ) ; } return key ; }
public void loadFromFile ( final File file ) { final String content = readFileAsStringGuessEncoding ( file ) ; loadFromString ( content ) ; }
@ Nullable public static String readFileAsStringGuessEncoding ( final @ NonNull File file ) { try { final byte [] fileData = new byte [ ( int ) file . length ( ) ] ; final DataInputStream dataInputStream = new DataInputStream ( new FileInputStream ( file ) ) ; dataInputStream . readFully ( fileData ) ; dataInputStream . close ( ) ; final CharsetMatch match = new CharsetDetector ( ) . setText ( fileData ) . detect ( ) ; if ( match != null ) try { return new String ( fileData , match . getName ( ) ) ; } catch ( UnsupportedEncodingException ignored ) { } return new String ( fileData ) ; } catch ( Throwable e ) { App . component ( ) . tracker ( ) . trackException ( "problem_reading_translation" , e , false ) ; e . printStackTrace ( ) ; return null ; } }
public AtomicFileAssert ( AtomicFile actual ) { super( actual , AtomicFileAssert .class ); }
public GPUImageContrastFilter ( ) { this( 1.2f ); }
public GPUImageContrastFilter ( float contrast ) { super( NO_FILTER_VERTEX_SHADER , CONTRAST_FRAGMENT_SHADER ); mContrast = contrast ; }
@ Override public void onInit ( ) { super. onInit ( ) ; mContrastLocation = GLES20 . glGetUniformLocation ( getProgram ( ) , "contrast" ) ; }
@ Override public void onInitialized ( ) { super. onInitialized ( ) ; setContrast ( mContrast ) ; }
public void setContrast ( final float contrast ) { mContrast = contrast ; setFloat ( mContrastLocation , mContrast ) ; }
@ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { View view = inflater . inflate ( R . layout . fragment_listview , container , false ) ; Activity parentActivity = getActivity ( ) ; final ObservableListView listView = ( ObservableListView ) view . findViewById ( R . id . scroll ) ; setDummyDataWithHeader ( listView , inflater . inflate ( R . layout . padding , listView , false ) ) ; if ( parentActivity instanceof ObservableScrollViewCallbacks ) { Bundle args = getArguments ( ) ; if ( args != null && args . containsKey ( ARG_INITIAL_POSITION ) ) { final int initialPosition = args . getInt ( ARG_INITIAL_POSITION , 0 ) ; ScrollUtils . addOnGlobalLayoutListener ( listView , new Runnable ( ) { @ Override public void run ( ) { listView . setSelection ( initialPosition ) ; } } ) ; } listView . setTouchInterceptionViewGroup ( ( ViewGroup ) parentActivity . findViewById ( R . id . root ) ) ; listView . setScrollViewCallbacks ( ( ObservableScrollViewCallbacks ) parentActivity ) ; } return view ; }
@ Override public void run ( ) { listView . setSelection ( initialPosition ) ; }
public Cube ( GLWorld world , float left , float bottom , float back , float right , float top , float front ) { super( world ); GLVertex leftBottomBack = addVertex ( left , bottom , back ) ; GLVertex rightBottomBack = addVertex ( right , bottom , back ) ; GLVertex leftTopBack = addVertex ( left , top , back ) ; GLVertex rightTopBack = addVertex ( right , top , back ) ; GLVertex leftBottomFront = addVertex ( left , bottom , front ) ; GLVertex rightBottomFront = addVertex ( right , bottom , front ) ; GLVertex leftTopFront = addVertex ( left , top , front ) ; GLVertex rightTopFront = addVertex ( right , top , front ) ; addFace ( new GLFace ( leftBottomBack , leftBottomFront , rightBottomFront , rightBottomBack ) ) ; addFace ( new GLFace ( leftBottomFront , leftTopFront , rightTopFront , rightBottomFront ) ) ; addFace ( new GLFace ( leftBottomBack , leftTopBack , leftTopFront , leftBottomFront ) ) ; addFace ( new GLFace ( rightBottomBack , rightBottomFront , rightTopFront , rightTopBack ) ) ; addFace ( new GLFace ( leftBottomBack , rightBottomBack , rightTopBack , leftTopBack ) ) ; addFace ( new GLFace ( leftTopBack , rightTopBack , rightTopFront , leftTopFront ) ) ; }
private static File getDB ( Context context ) { return ObaProvider . getDatabasePath ( context ) ; }
private static File getBackup ( Context context ) { File backupDir = Environment . getExternalStoragePublicDirectory ( BACKUP_TYPE ) ; return new File ( backupDir , BACKUP_NAME ) ; }
public static String backup ( Context context ) throws IOException { File backupPath = getBackup ( context ) ; FileUtils . copyFile ( getDB ( context ) , backupPath ) ; return backupPath . getAbsolutePath ( ) ; }
public static void restore ( Context context ) throws IOException { File dbPath = getDB ( context ) ; File backupPath = getBackup ( context ) ; ContentProviderClient client = null ; try { client = context . getContentResolver ( ) . acquireContentProviderClient ( ObaContract . AUTHORITY ) ; ObaProvider provider = ( ObaProvider ) client . getLocalContentProvider ( ) ; provider . closeDB ( ) ; FileUtils . copyFile ( backupPath , dbPath ) ; } finally { if ( client != null ) { client . release ( ) ; } } }
public static boolean isRestoreAvailable ( Context context ) { return getBackup ( context ) . exists ( ) ; }
public void onRegionTaskFinished ( boolean currentRegionChanged );
public ObaRegionsTask ( Context context , List < ObaRegionsTask . Callback > callbacks ) { mContext = context ; mCallbacks = callbacks ; mForceReload = false ; mShowProgressDialog = true ; }
public ObaRegionsTask ( Context context , List < ObaRegionsTask . Callback > callbacks , boolean force , boolean showProgressDialog ) { mContext = context ; mCallbacks = callbacks ; mForceReload = force ; mShowProgressDialog = showProgressDialog ; GoogleApiAvailability api = GoogleApiAvailability . getInstance ( ) ; if ( api . isGooglePlayServicesAvailable ( context ) == ConnectionResult . SUCCESS ) { mGoogleApiClient = LocationUtils . getGoogleApiClientWithCallbacks ( context ) ; mGoogleApiClient . connect ( ) ; } }
@ Override protected void onPreExecute ( ) { if ( mShowProgressDialog && UIUtils . canManageDialog ( mContext ) ) { if ( mProgressDialogMessage == null ) { mProgressDialogMessage = mContext . getString ( R . string . region_detecting_server ) ; } mProgressDialog = ProgressDialog . show ( mContext , "" , mProgressDialogMessage , true ) ; mProgressDialog . setIndeterminate ( true ) ; mProgressDialog . setCancelable ( false ) ; mProgressDialog . show ( ) ; } super. onPreExecute ( ) ; }
@ Override protected ArrayList < ObaRegion > doInBackground ( Void ... params ) { return RegionUtils . getRegions ( mContext , mForceReload ) ; }
private void doCallback ( final boolean currentRegionChanged ) { final Handler mPauseForCallbackHandler = new Handler ( ) ; final Runnable mPauseForCallback = new Runnable ( ) { public void run ( ) { if ( mCallbacks != null ) { for ( Callback callback : mCallbacks ) { if ( callback != null ) { callback . onRegionTaskFinished ( currentRegionChanged ) ; } } } } } ; mPauseForCallbackHandler . postDelayed ( mPauseForCallback , CALLBACK_DELAY ) ; }
public void run ( ) { if ( mCallbacks != null ) { for ( Callback callback : mCallbacks ) { if ( callback != null ) { callback . onRegionTaskFinished ( currentRegionChanged ) ; } } } }
public void setProgressDialogMessage ( String progressDialogMessage ) { mProgressDialogMessage = progressDialogMessage ; }
public ObservableWebView ( final Context context ) { super( context ); }
public ObservableWebView ( final Context context , final AttributeSet attrs ) { super( context , attrs ); }
public ObservableWebView ( final Context context , final AttributeSet attrs , final int defStyle ) { super( context , attrs , defStyle ); }
@ Override protected void onScrollChanged ( final int l , final int t , final int oldl , final int oldt ) { super. onScrollChanged ( l , t , oldl , oldt ) ; if( mOnScrollChangedCallback != null ) mOnScrollChangedCallback . onScroll ( l , t , oldl , oldt ) ; }
public OnScrollChangedCallback getOnScrollChangedCallback ( ) { return mOnScrollChangedCallback ; }
public void setOnScrollChangedCallback ( final OnScrollChangedCallback onScrollChangedCallback ) { mOnScrollChangedCallback = onScrollChangedCallback ; }
public void onScroll ( int l , int t , int oldL , int oldT );
@ Override public void onCreate ( Bundle savedInstanceState ) { super. onCreate ( savedInstanceState ) ; Log . i ( TAG , "onCreate" ) ; setContentView ( R . layout . main ) ; button = ( Button ) findViewById ( R . id . button_main ) ; textView = ( TextView ) findViewById ( R . id . textview_hello ) ; button . setOnClickListener ( new ButtonClickListener ( ) ) ; computer = new DummyComputer ( ) ; }
public void setComputer ( Computer computer ) { this . computer = computer ; }
public SimpleHeaderRecyclerAdapter ( Context context , ArrayList < String > items , View headerView ) { mInflater = LayoutInflater . from ( context ) ; mItems = items ; mHeaderView = headerView ; }
@ Override public int getItemCount ( ) { if ( mHeaderView == null ) { return mItems . size ( ) ; } else { return mItems . size ( ) + 1 ; } }
@ Override public int getItemViewType ( int position ) { return ( position == 0 ) ? VIEW_TYPE_HEADER : VIEW_TYPE_ITEM ; }
@ Override public RecyclerView . ViewHolder onCreateViewHolder ( ViewGroup parent , int viewType ) { if ( viewType == VIEW_TYPE_HEADER ) { return new HeaderViewHolder ( mHeaderView ) ; } else { return new ItemViewHolder ( mInflater . inflate ( android . R . layout . simple_list_item_1 , parent , false ) ) ; } }
@ Override public void onBindViewHolder ( RecyclerView . ViewHolder viewHolder , int position ) { if ( viewHolder instanceof ItemViewHolder ) { ( ( ItemViewHolder ) viewHolder ) . textView . setText ( mItems . get ( position - 1 ) ) ; } }
public HeaderViewHolder ( View view ) { super( view ); }
public ItemViewHolder ( View view ) { super( view ); textView = ( TextView ) view . findViewById ( android . R . id . text1 ) ; }
@ Override protected void onCreate ( Bundle savedInstanceState ) { super. onCreate ( savedInstanceState ) ; final Resources res = getResources ( ) ; final ActionBar bar = getSupportActionBar ( ) ; bar . setNavigationMode ( ActionBar . NAVIGATION_MODE_TABS ) ; bar . setDisplayOptions ( 0 , ActionBar . DISPLAY_SHOW_TITLE ) ; bar . addTab ( bar . newTab ( ) . setTag ( MyRecentStopsFragment . TAB_NAME ) . setText ( res . getString ( R . string . my_recent_title ) ) . setIcon ( res . getDrawable ( R . drawable . ic_tab_recent ) ) . setTabListener ( new TabListener < MyRecentStopsFragment > ( this , MyRecentStopsFragment . TAB_NAME , MyRecentStopsFragment .class ) ) ) ; bar . addTab ( bar . newTab ( ) . setTag ( MyStarredStopsFragment . TAB_NAME ) . setText ( res . getString ( R . string . my_starred_title ) ) . setIcon ( res . getDrawable ( R . drawable . ic_tab_starred ) ) . setTabListener ( new TabListener < MyStarredStopsFragment > ( this , MyStarredStopsFragment . TAB_NAME , MyStarredStopsFragment .class ) ) ) ; bar . addTab ( bar . newTab ( ) . setTag ( MySearchStopsFragment . TAB_NAME ) . setText ( res . getString ( R . string . my_search_title ) ) . setIcon ( res . getDrawable ( R . drawable . ic_tab_search ) ) . setTabListener ( new TabListener < MySearchStopsFragment > ( this , MySearchStopsFragment . TAB_NAME , MySearchStopsFragment .class ) ) ) ; restoreDefaultTab ( ) ; UIUtils . setupActionBar ( this ) ; }
@ Override protected void onStart ( ) { super. onStart ( ) ; ObaAnalytics . reportActivityStart ( this ) ; }
@ Override protected String getLastTabPref ( ) { return "MyStopsActivity.LastTab" ; }
public static ObaRegion getTampa ( Context context ) { ArrayList < ObaRegion > regions = RegionUtils . getRegionsFromResources ( context ) ; for ( ObaRegion r : regions ) { if ( r . getId ( ) == TAMPA_REGION_ID ) { return r ; } } return null ; }
public static ObaRegion getPugetSound ( Context context ) { ArrayList < ObaRegion > regions = RegionUtils . getRegionsFromResources ( context ) ; for ( ObaRegion r : regions ) { if ( r . getId ( ) == PUGET_SOUND_REGION_ID ) { return r ; } } return null ; }
public static ObaRegion getAtlanta ( Context context ) { ArrayList < ObaRegion > regions = RegionUtils . getRegionsFromResources ( context ) ; for ( ObaRegion r : regions ) { if ( r . getId ( ) == ATLANTA_REGION_ID ) { return r ; } } return null ; }
public static ObaRegion getRegionWithPathNoSeparator ( Context context ) { ObaRegionElement . Bounds bound = new ObaRegionElement . Bounds ( 27.976910500000002 , - 82.445851 , 0.5424609999999994 , 0.576357999999999 ) ; ObaRegionElement . Bounds [] bounds = new ObaRegionElement . Bounds [ 1 ] ; bounds [ 0 ] = bound ; return new ObaRegionElement ( 0 , "Test-RegionWithPathNoSeparator" , true , "http: , null , bounds , new ObaRegionElement . Open311Server [ 0 ] , "en_US" , "[email protected]" , true , true , false , null , false , null , null , null ) ; }
public static ObaRegion getRegionNoSeparator ( Context context ) { ObaRegionElement . Bounds bound = new ObaRegionElement . Bounds ( 47.221315 , - 122.4051325 , 0.33704 , 0.440483 ) ; ObaRegionElement . Bounds [] bounds = new ObaRegionElement . Bounds [ 1 ] ; bounds [ 0 ] = bound ; return new ObaRegionElement ( 0 , "Test-RegionWithPathNoSeparator" , true , "http: , null , bounds , new ObaRegionElement . Open311Server [ 0 ] , "en_US" , "[email protected]" , true , true , false , null , false , "http: , null , null ) ; }
public static ObaRegion getRegionWithPort ( Context context ) { ObaRegionElement . Bounds bound = new ObaRegionElement . Bounds ( 27.976910500000002 , - 82.445851 , 0.5424609999999994 , 0.576357999999999 ) ; ObaRegionElement . Bounds [] bounds = new ObaRegionElement . Bounds [ 1 ] ; bounds [ 0 ] = bound ; return new ObaRegionElement ( 0 , "Test-RegionWithPort" , true , "http: , null , bounds , new ObaRegionElement . Open311Server [ 0 ] , "en_US" , "[email protected]" , true , true , false , null , false , null , null , null ) ; }
public static ObaRegion getRegionNoScheme ( Context context ) { ObaRegionElement . Bounds bound = new ObaRegionElement . Bounds ( 27.976910500000002 , - 82.445851 , 0.5424609999999994 , 0.576357999999999 ) ; ObaRegionElement . Bounds [] bounds = new ObaRegionElement . Bounds [ 1 ] ; bounds [ 0 ] = bound ; return new ObaRegionElement ( 0 , "Test-RegionNoScheme" , true , "api.tampa.onebusaway.org/api/" , null , bounds , new ObaRegionElement . Open311Server [ 0 ] , "en_US" , "[email protected]" , true , true , false , null , false , null , null , null ) ; }
public static ObaRegion getRegionWithHttps ( ) { ObaRegionElement . Bounds bound = new ObaRegionElement . Bounds ( 27.976910500000002 , - 82.445851 , 0.5424609999999994 , 0.576357999999999 ) ; ObaRegionElement . Bounds [] bounds = new ObaRegionElement . Bounds [ 1 ] ; bounds [ 0 ] = bound ; return new ObaRegionElement ( 0 , "Test-RegionWithHttps" , true , "https: , null , bounds , new ObaRegionElement . Open311Server [ 0 ] , "en_US" , "[email protected]" , true , true , false , null , false , null , null , null ) ; }
public static ObaRegion getRegionWithHttpsAndPort ( ) { ObaRegionElement . Bounds bound = new ObaRegionElement . Bounds ( 27.976910500000002 , - 82.445851 , 0.5424609999999994 , 0.576357999999999 ) ; ObaRegionElement . Bounds [] bounds = new ObaRegionElement . Bounds [ 1 ] ; bounds [ 0 ] = bound ; return new ObaRegionElement ( 0 , "Test-RegionWithHttpsAndPort" , true , "https: , null , bounds , new ObaRegionElement . Open311Server [ 0 ] , "en_US" , "[email protected]" , true , true , false , null , false , null , null , null ) ; }
public static ObaRegion getRegionWithoutObaApis ( Context context ) { ObaRegionElement . Bounds bound = new ObaRegionElement . Bounds ( 27.976910500000002 , - 82.445851 , 0.5424609999999994 , 0.576357999999999 ) ; ObaRegionElement . Bounds [] bounds = new ObaRegionElement . Bounds [ 1 ] ; bounds [ 0 ] = bound ; return new ObaRegionElement ( 0 , "Test-RegionWithoutOBAApis" , true , "http: , null , bounds , null , "en_US" , "[email protected]" , false , false , false , null , false , null , null , null ) ; }
public static ObaRegion getInactiveRegion ( Context context ) { ObaRegionElement . Bounds bound = new ObaRegionElement . Bounds ( 27.976910500000002 , - 82.445851 , 0.5424609999999994 , 0.576357999999999 ) ; ObaRegionElement . Bounds [] bounds = new ObaRegionElement . Bounds [ 1 ] ; bounds [ 0 ] = bound ; return new ObaRegionElement ( 0 , "Test-RegionWithoutOBAApis" , true , "http: , null , bounds , null , "en_US" , "[email protected]" , false , false , false , null , false , null , null , null ) ; }
public NotifierTask ( Context context , TaskContext taskContext , Uri uri , String notifyText ) { mContext = context ; mTaskContext = taskContext ; mCR = mContext . getContentResolver ( ) ; mUri = uri ; mNotifyText = notifyText ; }
@ Override public void run ( ) { Cursor c = mCR . query ( mUri , ALERT_PROJECTION , null , null , null ) ; try { if ( c != null ) { while ( c . moveToNext ( ) ) { notify ( c ) ; } } } finally { if ( c != null ) { c . close ( ) ; } mTaskContext . taskComplete ( ) ; } }
private void notify ( Cursor c ) { final int id = c . getInt ( COL_ID ) ; final String stopId = c . getString ( COL_STOP_ID ) ; final int state = c . getInt ( COL_STATE ) ; if ( state == ObaContract . TripAlerts . STATE_CANCELLED ) { return; } Intent deleteIntent = new Intent ( mContext , TripService .class ) ; deleteIntent . setAction ( TripService . ACTION_CANCEL ) ; deleteIntent . setData ( mUri ) ; PendingIntent pendingDeleteIntent = PendingIntent . getService ( mContext , 0 , deleteIntent , PendingIntent . FLAG_UPDATE_CURRENT ) ; final PendingIntent pendingContentIntent = PendingIntent . getActivity ( mContext , 0 , new ArrivalsListActivity . Builder ( mContext , stopId ) . getIntent ( ) , PendingIntent . FLAG_UPDATE_CURRENT ) ; Notification notification = createNotification ( mNotifyText , pendingContentIntent , pendingDeleteIntent ) ; mTaskContext . setNotification ( id , notification ) ; }
private Notification createNotification ( String notifyText , PendingIntent contentIntent , PendingIntent deleteIntent ) { final String title = mContext . getString ( R . string . app_name ) ; return new NotificationCompat . Builder ( mContext ) . setSmallIcon ( R . drawable . ic_stat_notification ) . setDefaults ( Notification . DEFAULT_ALL ) . setOnlyAlertOnce ( true ) . setContentIntent ( contentIntent ) . setDeleteIntent ( deleteIntent ) . setContentTitle ( title ) . setContentText ( notifyText ) . build ( ) ; }
@ Override protected void onCreate ( Bundle savedInstanceState ) { super. onCreate ( savedInstanceState ) ; context = getApplicationContext ( ) ; activity = this ; settings = PreferenceManager . getDefaultSharedPreferences ( this . context ) ; protocol = settings . getString ( "git_remote_protocol" , "ssh: ) ; connectionMode = settings . getString ( "git_remote_auth" , "ssh-key" ) ; int operationCode = getIntent ( ) . getExtras ( ) . getInt ( "Operation" ) ; getSupportActionBar ( ) . setDisplayHomeAsUpEnabled ( true ) ; switch ( operationCode ) { case REQUEST_CLONE : case EDIT_SERVER : setContentView ( R . layout . activity_git_clone ) ; setTitle ( R . string . title_activity_git_clone ) ; final Spinner protcol_spinner = ( Spinner ) findViewById ( R . id . clone_protocol ) ; final Spinner connection_mode_spinner = ( Spinner ) findViewById ( R . id . connection_mode ) ; final ArrayAdapter < CharSequence > connection_mode_adapter = ArrayAdapter . createFromResource ( this , R . array . connection_modes , android . R . layout . simple_spinner_item ) ; connection_mode_adapter . setDropDownViewResource ( android . R . layout . simple_spinner_dropdown_item ) ; connection_mode_spinner . setAdapter ( connection_mode_adapter ) ; connection_mode_spinner . setOnItemSelectedListener ( new AdapterView . OnItemSelectedListener ( ) { @ Override public void onItemSelected ( AdapterView < ? > adapterView , View view , int i , long l ) { String selection = ( ( Spinner ) findViewById ( R . id . connection_mode ) ) . getSelectedItem ( ) . toString ( ) ; connectionMode = selection ; settings . edit ( ) . putString ( "git_remote_auth" , selection ) . apply ( ) ; } @ Override public void onNothingSelected ( AdapterView < ? > adapterView ) { } } ) ; ArrayAdapter < CharSequence > protocol_adapter = ArrayAdapter . createFromResource ( this , R . array . clone_protocols , android . R . layout . simple_spinner_item ) ; protocol_adapter . setDropDownViewResource ( android . R . layout . simple_spinner_dropdown_item ) ; protcol_spinner . setAdapter ( protocol_adapter ) ; protcol_spinner . setOnItemSelectedListener ( new AdapterView . OnItemSelectedListener ( ) { @ Override public void onItemSelected ( AdapterView < ? > adapterView , View view , int i , long l ) { protocol = ( ( Spinner ) findViewById ( R . id . clone_protocol ) ) . getSelectedItem ( ) . toString ( ) ; if ( protocol . equals ( "ssh: ) ) { ( ( EditText ) findViewById ( R . id . clone_uri ) ) . setHint ( "user@hostname:path" ) ; ( ( EditText ) findViewById ( R . id . server_port ) ) . setHint ( R . string . default_ssh_port ) ; connection_mode_spinner . setSelection ( 0 ) ; connection_mode_spinner . setEnabled ( true ) ; if ( connectionMode . equals ( "ssh-key" ) ) { connection_mode_spinner . setSelection ( 0 ) ; } else { connection_mode_spinner . setSelection ( 1 ) ; } } else { ( ( EditText ) findViewById ( R . id . clone_uri ) ) . setHint ( "hostname/path" ) ; ( ( EditText ) findViewById ( R . id . server_port ) ) . setHint ( R . string . default_https_port ) ; connection_mode_spinner . setSelection ( 1 ) ; connection_mode_spinner . setEnabled ( false ) ; } } @ Override public void onNothingSelected ( AdapterView < ? > adapterView ) { } } ) ; if ( protocol . equals ( "ssh: ) ) { protcol_spinner . setSelection ( 0 ) ; } else { protcol_spinner . setSelection ( 1 ) ; } final EditText server_url = ( ( EditText ) findViewById ( R . id . server_url ) ) ; final EditText server_port = ( ( EditText ) findViewById ( R . id . server_port ) ) ; final EditText server_path = ( ( EditText ) findViewById ( R . id . server_path ) ) ; final EditText server_user = ( ( EditText ) findViewById ( R . id . server_user ) ) ; final EditText server_uri = ( ( EditText ) findViewById ( R . id . clone_uri ) ) ; View . OnFocusChangeListener updateListener = new View . OnFocusChangeListener ( ) { @ Override public void onFocusChange ( View view , boolean b ) { updateURI ( ) ; } } ; server_url . setText ( settings . getString ( "git_remote_server" , "" ) ) ; server_port . setText ( settings . getString ( "git_remote_port" , "" ) ) ; server_user . setText ( settings . getString ( "git_remote_username" , "" ) ) ; server_path . setText ( settings . getString ( "git_remote_location" , "" ) ) ; server_url . addTextChangedListener ( new TextWatcher ( ) { @ Override public void beforeTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { } @ Override public void onTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { if ( server_url . isFocused ( ) ) updateURI ( ) ; } @ Override public void afterTextChanged ( Editable editable ) { } } ) ; server_port . addTextChangedListener ( new TextWatcher ( ) { @ Override public void beforeTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { } @ Override public void onTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { if ( server_port . isFocused ( ) ) updateURI ( ) ; } @ Override public void afterTextChanged ( Editable editable ) { } } ) ; server_user . addTextChangedListener ( new TextWatcher ( ) { @ Override public void beforeTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { } @ Override public void onTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { if ( server_user . isFocused ( ) ) updateURI ( ) ; } @ Override public void afterTextChanged ( Editable editable ) { } } ) ; server_path . addTextChangedListener ( new TextWatcher ( ) { @ Override public void beforeTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { } @ Override public void onTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { if ( server_path . isFocused ( ) ) updateURI ( ) ; } @ Override public void afterTextChanged ( Editable editable ) { } } ) ; server_uri . addTextChangedListener ( new TextWatcher ( ) { @ Override public void beforeTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { } @ Override public void onTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { if ( server_uri . isFocused ( ) ) splitURI ( ) ; } @ Override public void afterTextChanged ( Editable editable ) { } } ) ; if ( operationCode == EDIT_SERVER ) { findViewById ( R . id . clone_button ) . setVisibility ( View . INVISIBLE ) ; findViewById ( R . id . save_button ) . setVisibility ( View . VISIBLE ) ; } else { findViewById ( R . id . clone_button ) . setVisibility ( View . VISIBLE ) ; findViewById ( R . id . save_button ) . setVisibility ( View . INVISIBLE ) ; } updateURI ( ) ; break; case REQUEST_PULL : syncRepository ( REQUEST_PULL ) ; break; case REQUEST_PUSH : syncRepository ( REQUEST_PUSH ) ; break; case REQUEST_SYNC : syncRepository ( REQUEST_SYNC ) ; break; } }
@ Override public void onItemSelected ( AdapterView < ? > adapterView , View view , int i , long l ) { String selection = ( ( Spinner ) findViewById ( R . id . connection_mode ) ) . getSelectedItem ( ) . toString ( ) ; connectionMode = selection ; settings . edit ( ) . putString ( "git_remote_auth" , selection ) . apply ( ) ; }
@ Override public void onNothingSelected ( AdapterView < ? > adapterView ) { }
@ Override public void onItemSelected ( AdapterView < ? > adapterView , View view , int i , long l ) { protocol = ( ( Spinner ) findViewById ( R . id . clone_protocol ) ) . getSelectedItem ( ) . toString ( ) ; if ( protocol . equals ( "ssh: ) ) { ( ( EditText ) findViewById ( R . id . clone_uri ) ) . setHint ( "user@hostname:path" ) ; ( ( EditText ) findViewById ( R . id . server_port ) ) . setHint ( R . string . default_ssh_port ) ; connection_mode_spinner . setSelection ( 0 ) ; connection_mode_spinner . setEnabled ( true ) ; if ( connectionMode . equals ( "ssh-key" ) ) { connection_mode_spinner . setSelection ( 0 ) ; } else { connection_mode_spinner . setSelection ( 1 ) ; } } else { ( ( EditText ) findViewById ( R . id . clone_uri ) ) . setHint ( "hostname/path" ) ; ( ( EditText ) findViewById ( R . id . server_port ) ) . setHint ( R . string . default_https_port ) ; connection_mode_spinner . setSelection ( 1 ) ; connection_mode_spinner . setEnabled ( false ) ; } }
@ Override public void onNothingSelected ( AdapterView < ? > adapterView ) { }
@ Override public void onFocusChange ( View view , boolean b ) { updateURI ( ) ; }
@ Override public void beforeTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { }
@ Override public void onTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { if ( server_url . isFocused ( ) ) updateURI ( ) ; }
@ Override public void afterTextChanged ( Editable editable ) { }
@ Override public void beforeTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { }
@ Override public void onTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { if ( server_port . isFocused ( ) ) updateURI ( ) ; }
@ Override public void afterTextChanged ( Editable editable ) { }
@ Override public void beforeTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { }
@ Override public void onTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { if ( server_user . isFocused ( ) ) updateURI ( ) ; }
@ Override public void afterTextChanged ( Editable editable ) { }
@ Override public void beforeTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { }
@ Override public void onTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { if ( server_path . isFocused ( ) ) updateURI ( ) ; }
@ Override public void afterTextChanged ( Editable editable ) { }
@ Override public void beforeTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { }
@ Override public void onTextChanged ( CharSequence charSequence , int i , int i2 , int i3 ) { if ( server_uri . isFocused ( ) ) splitURI ( ) ; }
@ Override public void afterTextChanged ( Editable editable ) { }
private void updateURI ( ) { EditText uri = ( EditText ) findViewById ( R . id . clone_uri ) ; EditText server_url = ( ( EditText ) findViewById ( R . id . server_url ) ) ; EditText server_port = ( ( EditText ) findViewById ( R . id . server_port ) ) ; EditText server_path = ( ( EditText ) findViewById ( R . id . server_path ) ) ; EditText server_user = ( ( EditText ) findViewById ( R . id . server_user ) ) ; if ( uri != null ) { switch ( protocol ) { case "ssh: : { String hostname = server_user . getText ( ) + "@" + server_url . getText ( ) . toString ( ) . trim ( ) + ":" ; if ( server_port . getText ( ) . toString ( ) . equals ( "22" ) ) { hostname += server_path . getText ( ) . toString ( ) ; ( ( TextView ) findViewById ( R . id . warn_url ) ) . setVisibility ( View . GONE ) ; } else { TextView warn_url = ( TextView ) findViewById ( R . id . warn_url ) ; if ( ! server_path . getText ( ) . toString ( ) . matches ( "/.*" ) && ! server_port . getText ( ) . toString ( ) . isEmpty ( ) ) { warn_url . setText ( R . string . warn_malformed_url_port ) ; warn_url . setVisibility ( View . VISIBLE ) ; } else { warn_url . setVisibility ( View . GONE ) ; } hostname += server_port . getText ( ) . toString ( ) + server_path . getText ( ) . toString ( ) ; } if ( ! hostname . equals ( "@:" ) ) uri . setText ( hostname ) ; } break; case "https: : { StringBuilder hostname = new StringBuilder ( ) ; hostname . append ( server_url . getText ( ) . toString ( ) . trim ( ) ) ; if ( server_port . getText ( ) . toString ( ) . equals ( "443" ) ) { hostname . append ( server_path . getText ( ) . toString ( ) ) ; ( ( TextView ) findViewById ( R . id . warn_url ) ) . setVisibility ( View . GONE ) ; } else { hostname . append ( "/" ) ; hostname . append ( server_port . getText ( ) . toString ( ) ) . append ( server_path . getText ( ) . toString ( ) ) ; } if ( ! hostname . toString ( ) . equals ( "@/" ) ) uri . setText ( hostname ) ; } break; default: break; } } }
private void splitURI ( ) { EditText server_uri = ( EditText ) findViewById ( R . id . clone_uri ) ; EditText server_url = ( ( EditText ) findViewById ( R . id . server_url ) ) ; EditText server_port = ( ( EditText ) findViewById ( R . id . server_port ) ) ; EditText server_path = ( ( EditText ) findViewById ( R . id . server_path ) ) ; EditText server_user = ( ( EditText ) findViewById ( R . id . server_user ) ) ; String uri = server_uri . getText ( ) . toString ( ) ; Pattern pattern = Pattern . compile ( "(.+)@([\\w\\d\\.]+):([\\d]+)*(.*)" ) ; Matcher matcher = pattern . matcher ( uri ) ; if ( matcher . find ( ) ) { int count = matcher . groupCount ( ) ; if ( count > 1 ) { server_user . setText ( matcher . group ( 1 ) ) ; server_url . setText ( matcher . group ( 2 ) ) ; } if ( count == 4 ) { server_port . setText ( matcher . group ( 3 ) ) ; server_path . setText ( matcher . group ( 4 ) ) ; TextView warn_url = ( TextView ) findViewById ( R . id . warn_url ) ; if ( ! server_path . getText ( ) . toString ( ) . matches ( "/.*" ) && ! server_port . getText ( ) . toString ( ) . isEmpty ( ) ) { warn_url . setText ( R . string . warn_malformed_url_port ) ; warn_url . setVisibility ( View . VISIBLE ) ; } else { warn_url . setVisibility ( View . GONE ) ; } } } }
@ Override public void onResume ( ) { super. onResume ( ) ; updateURI ( ) ; }
@ Override public boolean onCreateOptionsMenu ( Menu menu ) { getMenuInflater ( ) . inflate ( R . menu . git_clone , menu ) ; return true ; }
private boolean saveConfiguration ( ) { SharedPreferences . Editor editor = settings . edit ( ) ; editor . putString ( "git_remote_server" , ( ( EditText ) findViewById ( R . id . server_url ) ) . getText ( ) . toString ( ) ) ; editor . putString ( "git_remote_location" , ( ( EditText ) findViewById ( R . id . server_path ) ) . getText ( ) . toString ( ) ) ; editor . putString ( "git_remote_username" , ( ( EditText ) findViewById ( R . id . server_user ) ) . getText ( ) . toString ( ) ) ; editor . putString ( "git_remote_protocol" , protocol ) ; editor . putString ( "git_remote_auth" , connectionMode ) ; editor . putString ( "git_remote_port" , ( ( EditText ) findViewById ( R . id . server_port ) ) . getText ( ) . toString ( ) ) ; editor . putString ( "git_remote_uri" , ( ( EditText ) findViewById ( R . id . clone_uri ) ) . getText ( ) . toString ( ) ) ; hostname = ( ( EditText ) findViewById ( R . id . clone_uri ) ) . getText ( ) . toString ( ) ; port = ( ( EditText ) findViewById ( R . id . server_port ) ) . getText ( ) . toString ( ) ; hostname = hostname . replaceFirst ( "^.+: , "" ) ; ( ( TextView ) findViewById ( R . id . clone_uri ) ) . setText ( hostname ) ; if ( ! protocol . equals ( "ssh: ) ) { hostname = protocol + hostname ; } else { if ( ! port . isEmpty ( ) && ! port . equals ( "22" ) ) hostname = protocol + hostname ; if ( ! hostname . matches ( "^.+@.+" ) ) { new AlertDialog . Builder ( this ) . setMessage ( activity . getResources ( ) . getString ( R . string . forget_username_dialog_text ) ) . setPositiveButton ( activity . getResources ( ) . getString ( R . string . dialog_oops ) , null ) . show ( ) ; return false ; } } if ( PasswordRepository . isInitialized ( ) ) { PasswordRepository . addRemote ( "origin" , hostname , true ) ; } editor . apply ( ) ; return true ; }
public void saveConfiguration ( View view ) { if ( ! saveConfiguration ( ) ) return; finish ( ) ; }
public void onClick ( DialogInterface dialog , int id ) { try { FileUtils . deleteDirectory ( localDir ) ; try { new CloneOperation ( localDir , activity ) . setCommand ( hostname ) . executeAfterAuthentication ( connectionMode , settings . getString ( "git_remote_username" , "git" ) , new File ( getFilesDir ( ) + "/.ssh_key" ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; new AlertDialog . Builder ( GitActivity .this ) . setMessage ( e . getMessage ( ) ) . show ( ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; new AlertDialog . Builder ( GitActivity .this ) . setMessage ( e . getMessage ( ) ) . show ( ) ; } dialog . cancel ( ) ; }
public void onClick ( DialogInterface dialog , int id ) { dialog . cancel ( ) ; }
@ Override public void onClick ( DialogInterface dialogInterface , int i ) { Intent intent = new Intent ( activity , UserPreference .class ) ; startActivityForResult ( intent , REQUEST_PULL ) ; }
@ Override public void onClick ( DialogInterface dialogInterface , int i ) { setResult ( RESULT_OK ) ; finish ( ) ; }
void onFocusChanged ( ObaStop stop , HashMap < String , ObaRoute > routes , Location location );
void onProgressBarChanged ( boolean showProgressBar );
public static BaseMapFragment newInstance ( ) { return new BaseMapFragment ( ) ; }
@ Override public View onCreateView ( LayoutInflater inflater , ViewGroup container , Bundle savedInstanceState ) { View v = super. onCreateView ( inflater , container , savedInstanceState ) ; mLocationHelper = new LocationHelper ( getActivity ( ) ) ; mLocationHelper . registerListener ( this ) ; if ( MapHelpV2 . isMapsInstalled ( getActivity ( ) ) ) { mLastSavedInstanceState = savedInstanceState ; getMapAsync ( this ) ; } else { MapHelpV2 . promptUserInstallMaps ( getActivity ( ) ) ; } Location l = Application . getLastKnownLocation ( getActivity ( ) , mLocationHelper . getGoogleApiClient ( ) ) ; if ( l != null ) { final long TIME_THRESHOLD = TimeUnit . MINUTES . toMillis ( 5 ) ; if ( System . currentTimeMillis ( ) - l . getTime ( ) < TIME_THRESHOLD ) { onLocationChanged ( l ) ; } } return v ; }
@ Override public void onMapReady ( com . google . android . gms . maps . GoogleMap map ) { mMap = map ; initMap ( mLastSavedInstanceState ) ; }
private void initMap ( Bundle savedInstanceState ) { UiSettings uiSettings = mMap . getUiSettings ( ) ; mMap . setMyLocationEnabled ( true ) ; mMap . setLocationSource ( this ) ; mMap . setOnCameraChangeListener ( this ) ; uiSettings . setMyLocationButtonEnabled ( false ) ; uiSettings . setZoomControlsEnabled ( false ) ; uiSettings . setMapToolbarEnabled ( false ) ; mSimpleMarkerOverlay = new SimpleMarkerOverlay ( mMap ) ; if ( savedInstanceState != null ) { initMapState ( savedInstanceState ) ; } else { Bundle args = getActivity ( ) . getIntent ( ) . getExtras ( ) ; if ( args == null ) { args = new Bundle ( ) ; } double lat = args . getDouble ( MapParams . CENTER_LAT , 0.0d ) ; double lon = args . getDouble ( MapParams . CENTER_LON , 0.0d ) ; if ( lat == 0.0d && lon == 0.0d ) { PreferenceUtils . maybeRestoreMapViewToBundle ( args ) ; } initMapState ( args ) ; } }
private void initMapState ( Bundle args ) { mFocusStopId = args . getString ( MapParams . STOP_ID ) ; mMapPaddingLeft = args . getInt ( MapParams . MAP_PADDING_LEFT , MapParams . DEFAULT_MAP_PADDING ) ; mMapPaddingTop = args . getInt ( MapParams . MAP_PADDING_TOP , MapParams . DEFAULT_MAP_PADDING ) ; mMapPaddingRight = args . getInt ( MapParams . MAP_PADDING_RIGHT , MapParams . DEFAULT_MAP_PADDING ) ; mMapPaddingBottom = args . getInt ( MapParams . MAP_PADDING_BOTTOM , MapParams . DEFAULT_MAP_PADDING ) ; setPadding ( mMapPaddingLeft , mMapPaddingTop , mMapPaddingRight , mMapPaddingBottom ) ; String mode = args . getString ( MapParams . MODE ) ; if ( mode == null ) { mode = MapParams . MODE_STOP ; } setMapMode ( mode , args ) ; }
@ Override public void onDestroy ( ) { if ( mController != null ) { mController . destroy ( ) ; } super. onDestroy ( ) ; }
@ Override public void onPause ( ) { if ( mLocationHelper != null ) { mLocationHelper . onPause ( ) ; } if ( mController != null ) { mController . onPause ( ) ; } Location center = getMapCenterAsLocation ( ) ; if ( center != null ) { PreferenceUtils . saveMapViewToPreferences ( center . getLatitude ( ) , center . getLongitude ( ) , getZoomLevelAsFloat ( ) ) ; } mRunning = false ; super. onPause ( ) ; }
@ Override public void onHiddenChanged ( boolean hidden ) { if ( mController != null ) { mController . onHidden ( hidden ) ; } super. onHiddenChanged ( hidden ) ; }
@ Override public void onResume ( ) { if ( mLocationHelper != null ) { mLocationHelper . onResume ( ) ; } mRunning = true ; if ( mController != null ) { mController . onResume ( ) ; } super. onResume ( ) ; }
@ Override public void onSaveInstanceState ( Bundle outState ) { if ( mController != null ) { mController . onSaveInstanceState ( outState ) ; } outState . putString ( MapParams . MODE , getMapMode ( ) ) ; outState . putString ( MapParams . STOP_ID , mFocusStopId ) ; Location center = getMapCenterAsLocation ( ) ; if ( mMap != null ) { outState . putDouble ( MapParams . CENTER_LAT , center . getLatitude ( ) ) ; outState . putDouble ( MapParams . CENTER_LON , center . getLongitude ( ) ) ; outState . putFloat ( MapParams . ZOOM , getZoomLevelAsFloat ( ) ) ; } outState . putInt ( MapParams . MAP_PADDING_LEFT , mMapPaddingLeft ) ; outState . putInt ( MapParams . MAP_PADDING_TOP , mMapPaddingTop ) ; outState . putInt ( MapParams . MAP_PADDING_RIGHT , mMapPaddingRight ) ; outState . putInt ( MapParams . MAP_PADDING_BOTTOM , mMapPaddingBottom ) ; }
@ Override public void onViewStateRestored ( Bundle savedInstanceState ) { if ( mController != null ) { mController . onViewStateRestored ( savedInstanceState ) ; } super. onViewStateRestored ( savedInstanceState ) ; }
public boolean isRouteDisplayed ( ) { return ( mController != null ) && MapParams . MODE_ROUTE . equals ( mController . getMode ( ) ) ; }
public boolean setupStopOverlay ( ) { if ( mStopOverlay != null ) { return true ; } if ( mMap == null ) { return false ; } mStopOverlay = new StopOverlay ( getActivity ( ) , mMap ) ; mStopOverlay . setOnFocusChangeListener ( this ) ; return true ; }
public void setupVehicleOverlay ( ) { Activity a = getActivity ( ) ; if ( mVehicleOverlay == null && a != null ) { mVehicleOverlay = new VehicleOverlay ( a , mMap ) ; mVehicleOverlay . setController ( this ) ; } }
protected void showDialog ( int id ) { MapDialogFragment . newInstance ( id , this ) . show ( getFragmentManager ( ) , MapDialogFragment . TAG ) ; }
@ Override public String getMapMode ( ) { if ( mController != null ) { return mController . getMode ( ) ; } return null ; }
@ Override public void setMapMode ( String mode , Bundle args ) { String oldMode = getMapMode ( ) ; if ( oldMode != null && oldMode . equals ( mode ) ) { mController . setState ( args ) ; return; } if ( mController != null ) { mController . destroy ( ) ; } if ( mStopOverlay != null ) { mStopOverlay . clear ( false ) ; } if ( MapParams . MODE_ROUTE . equals ( mode ) ) { mController = new RouteMapController ( this ) ; } else if ( MapParams . MODE_STOP . equals ( mode ) ) { mController = new StopMapController ( this ) ; } else if ( MapParams . MODE_DIRECTIONS . equals ( mode ) ) { mController = new DirectionsMapController ( this ) ; } mController . setState ( args ) ; mController . onResume ( ) ; }
@ Override public MapModeController . ObaMapView getMapView ( ) { return this ; }
@ Override public int addMarker ( Location location , Float hue ) { if ( mSimpleMarkerOverlay == null ) { return - 1 ; } return mSimpleMarkerOverlay . addMarker ( location , hue ) ; }
@ Override public void removeMarker ( int markerId ) { if ( mSimpleMarkerOverlay == null ) { return; } mSimpleMarkerOverlay . removeMarker ( markerId ) ; }
@ Override public void setPadding ( Integer left , Integer top , Integer right , Integer bottom ) { if ( left != null ) { mMapPaddingLeft = left ; } if ( top != null ) { mMapPaddingTop = top ; } if ( right != null ) { mMapPaddingRight = right ; } if ( bottom != null ) { mMapPaddingBottom = bottom ; } if ( mMap != null ) { mMap . setPadding ( mMapPaddingLeft , mMapPaddingTop , mMapPaddingRight , mMapPaddingBottom ) ; } }
@ Override public void showProgress ( boolean show ) { if ( mOnProgressBarChangedListener != null ) { mOnProgressBarChangedListener . onProgressBarChanged ( show ) ; } }
@ Override public void showStops ( List < ObaStop > stops , ObaReferences refs ) { if ( setupStopOverlay ( ) && stops != null ) { mStopOverlay . populateStops ( stops , refs ) ; } }
@ Override public void notifyOutOfRange ( ) { String serverName = Application . get ( ) . getCustomApiUrl ( ) ; if ( mWarnOutOfRange && ( Application . get ( ) . getCurrentRegion ( ) != null || ! TextUtils . isEmpty ( serverName ) ) ) { if ( mRunning && UIUtils . canManageDialog ( getActivity ( ) ) ) { showDialog ( MapDialogFragment . OUTOFRANGE_DIALOG ) ; } } }
@ Override public void onRegionTaskFinished ( boolean currentRegionChanged ) { if ( ! isAdded ( ) ) { return; } Location l = Application . getLastKnownLocation ( getActivity ( ) , mLocationHelper . getGoogleApiClient ( ) ) ; Location mapCenter = getMapCenterAsLocation ( ) ; if ( currentRegionChanged && ( l == null || ( mapCenter != null && mapCenter . getLatitude ( ) == 0.0 && mapCenter . getLongitude ( ) == 0.0 ) ) ) { zoomToRegion ( ) ; } }
public void setOnFocusChangeListener ( OnFocusChangedListener onFocusChangedListener ) { mOnFocusChangedListener = onFocusChangedListener ; }
public void setOnProgressBarChangedListener ( OnProgressBarChangedListener onProgressBarChangedListener ) { mOnProgressBarChangedListener = onProgressBarChangedListener ; }
public void onFocusChanged ( final ObaStop stop , final HashMap < String , ObaRoute > routes , final Location location ) { mStopChangedHandler . post ( new Runnable ( ) { public void run ( ) { if ( stop != null ) { mFocusStopId = stop . getId ( ) ; } else { mFocusStopId = null ; } if ( mOnFocusChangedListener != null ) { mOnFocusChangedListener . onFocusChanged ( stop , routes , location ) ; } } } ) ; }
public void run ( ) { if ( stop != null ) { mFocusStopId = stop . getId ( ) ; } else { mFocusStopId = null ; } if ( mOnFocusChangedListener != null ) { mOnFocusChangedListener . onFocusChanged ( stop , routes , location ) ; } }
@ Override @ SuppressWarnings ( "deprecation" ) public boolean setMyLocation ( boolean useDefaultZoom , boolean animateToLocation ) { if ( ! LocationUtils . isLocationEnabled ( getActivity ( ) ) && mRunning && UIUtils . canManageDialog ( getActivity ( ) ) ) { SharedPreferences prefs = Application . getPrefs ( ) ; if ( ! prefs . getBoolean ( getString ( R . string . preference_key_never_show_location_dialog ) , false ) ) { showDialog ( MapDialogFragment . NOLOCATION_DIALOG ) ; } return false ; } GoogleApiClient apiClient = null ; if ( mLocationHelper != null ) { apiClient = mLocationHelper . getGoogleApiClient ( ) ; } Location lastLocation = Application . getLastKnownLocation ( getActivity ( ) , apiClient ) ; if ( lastLocation == null ) { Toast . makeText ( getActivity ( ) , getResources ( ) . getString ( R . string . main_waiting_for_location ) , Toast . LENGTH_SHORT ) . show ( ) ; return false ; } setMyLocation ( lastLocation , useDefaultZoom , animateToLocation ) ; return true ; }
private void setMyLocation ( Location l , boolean useDefaultZoom , boolean animateToLocation ) { if ( mMap != null ) { CameraPosition . Builder cameraPosition = new CameraPosition . Builder ( ) . target ( MapHelpV2 . makeLatLng ( l ) ) ; if ( useDefaultZoom ) { cameraPosition . zoom ( CAMERA_DEFAULT_ZOOM ) ; } else { cameraPosition . zoom ( mMap . getCameraPosition ( ) . zoom ) ; } if ( animateToLocation ) { mMap . animateCamera ( CameraUpdateFactory . newCameraPosition ( cameraPosition . build ( ) ) ) ; } else { mMap . moveCamera ( CameraUpdateFactory . newCameraPosition ( cameraPosition . build ( ) ) ) ; } } if ( mController != null ) { mController . onLocation ( ) ; } }
public void zoomToRegion ( ) { ObaRegion region = Application . get ( ) . getCurrentRegion ( ) ; if ( region != null && mMap != null ) { LatLngBounds b = MapHelpV2 . getRegionBounds ( region ) ; int width = getResources ( ) . getDisplayMetrics ( ) . widthPixels ; int height = getResources ( ) . getDisplayMetrics ( ) . heightPixels ; int padding = 0 ; mMap . animateCamera ( ( CameraUpdateFactory . newLatLngBounds ( b , width , height , padding ) ) ) ; } }
public static void showMapError ( ObaResponse response ) { Context context = Application . get ( ) . getApplicationContext ( ) ; int code ; if ( response != null ) { code = response . getCode ( ) ; } else { code = ObaApi . OBA_INTERNAL_ERROR ; } if ( UIUtils . canManageDialog ( context ) ) { Toast . makeText ( context , context . getString ( UIUtils . getMapErrorString ( context , code ) ) , Toast . LENGTH_LONG ) . show ( ) ; } }
@ Override public void setZoom ( float zoomLevel ) { if ( mMap != null ) { mMap . moveCamera ( CameraUpdateFactory . zoomTo ( zoomLevel ) ) ; } }
@ Override public Location getMapCenterAsLocation ( ) { if ( mMap != null ) { LatLng center = mMap . getCameraPosition ( ) . target ; if ( mCenter == null || mCenter != center ) { mCenter = center ; mCenterLocation = MapHelpV2 . makeLocation ( mCenter ) ; } } return mCenterLocation ; }
@ Override public void setMapCenter ( Location location , boolean animateToLocation , boolean overlayExpanded ) { if ( mMap != null ) { CameraPosition cp = mMap . getCameraPosition ( ) ; LatLng target = MapHelpV2 . makeLatLng ( location ) ; LatLng offsetTarget ; if ( isRouteDisplayed ( ) && overlayExpanded ) { double percentageOffset = 0.2 ; double bias = ( getLongitudeSpanInDecDegrees ( ) * percentageOffset ) / 2 ; offsetTarget = new LatLng ( target . latitude - bias , target . longitude ) ; target = offsetTarget ; } if ( animateToLocation ) { mMap . animateCamera ( CameraUpdateFactory . newCameraPosition ( new CameraPosition . Builder ( ) . target ( target ) . zoom ( cp . zoom ) . bearing ( cp . bearing ) . tilt ( cp . tilt ) . build ( ) ) ) ; } else { mMap . moveCamera ( CameraUpdateFactory . newCameraPosition ( new CameraPosition . Builder ( ) . target ( target ) . zoom ( cp . zoom ) . bearing ( cp . bearing ) . tilt ( cp . tilt ) . build ( ) ) ) ; } } }
@ Override public double getLatitudeSpanInDecDegrees ( ) { VisibleRegion vr = mMap . getProjection ( ) . getVisibleRegion ( ) ; return Math . abs ( vr . latLngBounds . northeast . latitude - vr . latLngBounds . southwest . latitude ) ; }
@ Override public double getLongitudeSpanInDecDegrees ( ) { VisibleRegion vr = mMap . getProjection ( ) . getVisibleRegion ( ) ; return Math . abs ( vr . latLngBounds . northeast . longitude - vr . latLngBounds . southwest . longitude ) ; }
@ Override public float getZoomLevelAsFloat ( ) { return mMap . getCameraPosition ( ) . zoom ; }
@ Override public void setRouteOverlay ( int lineOverlayColor , ObaShape [] shapes ) { setRouteOverlay ( lineOverlayColor , shapes , true ) ; }
@ Override public void updateVehicles ( HashSet < String > routeIds , ObaTripsForRouteResponse response ) { setupVehicleOverlay ( ) ; if ( mVehicleOverlay != null ) { mVehicleOverlay . updateVehicles ( routeIds , response ) ; } }
@ Override public void removeVehicleOverlay ( ) { if ( mVehicleOverlay != null ) { mVehicleOverlay . clear ( ) ; } }
@ Override public void zoomToRoute ( ) { if ( mMap != null ) { if ( ! mLineOverlay . isEmpty ( ) ) { LatLngBounds . Builder builder = new LatLngBounds . Builder ( ) ; for ( Polyline p : mLineOverlay ) { for ( LatLng l : p . getPoints ( ) ) { builder . include ( l ) ; } } Activity a = getActivity ( ) ; if ( a != null ) { int padding = UIUtils . dpToPixels ( a , DEFAULT_MAP_PADDING_DP ) ; mMap . moveCamera ( ( CameraUpdateFactory . newLatLngBounds ( builder . build ( ) , padding ) ) ) ; } } else { Toast . makeText ( getActivity ( ) , getString ( R . string . route_info_no_shape_data ) , Toast . LENGTH_SHORT ) . show ( ) ; } } }
@ Override public void zoomToItinerary ( ) { if ( mMap != null ) { if ( ! mLineOverlay . isEmpty ( ) ) { LatLngBounds . Builder builder = new LatLngBounds . Builder ( ) ; for ( Polyline p : mLineOverlay ) { for ( LatLng l : p . getPoints ( ) ) { builder . include ( l ) ; } } Activity a = getActivity ( ) ; if ( a != null ) { int padding = UIUtils . dpToPixels ( a , DEFAULT_MAP_PADDING_DP ) ; mMap . moveCamera ( ( CameraUpdateFactory . newLatLngBounds ( builder . build ( ) , getResources ( ) . getDisplayMetrics ( ) . widthPixels , getResources ( ) . getDisplayMetrics ( ) . heightPixels , padding ) ) ) ; } } } }
@ Override public void zoomIncludeClosestVehicle ( HashSet < String > routeIds , ObaTripsForRouteResponse response ) { if ( mMap == null ) { return; } LatLng closestVehicleLocation = MapHelpV2 . getClosestVehicle ( response , routeIds , getMapCenterAsLocation ( ) ) ; LatLngBounds visibleBounds = mMap . getProjection ( ) . getVisibleRegion ( ) . latLngBounds ; if ( closestVehicleLocation == null || visibleBounds . contains ( closestVehicleLocation ) ) { return; } LatLngBounds . Builder builder = new LatLngBounds . Builder ( ) ; builder . include ( visibleBounds . northeast ) ; builder . include ( visibleBounds . southwest ) ; builder . include ( closestVehicleLocation ) ; Activity a = getActivity ( ) ; if ( a != null ) { int padding = UIUtils . dpToPixels ( a , DEFAULT_MAP_PADDING_DP ) ; mMap . animateCamera ( CameraUpdateFactory . newLatLngBounds ( builder . build ( ) , padding ) ) ; } }
@ Override public void removeRouteOverlay ( ) { for ( Polyline p : mLineOverlay ) { p . remove ( ) ; } mLineOverlay . clear ( ) ; }
@ Override public void removeStopOverlay ( boolean clearFocusedStop ) { if ( mStopOverlay != null ) { mStopOverlay . clear ( clearFocusedStop ) ; } }
@ Override public boolean canWatchMapChanges ( ) { return true ; }
@ Override public void setFocusStop ( ObaStop stop , List < ObaRoute > routes ) { if ( setupStopOverlay ( ) ) { mStopOverlay . setFocus ( stop , routes ) ; } }
@ Override public void onCameraChange ( CameraPosition cameraPosition ) { Log . d ( TAG , "onCameraChange" ) ; if ( mController != null ) { mController . notifyMapChanged ( ) ; } }
@ Override public void activate ( OnLocationChangedListener listener ) { mListener = listener ; }
@ Override public void deactivate ( ) { mListener = null ; }
public void onLocationChanged ( Location l ) { if ( mListener != null ) { mListener . onLocationChanged ( l ) ; } }
@ Override public void postInvalidate ( ) { }
@ Override public String getFocusedStopId ( ) { return mFocusStopId ; }
static MapDialogFragment newInstance ( int dialogType , BaseMapFragment fragment ) { mMapFragment = fragment ; MapDialogFragment f = new MapDialogFragment ( ) ; Bundle args = new Bundle ( ) ; args . putInt ( DIALOG_TYPE_KEY , dialogType ) ; f . setArguments ( args ) ; f . setCancelable ( false ) ; return f ; }
private Dialog createOutOfRangeDialog ( ) { Drawable icon = getResources ( ) . getDrawable ( android . R . drawable . ic_dialog_map ) ; DrawableCompat . setTint ( icon , getResources ( ) . getColor ( R . color . theme_primary ) ) ; AlertDialog . Builder builder = new AlertDialog . Builder ( getActivity ( ) ) . setTitle ( R . string . main_outofrange_title ) . setIcon ( icon ) . setCancelable ( false ) . setMessage ( getString ( R . string . main_outofrange , Application . get ( ) . getCurrentRegion ( ) != null ? Application . get ( ) . getCurrentRegion ( ) . getName ( ) : "" ) ) . setPositiveButton ( R . string . main_outofrange_yes , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { mMapFragment . zoomToRegion ( ) ; } } ) . setNegativeButton ( R . string . main_outofrange_no , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { mMapFragment . mWarnOutOfRange = false ; } } ) ; return builder . create ( ) ; }
@ Override public void onClick ( DialogInterface dialog , int which ) { mMapFragment . zoomToRegion ( ) ; }
@ Override public void onClick ( DialogInterface dialog , int which ) { mMapFragment . mWarnOutOfRange = false ; }
@ SuppressWarnings ( "deprecation" ) private Dialog createNoLocationDialog ( ) { View view = getActivity ( ) . getLayoutInflater ( ) . inflate ( R . layout . no_location_dialog , null ) ; CheckBox neverShowDialog = ( CheckBox ) view . findViewById ( R . id . location_never_ask_again ) ; neverShowDialog . setOnCheckedChangeListener ( new CompoundButton . OnCheckedChangeListener ( ) { @ Override public void onCheckedChanged ( CompoundButton compoundButton , boolean isChecked ) { PreferenceUtils . saveBoolean ( getString ( R . string . preference_key_never_show_location_dialog ) , isChecked ) ; } } ) ; Drawable icon = getResources ( ) . getDrawable ( android . R . drawable . ic_dialog_map ) ; DrawableCompat . setTint ( icon , getResources ( ) . getColor ( R . color . theme_primary ) ) ; AlertDialog . Builder builder = new AlertDialog . Builder ( getActivity ( ) ) . setTitle ( R . string . main_nolocation_title ) . setIcon ( icon ) . setCancelable ( false ) . setView ( view ) . setPositiveButton ( R . string . rt_yes , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { startActivityForResult ( new Intent ( Settings . ACTION_LOCATION_SOURCE_SETTINGS ) , REQUEST_NO_LOCATION ) ; } } ) . setNegativeButton ( R . string . rt_no , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { mMapFragment . mController . onLocation ( ) ; } } ) ; return builder . create ( ) ; }
@ Override public void onCheckedChanged ( CompoundButton compoundButton , boolean isChecked ) { PreferenceUtils . saveBoolean ( getString ( R . string . preference_key_never_show_location_dialog ) , isChecked ) ; }
@ Override public void onClick ( DialogInterface dialog , int which ) { startActivityForResult ( new Intent ( Settings . ACTION_LOCATION_SOURCE_SETTINGS ) , REQUEST_NO_LOCATION ) ; }
@ Override public void onClick ( DialogInterface dialog , int which ) { mMapFragment . mController . onLocation ( ) ; }
private void computeDuplicateFilesInSource ( File folder ) { String rPath = folder . getAbsolutePath ( ) ; for ( File file : Files . fileTreeTraverser ( ) . breadthFirstTraversal ( folder ) . toList ( ) ) { String lPath = file . getAbsolutePath ( ) ; if ( lPath . equals ( rPath ) ) { continue; } lPath = lPath . substring ( rPath . length ( ) + 1 ) ; if ( jars . get ( lPath ) == null ) { jars . put ( lPath , new ArrayList < File > ( ) ) ; } jars . get ( lPath ) . add ( folder ) ; } }
public boolean accept ( File dir , String name ) { return PATTERN_JAR_EXT . matcher ( name ) . matches ( ) ; }
private void addSecondaryDexes ( File dexFile , ApkBuilder apkBuilder ) throws ApkCreationException , SealedApkException , DuplicateFileException { int dexNumber = 2 ; String dexFileName = getNextDexFileName ( dexNumber ) ; File secondDexFile = createNextDexFile ( dexFile , dexFileName ) ; while ( secondDexFile . exists ( ) ) { apkBuilder . addFile ( secondDexFile , dexFileName ) ; dexNumber ++ ; dexFileName = getNextDexFileName ( dexNumber ) ; secondDexFile = createNextDexFile ( dexFile , dexFileName ) ; } }
private File createNextDexFile ( File dexFile , String dexFileName ) { return new File ( dexFile . getParentFile ( ) , dexFileName ) ; }
private String getNextDexFileName ( int dexNumber ) { return CLASSES + dexNumber + DEX_SUFFIX ; }
private static void copyStreamWithoutClosing ( InputStream in , OutputStream out ) throws IOException { final int bufferSize = 4096 ; byte [] b = new byte [ bufferSize ] ; int n ; while ( ( n = in . read ( b ) ) != - 1 ) { out . write ( b , 0 , n ) ; } }
private Set < Artifact > getNativeLibraryArtifacts ( ) MojoExecutionException { return getNativeHelper ( ) . getNativeDependenciesArtifacts ( this , getUnpackedLibsDirectory ( ) , true ) ; }
protected AndroidSigner getAndroidSigner ( ) { if ( sign == null ) { return new AndroidSigner ( signDebug ) ; } else { return new AndroidSigner ( sign . getDebug ( ) ) ; } }
private MetaInf getDefaultMetaInf ( ) { if ( apkMetaIncludes != null && apkMetaIncludes . length > 0 ) { return new MetaInf ( ) . include ( apkMetaIncludes ) ; } return this . pluginMetaInf ; }
public CommonSQLiteOpenHelper ( @ Nonnull Context context , @ Nonnull SQLiteOpenHelperConfiguration configuration ) { super( context . getApplicationContext ( ) , configuration . getName ( ) , configuration . getCursorFactory ( ) , configuration . getVersion ( ) ); this . context = context . getApplicationContext ( ) ; this . databaseName = configuration . getName ( ) ; this . version = configuration . getVersion ( ) ; }
@ Override public void onCreate ( @ Nonnull SQLiteDatabase db ) { onUpgrade ( db , 0 , this . version ) ; }
@ Nonnull public String convertStreamToString ( java . io . InputStream is ) { try { return new Scanner ( is , "UTF-8" ) . useDelimiter ( "\\A" ) . next ( ) ; } catch ( java . util . NoSuchElementException e ) { return "" ; } }
public MatcherPattern ( TableInfo tableInfo , SubType subType , String pattern , int patternCode ) { this . tableInfo = tableInfo ; this . subType = subType ; this . pattern = pattern ; this . patternCode = patternCode ; if ( this . tableInfo . getDefaultContentUriInfo ( ) . isValid ( ) ) { this . contentUriInfo = this . tableInfo . getDefaultContentUriInfo ( ) ; } else { this . contentUriInfo = null ; } if ( this . tableInfo . getDefaultContentMimeTypeVndInfo ( ) . isValid ( ) ) { this . contentMimeTypeVndInfo = this . tableInfo . getDefaultContentMimeTypeVndInfo ( ) ; } else { this . contentMimeTypeVndInfo = null ; } if ( this . contentMimeTypeVndInfo != null ) { this . mimeTypeVnd = new MimeTypeVnd ( this . subType , this . contentMimeTypeVndInfo ) ; } else { this . mimeTypeVnd = null ; } }
@ Override public boolean isValid ( ) { return isValid ( false ) ; }
protected void initialize ( ) { this . initialized = true ; }
public MatcherPattern setContentUri ( String authority , String path ) { return this . setContentUri ( new ContentUriInfo ( authority , path ) ) ; }
public MatcherPattern setContentMimeTypeVnd ( String name , String type ) { return this . setContentMimeTypeVnd ( new ContentMimeTypeVndInfo ( name , type ) ) ; }
public TableInfo getTableInfo ( ) { return this . tableInfo ; }
public SubType getSubType ( ) { return this . subType ; }
public String getPattern ( ) { return this . pattern ; }
public int getPatternCode ( ) { return this . patternCode ; }
public ContentUriInfo getContentUriInfo ( ) { return this . contentUriInfo ; }
public MimeTypeVnd getMimeTypeVnd ( ) { return this . mimeTypeVnd ; }
public String getPathAndPatternString ( ) { return this . contentUriInfo . getPath ( ) + "/" + this . pattern ; }
public Uri getContentUriPattern ( ) { return Uri . parse ( this . contentUriInfo . getContentUri ( ) + "/" + this . pattern ) ; }
public String getMimeTypeVndString ( ) { return this . mimeTypeVnd . getMimeTypeString ( ) ; }
@ Override public String toString ( ) { return getContentUriPattern ( ) . toString ( ) ; }
public UiSettingsAssert ( UiSettings actual ) { super( actual , UiSettingsAssert .class ); }
public GPUImageSmoothToonFilter ( ) { blurFilter = new GPUImageGaussianBlurFilter ( ) ; addFilter ( blurFilter ) ; toonFilter = new GPUImageToonFilter ( ) ; addFilter ( toonFilter ) ; getFilters ( ) . add ( blurFilter ) ; setBlurSize ( 0.5f ) ; setThreshold ( 0.2f ) ; setQuantizationLevels ( 10.0f ) ; }
public void setTexelWidth ( float value ) { toonFilter . setTexelWidth ( value ) ; }
public void setTexelHeight ( float value ) { toonFilter . setTexelHeight ( value ) ; }
public void setBlurSize ( float value ) { blurFilter . setBlurSize ( value ) ; }
public void setThreshold ( float value ) { toonFilter . setThreshold ( value ) ; }
public void setQuantizationLevels ( float value ) { toonFilter . setQuantizationLevels ( value ) ; }
@ Before public void setUp ( ) { RxJavaPlugins . reset ( ) ; pauseMainLooper ( ) ; }
@ After public void tearDown ( ) { RxJavaPlugins . reset ( ) ; unPauseMainLooper ( ) ; }
@ Test public void directScheduleOncePostsImmediately ( ) { CountingRunnable counter = new CountingRunnable ( ) ; scheduler . scheduleDirect ( counter ) ; runUiThreadTasks ( ) ; assertEquals ( 1 , counter . get ( ) ) ; }
@ Test public void directScheduleOnceWithNegativeDelayPostsImmediately ( ) { CountingRunnable counter = new CountingRunnable ( ) ; scheduler . scheduleDirect ( counter , - 1 , TimeUnit . MINUTES ) ; runUiThreadTasks ( ) ; assertEquals ( 1 , counter . get ( ) ) ; }
@ Test public void directScheduleOnceUsesHook ( ) { final CountingRunnable newCounter = new CountingRunnable ( ) ; final AtomicReference < Runnable > runnableRef = new AtomicReference <> ( ) ; RxJavaPlugins . setScheduleHandler ( new Function < Runnable , Runnable > ( ) { @ Override public Runnable apply ( Runnable runnable ) { runnableRef . set ( runnable ) ; return newCounter ; } } ) ; CountingRunnable counter = new CountingRunnable ( ) ; scheduler . scheduleDirect ( counter ) ; assertSame ( counter , runnableRef . get ( ) ) ; runUiThreadTasks ( ) ; assertEquals ( 1 , newCounter . get ( ) ) ; assertEquals ( 0 , counter . get ( ) ) ; }
@ Override public Runnable apply ( Runnable runnable ) { runnableRef . set ( runnable ) ; return newCounter ; }
@ Test public void directScheduleOnceDisposedDoesNotRun ( ) { CountingRunnable counter = new CountingRunnable ( ) ; Disposable disposable = scheduler . scheduleDirect ( counter ) ; disposable . dispose ( ) ; runUiThreadTasks ( ) ; assertEquals ( 0 , counter . get ( ) ) ; }
@ Test public void directScheduleOnceWithDelayPostsWithDelay ( ) { CountingRunnable counter = new CountingRunnable ( ) ; scheduler . scheduleDirect ( counter , 1 , MINUTES ) ; runUiThreadTasks ( ) ; assertEquals ( 0 , counter . get ( ) ) ; idleMainLooper ( 1 , MINUTES ) ; runUiThreadTasks ( ) ; assertEquals ( 1 , counter . get ( ) ) ; }
@ Test public void directScheduleOnceWithDelayUsesHook ( ) { final CountingRunnable newCounter = new CountingRunnable ( ) ; final AtomicReference < Runnable > runnableRef = new AtomicReference <> ( ) ; RxJavaPlugins . setScheduleHandler ( new Function < Runnable , Runnable > ( ) { @ Override public Runnable apply ( Runnable runnable ) { runnableRef . set ( runnable ) ; return newCounter ; } } ) ; CountingRunnable counter = new CountingRunnable ( ) ; scheduler . scheduleDirect ( counter , 1 , MINUTES ) ; assertSame ( counter , runnableRef . get ( ) ) ; idleMainLooper ( 1 , MINUTES ) ; runUiThreadTasks ( ) ; assertEquals ( 1 , newCounter . get ( ) ) ; assertEquals ( 0 , counter . get ( ) ) ; }
@ Override public Runnable apply ( Runnable runnable ) { runnableRef . set ( runnable ) ; return newCounter ; }
@ Test public void directScheduleOnceWithDelayDisposedDoesNotRun ( ) { CountingRunnable counter = new CountingRunnable ( ) ; Disposable disposable = scheduler . scheduleDirect ( counter , 1 , MINUTES ) ; idleMainLooper ( 30 , SECONDS ) ; disposable . dispose ( ) ; idleMainLooper ( 30 , SECONDS ) ; runUiThreadTasks ( ) ; assertEquals ( 0 , counter . get ( ) ) ; }
@ Override public Runnable apply ( Runnable runnable ) { runnableRef . set ( runnable ) ; return newCounter ; }
@ Override public void run ( ) { super. run ( ) ; if ( get ( ) == 2 ) { disposableRef . get ( ) . dispose ( ) ; } }
@ Override public void run ( ) { super. run ( ) ; if ( get ( ) == 2 ) { throw new RuntimeException ( "Broken!" ) ; } }
@ Test public void workerScheduleOncePostsImmediately ( ) { Worker worker = scheduler . createWorker ( ) ; CountingRunnable counter = new CountingRunnable ( ) ; worker . schedule ( counter ) ; runUiThreadTasks ( ) ; assertEquals ( 1 , counter . get ( ) ) ; }
@ Test public void workerScheduleOnceWithNegativeDelayPostsImmediately ( ) { Worker worker = scheduler . createWorker ( ) ; CountingRunnable counter = new CountingRunnable ( ) ; worker . schedule ( counter , - 1 , TimeUnit . MINUTES ) ; runUiThreadTasks ( ) ; assertEquals ( 1 , counter . get ( ) ) ; }
@ Test public void workerScheduleOnceUsesHook ( ) { final CountingRunnable newCounter = new CountingRunnable ( ) ; final AtomicReference < Runnable > runnableRef = new AtomicReference <> ( ) ; RxJavaPlugins . setScheduleHandler ( new Function < Runnable , Runnable > ( ) { @ Override public Runnable apply ( Runnable runnable ) { runnableRef . set ( runnable ) ; return newCounter ; } } ) ; Worker worker = scheduler . createWorker ( ) ; CountingRunnable counter = new CountingRunnable ( ) ; worker . schedule ( counter ) ; assertSame ( counter , runnableRef . get ( ) ) ; runUiThreadTasks ( ) ; assertEquals ( 1 , newCounter . get ( ) ) ; assertEquals ( 0 , counter . get ( ) ) ; }
@ Override public Runnable apply ( Runnable runnable ) { runnableRef . set ( runnable ) ; return newCounter ; }
@ Test public void workerScheduleOnceDisposedDoesNotRun ( ) { Worker worker = scheduler . createWorker ( ) ; CountingRunnable counter = new CountingRunnable ( ) ; Disposable disposable = worker . schedule ( counter ) ; disposable . dispose ( ) ; runUiThreadTasks ( ) ; assertEquals ( 0 , counter . get ( ) ) ; }
@ Test public void workerScheduleOnceWithDelayPostsWithDelay ( ) { Worker worker = scheduler . createWorker ( ) ; CountingRunnable counter = new CountingRunnable ( ) ; worker . schedule ( counter , 1 , MINUTES ) ; runUiThreadTasks ( ) ; assertEquals ( 0 , counter . get ( ) ) ; idleMainLooper ( 1 , MINUTES ) ; runUiThreadTasks ( ) ; assertEquals ( 1 , counter . get ( ) ) ; }
@ Test public void workerScheduleOnceWithDelayUsesHook ( ) { final CountingRunnable newCounter = new CountingRunnable ( ) ; final AtomicReference < Runnable > runnableRef = new AtomicReference <> ( ) ; RxJavaPlugins . setScheduleHandler ( new Function < Runnable , Runnable > ( ) { @ Override public Runnable apply ( Runnable runnable ) { runnableRef . set ( runnable ) ; return newCounter ; } } ) ; Worker worker = scheduler . createWorker ( ) ; CountingRunnable counter = new CountingRunnable ( ) ; worker . schedule ( counter , 1 , MINUTES ) ; assertSame ( counter , runnableRef . get ( ) ) ; idleMainLooper ( 1 , MINUTES ) ; runUiThreadTasks ( ) ; assertEquals ( 1 , newCounter . get ( ) ) ; assertEquals ( 0 , counter . get ( ) ) ; }
@ Override public Runnable apply ( Runnable runnable ) { runnableRef . set ( runnable ) ; return newCounter ; }
@ Test public void workerScheduleOnceWithDelayDisposedDoesNotRun ( ) { Worker worker = scheduler . createWorker ( ) ; CountingRunnable counter = new CountingRunnable ( ) ; Disposable disposable = worker . schedule ( counter , 1 , MINUTES ) ; idleMainLooper ( 30 , SECONDS ) ; disposable . dispose ( ) ; idleMainLooper ( 30 , SECONDS ) ; runUiThreadTasks ( ) ; assertEquals ( 0 , counter . get ( ) ) ; }
@ Override public Runnable apply ( Runnable runnable ) { runnableRef . set ( runnable ) ; return newCounter ; }
@ Override public void run ( ) { super. run ( ) ; if ( get ( ) == 2 ) { disposableRef . get ( ) . dispose ( ) ; } }
@ Override public void run ( ) { super. run ( ) ; if ( get ( ) == 2 ) { throw new RuntimeException ( "Broken!" ) ; } }
@ Test public void workerDisposableTracksDisposedState ( ) { Worker worker = scheduler . createWorker ( ) ; CountingRunnable counter = new CountingRunnable ( ) ; Disposable disposable = worker . schedule ( counter ) ; assertFalse ( disposable . isDisposed ( ) ) ; disposable . dispose ( ) ; assertTrue ( disposable . isDisposed ( ) ) ; }
@ Test public void workerUnsubscriptionDuringSchedulingCancelsScheduledAction ( ) { final AtomicReference < Worker > workerRef = new AtomicReference <> ( ) ; RxJavaPlugins . setScheduleHandler ( new Function < Runnable , Runnable > ( ) { @ Override public Runnable apply ( Runnable runnable ) { workerRef . get ( ) . dispose ( ) ; return runnable ; } } ) ; Worker worker = scheduler . createWorker ( ) ; workerRef . set ( worker ) ; CountingRunnable counter = new CountingRunnable ( ) ; worker . schedule ( counter ) ; runUiThreadTasks ( ) ; assertEquals ( 0 , counter . get ( ) ) ; }
@ Override public Runnable apply ( Runnable runnable ) { workerRef . get ( ) . dispose ( ) ; return runnable ; }
@ Test public void workerDisposeCancelsScheduled ( ) { Worker worker = scheduler . createWorker ( ) ; CountingRunnable counter = new CountingRunnable ( ) ; worker . schedule ( counter , 1 , MINUTES ) ; worker . dispose ( ) ; runUiThreadTasks ( ) ; assertEquals ( 0 , counter . get ( ) ) ; }
@ Test public void workerUnsubscriptionDoesNotAffectOtherWorkers ( ) { Worker workerA = scheduler . createWorker ( ) ; CountingRunnable counterA = new CountingRunnable ( ) ; workerA . schedule ( counterA , 1 , MINUTES ) ; Worker workerB = scheduler . createWorker ( ) ; CountingRunnable counterB = new CountingRunnable ( ) ; workerB . schedule ( counterB , 1 , MINUTES ) ; workerA . dispose ( ) ; runUiThreadTasksIncludingDelayedTasks ( ) ; assertEquals ( 0 , counterA . get ( ) ) ; assertEquals ( 1 , counterB . get ( ) ) ; }
@ Test public void workerTracksDisposedState ( ) { Worker worker = scheduler . createWorker ( ) ; assertFalse ( worker . isDisposed ( ) ) ; worker . dispose ( ) ; assertTrue ( worker . isDisposed ( ) ) ; }
@ Test public void disposedWorkerReturnsDisposedDisposables ( ) { Worker worker = scheduler . createWorker ( ) ; worker . dispose ( ) ; Disposable disposable = worker . schedule ( new CountingRunnable ( ) ) ; assertTrue ( disposable . isDisposed ( ) ) ; }
@ Override public void uncaughtException ( Thread thread , Throwable ex ) { throwableRef . set ( ex ) ; }
@ Override public void run ( ) { throw npe ; }
private static void idleMainLooper ( long amount , TimeUnit unit ) { ShadowLooper . idleMainLooper ( unit . toMillis ( amount ) ) ; }
public ObservableScrollView ( Context context ) { super( context ); }
public ObservableScrollView ( Context context , AttributeSet attrs ) { super( context , attrs ); }
public ObservableScrollView ( Context context , AttributeSet attrs , int defStyle ) { super( context , attrs , defStyle ); }
@ Override public void onRestoreInstanceState ( Parcelable state ) { SavedState ss = ( SavedState ) state ; mPrevScrollY = ss . prevScrollY ; mScrollY = ss . scrollY ; super. onRestoreInstanceState ( ss . getSuperState ( ) ) ; }
@ Override public Parcelable onSaveInstanceState ( ) { Parcelable superState = super. onSaveInstanceState ( ) ; SavedState ss = new SavedState ( superState ) ; ss . prevScrollY = mPrevScrollY ; ss . scrollY = mScrollY ; return ss ; }
@ Override protected void onScrollChanged ( int l , int t , int oldl , int oldt ) { super. onScrollChanged ( l , t , oldl , oldt ) ; if ( hasNoCallbacks ( ) ) { return; } mScrollY = t ; dispatchOnScrollChanged ( t , mFirstScroll , mDragging ) ; if ( mFirstScroll ) { mFirstScroll = false ; } if ( mPrevScrollY < t ) { mScrollState = ScrollState . UP ; } else if ( t < mPrevScrollY ) { mScrollState = ScrollState . DOWN ; } mPrevScrollY = t ; }
@ Override public boolean onInterceptTouchEvent ( MotionEvent ev ) { if ( hasNoCallbacks ( ) ) { return super. onInterceptTouchEvent ( ev ) ; } switch ( ev . getActionMasked ( ) ) { case MotionEvent . ACTION_DOWN : mFirstScroll = mDragging = true ; dispatchOnDownMotionEvent ( ) ; break; } return super. onInterceptTouchEvent ( ev ) ; }
@ Override public boolean onTouchEvent ( MotionEvent ev ) { if ( hasNoCallbacks ( ) ) { return super. onTouchEvent ( ev ) ; } switch ( ev . getActionMasked ( ) ) { case MotionEvent . ACTION_UP : case MotionEvent . ACTION_CANCEL : mIntercepted = false ; mDragging = false ; dispatchOnUpOrCancelMotionEvent ( mScrollState ) ; break; case MotionEvent . ACTION_MOVE : if ( mPrevMoveEvent == null ) { mPrevMoveEvent = ev ; } float diffY = ev . getY ( ) - mPrevMoveEvent . getY ( ) ; mPrevMoveEvent = MotionEvent . obtainNoHistory ( ev ) ; if ( getCurrentScrollY ( ) - diffY <= 0 ) { if ( mIntercepted ) { return false ; } final ViewGroup parent ; if ( mTouchInterceptionViewGroup == null ) { parent = ( ViewGroup ) getParent ( ) ; } else { parent = mTouchInterceptionViewGroup ; } float offsetX = 0 ; float offsetY = 0 ; for ( View v = this ; v != null && v != parent ; v = ( View ) v . getParent ( ) ) { offsetX += v . getLeft ( ) - v . getScrollX ( ) ; offsetY += v . getTop ( ) - v . getScrollY ( ) ; } final MotionEvent event = MotionEvent . obtainNoHistory ( ev ) ; event . offsetLocation ( offsetX , offsetY ) ; if ( parent . onInterceptTouchEvent ( event ) ) { mIntercepted = true ; event . setAction ( MotionEvent . ACTION_DOWN ) ; post ( new Runnable ( ) { @ Override public void run ( ) { parent . dispatchTouchEvent ( event ) ; } } ) ; return false ; } return super. onTouchEvent ( ev ) ; } break; } return super. onTouchEvent ( ev ) ; }
@ Override public void run ( ) { parent . dispatchTouchEvent ( event ) ; }
@ Override public void setScrollViewCallbacks ( ObservableScrollViewCallbacks listener ) { mCallbacks = listener ; }
@ Override public void addScrollViewCallbacks ( ObservableScrollViewCallbacks listener ) { if ( mCallbackCollection == null ) { mCallbackCollection = new ArrayList <> ( ) ; } mCallbackCollection . add ( listener ) ; }
@ Override public void removeScrollViewCallbacks ( ObservableScrollViewCallbacks listener ) { if ( mCallbackCollection != null ) { mCallbackCollection . remove ( listener ) ; } }
@ Override public void clearScrollViewCallbacks ( ) { if ( mCallbackCollection != null ) { mCallbackCollection . clear ( ) ; } }
@ Override public void setTouchInterceptionViewGroup ( ViewGroup viewGroup ) { mTouchInterceptionViewGroup = viewGroup ; }
@ Override public void scrollVerticallyTo ( int y ) { scrollTo ( 0 , y ) ; }
@ Override public int getCurrentScrollY ( ) { return mScrollY ; }
private void dispatchOnDownMotionEvent ( ) { if ( mCallbacks != null ) { mCallbacks . onDownMotionEvent ( ) ; } if ( mCallbackCollection != null ) { for ( int i = 0 ; i < mCallbackCollection . size ( ) ; i ++ ) { ObservableScrollViewCallbacks callbacks = mCallbackCollection . get ( i ) ; callbacks . onDownMotionEvent ( ) ; } } }
private void dispatchOnScrollChanged ( int scrollY , boolean firstScroll , boolean dragging ) { if ( mCallbacks != null ) { mCallbacks . onScrollChanged ( scrollY , firstScroll , dragging ) ; } if ( mCallbackCollection != null ) { for ( int i = 0 ; i < mCallbackCollection . size ( ) ; i ++ ) { ObservableScrollViewCallbacks callbacks = mCallbackCollection . get ( i ) ; callbacks . onScrollChanged ( scrollY , firstScroll , dragging ) ; } } }
private void dispatchOnUpOrCancelMotionEvent ( ScrollState scrollState ) { if ( mCallbacks != null ) { mCallbacks . onUpOrCancelMotionEvent ( scrollState ) ; } if ( mCallbackCollection != null ) { for ( int i = 0 ; i < mCallbackCollection . size ( ) ; i ++ ) { ObservableScrollViewCallbacks callbacks = mCallbackCollection . get ( i ) ; callbacks . onUpOrCancelMotionEvent ( scrollState ) ; } } }
private boolean hasNoCallbacks ( ) { return mCallbacks == null && mCallbackCollection == null ; }
SavedState ( Parcelable superState ) { super( superState ); }
private SavedState ( Parcel in ) { super( in ); prevScrollY = in . readInt ( ) ; scrollY = in . readInt ( ) ; }
@ Override public void writeToParcel ( Parcel out , int flags ) { super. writeToParcel ( out , flags ) ; out . writeInt ( prevScrollY ) ; out . writeInt ( scrollY ) ; }
@ Override public SavedState createFromParcel ( Parcel in ) { return new SavedState ( in ) ; }
@ Override public SavedState [] newArray ( int size ) { return new SavedState [ size ] ; }
protected void setMatcherController ( MatcherController controller ) { this . controller = controller ; controller . initialize ( ) ; }
public abstract Cursor onQuery ( T helper , SQLiteDatabase db , MatcherPattern target , QueryParameters parameter );
public abstract Uri onInsert ( T helper , SQLiteDatabase db , MatcherPattern target , InsertParameters parameter );
public abstract int onDelete ( T helper , SQLiteDatabase db , MatcherPattern target , DeleteParameters parameter );
public abstract int onUpdate ( T helper , SQLiteDatabase db , MatcherPattern target , UpdateParameters parameter );
protected void onQueryCompleted ( Cursor result , Uri uri , MatcherPattern target , QueryParameters parameter ) { result . setNotificationUri ( this . getContext ( ) . getContentResolver ( ) , uri ) ; }
protected void onInsertCompleted ( Uri result , Uri uri , MatcherPattern target , InsertParameters parameter ) { this . getContext ( ) . getContentResolver ( ) . notifyChange ( result , null ) ; }
protected void onDeleteCompleted ( int result , Uri uri , MatcherPattern target , DeleteParameters parameter ) { this . getContext ( ) . getContentResolver ( ) . notifyChange ( uri , null ) ; }
protected void onUpdateCompleted ( int result , Uri uri , MatcherPattern target , UpdateParameters parameter ) { this . getContext ( ) . getContentResolver ( ) . notifyChange ( uri , null ) ; }
public Uri onBulkInsert ( T helper , SQLiteDatabase db , MatcherPattern target , InsertParameters parameter ) { return onInsert ( helper , db , target , parameter ) ; }
protected void onBulkInsertCompleted ( int result , Uri uri ) { this . getContext ( ) . getContentResolver ( ) . notifyChange ( uri , null ) ; }
@ Override public ContentProviderResult [] applyBatch ( ArrayList < ContentProviderOperation > operations ) throws OperationApplicationException { ContentProviderResult [] result = null ; SQLiteDatabase db = this . getHelper ( ) . getWritableDatabase ( ) ; db . beginTransaction ( ) ; try { result = super. applyBatch ( operations ) ; db . setTransactionSuccessful ( ) ; } finally { db . endTransaction ( ) ; } return result ; }
private Fragments ( ) { }
public static void showDialog ( @ Nonnull DialogFragment dialogFragment , @ Nonnull String fragmentTag , @ Nonnull FragmentManager fm ) { showDialog ( dialogFragment , fragmentTag , fm , true ) ; }
public static void showDialog ( DialogFragment dialogFragment , String fragmentTag , FragmentManager fm , boolean useExisting ) { Fragment prev = fm . findFragmentByTag ( fragmentTag ) ; if ( prev != null ) { if ( ! useExisting ) { final FragmentTransaction ft = fm . beginTransaction ( ) ; ft . remove ( prev ) ; ft . addToBackStack ( null ) ; dialogFragment . show ( ft , fragmentTag ) ; fm . executePendingTransactions ( ) ; } } else { final FragmentTransaction ft = fm . beginTransaction ( ) ; ft . addToBackStack ( null ) ; dialogFragment . show ( ft , fragmentTag ) ; fm . executePendingTransactions ( ) ; } }
public ExperimentalRegionsPreference ( Context context ) { super( context ); initCheckedState ( ) ; }
public ExperimentalRegionsPreference ( Context context , AttributeSet attrs ) { super( context , attrs ); initCheckedState ( ) ; }
public ExperimentalRegionsPreference ( Context context , AttributeSet attrs , int defStyle ) { super( context , attrs , defStyle ); initCheckedState ( ) ; }
protected void initCheckedState ( ) { setChecked ( Application . getPrefs ( ) . getBoolean ( getContext ( ) . getString ( R . string . preference_key_experimental_regions ) , DEFAULT_VALUE ) ) ; }
@ Override public boolean isPersistent ( ) { return true ; }
@ Override protected void onClick ( ) { if ( ! isChecked ( ) ) { AlertDialog dialog = new AlertDialog . Builder ( getContext ( ) ) . setMessage ( R . string . preferences_experimental_regions_enable_warning ) . setPositiveButton ( android . R . string . ok , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; setValue ( true ) ; } } ) . setNegativeButton ( android . R . string . cancel , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; } } ) . create ( ) ; dialog . show ( ) ; } else { if ( Application . get ( ) . getCurrentRegion ( ) != null && Application . get ( ) . getCurrentRegion ( ) . getExperimental ( ) ) { AlertDialog dialog = new AlertDialog . Builder ( getContext ( ) ) . setMessage ( R . string . preferences_experimental_regions_disable_warning ) . setPositiveButton ( android . R . string . ok , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; Application . get ( ) . setCurrentRegion ( null ) ; setValue ( false ) ; } } ) . setNegativeButton ( android . R . string . cancel , new DialogInterface . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; } } ) . create ( ) ; dialog . show ( ) ; } else { setValue ( false ) ; } } }
@ Override public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; setValue ( true ) ; }
@ Override public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; }
@ Override public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; Application . get ( ) . setCurrentRegion ( null ) ; setValue ( false ) ; }
@ Override public void onClick ( DialogInterface dialog , int which ) { dialog . dismiss ( ) ; }
public void setValue ( boolean newValue ) { mCurrentValue = newValue ; setChecked ( newValue ) ; PreferenceUtils . saveBoolean ( getContext ( ) . getString ( R . string . preference_key_experimental_regions ) , newValue ) ; }
@ Override protected void onSetInitialValue ( boolean restorePersistedValue , Object defaultValue ) { if ( restorePersistedValue ) { mCurrentValue = this . getPersistedBoolean ( mCurrentValue ) ; } else { mCurrentValue = ( Boolean ) defaultValue ; persistBoolean ( mCurrentValue ) ; } }
@ Override protected Object onGetDefaultValue ( TypedArray a , int index ) { return a . getBoolean ( index , DEFAULT_VALUE ) ; }
@ Override protected Parcelable onSaveInstanceState ( ) { final Parcelable superState = super. onSaveInstanceState ( ) ; final SavedState myState = new SavedState ( superState ) ; myState . value = mCurrentValue ; return myState ; }
@ Override protected void onRestoreInstanceState ( Parcelable state ) { if ( state == null || ! state . getClass ( ) . equals ( SavedState .class ) ) { super. onRestoreInstanceState ( state ) ; return; } SavedState myState = ( SavedState ) state ; super. onRestoreInstanceState ( myState . getSuperState ( ) ) ; setValue ( myState . value ) ; }
public SavedState ( Parcelable superState ) { super( superState ); }
public SavedState ( Parcel source ) { super( source ); value = source . readByte ( ) != 0 ; }
@ Override public void writeToParcel ( Parcel dest , int flags ) { super. writeToParcel ( dest , flags ) ; dest . writeByte ( ( byte ) ( value ? 1 : 0 ) ) ; }
public SavedState createFromParcel ( Parcel in ) { return new SavedState ( in ) ; }
public SavedState [] newArray ( int size ) { return new SavedState [ size ] ; }
public HelloFlashLightSampleIT ( MavenRuntimeBuilder builder ) throws Exception { this . mavenRuntime = builder . build ( ) ; }
Location getStopLocation ( )
String getStopName ( )
String getStopDirection ( )
String getUserStopName ( )
String getStopId ( )
void setUserStopName ( String userName );
long getLastGoodResponseTime ( )
ArrayList < ArrivalInfo > getArrivalInfo ( )
ArrayList < String > getRoutesFilter ( )
void setRoutesFilter ( ArrayList < String > filter );
int getNumRoutes ( )
boolean isFavoriteStop ( )
boolean setFavoriteStop ( boolean favorite );
AlertList getAlertList ( )
List < String > getRouteDisplayNames ( )
int getMinutesAfter ( )
void showListItemMenu ( View v , final ArrivalInfo stop );
void refreshLocal ( )
void refresh ( )
ArrivalsListHeader ( Context context , Controller controller , FragmentManager fm ) { mController = controller ; mContext = context ; mResources = context . getResources ( ) ; mFragmentManager = fm ; mShortAnimationDuration = mResources . getInteger ( android . R . integer . config_shortAnimTime ) ; }
public void onClick ( View v ) { mController . setRoutesFilter ( new ArrayList < String > ( ) ) ; }
@ Override public void onClick ( View v ) { mController . setFavoriteStop ( ! mController . isFavoriteStop ( ) ) ; refreshStopFavorite ( ) ; }
@ Override public void onClick ( View v ) { beginNameEdit ( null ) ; }
@ Override public void onClick ( View v ) { mController . setUserStopName ( mEditNameView . getText ( ) . toString ( ) ) ; endNameEdit ( ) ; }
@ Override public boolean onEditorAction ( TextView v , int actionId , KeyEvent event ) { if ( actionId == EditorInfo . IME_ACTION_DONE ) { mController . setUserStopName ( mEditNameView . getText ( ) . toString ( ) ) ; endNameEdit ( ) ; return true ; } return false ; }
@ Override public void onClick ( View v ) { endNameEdit ( ) ; }
@ Override public void onClick ( View v ) { mController . setUserStopName ( null ) ; endNameEdit ( ) ; }
public void setSlidingPanelController ( HomeActivity . SlidingPanelController controller ) { mSlidingPanelController = controller ; }
public void onPause ( ) { if ( mInNameEdit ) { mController . setUserStopName ( null ) ; endNameEdit ( ) ; } }
synchronized public void setSlidingPanelCollapsed ( boolean collapsed ) { if ( mExpandCollapse != null && collapsed != mIsSlidingPanelCollapsed ) { mIsSlidingPanelCollapsed = collapsed ; doExpandCollapseRotation ( collapsed ) ; } }
public void setTripsForStop ( ContentQueryMap tripsForStop ) { mTripsForStop = tripsForStop ; refreshArrivalInfoVisibilityAndListeners ( ) ; }
@ TargetApi ( Build . VERSION_CODES . HONEYCOMB_MR1 ) private void doExpandCollapseRotation ( boolean collapsed ) { if ( ! UIUtils . canAnimateViewModern ( ) ) { rotateExpandCollapseImageViewLegacy ( collapsed ) ; return; } if ( ! collapsed ) { mExpandCollapse . animate ( ) . setDuration ( ANIM_DURATION ) . rotationBy ( ANIM_STATE_INVERTED ) ; } else { mExpandCollapse . animate ( ) . setDuration ( ANIM_DURATION ) . rotationBy ( - ANIM_STATE_INVERTED ) ; } }
private void rotateExpandCollapseImageViewLegacy ( boolean isSlidingPanelCollapsed ) { RotateAnimation rotate ; if ( ! isSlidingPanelCollapsed ) { rotate = getRotation ( ANIM_STATE_NORMAL , ANIM_STATE_INVERTED ) ; } else { rotate = getRotation ( ANIM_STATE_INVERTED , ANIM_STATE_NORMAL ) ; } mExpandCollapse . setAnimation ( rotate ) ; }
@ TargetApi ( Build . VERSION_CODES . HONEYCOMB_MR1 ) private synchronized void resetExpandCollapseAnimation ( ) { if ( mExpandCollapse == null ) { return; } if ( UIUtils . canAnimateViewModern ( ) ) { if ( mExpandCollapse . getRotation ( ) != 0 ) { mExpandCollapse . setRotation ( 0 ) ; } } else { mExpandCollapse . clearAnimation ( ) ; } }
public void showExpandCollapseIndicator ( boolean value ) { if ( mExpandCollapse != null ) { if ( value ) { mExpandCollapse . setVisibility ( View . VISIBLE ) ; } else { mExpandCollapse . setVisibility ( View . GONE ) ; } } }
public void showArrivals ( boolean value ) { mShowArrivals = value ; if ( mView != null ) { TableLayout arrivalTable = ( TableLayout ) mView . findViewById ( R . id . eta_table ) ; if ( arrivalTable != null ) { if ( mShowArrivals ) { arrivalTable . setVisibility ( View . VISIBLE ) ; mProgressBar . setVisibility ( View . VISIBLE ) ; } else { arrivalTable . setVisibility ( View . GONE ) ; mProgressBar . setVisibility ( View . GONE ) ; } } } }
public boolean isShowingArrivals ( ) { return mShowArrivals ; }
private static RotateAnimation getRotation ( float startState , float endState ) { RotateAnimation r = new RotateAnimation ( startState , endState , Animation . RELATIVE_TO_SELF , ANIM_PIVOT_VALUE , Animation . RELATIVE_TO_SELF , ANIM_PIVOT_VALUE ) ; r . setDuration ( ANIM_DURATION ) ; r . setFillAfter ( true ) ; return r ; }
synchronized void refresh ( ) { refreshName ( ) ; refreshArrivalInfoData ( ) ; refreshStopFavorite ( ) ; refreshFilter ( ) ; refreshError ( ) ; refreshHiddenAlerts ( ) ; refreshArrivalInfoVisibilityAndListeners ( ) ; refreshHeaderSize ( ) ; }
private void refreshName ( ) { String name = mController . getStopName ( ) ; String userName = mController . getUserStopName ( ) ; String stopDirection = mController . getStopDirection ( ) ; if ( ! TextUtils . isEmpty ( userName ) ) { mNameView . setText ( UIUtils . formatDisplayText ( userName ) ) ; } else if ( name != null ) { mNameView . setText ( UIUtils . formatDisplayText ( name ) ) ; } if ( ! TextUtils . isEmpty ( stopDirection ) ) { mDirectionView . setText ( mContext . getString ( R . string . arrival_list_stop_directions , stopDirection ) ) ; mDirectionView . setVisibility ( View . VISIBLE ) ; } else { mDirectionView . setVisibility ( View . GONE ) ; } }
private void refreshArrivalInfoData ( ) { mArrivalInfo = mController . getArrivalInfo ( ) ; mHeaderArrivalInfo . clear ( ) ; if ( mArrivalInfo != null && ! mInNameEdit ) { ArrayList < Integer > etaIndexes = ArrivalInfoUtils . findPreferredArrivalIndexes ( mArrivalInfo ) ; if ( etaIndexes != null ) { final int i1 = etaIndexes . get ( 0 ) ; ObaArrivalInfo info1 = mArrivalInfo . get ( i1 ) . getInfo ( ) ; boolean isFavorite = ObaContract . RouteHeadsignFavorites . isFavorite ( info1 . getRouteId ( ) , info1 . getHeadsign ( ) , info1 . getStopId ( ) ) ; mEtaRouteFavorite1 . setImageResource ( isFavorite ? R . drawable . focus_star_on : R . drawable . focus_star_off ) ; mEtaRouteName1 . setText ( info1 . getShortName ( ) ) ; mEtaRouteDirection1 . setText ( UIUtils . formatDisplayText ( info1 . getHeadsign ( ) ) ) ; long eta = mArrivalInfo . get ( i1 ) . getEta ( ) ; if ( eta == 0 ) { mEtaArrivalInfo1 . setText ( mContext . getString ( R . string . stop_info_eta_now ) ) ; mEtaArrivalInfo1 . setTextSize ( ETA_TEXT_NOW_SIZE_SP ) ; UIUtils . hideViewWithAnimation ( mEtaMin1 , mShortAnimationDuration ) ; } else if ( eta > 0 ) { mEtaArrivalInfo1 . setText ( Long . toString ( eta ) ) ; mEtaArrivalInfo1 . setTextSize ( ETA_TEXT_SIZE_SP ) ; UIUtils . showViewWithAnimation ( mEtaMin1 , mShortAnimationDuration ) ; } mEtaAndMin1 . setBackgroundResource ( R . drawable . round_corners_style_b_header_status ) ; GradientDrawable d1 = ( GradientDrawable ) mEtaAndMin1 . getBackground ( ) ; final int c1 = mArrivalInfo . get ( i1 ) . getColor ( ) ; if ( c1 != R . color . stop_info_ontime ) { d1 . setColor ( mResources . getColor ( c1 ) ) ; } else { d1 . setColor ( mResources . getColor ( R . color . header_stop_info_ontime ) ) ; } mEtaAndMin1 . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { if ( mPopup1 != null && mPopup1 . isShowing ( ) ) { mPopup1 . dismiss ( ) ; return; } mPopup1 = setupPopup ( 0 , c1 , mArrivalInfo . get ( i1 ) . getStatusText ( ) ) ; mPopup1 . showAsDropDown ( mEtaAndMin1 ) ; } } ) ; if ( mArrivalInfo . get ( i1 ) . getPredicted ( ) ) { UIUtils . showViewWithAnimation ( mEtaRealtime1 , mShortAnimationDuration ) ; } else { mEtaRealtime1 . setVisibility ( View . INVISIBLE ) ; if ( mArrivalInfo . get ( i1 ) . getInfo ( ) . getFrequency ( ) != null ) { mEtaArrivalInfo1 . setText ( mResources . getString ( R . string . stop_info_frequency_approximate ) + mEtaArrivalInfo1 . getText ( ) ) ; } } mHeaderArrivalInfo . add ( mArrivalInfo . get ( i1 ) ) ; if ( etaIndexes . size ( ) >= 2 ) { final int i2 = etaIndexes . get ( 1 ) ; ObaArrivalInfo info2 = mArrivalInfo . get ( i2 ) . getInfo ( ) ; boolean isFavorite2 = ObaContract . RouteHeadsignFavorites . isFavorite ( info2 . getRouteId ( ) , info2 . getHeadsign ( ) , info2 . getStopId ( ) ) ; mEtaRouteFavorite2 . setImageResource ( isFavorite2 ? R . drawable . focus_star_on : R . drawable . focus_star_off ) ; mEtaRouteName2 . setText ( info2 . getShortName ( ) ) ; mEtaRouteDirection2 . setText ( UIUtils . formatDisplayText ( info2 . getHeadsign ( ) ) ) ; eta = mArrivalInfo . get ( i2 ) . getEta ( ) ; if ( eta == 0 ) { mEtaArrivalInfo2 . setText ( mContext . getString ( R . string . stop_info_eta_now ) ) ; mEtaArrivalInfo2 . setTextSize ( ETA_TEXT_NOW_SIZE_SP ) ; UIUtils . hideViewWithAnimation ( mEtaMin2 , mShortAnimationDuration ) ; } else if ( eta > 0 ) { mEtaArrivalInfo2 . setText ( Long . toString ( eta ) ) ; mEtaArrivalInfo2 . setTextSize ( ETA_TEXT_SIZE_SP ) ; UIUtils . showViewWithAnimation ( mEtaMin2 , mShortAnimationDuration ) ; } mEtaAndMin2 . setBackgroundResource ( R . drawable . round_corners_style_b_header_status ) ; GradientDrawable d2 = ( GradientDrawable ) mEtaAndMin2 . getBackground ( ) ; final int c2 = mArrivalInfo . get ( i2 ) . getColor ( ) ; if ( c2 != R . color . stop_info_ontime ) { d2 . setColor ( mResources . getColor ( c2 ) ) ; } else { d2 . setColor ( mResources . getColor ( R . color . header_stop_info_ontime ) ) ; } mEtaAndMin2 . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { if ( mPopup2 != null && mPopup2 . isShowing ( ) ) { mPopup2 . dismiss ( ) ; return; } mPopup2 = setupPopup ( 1 , c2 , mArrivalInfo . get ( i2 ) . getStatusText ( ) ) ; mPopup2 . showAsDropDown ( mEtaAndMin2 ) ; } } ) ; if ( mArrivalInfo . get ( i2 ) . getPredicted ( ) ) { UIUtils . showViewWithAnimation ( mEtaRealtime2 , mShortAnimationDuration ) ; } else { mEtaRealtime2 . setVisibility ( View . INVISIBLE ) ; if ( mArrivalInfo . get ( i2 ) . getInfo ( ) . getFrequency ( ) != null ) { mEtaArrivalInfo2 . setText ( mResources . getString ( R . string . stop_info_frequency_approximate ) + mEtaArrivalInfo2 . getText ( ) ) ; } } mNumHeaderArrivals = 2 ; mHeaderArrivalInfo . add ( mArrivalInfo . get ( i2 ) ) ; } else { mNumHeaderArrivals = 1 ; } } else { int minAfter = mController . getMinutesAfter ( ) ; if ( minAfter != - 1 ) { mNoArrivals . setText ( UIUtils . getNoArrivalsMessage ( mContext , minAfter , false , false ) ) ; } else { minAfter = 35 ; mNoArrivals . setText ( UIUtils . getNoArrivalsMessage ( mContext , minAfter , false , false ) ) ; } mNumHeaderArrivals = 0 ; } } }
@ Override public void onClick ( View v ) { if ( mPopup1 != null && mPopup1 . isShowing ( ) ) { mPopup1 . dismiss ( ) ; return; } mPopup1 = setupPopup ( 0 , c1 , mArrivalInfo . get ( i1 ) . getStatusText ( ) ) ; mPopup1 . showAsDropDown ( mEtaAndMin1 ) ; }
@ Override public void onClick ( View v ) { if ( mPopup2 != null && mPopup2 . isShowing ( ) ) { mPopup2 . dismiss ( ) ; return; } mPopup2 = setupPopup ( 1 , c2 , mArrivalInfo . get ( i2 ) . getStatusText ( ) ) ; mPopup2 . showAsDropDown ( mEtaAndMin2 ) ; }
private PopupWindow setupPopup ( final int index , int color , String statusText ) { LayoutInflater inflater = LayoutInflater . from ( mContext ) ; TextView statusView = ( TextView ) inflater . inflate ( R . layout . arrivals_list_tv_template_style_b_status_large , null ) ; statusView . setBackgroundResource ( R . drawable . round_corners_style_b_status ) ; GradientDrawable d = ( GradientDrawable ) statusView . getBackground ( ) ; if ( color != R . color . stop_info_ontime ) { d . setColor ( mResources . getColor ( color ) ) ; } else { d . setColor ( mResources . getColor ( R . color . header_stop_info_ontime ) ) ; } d . setStroke ( UIUtils . dpToPixels ( mContext , 1 ) , mResources . getColor ( R . color . header_text_color ) ) ; int pSides = UIUtils . dpToPixels ( mContext , 5 ) ; int pTopBottom = UIUtils . dpToPixels ( mContext , 2 ) ; statusView . setPadding ( pSides , pTopBottom , pSides , pTopBottom ) ; statusView . setLayoutParams ( new ViewGroup . LayoutParams ( ViewGroup . LayoutParams . WRAP_CONTENT , ViewGroup . LayoutParams . WRAP_CONTENT ) ) ; statusView . measure ( TextView . MeasureSpec . UNSPECIFIED , TextView . MeasureSpec . UNSPECIFIED ) ; statusView . setText ( statusText ) ; PopupWindow p = new PopupWindow ( statusView , statusView . getWidth ( ) , statusView . getHeight ( ) ) ; p . setWindowLayoutMode ( ViewGroup . LayoutParams . WRAP_CONTENT , ViewGroup . LayoutParams . WRAP_CONTENT ) ; p . setBackgroundDrawable ( new ColorDrawable ( mResources . getColor ( android . R . color . transparent ) ) ) ; p . setOutsideTouchable ( true ) ; p . setTouchInterceptor ( new View . OnTouchListener ( ) { @ Override public boolean onTouch ( View v , MotionEvent event ) { boolean touchInView ; if ( index == 0 ) { touchInView = UIUtils . isTouchInView ( mEtaAndMin1 , event ) ; } else { touchInView = UIUtils . isTouchInView ( mEtaAndMin2 , event ) ; } return touchInView ; } } ) ; return p ; }
@ Override public boolean onTouch ( View v , MotionEvent event ) { boolean touchInView ; if ( index == 0 ) { touchInView = UIUtils . isTouchInView ( mEtaAndMin1 , event ) ; } else { touchInView = UIUtils . isTouchInView ( mEtaAndMin2 , event ) ; } return touchInView ; }
private void refreshStopFavorite ( ) { mStopFavorite . setImageResource ( mController . isFavoriteStop ( ) ? R . drawable . focus_star_on : R . drawable . focus_star_off ) ; }
private void refreshFilter ( ) { TextView v = ( TextView ) mView . findViewById ( R . id . filter_text ) ; ArrayList < String > routesFilter = mController . getRoutesFilter ( ) ; final int num = ( routesFilter != null ) ? routesFilter . size ( ) : 0 ; if ( num > 0 ) { final int total = mController . getNumRoutes ( ) ; v . setText ( mContext . getString ( R . string . stop_info_filter_header , num , total ) ) ; if ( mInNameEdit ) { mFilterGroup . setVisibility ( View . GONE ) ; } else { mFilterGroup . setVisibility ( View . VISIBLE ) ; } } else { mFilterGroup . setVisibility ( View . GONE ) ; } }
private boolean isFilteringRoutes ( ) { ArrayList < String > routesFilter = mController . getRoutesFilter ( ) ; final int num = ( routesFilter != null ) ? routesFilter . size ( ) : 0 ; return num > 0 ; }
@ TargetApi ( Build . VERSION_CODES . HONEYCOMB ) private void refreshArrivalInfoVisibilityAndListeners ( ) { if ( mInNameEdit ) { return; } if ( mArrivalInfo == null ) { UIUtils . showViewWithAnimation ( mProgressBar , mShortAnimationDuration ) ; UIUtils . hideViewWithAnimation ( mNoArrivals , mShortAnimationDuration ) ; UIUtils . hideViewWithAnimation ( mEtaContainer1 , mShortAnimationDuration ) ; UIUtils . hideViewWithAnimation ( mEtaSeparator , mShortAnimationDuration ) ; UIUtils . hideViewWithAnimation ( mEtaContainer2 , mShortAnimationDuration ) ; return; } if ( mNumHeaderArrivals == 0 ) { UIUtils . showViewWithAnimation ( mNoArrivals , mShortAnimationDuration ) ; UIUtils . hideViewWithAnimation ( mEtaContainer1 , mShortAnimationDuration ) ; UIUtils . hideViewWithAnimation ( mEtaSeparator , mShortAnimationDuration ) ; UIUtils . hideViewWithAnimation ( mEtaContainer2 , mShortAnimationDuration ) ; } if ( mNumHeaderArrivals >= 1 ) { UIUtils . showViewWithAnimation ( mEtaContainer1 , mShortAnimationDuration ) ; UIUtils . hideViewWithAnimation ( mNoArrivals , mShortAnimationDuration ) ; final ObaArrivalInfo info1 = mHeaderArrivalInfo . get ( 0 ) . getInfo ( ) ; final boolean isRouteFavorite = ObaContract . RouteHeadsignFavorites . isFavorite ( info1 . getRouteId ( ) , info1 . getHeadsign ( ) , info1 . getStopId ( ) ) ; mEtaRouteFavorite1 . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { RouteFavoriteDialogFragment dialog = new RouteFavoriteDialogFragment . Builder ( info1 . getRouteId ( ) , UIUtils . formatDisplayText ( info1 . getHeadsign ( ) ) ) . setRouteShortName ( info1 . getShortName ( ) ) . setRouteLongName ( info1 . getRouteLongName ( ) ) . setStopId ( info1 . getStopId ( ) ) . setFavorite ( ! isRouteFavorite ) . build ( ) ; dialog . setCallback ( new RouteFavoriteDialogFragment . Callback ( ) { @ Override public void onSelectionComplete ( boolean savedFavorite ) { if ( savedFavorite ) { mController . refreshLocal ( ) ; } } } ) ; dialog . show ( mFragmentManager , RouteFavoriteDialogFragment . TAG ) ; } } ) ; mEtaReminder1 . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { TripInfoActivity . start ( mContext , info1 . getTripId ( ) , mController . getStopId ( ) , info1 . getRouteId ( ) , info1 . getShortName ( ) , mController . getStopName ( ) , info1 . getScheduledDepartureTime ( ) , info1 . getHeadsign ( ) ) ; } } ) ; mEtaMoreVert1 . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { mController . showListItemMenu ( mEtaContainer1 , mHeaderArrivalInfo . get ( 0 ) ) ; } } ) ; View r = mEtaContainer1 . findViewById ( R . id . reminder ) ; refreshReminder ( mHeaderArrivalInfo . get ( 0 ) . getInfo ( ) . getTripId ( ) , r ) ; } if ( mNumHeaderArrivals >= 2 ) { UIUtils . showViewWithAnimation ( mEtaSeparator , mShortAnimationDuration ) ; UIUtils . showViewWithAnimation ( mEtaContainer2 , mShortAnimationDuration ) ; final ObaArrivalInfo info2 = mHeaderArrivalInfo . get ( 1 ) . getInfo ( ) ; final boolean isRouteFavorite2 = ObaContract . RouteHeadsignFavorites . isFavorite ( info2 . getRouteId ( ) , info2 . getHeadsign ( ) , info2 . getStopId ( ) ) ; mEtaRouteFavorite2 . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { RouteFavoriteDialogFragment dialog = new RouteFavoriteDialogFragment . Builder ( info2 . getRouteId ( ) , info2 . getHeadsign ( ) ) . setRouteShortName ( info2 . getShortName ( ) ) . setRouteLongName ( info2 . getRouteLongName ( ) ) . setStopId ( info2 . getStopId ( ) ) . setFavorite ( ! isRouteFavorite2 ) . build ( ) ; dialog . setCallback ( new RouteFavoriteDialogFragment . Callback ( ) { @ Override public void onSelectionComplete ( boolean savedFavorite ) { if ( savedFavorite ) { mController . refreshLocal ( ) ; } } } ) ; dialog . show ( mFragmentManager , RouteFavoriteDialogFragment . TAG ) ; } } ) ; mEtaReminder2 . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { TripInfoActivity . start ( mContext , info2 . getTripId ( ) , mController . getStopId ( ) , info2 . getRouteId ( ) , info2 . getShortName ( ) , mController . getStopName ( ) , info2 . getScheduledDepartureTime ( ) , info2 . getHeadsign ( ) ) ; } } ) ; mEtaMoreVert2 . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { mController . showListItemMenu ( mEtaContainer2 , mHeaderArrivalInfo . get ( 1 ) ) ; } } ) ; View r = mEtaContainer2 . findViewById ( R . id . reminder ) ; refreshReminder ( mHeaderArrivalInfo . get ( 1 ) . getInfo ( ) . getTripId ( ) , r ) ; } else { UIUtils . hideViewWithAnimation ( mEtaSeparator , mShortAnimationDuration ) ; UIUtils . hideViewWithAnimation ( mEtaContainer2 , mShortAnimationDuration ) ; } UIUtils . hideViewWithAnimation ( mProgressBar , mShortAnimationDuration ) ; }
@ Override public void onClick ( View v ) { RouteFavoriteDialogFragment dialog = new RouteFavoriteDialogFragment . Builder ( info1 . getRouteId ( ) , UIUtils . formatDisplayText ( info1 . getHeadsign ( ) ) ) . setRouteShortName ( info1 . getShortName ( ) ) . setRouteLongName ( info1 . getRouteLongName ( ) ) . setStopId ( info1 . getStopId ( ) ) . setFavorite ( ! isRouteFavorite ) . build ( ) ; dialog . setCallback ( new RouteFavoriteDialogFragment . Callback ( ) { @ Override public void onSelectionComplete ( boolean savedFavorite ) { if ( savedFavorite ) { mController . refreshLocal ( ) ; } } } ) ; dialog . show ( mFragmentManager , RouteFavoriteDialogFragment . TAG ) ; }
@ Override public void onSelectionComplete ( boolean savedFavorite ) { if ( savedFavorite ) { mController . refreshLocal ( ) ; } }
@ Override public void onClick ( View v ) { TripInfoActivity . start ( mContext , info1 . getTripId ( ) , mController . getStopId ( ) , info1 . getRouteId ( ) , info1 . getShortName ( ) , mController . getStopName ( ) , info1 . getScheduledDepartureTime ( ) , info1 . getHeadsign ( ) ) ; }
@ Override public void onClick ( View v ) { mController . showListItemMenu ( mEtaContainer1 , mHeaderArrivalInfo . get ( 0 ) ) ; }
@ Override public void onClick ( View v ) { RouteFavoriteDialogFragment dialog = new RouteFavoriteDialogFragment . Builder ( info2 . getRouteId ( ) , info2 . getHeadsign ( ) ) . setRouteShortName ( info2 . getShortName ( ) ) . setRouteLongName ( info2 . getRouteLongName ( ) ) . setStopId ( info2 . getStopId ( ) ) . setFavorite ( ! isRouteFavorite2 ) . build ( ) ; dialog . setCallback ( new RouteFavoriteDialogFragment . Callback ( ) { @ Override public void onSelectionComplete ( boolean savedFavorite ) { if ( savedFavorite ) { mController . refreshLocal ( ) ; } } } ) ; dialog . show ( mFragmentManager , RouteFavoriteDialogFragment . TAG ) ; }
@ Override public void onSelectionComplete ( boolean savedFavorite ) { if ( savedFavorite ) { mController . refreshLocal ( ) ; } }
@ Override public void onClick ( View v ) { TripInfoActivity . start ( mContext , info2 . getTripId ( ) , mController . getStopId ( ) , info2 . getRouteId ( ) , info2 . getShortName ( ) , mController . getStopName ( ) , info2 . getScheduledDepartureTime ( ) , info2 . getHeadsign ( ) ) ; }
@ Override public void onClick ( View v ) { mController . showListItemMenu ( mEtaContainer2 , mHeaderArrivalInfo . get ( 1 ) ) ; }
void refreshReminder ( String tripId , View v ) { ContentValues values = null ; if ( mTripsForStop != null ) { values = mTripsForStop . getValues ( tripId ) ; } if ( values != null ) { v . setVisibility ( View . VISIBLE ) ; } else { v . setVisibility ( View . GONE ) ; } }
void refreshHeaderSize ( ) { if ( mInNameEdit ) { if ( ! mShowArrivals ) { setHeaderSize ( HEADER_HEIGHT_EDIT_NAME_DP ) ; } return; } float newSize = 0 ; if ( ! mShowArrivals ) { newSize = HEADER_HEIGHT_NO_ARRIVALS_DP ; } else if ( mNumHeaderArrivals == 0 || mNumHeaderArrivals == 1 ) { newSize = HEADER_HEIGHT_ONE_ARRIVAL_DP ; } else if ( mNumHeaderArrivals == 2 ) { newSize = HEADER_HEIGHT_TWO_ARRIVALS_DP ; } if ( isFilteringRoutes ( ) ) { newSize += HEADER_OFFSET_FILTER_ROUTES_DP ; } if ( newSize != 0 ) { setHeaderSize ( newSize ) ; } }
void setHeaderSize ( float newHeightDp ) { int heightPixels = UIUtils . dpToPixels ( mContext , newHeightDp ) ; if ( mSlidingPanelController != null ) { mSlidingPanelController . setPanelHeightPixels ( heightPixels ) ; } else { mView . getLayoutParams ( ) . height = heightPixels ; mMainContainerView . getLayoutParams ( ) . height = heightPixels ; } }
ResponseError ( CharSequence seq ) { mString = seq ; }
@ Override public int getType ( ) { return TYPE_ERROR ; }
@ Override public int getFlags ( ) { return 0 ; }
@ Override public CharSequence getString ( ) { return mString ; }
@ Override public void onClick ( ) { }
@ Override public int hashCode ( ) { return getId ( ) . hashCode ( ) ; }
private void refreshError ( ) { final long now = System . currentTimeMillis ( ) ; final long responseTime = mController . getLastGoodResponseTime ( ) ; AlertList alerts = mController . getAlertList ( ) ; mHasWarning = false ; mHasError = false ; if ( mResponseError != null ) { alerts . remove ( mResponseError ) ; } if ( ( responseTime ) != 0 && ( ( now - responseTime ) >= 2 * DateUtils . MINUTE_IN_MILLIS ) ) { CharSequence relativeTime = DateUtils . getRelativeTimeSpanString ( responseTime , now , DateUtils . MINUTE_IN_MILLIS , 0 ) ; CharSequence s = mContext . getString ( R . string . stop_info_old_data , relativeTime ) ; mResponseError = new ResponseError ( s ) ; alerts . insert ( mResponseError , 0 ) ; } for ( int i = 0 ; i < alerts . getCount ( ) ; i ++ ) { AlertList . Alert a = alerts . getItem ( i ) ; if ( a . getType ( ) == AlertList . Alert . TYPE_WARNING ) { mHasWarning = true ; } if ( a . getType ( ) == AlertList . Alert . TYPE_ERROR ) { mHasError = true ; } } if ( mHasError ) { mAlertView . setVisibility ( View . VISIBLE ) ; mAlertView . setColorFilter ( mResources . getColor ( R . color . alert_icon_error ) ) ; mAlertView . setContentDescription ( mResources . getString ( R . string . alert_content_description_error ) ) ; } else if ( mHasWarning ) { mAlertView . setVisibility ( View . VISIBLE ) ; mAlertView . setColorFilter ( mResources . getColor ( R . color . alert_icon_warning ) ) ; mAlertView . setContentDescription ( mResources . getString ( R . string . alert_content_description_warning ) ) ; } else { mAlertView . setVisibility ( View . GONE ) ; mAlertView . setContentDescription ( "" ) ; } }
ShowHiddenAlert ( CharSequence seq , Controller controller ) { mString = seq ; mController = controller ; }
@ Override public int getType ( ) { return TYPE_SHOW_HIDDEN_ALERTS ; }
@ Override public int getFlags ( ) { return FLAG_HASMORE ; }
@ Override public CharSequence getString ( ) { return mString ; }
@ Override public void onClick ( ) { ObaContract . ServiceAlerts . showAllAlerts ( ) ; mController . refresh ( ) ; }
@ Override public int hashCode ( ) { return getId ( ) . hashCode ( ) ; }
private void refreshHiddenAlerts ( ) { AlertList alerts = mController . getAlertList ( ) ; mIsAlertHidden = alerts . isAlertHidden ( ) ; if ( mShowHiddenAlert != null ) { alerts . remove ( mShowHiddenAlert ) ; } if ( mIsAlertHidden ) { CharSequence cs = mContext . getResources ( ) . getQuantityString ( R . plurals . alert_filter_text , alerts . getHiddenAlertCount ( ) , alerts . getHiddenAlertCount ( ) ) ; mShowHiddenAlert = new ShowHiddenAlert ( cs , mController ) ; alerts . insert ( mShowHiddenAlert , alerts . getCount ( ) ) ; } }
synchronized void beginNameEdit ( String initial ) { mEditNameView . setText ( ( initial != null ) ? initial : mNameView . getText ( ) ) ; mNameContainerView . setVisibility ( View . GONE ) ; mFilterGroup . setVisibility ( View . GONE ) ; mStopFavorite . setVisibility ( View . GONE ) ; mEtaContainer1 . setVisibility ( View . GONE ) ; mEtaSeparator . setVisibility ( View . GONE ) ; mEtaContainer2 . setVisibility ( View . GONE ) ; mNoArrivals . setVisibility ( View . GONE ) ; mAlertView . setVisibility ( View . GONE ) ; cachedExpandCollapseViewVisibility = mExpandCollapse . getVisibility ( ) ; if ( ! UIUtils . canAnimateViewModern ( ) ) { mExpandCollapse . clearAnimation ( ) ; } mExpandCollapse . setVisibility ( View . GONE ) ; mEditNameContainerView . setVisibility ( View . VISIBLE ) ; if ( ! mShowArrivals ) { setHeaderSize ( HEADER_HEIGHT_EDIT_NAME_DP ) ; } mEditNameView . requestFocus ( ) ; mEditNameView . setSelection ( mEditNameView . getText ( ) . length ( ) ) ; mInNameEdit = true ; UIUtils . openKeyboard ( mContext ) ; }
synchronized void endNameEdit ( ) { mInNameEdit = false ; mNameContainerView . setVisibility ( View . VISIBLE ) ; mEditNameContainerView . setVisibility ( View . GONE ) ; mStopFavorite . setVisibility ( View . VISIBLE ) ; mExpandCollapse . setVisibility ( cachedExpandCollapseViewVisibility ) ; mNoArrivals . setVisibility ( View . VISIBLE ) ; if ( mHasError || mHasWarning ) { mAlertView . setVisibility ( View . VISIBLE ) ; } UIUtils . closeKeyboard ( mContext , mEditNameView ) ; refresh ( ) ; }
public void closeStatusPopups ( ) { if ( mPopup1 != null ) { mPopup1 . dismiss ( ) ; } if ( mPopup2 != null ) { mPopup2 . dismiss ( ) ; } }
public void showProgress ( boolean visibility ) { if ( mProgressBar == null ) return; if ( visibility ) { mProgressBar . setVisibility ( View . VISIBLE ) ; } else { mProgressBar . setVisibility ( View . GONE ) ; } }
public ObaContext ( ) { }
public void setAppInfo ( int version , String uuid ) { mAppVer = version ; mAppUid = uuid ; }
public void setAppInfo ( Uri . Builder builder ) { if ( mAppVer != 0 ) { builder . appendQueryParameter ( "app_ver" , String . valueOf ( mAppVer ) ) ; } if ( mAppUid != null ) { builder . appendQueryParameter ( "app_uid" , mAppUid ) ; } }
public void setApiKey ( String apiKey ) { mApiKey = apiKey ; }
public String getApiKey ( ) { return mApiKey ; }
public void setRegion ( ObaRegion region ) { mRegion = region ; }
public ObaRegion getRegion ( ) { return mRegion ; }
public ObaConnectionFactory setConnectionFactory ( ObaConnectionFactory factory ) { ObaConnectionFactory prev = mConnectionFactory ; mConnectionFactory = factory ; return prev ; }
public ObaConnectionFactory getConnectionFactory ( ) { return mConnectionFactory ; }
@ Override public ObaContext clone ( ) { ObaContext result = new ObaContext ( ) ; result . setApiKey ( mApiKey ) ; result . setAppInfo ( mAppVer , mAppUid ) ; result . setConnectionFactory ( mConnectionFactory ) ; return result ; }
public GitOperation ( File fileDir , Activity callingActivity ) { this . repository = PasswordRepository . getRepository ( fileDir ) ; this . callingActivity = callingActivity ; }
public GitOperation setAuthentication ( String username , String password ) { SshSessionFactory . setInstance ( new GitConfigSessionFactory ( ) ) ; this . provider = new UsernamePasswordCredentialsProvider ( username , password ) ; return this ; }
public GitOperation setAuthentication ( File sshKey , String username , String passphrase ) { JschConfigSessionFactory sessionFactory = new SshConfigSessionFactory ( sshKey . getAbsolutePath ( ) , username , passphrase ) ; SshSessionFactory . setInstance ( sessionFactory ) ; this . provider = null ; return this ; }
public abstract void execute ( )
public void executeAfterAuthentication ( final String connectionMode , final String username , @ Nullable final File sshKey ) { executeAfterAuthentication ( connectionMode , username , sshKey , false ) ; }
@ Override public void onClick ( DialogInterface dialog , int id ) { callingActivity . finish ( ) ; }
public void onClick ( DialogInterface dialog , int whichButton ) { if ( keyPair . decrypt ( passphrase . getText ( ) . toString ( ) ) ) { setAuthentication ( sshKey , username , passphrase . getText ( ) . toString ( ) ) . execute ( ) ; } else { executeAfterAuthentication ( connectionMode , username , sshKey , true ) ; } }
public void onClick ( DialogInterface dialog , int whichButton ) { }
@ Override public void onClick ( DialogInterface dialogInterface , int i ) { }
public void onClick ( DialogInterface dialog , int whichButton ) { setAuthentication ( username , password . getText ( ) . toString ( ) ) . execute ( ) ; }
public void onClick ( DialogInterface dialog , int whichButton ) { }
@ Override public void onClick ( DialogInterface dialogInterface , int i ) { callingActivity . setResult ( Activity . RESULT_CANCELED ) ; callingActivity . finish ( ) ; }
public String getShortName ( )
public String getShapeId ( )
public int getDirectionId ( )
public String getServiceId ( )
public String getHeadsign ( )
public String getTimezone ( )
public String getRouteId ( )
public String getBlockId ( )
public BuildConfigInjectionSampleIT ( MavenRuntimeBuilder builder ) throws Exception { this . mavenRuntime = builder . build ( ) ; }
@ Override public void onCreate ( ) { super. onCreate ( ) ; component = createComponent ( ) ; AppCompatDelegate . setCompatVectorFromResourcesEnabled ( true ) ; installLeakCanary ( ) ; AndroidThreeTen . init ( this ) ; initTraceDroid ( ) ; AppCompatDelegate . setDefaultNightMode ( component . settings ( ) . getNightMode ( ) ) ; }
public void installLeakCanary ( ) { LeakCanary . install ( this ) ; }
public AppComponent createComponent ( ) { return DaggerAppComponent . builder ( ) . appModule ( new AppModule ( this ) ) . trackerModule ( new TrackerModule ( this ) ) . build ( ) ; }
private void initTraceDroid ( ) { TraceDroid . init ( this ) ; Log . setTAG ( "PassAndroid" ) ; }
public static AppComponent component ( ) { return component ; }
@ VisibleForTesting public static void setComponent ( AppComponent newComponent ) { component = newComponent ; }
static void notifyLoadFinished ( Context context ) { sendBroadcast ( context , CATEGORY_TEST , ACTION_LOAD_FINISHED ) ; }
static void sendBroadcast ( Context context , String action , String category ) { if ( BuildConfig . DEBUG ) { Intent intent = new Intent ( ) ; intent . setAction ( action ) ; intent . addCategory ( category ) ; context . sendBroadcast ( intent ) ; } }
public static void waitForLoadFinished ( Context context ) throws InterruptedException { waitForBroadcast ( context , ACTION_LOAD_FINISHED , CATEGORY_TEST ) ; }
public static void waitForBroadcast ( Context context , String action , String category ) throws InterruptedException { final CountDownLatch signal = new CountDownLatch ( 1 ) ; IntentFilter intentFilter = new IntentFilter ( action ) ; intentFilter . addCategory ( category ) ; BroadcastReceiver broadcastReceiver = new BroadcastReceiver ( ) { @ Override public void onReceive ( Context context , Intent intent ) { signal . countDown ( ) ; } } ; context . registerReceiver ( broadcastReceiver , intentFilter ) ; signal . await ( 10000 , TimeUnit . MILLISECONDS ) ; context . unregisterReceiver ( broadcastReceiver ) ; Thread . sleep ( 1000 ) ; }
@ Override public void onReceive ( Context context , Intent intent ) { signal . countDown ( ) ; }
public static boolean isRunningOnEmulator ( ) { return Build . FINGERPRINT . contains ( "generic" ) ; }
PassSortOrder getSortOrder ( )
boolean doTraceDroidEmailSend ( )
File getPassesDir ( )
File getStateDir ( )
boolean isCondensedModeEnabled ( )
boolean isAutomaticLightEnabled ( )
@ AppCompatDelegate . NightMode int getNightMode ( )
@ Override public void onActivityCreated ( Bundle savedInstanceState ) { super. onActivityCreated ( savedInstanceState ) ; mAdapter = new MyAdapter ( getActivity ( ) ) ; setListAdapter ( mAdapter ) ; }
@ Override public View onCreateView ( LayoutInflater inflater , ViewGroup root , Bundle savedInstanceState ) { if ( root == null ) { return null ; } return inflater . inflate ( R . layout . my_search_route_list , null ) ; }
@ Override public Loader < ObaRoutesForLocationResponse > onCreateLoader ( int id , Bundle args ) { String query = args . getString ( QUERY_TEXT ) ; return new MyLoader ( getActivity ( ) , query , getSearchCenter ( ) ) ; }
@ Override public void onLoadFinished ( Loader < ObaRoutesForLocationResponse > loader , ObaRoutesForLocationResponse response ) { UIUtils . showProgress ( this , false ) ; final int code = response . getCode ( ) ; if ( code == ObaApi . OBA_OK ) { setEmptyText ( getString ( R . string . find_hint_noresults ) ) ; mAdapter . setData ( Arrays . asList ( response . getRoutesForLocation ( ) ) ) ; } else if ( code != 0 ) { setEmptyText ( getString ( R . string . find_hint_noresults ) ) ; } else { setEmptyText ( getString ( R . string . generic_comm_error ) ) ; } }
@ Override public void onLoaderReset ( Loader < ObaRoutesForLocationResponse > loader ) { mAdapter . clear ( ) ; }
@ Override protected void doSearch ( String text ) { UIUtils . showProgress ( this , true ) ; Bundle args = new Bundle ( ) ; args . putString ( QUERY_TEXT , text ) ; Loader < ? > loader = getLoaderManager ( ) . restartLoader ( 0 , args , this ) ; loader . onContentChanged ( ) ; }
@ Override protected int getEditBoxHintText ( ) { return R . string . search_route_hint ; }
@ Override protected int getMinSearchLength ( ) { return 1 ; }
@ Override protected CharSequence getHintText ( ) { return getString ( R . string . find_hint_nofavoriteroutes ) ; }
@ Override public void onListItemClick ( ListView l , View v , int position , long id ) { ListAdapter adapter = l . getAdapter ( ) ; ObaRoute route = ( ObaRoute ) adapter . getItem ( position - l . getHeaderViewsCount ( ) ) ; final String routeId = route . getId ( ) ; final String routeName = UIUtils . getRouteDisplayName ( route ) ; if ( isShortcutMode ( ) ) { Intent intent = RouteInfoActivity . makeIntent ( getActivity ( ) , routeId ) ; makeShortcut ( routeName , intent ) ; } else { RouteInfoActivity . start ( getActivity ( ) , routeId ) ; } }
@ Override public void onCreateContextMenu ( ContextMenu menu , View v , ContextMenuInfo menuInfo ) { super. onCreateContextMenu ( menu , v , menuInfo ) ; AdapterContextMenuInfo info = ( AdapterContextMenuInfo ) menuInfo ; final TextView text = ( TextView ) info . targetView . findViewById ( R . id . short_name ) ; menu . setHeaderTitle ( getString ( R . string . route_name , text . getText ( ) ) ) ; if ( isShortcutMode ( ) ) { menu . add ( 0 , CONTEXT_MENU_DEFAULT , 0 , R . string . my_context_create_shortcut ) ; } else { menu . add ( 0 , CONTEXT_MENU_DEFAULT , 0 , R . string . my_context_get_route_info ) ; } menu . add ( 0 , CONTEXT_MENU_SHOW_ON_MAP , 0 , R . string . my_context_showonmap ) ; final String url = getUrl ( getListView ( ) , info . position ) ; if ( url != null ) { menu . add ( 0 , CONTEXT_MENU_SHOW_URL , 0 , R . string . my_context_show_schedule ) ; } }
@ Override public boolean onContextItemSelected ( MenuItem item ) { AdapterContextMenuInfo info = ( AdapterContextMenuInfo ) item . getMenuInfo ( ) ; switch ( item . getItemId ( ) ) { case CONTEXT_MENU_DEFAULT : onListItemClick ( getListView ( ) , info . targetView , info . position , info . id ) ; return true ; case CONTEXT_MENU_SHOW_ON_MAP : HomeActivity . start ( getActivity ( ) , getId ( getListView ( ) , info . position ) ) ; return true ; case CONTEXT_MENU_SHOW_URL : UIUtils . goToUrl ( getActivity ( ) , getUrl ( getListView ( ) , info . position ) ) ; return true ; default: return super. onContextItemSelected ( item ) ; } }
private String getId ( ListView l , int position ) { ListAdapter adapter = l . getAdapter ( ) ; ObaRoute route = ( ObaRoute ) adapter . getItem ( position - l . getHeaderViewsCount ( ) ) ; return route . getId ( ) ; }
private String getUrl ( ListView l , int position ) { ListAdapter adapter = l . getAdapter ( ) ; ObaRoute route = ( ObaRoute ) adapter . getItem ( position - l . getHeaderViewsCount ( ) ) ; return route . getUrl ( ) ; }
public MyAdapter ( Context context ) { super( context , R . layout . route_list_item ); }
@ Override protected void initView ( View view , ObaRoute route ) { UIUtils . setRouteView ( view , route ) ; }
public MyLoader ( Context context , String query , Location center ) { super( context ); mQueryText = query ; mCenter = center ; }
@ Override public ObaRoutesForLocationResponse loadInBackground ( ) { ObaRoutesForLocationResponse response = new ObaRoutesForLocationRequest . Builder ( getContext ( ) , mCenter ) . setQuery ( mQueryText ) . build ( ) . call ( ) ; if ( response . getCode ( ) == ObaApi . OBA_OK ) { ObaRoute [] routes = response . getRoutesForLocation ( ) ; if ( routes . length != 0 ) { return response ; } } Location center = LocationUtils . getDefaultSearchCenter ( ) ; if ( center != null ) { return new ObaRoutesForLocationRequest . Builder ( getContext ( ) , center ) . setRadius ( LocationUtils . DEFAULT_SEARCH_RADIUS ) . setQuery ( mQueryText ) . build ( ) . call ( ) ; } return response ; }
public ObaStopElement ( ) { id = "" ; lat = 0 ; lon = 0 ; direction = "" ; locationType = LOCATION_STOP ; name = "" ; code = "" ; routeIds = EMPTY_ROUTES ; }
public ObaStopElement ( String id , double lat , double lon , String name , String code ) { this . id = id ; this . lat = lat ; this . lon = lon ; direction = "" ; locationType = LOCATION_STOP ; this . name = name ; this . code = code ; routeIds = EMPTY_ROUTES ; }
public String getId ( ) { return id ; }
public String getStopCode ( ) { return code ; }
public String getName ( ) { return name ; }
public Location getLocation ( ) { return LocationUtils . makeLocation ( lat , lon ) ; }
public double getLatitude ( ) { return lat ; }
public double getLongitude ( ) { return lon ; }
public String getDirection ( ) { return direction ; }
public int getLocationType ( ) { return locationType ; }
public String [] getRouteIds ( ) { return routeIds ; }
@ Override public int hashCode ( ) { final int prime = 31 ; int result = 1 ; result = prime * result + ( ( id == null ) ? 0 : id . hashCode ( ) ) ; return result ; }
@ Override public boolean equals ( Object obj ) { if ( this == obj ) { return true ; } if ( obj == null ) { return false ; } if ( ! ( obj instanceof ObaStopElement ) ) { return false ; } ObaStopElement other = ( ObaStopElement ) obj ; if ( id == null ) { if ( other . id != null ) { return false ; } } else if ( ! id . equals ( other . id ) ) { return false ; } return true ; }
public StoryListAdapter ( @ NonNull Context context , List < Story > storyList , StoryListAdapterListener listener , boolean nightMode ) { mContext = context ; mStoryList = storyList ; mListener = listener ; mNightMode = nightMode ; }
@ Override public StoryViewHolder onCreateViewHolder ( ViewGroup parent , int viewType ) { return StoryViewHolder . create ( mContext , parent ) ; }
@ Override public void onBindViewHolder ( StoryViewHolder viewHolder , int position ) { StoryViewHolder . bind ( viewHolder , position , getItem ( position ) , mListener , mNightMode ) ; }
@ Override public int getItemCount ( ) { return mStoryList . size ( ) ; }
@ Override public long getItemId ( int position ) { return mStoryList . get ( position ) . getStoryId ( ) ; }
public Story getItem ( int position ) { return mStoryList . get ( position ) ; }
public void clear ( ) { mStoryList . clear ( ) ; notifyDataSetChanged ( ) ; }
public void addStories ( @ NonNull List < Story > storyList ) { mStoryList . addAll ( storyList ) ; notifyDataSetChanged ( ) ; }
public int getPositionOfItem ( @ NonNull Story story ) { return mStoryList . indexOf ( story ) ; }
public void addStory ( @ NonNull Story story ) { mStoryList . add ( story ) ; notifyItemInserted ( mStoryList . size ( ) ) ; }
public void removeItem ( int position ) { mStoryList . remove ( position ) ; notifyItemRemoved ( position ) ; }
public void removeAllItems ( ) { mStoryList . clear ( ) ; notifyDataSetChanged ( ) ; }
public void markStoryAsRead ( int position , Story story ) { mStoryList . remove ( position ) ; mStoryList . add ( position , story ) ; notifyItemChanged ( position ) ; }
void onStoryClick ( int position );
void onStorySave ( int position , boolean save );
public RegionsTest ( ) { super( ObaProvider .class , ObaContract . AUTHORITY ); }
public HelloAndroidActivityRobotiumTest ( ) { super( HelloAndroidActivity .class ); }
@ Override public void setUp ( ) Exception { solo = new Solo ( getInstrumentation ( ) , getActivity ( ) ) ; }
@ Override public void tearDown ( ) Exception { solo . finishOpenedActivities ( ) ; }
public CloneOperation ( File fileDir , Activity callingActivity ) { super( fileDir , callingActivity ); }
public CloneOperation setCommand ( String uri ) { this . command = Git . cloneRepository ( ) . setCloneAllBranches ( true ) . setDirectory ( repository . getWorkTree ( ) ) . setURI ( uri ) ; return this ; }
@ Override public CloneOperation setAuthentication ( String username , String password ) { super. setAuthentication ( username , password ) ; return this ; }
@ Override public CloneOperation setAuthentication ( File sshKey , String username , String passphrase ) { super. setAuthentication ( sshKey , username , passphrase ) ; return this ; }
@ Override public void execute ( ) { if ( this . provider != null ) { ( ( CloneCommand ) this . command ) . setCredentialsProvider ( this . provider ) ; } new GitAsyncTask ( callingActivity , true , false , this ) . execute ( this . command ) ; }
@ Override public void onClick ( DialogInterface dialogInterface , int i ) { }
@ Override protected void onCreate ( Bundle savedInstanceState ) { requestWindowFeature ( Window . FEATURE_INDETERMINATE_PROGRESS ) ; super. onCreate ( savedInstanceState ) ; UIUtils . setupActionBar ( this ) ; setSupportProgressBarIndeterminateVisibility ( false ) ; final Intent intent = getIntent ( ) ; final String action = intent . getAction ( ) ; mShortcutMode = Intent . ACTION_CREATE_SHORTCUT . equals ( action ) ; if ( ! mShortcutMode ) { setTitle ( R . string . app_name ) ; } mSearchCenter = getSearchCenter ( intent ) ; if ( savedInstanceState != null ) { mDefaultTab = savedInstanceState . getString ( "tab" ) ; } final Uri data = intent . getData ( ) ; if ( data != null && mDefaultTab == null ) { mDefaultTab = getDefaultTabFromUri ( data ) ; } }
@ Override public void onDestroy ( ) { if ( mDefaultTab == null ) { final ActionBar bar = getSupportActionBar ( ) ; final ActionBar . Tab tab = bar . getSelectedTab ( ) ; PreferenceUtils . saveString ( getLastTabPref ( ) , ( String ) tab . getTag ( ) ) ; } super. onDestroy ( ) ; }
@ Override public boolean onOptionsItemSelected ( MenuItem item ) { if ( item . getItemId ( ) == android . R . id . home ) { NavHelp . goHome ( this , false ) ; return true ; } return false ; }
protected void restoreDefaultTab ( ) { final String def ; if ( mDefaultTab != null ) { def = mDefaultTab ; } else { SharedPreferences settings = Application . getPrefs ( ) ; def = settings . getString ( getLastTabPref ( ) , null ) ; } if ( def != null ) { final ActionBar bar = getSupportActionBar ( ) ; for ( int i = 0 ; i < bar . getTabCount ( ) ; ++ i ) { ActionBar . Tab tab = bar . getTabAt ( i ) ; if ( def . equals ( tab . getTag ( ) ) ) { tab . select ( ) ; } } } }
boolean isShortcutMode ( ) { return mShortcutMode ; }
Location getSearchCenter ( ) { return mSearchCenter ; }
public static final Uri getDefaultTabUri ( String tab ) { return Uri . fromParts ( TAB_SCHEME , tab , null ) ; }
public static String getDefaultTabFromUri ( Uri uri ) { if ( TAB_SCHEME . equals ( uri . getScheme ( ) ) ) { return uri . getSchemeSpecificPart ( ) ; } return null ; }
protected abstract String getLastTabPref ( )
public static final Intent putSearchCenter ( Intent intent , Location pt ) { if ( pt != null ) { double [] p = { pt . getLatitude ( ) , pt . getLongitude ( ) } ; intent . putExtra ( EXTRA_SEARCHCENTER , p ) ; } return intent ; }
private static final Location getSearchCenter ( Intent intent ) { double [] p = intent . getDoubleArrayExtra ( EXTRA_SEARCHCENTER ) ; if ( p != null && p . length == 2 ) { return LocationUtils . makeLocation ( p [ 0 ] , p [ 1 ] ) ; } return null ; }
public IntentAssert ( Intent actual ) { super( actual , IntentAssert .class ); }
public IntentAssert hasData ( String uri ) { return hasData ( Uri . parse ( uri ) ) ; }
public IntentAssert hasComponent ( Context context , Class < ? > cls ) { return hasComponent ( new ComponentName ( context , cls . getName ( ) ) ) ; }
public IntentAssert hasComponent ( String appPkg , Class < ? > cls ) { return hasComponent ( new ComponentName ( appPkg , cls . getName ( ) ) ) ; }
public static String flagsToString ( @ IntentFlags int flags ) { return buildBitMaskString ( flags ) . flag ( FLAG_GRANT_PERSISTABLE_URI_PERMISSION , "grant_persistable_uri_permission" ) . flag ( FLAG_GRANT_READ_URI_PERMISSION , "grant_read_uri_permission" ) . flag ( FLAG_GRANT_WRITE_URI_PERMISSION , "grant_write_uri_permission" ) . flag ( FLAG_DEBUG_LOG_RESOLUTION , "debug_log_resolution" ) . flag ( FLAG_FROM_BACKGROUND , "from_background" ) . flag ( FLAG_ACTIVITY_BROUGHT_TO_FRONT , "activity_brought_to_front" ) . flag ( FLAG_ACTIVITY_CLEAR_TASK , "activity_clear_task" ) . flag ( FLAG_ACTIVITY_CLEAR_TOP , "activity_clear_top" ) . flag ( FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET , "activity_clear_when_task_reset" ) . flag ( FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS , "activity_exclude_from_recents" ) . flag ( FLAG_ACTIVITY_FORWARD_RESULT , "activity_forward_result" ) . flag ( FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY , "activity_launched_from_history" ) . flag ( FLAG_ACTIVITY_MULTIPLE_TASK , "activity_multiple_task" ) . flag ( FLAG_ACTIVITY_NEW_TASK , "activity_new_task" ) . flag ( FLAG_ACTIVITY_NO_ANIMATION , "activity_no_animation" ) . flag ( FLAG_ACTIVITY_NO_HISTORY , "activity_no_history" ) . flag ( FLAG_RECEIVER_NO_ABORT , "receiver_no_abort" ) . flag ( FLAG_RECEIVER_REGISTERED_ONLY , "receiver_registered_only" ) . flag ( FLAG_ACTIVITY_NO_USER_ACTION , "activity_no_user_action" ) . flag ( FLAG_ACTIVITY_PREVIOUS_IS_TOP , "activity_previous_is_top" ) . flag ( FLAG_ACTIVITY_RESET_TASK_IF_NEEDED , "activity_reset_task_if" ) . flag ( FLAG_ACTIVITY_REORDER_TO_FRONT , "activity_reorder_to_front" ) . flag ( FLAG_ACTIVITY_SINGLE_TOP , "activity_single_top" ) . flag ( FLAG_ACTIVITY_TASK_ON_HOME , "activity_task_on_home" ) . flag ( FLAG_INCLUDE_STOPPED_PACKAGES , "include_stopped_packages" ) . get ( ) ; }
Frequency ( ) { startTime = 0 ; endTime = 0 ; headway = 0 ; }
public long getStartTime ( ) { return startTime ; }
public long getEndTime ( ) { return endTime ; }
public long getHeadway ( ) { return headway ; }
ObaArrivalInfo ( ) { routeId = "" ; routeShortName = "" ; routeLongName = "" ; tripId = "" ; tripHeadsign = "" ; stopId = "" ; predictedArrivalTime = 0 ; scheduledArrivalTime = 0 ; predictedDepartureTime = 0 ; scheduledDepartureTime = 0 ; status = "" ; frequency = null ; vehicleId = null ; distanceFromStop = null ; numberOfStopsAway = null ; serviceDate = 0 ; lastUpdateTime = 0 ; predicted = null ; tripStatus = null ; situationIds = null ; arrivalEnabled = true ; departureEnabled = true ; stopSequence = 0 ; totalStopsInTrip = 0 ; blockTripSequence = 0 ; }
public String getRouteId ( ) { return routeId ; }
public String getShortName ( ) { return routeShortName ; }
public String getRouteLongName ( ) { return routeLongName ; }
public String getTripId ( ) { return tripId ; }
public String getHeadsign ( ) { return tripHeadsign ; }
public String getStopId ( ) { return stopId ; }
public long getScheduledArrivalTime ( ) { return scheduledArrivalTime ; }
public long getPredictedArrivalTime ( ) { return predictedArrivalTime ; }
public long getScheduledDepartureTime ( ) { return scheduledDepartureTime ; }
public long getPredictedDepartureTime ( ) { return predictedDepartureTime ; }
public String getStatus ( ) { return status ; }
public Frequency getFrequency ( ) { return frequency ; }
public String getVehicleId ( ) { return vehicleId ; }
public Double getDistanceFromStop ( ) { return distanceFromStop ; }
public Integer getNumberOfStopsAway ( ) { return numberOfStopsAway ; }
public long getServiceDate ( ) { return serviceDate ; }
public long getLastUpdateTime ( ) { return lastUpdateTime ; }
public boolean getPredicted ( ) { return ( predicted != null ) ? predicted : ( predictedDepartureTime != 0 ) ; }
public ObaTripStatus getTripStatus ( ) { return tripStatus ; }
public String [] getSituationIds ( ) { return situationIds ; }
public boolean getArrivalEnabled ( ) { return arrivalEnabled ; }
public boolean getDepartureEnabled ( ) { return departureEnabled ; }
public int getStopSequence ( ) { return stopSequence ; }
public int getTotalStopsInTrip ( ) { return totalStopsInTrip ; }
public int getBlockTripSequence ( ) { return blockTripSequence ; }
public RouteMapController ( Callback callback ) { mFragment = callback ; mLineOverlayColor = mFragment . getActivity ( ) . getResources ( ) . getColor ( R . color . route_line_color_default ) ; mShortAnimationDuration = mFragment . getActivity ( ) . getResources ( ) . getInteger ( android . R . integer . config_shortAnimTime ) ; mRoutePopup = new RoutePopup ( ) ; mRouteLoaderListener = new RouteLoaderListener ( ) ; mVehicleLoaderListener = new VehicleLoaderListener ( ) ; }
private void clearCurrentState ( ) { mRouteLoader . stopLoading ( ) ; mRouteLoader . reset ( ) ; mVehiclesLoader . stopLoading ( ) ; mVehiclesLoader . reset ( ) ; mVehicleRefreshHandler . removeCallbacks ( mVehicleRefresh ) ; mFragment . getMapView ( ) . removeRouteOverlay ( ) ; mFragment . getMapView ( ) . removeVehicleOverlay ( ) ; mFragment . getMapView ( ) . removeStopOverlay ( false ) ; }
@ Override public String getMode ( ) { return MapParams . MODE_ROUTE ; }
@ Override public void destroy ( ) { mRoutePopup . hide ( ) ; mFragment . getMapView ( ) . removeRouteOverlay ( ) ; mVehicleRefreshHandler . removeCallbacks ( mVehicleRefresh ) ; mFragment . getMapView ( ) . removeVehicleOverlay ( ) ; }
@ Override public void onPause ( ) { mVehicleRefreshHandler . removeCallbacks ( mVehicleRefresh ) ; }
@ Override public void onHidden ( boolean hidden ) { if ( hidden ) { mRoutePopup . hide ( ) ; } else { mRoutePopup . show ( ) ; } }
@ Override public void onResume ( ) { mVehicleRefreshHandler . removeCallbacks ( mVehicleRefresh ) ; if ( mLastUpdatedTimeVehicles == 0 ) { mVehicleRefreshHandler . postDelayed ( mVehicleRefresh , VEHICLE_REFRESH_PERIOD ) ; return; } long elapsedTimeMillis = TimeUnit . NANOSECONDS . toMillis ( UIUtils . getCurrentTimeForComparison ( ) - mLastUpdatedTimeVehicles ) ; long refreshPeriod ; if ( elapsedTimeMillis > VEHICLE_REFRESH_PERIOD ) { refreshPeriod = 100 ; } else { refreshPeriod = VEHICLE_REFRESH_PERIOD - elapsedTimeMillis ; } mVehicleRefreshHandler . postDelayed ( mVehicleRefresh , refreshPeriod ) ; }
@ Override public void onSaveInstanceState ( Bundle outState ) { outState . putString ( MapParams . ROUTE_ID , mRouteId ) ; outState . putBoolean ( MapParams . ZOOM_TO_ROUTE , mZoomToRoute ) ; outState . putBoolean ( MapParams . ZOOM_INCLUDE_CLOSEST_VEHICLE , mZoomIncludeClosestVehicle ) ; Location centerLocation = mFragment . getMapView ( ) . getMapCenterAsLocation ( ) ; outState . putDouble ( MapParams . CENTER_LAT , centerLocation . getLatitude ( ) ) ; outState . putDouble ( MapParams . CENTER_LON , centerLocation . getLongitude ( ) ) ; outState . putFloat ( MapParams . ZOOM , mFragment . getMapView ( ) . getZoomLevelAsFloat ( ) ) ; }
@ Override public void onViewStateRestored ( Bundle savedInstanceState ) { if ( savedInstanceState == null ) { return; } String stopId = savedInstanceState . getString ( MapParams . STOP_ID ) ; if ( stopId == null ) { float mapZoom = savedInstanceState . getFloat ( MapParams . ZOOM , MapParams . DEFAULT_ZOOM ) ; if ( mapZoom != MapParams . DEFAULT_ZOOM ) { mFragment . getMapView ( ) . setZoom ( mapZoom ) ; } double lat = savedInstanceState . getDouble ( MapParams . CENTER_LAT ) ; double lon = savedInstanceState . getDouble ( MapParams . CENTER_LON ) ; if ( lat != 0.0d && lon != 0.0d ) { Location location = LocationUtils . makeLocation ( lat , lon ) ; mFragment . getMapView ( ) . setMapCenter ( location , false , false ) ; } } }
@ Override public void onLocation ( ) { }
@ Override public void onNoLocation ( ) { }
@ Override public void notifyMapChanged ( ) { }
RoutePopup ( ) { mActivity = mFragment . getActivity ( ) ; float paddingDp = mActivity . getResources ( ) . getDimension ( R . dimen . map_route_vehicle_markers_padding ) / mActivity . getResources ( ) . getDisplayMetrics ( ) . density ; VEHICLE_MARKER_PADDING = UIUtils . dpToPixels ( mActivity , paddingDp ) ; mView = mActivity . findViewById ( R . id . route_info ) ; mFragment . getMapView ( ) . setPadding ( null , mView . getHeight ( ) + VEHICLE_MARKER_PADDING , null , null ) ; mRouteShortName = ( TextView ) mView . findViewById ( R . id . short_name ) ; mRouteLongName = ( TextView ) mView . findViewById ( R . id . long_name ) ; mAgencyName = ( TextView ) mView . findViewById ( R . id . agency ) ; mProgressBar = ( ProgressBar ) mView . findViewById ( R . id . route_info_loading_spinner ) ; View cancel = mView . findViewById ( R . id . cancel_route_mode ) ; cancel . setVisibility ( View . VISIBLE ) ; cancel . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { ObaMapView obaMapView = mFragment . getMapView ( ) ; Bundle bundle = new Bundle ( ) ; bundle . putBoolean ( MapParams . DO_N0T_CENTER_ON_LOCATION , true ) ; bundle . putFloat ( MapParams . ZOOM , obaMapView . getZoomLevelAsFloat ( ) ) ; Location point = obaMapView . getMapCenterAsLocation ( ) ; bundle . putDouble ( MapParams . CENTER_LAT , point . getLatitude ( ) ) ; bundle . putDouble ( MapParams . CENTER_LON , point . getLongitude ( ) ) ; mFragment . setMapMode ( MapParams . MODE_STOP , bundle ) ; } } ) ; }
@ Override public void onClick ( View v ) { ObaMapView obaMapView = mFragment . getMapView ( ) ; Bundle bundle = new Bundle ( ) ; bundle . putBoolean ( MapParams . DO_N0T_CENTER_ON_LOCATION , true ) ; bundle . putFloat ( MapParams . ZOOM , obaMapView . getZoomLevelAsFloat ( ) ) ; Location point = obaMapView . getMapCenterAsLocation ( ) ; bundle . putDouble ( MapParams . CENTER_LAT , point . getLatitude ( ) ) ; bundle . putDouble ( MapParams . CENTER_LON , point . getLongitude ( ) ) ; mFragment . setMapMode ( MapParams . MODE_STOP , bundle ) ; }
void showLoading ( ) { mFragment . getMapView ( ) . setPadding ( null , mView . getHeight ( ) + VEHICLE_MARKER_PADDING , null , null ) ; UIUtils . hideViewWithoutAnimation ( mRouteShortName ) ; UIUtils . hideViewWithoutAnimation ( mRouteLongName ) ; UIUtils . showViewWithoutAnimation ( mView ) ; UIUtils . showViewWithoutAnimation ( mProgressBar ) ; }
void show ( ObaRoute route , String agencyName ) { mRouteShortName . setText ( UIUtils . formatDisplayText ( UIUtils . getRouteDisplayName ( route ) ) ) ; mRouteLongName . setText ( UIUtils . formatDisplayText ( UIUtils . getRouteDescription ( route ) ) ) ; mAgencyName . setText ( agencyName ) ; show ( ) ; }
void show ( ) { UIUtils . hideViewWithAnimation ( mProgressBar , mShortAnimationDuration ) ; UIUtils . showViewWithAnimation ( mRouteShortName , mShortAnimationDuration ) ; UIUtils . showViewWithAnimation ( mRouteLongName , mShortAnimationDuration ) ; UIUtils . showViewWithAnimation ( mView , mShortAnimationDuration ) ; mFragment . getMapView ( ) . setPadding ( null , mView . getHeight ( ) + VEHICLE_MARKER_PADDING , null , null ) ; }
void hide ( ) { mFragment . getMapView ( ) . setPadding ( null , 0 , null , null ) ; UIUtils . hideViewWithAnimation ( mView , mShortAnimationDuration ) ; }
public void run ( ) { refresh ( ) ; }
private void refresh ( ) { if ( mVehiclesLoader != null ) { mVehiclesLoader . onContentChanged ( ) ; } }
public RoutesLoader ( Context context , String routeId ) { super( context ); mRouteId = routeId ; }
@ Override public void deliverResult ( ObaStopsForRouteResponse data ) { super. deliverResult ( data ) ; }
@ Override public void onStartLoading ( ) { forceLoad ( ) ; }
@ Override public Loader < ObaStopsForRouteResponse > onCreateLoader ( int id , Bundle args ) { return new RoutesLoader ( mFragment . getActivity ( ) , mRouteId ) ; }
@ Override public void onLoadFinished ( Loader < ObaStopsForRouteResponse > loader , ObaStopsForRouteResponse response ) { ObaMapView obaMapView = mFragment . getMapView ( ) ; if ( response == null || response . getCode ( ) != ObaApi . OBA_OK ) { BaseMapFragment . showMapError ( response ) ; return; } ObaRoute route = response . getRoute ( response . getRouteId ( ) ) ; mRoutePopup . show ( route , response . getAgency ( route . getAgencyId ( ) ) . getName ( ) ) ; if ( route . getColor ( ) != null ) { mLineOverlayColor = route . getColor ( ) ; } obaMapView . setRouteOverlay ( mLineOverlayColor , response . getShapes ( ) ) ; List < ObaStop > stops = response . getStops ( ) ; mFragment . showStops ( stops , response ) ; mFragment . showProgress ( false ) ; if ( mZoomToRoute ) { obaMapView . zoomToRoute ( ) ; mZoomToRoute = false ; } obaMapView . postInvalidate ( ) ; }
@ Override public void onLoaderReset ( Loader < ObaStopsForRouteResponse > loader ) { mFragment . getMapView ( ) . removeRouteOverlay ( ) ; mFragment . getMapView ( ) . removeVehicleOverlay ( ) ; }
@ Override public void onLoadComplete ( Loader < ObaStopsForRouteResponse > loader , ObaStopsForRouteResponse response ) { onLoadFinished ( loader , response ) ; }
public VehiclesLoader ( Context context , String routeId ) { super( context ); mRouteId = routeId ; }
@ Override public void deliverResult ( ObaTripsForRouteResponse data ) { super. deliverResult ( data ) ; }
@ Override public void onStartLoading ( ) { forceLoad ( ) ; }
@ Override public Loader < ObaTripsForRouteResponse > onCreateLoader ( int id , Bundle args ) { return new VehiclesLoader ( mFragment . getActivity ( ) , mRouteId ) ; }
@ Override public void onLoadFinished ( Loader < ObaTripsForRouteResponse > loader , ObaTripsForRouteResponse response ) { ObaMapView obaMapView = mFragment . getMapView ( ) ; if ( response == null || response . getCode ( ) != ObaApi . OBA_OK ) { BaseMapFragment . showMapError ( response ) ; return; } routes . clear ( ) ; routes . add ( mRouteId ) ; obaMapView . updateVehicles ( routes , response ) ; if ( mZoomIncludeClosestVehicle ) { obaMapView . zoomIncludeClosestVehicle ( routes , response ) ; mZoomIncludeClosestVehicle = false ; } mLastUpdatedTimeVehicles = UIUtils . getCurrentTimeForComparison ( ) ; mVehicleRefreshHandler . removeCallbacks ( mVehicleRefresh ) ; mVehicleRefreshHandler . postDelayed ( mVehicleRefresh , VEHICLE_REFRESH_PERIOD ) ; }
@ Override public void onLoaderReset ( Loader < ObaTripsForRouteResponse > loader ) { mFragment . getMapView ( ) . removeVehicleOverlay ( ) ; }
@ Override public void onLoadComplete ( Loader < ObaTripsForRouteResponse > loader , ObaTripsForRouteResponse response ) { onLoadFinished ( loader , response ) ; }
@ TargetApi ( 9 ) public static void saveString ( SharedPreferences prefs , String key , String value ) { SharedPreferences . Editor edit = prefs . edit ( ) ; edit . putString ( key , value ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . GINGERBREAD ) { edit . apply ( ) ; } else { edit . commit ( ) ; } }
public static void saveString ( String key , String value ) { saveString ( Application . getPrefs ( ) , key , value ) ; }
@ TargetApi ( 9 ) public static void saveInt ( SharedPreferences prefs , String key , int value ) { SharedPreferences . Editor edit = prefs . edit ( ) ; edit . putInt ( key , value ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . GINGERBREAD ) { edit . apply ( ) ; } else { edit . commit ( ) ; } }
public static void saveInt ( String key , int value ) { saveInt ( Application . getPrefs ( ) , key , value ) ; }
@ TargetApi ( 9 ) public static void saveLong ( SharedPreferences prefs , String key , long value ) { SharedPreferences . Editor edit = prefs . edit ( ) ; edit . putLong ( key , value ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . GINGERBREAD ) { edit . apply ( ) ; } else { edit . commit ( ) ; } }
public static void saveLong ( String key , long value ) { saveLong ( Application . getPrefs ( ) , key , value ) ; }
@ TargetApi ( 9 ) public static void saveBoolean ( SharedPreferences prefs , String key , boolean value ) { SharedPreferences . Editor edit = prefs . edit ( ) ; edit . putBoolean ( key , value ) ; if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . GINGERBREAD ) { edit . apply ( ) ; } else { edit . commit ( ) ; } }
public static void saveBoolean ( String key , boolean value ) { saveBoolean ( Application . getPrefs ( ) , key , value ) ; }
public static org . assertj . android . support . v4 . api . app . ActionBarDrawerToggleAssert assertThat ( android . support . v4 . app . ActionBarDrawerToggle actual ) { return new org . assertj . android . support . v4 . api . app . ActionBarDrawerToggleAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . app . DialogFragmentAssert assertThat ( android . support . v4 . app . DialogFragment actual ) { return new org . assertj . android . support . v4 . api . app . DialogFragmentAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . app . FragmentAssert assertThat ( android . support . v4 . app . Fragment actual ) { return new org . assertj . android . support . v4 . api . app . FragmentAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . app . FragmentManagerAssert assertThat ( android . support . v4 . app . FragmentManager actual ) { return new org . assertj . android . support . v4 . api . app . FragmentManagerAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . app . FragmentTransactionAssert assertThat ( android . support . v4 . app . FragmentTransaction actual ) { return new org . assertj . android . support . v4 . api . app . FragmentTransactionAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . app . ListFragmentAssert assertThat ( android . support . v4 . app . ListFragment actual ) { return new org . assertj . android . support . v4 . api . app . ListFragmentAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . app . LoaderManagerAssert assertThat ( android . support . v4 . app . LoaderManager actual ) { return new org . assertj . android . support . v4 . api . app . LoaderManagerAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . content . CursorLoaderAssert assertThat ( android . support . v4 . content . CursorLoader actual ) { return new org . assertj . android . support . v4 . api . content . CursorLoaderAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . content . LoaderAssert assertThat ( android . support . v4 . content . Loader actual ) { return new org . assertj . android . support . v4 . api . content . LoaderAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . media . TransportControllerAssert assertThat ( android . support . v4 . media . TransportController actual ) { return new org . assertj . android . support . v4 . api . media . TransportControllerAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . media . TransportMediatorAssert assertThat ( android . support . v4 . media . TransportMediator actual ) { return new org . assertj . android . support . v4 . api . media . TransportMediatorAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . print . PrintHelperAssert assertThat ( android . support . v4 . print . PrintHelper actual ) { return new org . assertj . android . support . v4 . api . print . PrintHelperAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . util . AtomicFileAssert assertThat ( android . support . v4 . util . AtomicFile actual ) { return new org . assertj . android . support . v4 . api . util . AtomicFileAssert ( actual ) ; }
public static < E > org . assertj . android . support . v4 . api . util . CircularArrayAssert < E > assertThat ( android . support . v4 . util . CircularArray < E > actual ) { return new org . assertj . android . support . v4 . api . util . CircularArrayAssert <> ( actual ) ; }
public static org . assertj . android . support . v4 . api . util . LongSparseArrayAssert assertThat ( android . support . v4 . util . LongSparseArray actual ) { return new org . assertj . android . support . v4 . api . util . LongSparseArrayAssert ( actual ) ; }
public static < K , V > org . assertj . android . support . v4 . api . util . LruCacheAssert < K , V > assertThat ( android . support . v4 . util . LruCache < K , V > actual ) { return new org . assertj . android . support . v4 . api . util . LruCacheAssert <> ( actual ) ; }
public static < E > org . assertj . android . support . v4 . api . util . SparseArrayCompatAssert < E > assertThat ( android . support . v4 . util . SparseArrayCompat < E > actual ) { return new org . assertj . android . support . v4 . api . util . SparseArrayCompatAssert <> ( actual ) ; }
public static org . assertj . android . support . v4 . api . view . PagerAdapterAssert assertThat ( android . support . v4 . view . PagerAdapter actual ) { return new org . assertj . android . support . v4 . api . view . PagerAdapterAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . view . ViewPagerAssert assertThat ( android . support . v4 . view . ViewPager actual ) { return new org . assertj . android . support . v4 . api . view . ViewPagerAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . widget . CursorAdapterAssert assertThat ( android . support . v4 . widget . CursorAdapter actual ) { return new org . assertj . android . support . v4 . api . widget . CursorAdapterAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . widget . SimpleCursorAdapterAssert assertThat ( android . support . v4 . widget . SimpleCursorAdapter actual ) { return new org . assertj . android . support . v4 . api . widget . SimpleCursorAdapterAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . widget . SlidingPaneLayoutAssert assertThat ( android . support . v4 . widget . SlidingPaneLayout actual ) { return new org . assertj . android . support . v4 . api . widget . SlidingPaneLayoutAssert ( actual ) ; }
public static org . assertj . android . support . v4 . api . widget . SwipeRefreshLayoutAssert assertThat ( android . support . v4 . widget . SwipeRefreshLayout actual ) { return new org . assertj . android . support . v4 . api . widget . SwipeRefreshLayoutAssert ( actual ) ; }
private Security ( ) { throw new AssertionError ( ) ; }
@ Nonnull public static Cipherer < byte [] , byte [] > newAndroidAesByteCipherer ( ) { return org . solovyev . common . security . Security . newCipherer ( CIPHER_ALGORITHM , PROVIDER , InitialVectorDef . newRandom ( IV_RANDOM_ALGORITHM , IV_LENGTH ) ) ; }
@ Nonnull public static Cipherer < byte [] , byte [] > newAndroidAesByteCipherer ( final byte [] initialVector ) { return org . solovyev . common . security . Security . newCipherer ( CIPHER_ALGORITHM , PROVIDER , InitialVectorDef . newPredefined ( initialVector ) ) ; }
@ Nonnull public static SecretKeyProvider newAndroidAesSecretKeyProvider ( ) { return org . solovyev . common . security . Security . newPbeSecretKeyProvider ( PBE_ITERATION_COUNT , PBE_ALGORITHM , CIPHERER_ALGORITHM_AES , PROVIDER , PBE_KEY_LENGTH , SALT_LENGTH ) ; }
@ Nonnull public static HashProvider < byte [] , byte [] > newAndroidSha512ByteHashProvider ( ) { return org . solovyev . common . security . Security . newHashProvider ( HASH_ALGORITHM , PROVIDER ) ; }
@ Nonnull public static HashProvider < String , String > newAndroidSha512StringHashProvider ( ) { return TypedHashProvider . newInstance ( newAndroidSha512ByteHashProvider ( ) , StringDecoder . getInstance ( ) , ABase64StringEncoder . getInstance ( ) ) ; }
@ Nonnull public static SaltGenerator newAndroidSaltGenerator ( ) { return org . solovyev . common . security . Security . newSaltGenerator ( IV_RANDOM_ALGORITHM , SALT_LENGTH ) ; }
@ Nonnull public static Cipherer < String , String > newAndroidAesStringCipherer ( ) { return TypedCipherer . newInstance ( newAndroidAesByteCipherer ( ) , StringDecoder . getInstance ( ) , StringEncoder . getInstance ( ) , ABase64StringDecoder . getInstance ( ) , ABase64StringEncoder . getInstance ( ) ) ; }
@ Nonnull public static Cipherer < String , String > newAndroidAesStringCipherer ( final byte [] initialVector ) { return TypedCipherer . newInstance ( newAndroidAesByteCipherer ( initialVector ) , StringDecoder . getInstance ( ) , StringEncoder . getInstance ( ) , ABase64StringDecoder . getInstance ( ) , ABase64StringEncoder . getInstance ( ) ) ; }
@ Nonnull public static SecurityService < byte [] , byte [] , byte [] > newAndroidAesByteSecurityService ( ) { return newSecurityService ( newAndroidAesByteCipherer ( ) , newAndroidAesSecretKeyProvider ( ) , newAndroidSaltGenerator ( ) , newAndroidSha512ByteHashProvider ( ) ) ; }