app/src/main/java/com/smedic/tubtub/fragments/PlaylistsFragment.java
@Override
    public void onPlaylistsReceived(ArrayList<YouTubePlaylist> youTubePlaylists) {

        //refresh playlists in database
        YouTubeSqlDb.getInstance().playlists().deleteAll();
        for (YouTubePlaylist playlist : youTubePlaylists) {
            YouTubeSqlDb.getInstance().playlists().create(playlist);
        }

        playlists.clear();
        playlists.addAll(youTubePlaylists);
        handler.post(new Runnable() {
            public void run() {
                if (playlistsAdapter != null) {
                    playlistsAdapter.notifyDataSetChanged();
                    swipeToRefresh.setRefreshing(false);
                }
            }
        });
    }
/**
     * Called when playlists are received
     *
     * @param youTubePlaylists - list of playlists to be shown in list view
     */
Called when playlists are received
@param youTubePlaylists - list of playlists to be shown in list view
Called when playlists are received @param youTubePlaylists - list of playlists to be shown in list view
@Override
    public void onPlaylistsReceived(ArrayList<YouTubePlaylist> youTubePlaylists) {
        YouTubeSqlDb.getInstance().playlists().deleteAll();
        for (YouTubePlaylist playlist : youTubePlaylists) {
            YouTubeSqlDb.getInstance().playlists().create(playlist);
        }
        playlists.clear();
        playlists.addAll(youTubePlaylists);
        handler.post(new Runnable() {
            public void run() {
                if (playlistsAdapter != null) {
                    playlistsAdapter.notifyDataSetChanged();
                    swipeToRefresh.setRefreshing(false);
                }
            }
        });
    }
@ Override public void onPlaylistsReceived ( ArrayList < YouTubePlaylist > youTubePlaylists ) { YouTubeSqlDb . getInstance ( ) . playlists ( ) . deleteAll ( ) ; for ( YouTubePlaylist playlist : youTubePlaylists ) { YouTubeSqlDb . getInstance ( ) . playlists ( ) . create ( playlist ) ; } playlists . clear ( ) ; playlists . addAll ( youTubePlaylists ) ; handler . post ( new Runnable ( ) { public void run ( ) { if ( playlistsAdapter != null ) { playlistsAdapter . notifyDataSetChanged ( ) ; swipeToRefresh . setRefreshing ( false ) ; } } } ) ; }
Called when playlists are received
 @param youTubePlaylists - list of playlists to be shown in list view
Called when playlists are received @param youTubePlaylists - list of playlists to be shown in list view
//refresh playlists in database