18
18
import static androidx .media .MediaBrowserServiceCompat .BrowserRoot .EXTRA_SUGGESTED ;
19
19
import static java .util .Arrays .asList ;
20
20
21
- import android .Manifest ;
22
21
import android .app .Activity ;
23
22
import android .app .PendingIntent ;
24
23
import android .content .Context ;
48
47
import android .view .View ;
49
48
import android .view .ViewGroup ;
50
49
import android .widget .AdapterView ;
51
- import android .widget .EditText ;
52
50
import android .widget .ImageButton ;
53
51
import android .widget .ImageView ;
54
52
import android .widget .Spinner ;
62
60
import androidx .appcompat .app .ActionBar ;
63
61
import androidx .appcompat .app .AppCompatActivity ;
64
62
import androidx .appcompat .widget .Toolbar ;
65
- import androidx .core .app .ActivityCompat ;
66
63
import androidx .core .content .ContextCompat ;
67
64
import androidx .core .content .res .ResourcesCompat ;
68
65
import androidx .core .graphics .drawable .DrawableCompat ;
71
68
import androidx .recyclerview .widget .LinearLayoutManager ;
72
69
import androidx .recyclerview .widget .RecyclerView ;
73
70
import androidx .viewpager .widget .PagerAdapter ;
74
- import androidx .viewpager .widget .ViewPager ;
75
71
76
72
import com .example .android .mediacontroller .databinding .ActivityMediaAppControllerBinding ;
77
73
import com .google .android .material .tabs .TabLayout ;
@@ -155,7 +151,7 @@ public class MediaAppControllerActivity extends AppCompatActivity {
155
151
* @return An Intent that can be used to start the Activity.
156
152
*/
157
153
public static Intent buildIntent (final Activity activity ,
158
- final MediaAppDetails appDetails ) {
154
+ final MediaAppDetails appDetails ) {
159
155
final Intent intent = new Intent (activity , MediaAppControllerActivity .class );
160
156
intent .putExtra (APP_DETAILS_EXTRA , appDetails );
161
157
return intent ;
@@ -465,8 +461,6 @@ private void setupMediaController() {
465
461
466
462
// Ensure views are visible.
467
463
binding .viewPager .setVisibility (View .VISIBLE );
468
-
469
- Log .d (TAG , "MediaControllerCompat created" );
470
464
} catch (RemoteException remoteException ) {
471
465
Log .e (TAG , "Failed to create MediaController from session token" , remoteException );
472
466
showToastAndFinish (getString (R .string .media_controller_failed_msg ));
@@ -801,7 +795,7 @@ private void showActions(@PlaybackStateCompat.Actions long actions) {
801
795
}
802
796
803
797
private boolean actionSupported (@ PlaybackStateCompat .Actions long actions ,
804
- @ PlaybackStateCompat .Actions long checkAction ) {
798
+ @ PlaybackStateCompat .Actions long checkAction ) {
805
799
return ((actions & checkAction ) != 0 );
806
800
}
807
801
@@ -828,8 +822,8 @@ private static class AudioFocusHelper
828
822
private final Spinner mFocusTypeSpinner ;
829
823
830
824
private AudioFocusHelper (@ NonNull Context context ,
831
- @ NonNull ToggleButton focusToggleButton ,
832
- @ NonNull Spinner focusTypeSpinner ) {
825
+ @ NonNull ToggleButton focusToggleButton ,
826
+ @ NonNull Spinner focusTypeSpinner ) {
833
827
834
828
mAudioManager = (AudioManager ) context .getSystemService (AUDIO_SERVICE );
835
829
mToggleButton = focusToggleButton ;
@@ -947,7 +941,7 @@ public int getItemCount() {
947
941
}
948
942
949
943
void setActions (MediaControllerCompat controller ,
950
- List <PlaybackStateCompat .CustomAction > actions ) {
944
+ List <PlaybackStateCompat .CustomAction > actions ) {
951
945
mControls = controller .getTransportControls ();
952
946
try {
953
947
mMediaAppResources = getPackageManager ()
@@ -1009,9 +1003,9 @@ private static abstract class ModeHelper implements AdapterView.OnItemSelectedLi
1009
1003
private final List <Integer > modes ;
1010
1004
1011
1005
ModeHelper (ViewGroup container ,
1012
- @ IdRes int stateSpinnerView ,
1013
- @ IdRes int iconImageView ,
1014
- List <Integer > modes ) {
1006
+ @ IdRes int stateSpinnerView ,
1007
+ @ IdRes int iconImageView ,
1008
+ List <Integer > modes ) {
1015
1009
this .context = container .getContext ();
1016
1010
this .spinner = container .findViewById (stateSpinnerView );
1017
1011
this .icon = container .findViewById (iconImageView );
@@ -1123,7 +1117,7 @@ private class BrowseMediaItemsAdapter extends
1123
1117
new MediaBrowserCompat .SubscriptionCallback () {
1124
1118
@ Override
1125
1119
public void onChildrenLoaded (@ NonNull String parentId ,
1126
- @ NonNull List <MediaItem > children ) {
1120
+ @ NonNull List <MediaItem > children ) {
1127
1121
updateItemsEmptyIfNull (children );
1128
1122
}
1129
1123
};
@@ -1333,19 +1327,19 @@ protected void subscribe() {
1333
1327
if (treeDepth () == 1 ) {
1334
1328
mBrowser .search (getCurrentNode (), null ,
1335
1329
new MediaBrowserCompat .SearchCallback () {
1336
- @ Override
1337
- public void onSearchResult (@ NonNull String query , Bundle extras ,
1338
- @ NonNull List <MediaBrowserCompat .MediaItem > items ) {
1339
- if (query .equals (getCurrentNode ())) {
1340
- updateItemsEmptyIfNull (items );
1341
- }
1342
- }
1343
-
1344
- @ Override
1345
- public void onError (@ NonNull String query , Bundle extras ) {
1346
- super .onError (query , extras );
1347
- }
1348
- });
1330
+ @ Override
1331
+ public void onSearchResult (@ NonNull String query , Bundle extras ,
1332
+ @ NonNull List <MediaBrowserCompat .MediaItem > items ) {
1333
+ if (query .equals (getCurrentNode ())) {
1334
+ updateItemsEmptyIfNull (items );
1335
+ }
1336
+ }
1337
+
1338
+ @ Override
1339
+ public void onError (@ NonNull String query , Bundle extras ) {
1340
+ super .onError (query , extras );
1341
+ }
1342
+ });
1349
1343
} else {
1350
1344
super .subscribe ();
1351
1345
}
0 commit comments