@ -82,7 +82,7 @@ public class MediaFileListFragment extends AbstractListFragment {
ListType . Sort sortMethod = null ;
String parentDirectory = null ;
int playlistId = PlaylistType . MUSIC_PLAYLISTID ; // this is the ID of the music player
// private MediaFileListAdapter adapter = null;
// private MediaFileListAdapter adapter = null;
boolean browseRootAlready = false ;
FileLocation loadOnVisible = null ;
@ -249,8 +249,8 @@ public class MediaFileListFragment extends AbstractListFragment {
if ( ! isAdded ( ) ) return ;
Toast . makeText ( getActivity ( ) ,
String . format ( getString ( R . string . error_getting_source_info ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
String . format ( getString ( R . string . error_getting_source_info ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
}
} , callbackHandler ) ;
}
@ -320,9 +320,9 @@ public class MediaFileListFragment extends AbstractListFragment {
} ;
Files . GetDirectory action = new Files . GetDirectory ( dir . file ,
mediaType ,
sortMethod ,
properties ) ;
mediaType ,
sortMethod ,
properties ) ;
action . execute ( hostManager . getConnection ( ) , new ApiCallback < List < ListType . ItemFile > > ( ) {
@Override
public void onSuccess ( List < ListType . ItemFile > result ) {
@ -348,8 +348,8 @@ public class MediaFileListFragment extends AbstractListFragment {
if ( ! isAdded ( ) ) return ;
Toast . makeText ( getActivity ( ) ,
String . format ( getString ( R . string . error_getting_source_info ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
String . format ( getString ( R . string . error_getting_source_info ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
}
} , callbackHandler ) ;
@ -366,21 +366,48 @@ public class MediaFileListFragment extends AbstractListFragment {
action . execute ( hostManager . getConnection ( ) , new ApiCallback < String > ( ) {
@Override
public void onSuccess ( String result ) {
while ( ! mediaQueueFileLocation . isEmpty ( ) ) {
queueMediaFile ( mediaQueueFileLocation . poll ( ) . file ) ;
}
HostConnection connection = hostManager . getConnection ( ) ;
startPlaylistIfNoActivePlayers ( connection , playlistId , callbackHandler ) ;
callbackHandler . post ( queueMediaQueueFileLocations ) ;
}
@Override
public void onError ( int errorCode , String description ) {
if ( ! isAdded ( ) ) return ;
Toast . makeText ( getActivity ( ) ,
String . format ( getString ( R . string . error_play_media_file ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
String . format ( getString ( R . string . error_play_media_file ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
}
} , callbackHandler ) ;
}
private Runnable queueMediaQueueFileLocations = new Runnable ( ) {
@Override
public void run ( ) {
if ( ! mediaQueueFileLocation . isEmpty ( ) ) {
final HostConnection connection = hostManager . getConnection ( ) ;
PlaylistType . Item item = new PlaylistType . Item ( ) ;
item . file = mediaQueueFileLocation . poll ( ) . file ;
Playlist . Add action = new Playlist . Add ( playlistId , item ) ;
action . execute ( connection , new ApiCallback < String > ( ) {
@Override
public void onSuccess ( String result ) {
callbackHandler . post ( queueMediaQueueFileLocations ) ;
}
@Override
public void onError ( int errorCode , String description ) {
if ( ! isAdded ( ) ) return ;
Toast . makeText ( getActivity ( ) ,
String . format ( getString ( R . string . error_queue_media_file ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
callbackHandler . post ( queueMediaQueueFileLocations ) ;
}
} , callbackHandler ) ;
}
}
} ;
/ * *
* Starts playing the given media file on the local device
* @param filename Filename to start playing
@ -420,8 +447,8 @@ public class MediaFileListFragment extends AbstractListFragment {
public void onError ( int errorCode , String description ) {
if ( ! isAdded ( ) ) return ;
Toast . makeText ( getActivity ( ) ,
String . format ( getString ( R . string . error_queue_media_file ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
String . format ( getString ( R . string . error_queue_media_file ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
}
} , callbackHandler ) ;
}
@ -450,8 +477,8 @@ public class MediaFileListFragment extends AbstractListFragment {
public void onError ( int errorCode , String description ) {
if ( ! isAdded ( ) ) return ;
Toast . makeText ( getActivity ( ) ,
String . format ( getString ( R . string . error_play_media_file ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
String . format ( getString ( R . string . error_play_media_file ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
}
} , callbackHandler ) ;
}
@ -461,8 +488,8 @@ public class MediaFileListFragment extends AbstractListFragment {
public void onError ( int errorCode , String description ) {
if ( ! isAdded ( ) ) return ;
Toast . makeText ( getActivity ( ) ,
String . format ( getString ( R . string . error_get_active_player ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
String . format ( getString ( R . string . error_get_active_player ) , description ) ,
Toast . LENGTH_SHORT ) . show ( ) ;
}
} , callbackHandler ) ;
@ -554,7 +581,6 @@ public class MediaFileListFragment extends AbstractListFragment {
mediaQueueFileLocation . clear ( ) ;
FileLocation fl ;
// start playing the selected one, then queue the rest
mediaQueueFileLocation . add ( loc ) ;
for ( int i = position + 1 ; i < fileLocationItems . size ( ) ; i + + ) {
fl = fileLocationItems . get ( i ) ;
if ( ! fl . isDirectory ) {
@ -582,9 +608,9 @@ public class MediaFileListFragment extends AbstractListFragment {
// Get the art dimensions
Resources resources = context . getResources ( ) ;
artWidth = ( int ) ( resources . getDimension ( R . dimen . filelist_art_width ) /
UIUtils . IMAGE_RESIZE_FACTOR ) ;
UIUtils . IMAGE_RESIZE_FACTOR ) ;
artHeight = ( int ) ( resources . getDimension ( R . dimen . filelist_art_heigth ) /
UIUtils . IMAGE_RESIZE_FACTOR ) ;
UIUtils . IMAGE_RESIZE_FACTOR ) ;
}
@ -616,7 +642,7 @@ public class MediaFileListFragment extends AbstractListFragment {
@Override
public RecyclerView . ViewHolder onCreateViewHolder ( ViewGroup parent , int viewType ) {
View view = LayoutInflater . from ( ctx )
. inflate ( resource , parent , false ) ;
. inflate ( resource , parent , false ) ;
return new ViewHolder ( view , getContext ( ) , hostManager , artWidth , artHeight , itemMenuClickListener ) ;
}
@ -781,8 +807,8 @@ public class MediaFileListFragment extends AbstractListFragment {
}
return new FileLocation ( title , itemFile . file ,
itemFile . filetype . equalsIgnoreCase ( ListType . ItemFile . FILETYPE_DIRECTORY ) ,
details , sizeDuration , artUrl ) ;
itemFile . filetype . equalsIgnoreCase ( ListType . ItemFile . FILETYPE_DIRECTORY ) ,
details , sizeDuration , artUrl ) ;
}
private FileLocation ( Parcel in ) {