1717 */
1818package de .yaacc .browser ;
1919
20+ import android .graphics .drawable .Drawable ;
2021import android .os .Bundle ;
2122import android .util .Log ;
2223import android .view .LayoutInflater ;
4748import de .yaacc .upnp .UpnpClient ;
4849import de .yaacc .upnp .UpnpClientListener ;
4950import de .yaacc .upnp .callback .contentdirectory .ContentDirectoryBrowseResult ;
51+ import de .yaacc .util .ThemeHelper ;
5052
5153/**
5254 * Activity for browsing devices and folders. Represents the entrypoint for the whole application.
@@ -91,6 +93,8 @@ public void run() {
9193 private void init (Bundle savedInstanceState , View contentlistView ) {
9294 upnpClient = ((Yaacc ) requireActivity ().getApplicationContext ()).getUpnpClient ();
9395 backButton = contentlistView .findViewById (R .id .contentListBackButton );
96+ Drawable icon = ThemeHelper .tintDrawable (getResources ().getDrawable (R .drawable .ic_baseline_arrow_back_24 , getContext ().getTheme ()), getContext ().getTheme ());
97+ backButton .setImageDrawable (icon );
9498 backButton .setOnClickListener ((v ) -> {
9599 onBackPressed ();
96100 });
@@ -100,6 +104,9 @@ private void init(Bundle savedInstanceState, View contentlistView) {
100104 topSeperator = contentlistView .findViewById (R .id .contentListTopSeperator );
101105 contentList = contentlistView .findViewById (R .id .contentList );
102106 contentList .setLayoutManager (new LinearLayoutManager (getActivity ()));
107+ contentList .setFocusable (true );
108+ contentList .setFocusableInTouchMode (false ); // Good for D-Pad primary interaction
109+ contentList .setDescendantFocusability (ViewGroup .FOCUS_AFTER_DESCENDANTS );
103110 upnpClient .addUpnpClientListener (this );
104111 if (getActivity () != null ) {
105112 getActivity ().runOnUiThread (() -> {
@@ -239,8 +246,6 @@ private void initBrowsItemAdapter(RecyclerView itemList) {
239246 public void onScrolled (@ NonNull RecyclerView recyclerView , int dx , int dy ) {
240247 super .onScrolled (recyclerView , dx , dy );
241248 LinearLayoutManager linearLayoutManager = (LinearLayoutManager ) recyclerView .getLayoutManager ();
242-
243-
244249 if (linearLayoutManager != null && linearLayoutManager .findLastCompletelyVisibleItemPosition () == bItemAdapter .getItemCount () - 1 ) {
245250 if (getActivity () != null ) {
246251 getActivity ().runOnUiThread (() -> {
@@ -249,8 +254,6 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
249254 });
250255 }
251256 }
252-
253-
254257 }
255258 });
256259 }
@@ -372,9 +375,9 @@ public void playAllChildsOfParentFrom(DIDLObject item) {
372375 return ;
373376 }
374377 ContentDirectoryBrowseResult result = upnpClient .browseSync (new Position (0 , item .getParentID (), upnpClient .getProviderDevice ().getIdentity ().getUdn ().getIdentifierString (), item .getTitle ()));
375- if (result == null || (result .getResult () != null && result .getResult ().getItems ().size () == 0 )) {
378+ if (result == null || (result .getResult () != null && result .getResult ().getItems ().isEmpty () )) {
376379 Log .d (getClass ().getName (), "Browse result of parent no direct items found..." );
377- if (result != null && result .getResult () != null && result .getResult ().getContainers ().size () > 0 ) {
380+ if (result != null && result .getResult () != null && ! result .getResult ().getContainers ().isEmpty () ) {
378381 play (upnpClient .initializePlayers (upnpClient .toItemList (result .getResult ())));
379382 } else {
380383 play (upnpClient .initializePlayers (item ));
0 commit comments