YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.browser.BrowseContentItemAdapter Class Reference

Adapter for browsing devices. More...

Inheritance diagram for de.yaacc.browser.BrowseContentItemAdapter:
Inheritance graph
Collaboration diagram for de.yaacc.browser.BrowseContentItemAdapter:
Collaboration graph

Classes

enum  SortMode
 The order in which browsed items are shown. More...
 
class  ViewHolder
 
enum  ViewMode
 Which layout presents the currently-loaded items. More...
 

Public Member Functions

 BrowseContentItemAdapter (ContentListFragment contentListFragment, RecyclerView contentList, UpnpClient upnpClient, ProgressBar progressBar)
 
SortMode getSortMode ()
 
ViewMode getViewMode ()
 
void setViewMode (ViewMode mode)
 Changes which layout presents the currently-loaded items.
 
boolean isNameAscending ()
 
boolean isDateAscending ()
 
void setSortMode (SortMode sortMode)
 Changes the current sort mode.
 
void toggleDirection ()
 Flips the currently-selected mode's own direction (Name: A-Z <-> Z-A; Date: newest-first <-> oldest-first), persists it, and reloads – same as setSortMode(SortMode).
 
boolean isDateSortAvailable ()
 
boolean isServerSortRejected ()
 
void markServerSortRejected ()
 Records that the server rejected a sorted Browse request for the current folder load, so later chunk requests skip straight to the unsorted request.
 
long getItemId (int position)
 
int getItemViewType (int position)
 
Navigator getNavigator ()
 
void setAllItemsFetched (boolean allItemsFetched)
 
Context getContext ()
 
boolean isLoading ()
 
boolean isLoadFailed ()
 
void setLoadFailed (boolean loadFailed)
 
void setLoading (boolean loading)
 
int getItemCount ()
 
void addAll (Collection<? extends DIDLObject > newObjects)
 
void clear ()
 
void release ()
 Ends the sort thread and drops a running sort; to be called when the adapter is not used any more (the view of its fragment is destroyed).
 
Object getItem (int position)
 
List< DIDLObject > getObjects ()
 Returns the currently-loaded children in their current, on-screen order – i.e.
 
BrowseContentItemAdapter.ViewHolder onCreateViewHolder (ViewGroup parent, int viewType)
 
void onBindViewHolder (final BrowseContentItemAdapter.ViewHolder holder, final int listPosition)
 
void cancelRunningTasks ()
 
void removeTask (AsyncTask task)
 
void onViewRecycled (ViewHolder holder)
 
DIDLObject getFolder (int position)
 
void loadMore ()
 
void loadMore (Long itemsToLoad, Integer scrollToPositionId)
 
void scrollToPositionId (Integer id)
 

Detailed Description

Adapter for browsing devices.

Author
Christoph Haehnel (eyeless)

Member Function Documentation

◆ getObjects()

List< DIDLObject > de.yaacc.browser.BrowseContentItemAdapter.getObjects ( )

Returns the currently-loaded children in their current, on-screen order – i.e.

already reflecting whatever client-side sort mode and direction is active (see sortObjects()). Used by ContentListFragment#playAllChildsOfParentFrom(DIDLObject) (issue play-all-ignores-sort-order) to build a playback queue that matches what the user sees and tapped, instead of re-fetching the folder from the server in its unsorted default order.

Returns a defensive snapshot copy (wrapped unmodifiable) rather than a live view over objects, because this method is also called from a background thread (see ContentListFragment#
playAllChildsOfParentFrom
, invoked from ContentItemPlayTask
#doInBackground
) while objects is mutated in place from the main thread (addAll/clear/sortObjects, driven by setSortMode/toggleDirection/loadMore). A live Collections.unmodifiableList(objects) view does not protect against that: a concurrent mutation while the background thread iterates/filters the view can still throw a ConcurrentModificationException or yield a torn read.

Returns
an unmodifiable snapshot copy of the adapter's current backing list, taken at the time of the call; never null.

Referenced by de.yaacc.browser.ContentListFragment.playAllChildsOfParentFrom().

Here is the caller graph for this function:

◆ isDateAscending()

boolean de.yaacc.browser.BrowseContentItemAdapter.isDateAscending ( )
Returns
Date mode's own current direction: true for oldest-first (ascending), false for newest-first (descending).

◆ isDateSortAvailable()

boolean de.yaacc.browser.BrowseContentItemAdapter.isDateSortAvailable ( )
Returns
true if at least one currently loaded item carries a non-null dc:date property, i.e. date sorting is meaningful for the current folder.

◆ isLoadFailed()

boolean de.yaacc.browser.BrowseContentItemAdapter.isLoadFailed ( )
Returns
true if the last chunk request of the current folder load failed (after the retries); what is shown is what was loaded before

◆ isLoading()

boolean de.yaacc.browser.BrowseContentItemAdapter.isLoading ( )
Returns
true while a chunk request is running

◆ isNameAscending()

boolean de.yaacc.browser.BrowseContentItemAdapter.isNameAscending ( )
Returns
Name mode's own current direction: true for A-Z (ascending), false for Z-A.

◆ isServerSortRejected()

boolean de.yaacc.browser.BrowseContentItemAdapter.isServerSortRejected ( )
Returns
true once this folder load has already observed the server reject a sorted (orderBy-bearing) Browse request (a UPnP action failure, per issue #252's post-ship bug fix) – reset in clear(). While true, BrowseItemLoadTask skips the doomed sorted attempt entirely for subsequent chunk requests of the same folder load.

◆ markServerSortRejected()

void de.yaacc.browser.BrowseContentItemAdapter.markServerSortRejected ( )

Records that the server rejected a sorted Browse request for the current folder load, so later chunk requests skip straight to the unsorted request.

Reset on clear() (i.e. on folder change or sort mode change).

◆ release()

void de.yaacc.browser.BrowseContentItemAdapter.release ( )

Ends the sort thread and drops a running sort; to be called when the adapter is not used any more (the view of its fragment is destroyed).

The adapter can be used again, the thread is created on demand.

◆ setSortMode()

void de.yaacc.browser.BrowseContentItemAdapter.setSortMode ( SortMode sortMode)

Changes the current sort mode.

If the mode actually changes, the currently loaded items are cleared and reloaded so the new mode can take effect server-side (see BrowseItemLoadTask) as well as client-side (see sortObjects()).

◆ setViewMode()

void de.yaacc.browser.BrowseContentItemAdapter.setViewMode ( ViewMode mode)

Changes which layout presents the currently-loaded items.

Unlike setSortMode(SortMode), this never clears/reloads – the backing data doesn't change, only how it's drawn, so a plain notifyDataSetChanged() is enough. No-op if mode already matches the current mode.

◆ toggleDirection()

void de.yaacc.browser.BrowseContentItemAdapter.toggleDirection ( )

Flips the currently-selected mode's own direction (Name: A-Z <-> Z-A; Date: newest-first <-> oldest-first), persists it, and reloads – same as setSortMode(SortMode).

The other (not-currently-selected) mode's direction is left untouched, per issue #252 Group 4.


The documentation for this class was generated from the following file: