app/src/main/java/com/smedic/tubtub/fragments/RecentlyWatchedFragment.java
void addListeners() {
        recentlyPlayedListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> av, View v, final int pos,
                                    long id) {
                if (conf.isNetworkAvailable()) {

                    Toast.makeText(getContext(), "Playing: " + recentlyPlayedVideos.get(pos).getTitle(), Toast.LENGTH_SHORT).show();

                    YouTubeSqlDb.getInstance().videos(YouTubeSqlDb.VIDEOS_TYPE.RECENTLY_WATCHED).create(recentlyPlayedVideos.get(pos));

                    Intent serviceIntent = new Intent(getContext(), BackgroundAudioService.class);
                    serviceIntent.setAction(BackgroundAudioService.ACTION_PLAY);
                    serviceIntent.putExtra(Config.YOUTUBE_TYPE, Config.YOUTUBE_MEDIA_TYPE_VIDEO);
                    serviceIntent.putExtra(Config.YOUTUBE_TYPE_VIDEO, recentlyPlayedVideos.get(pos));
                    getActivity().startService(serviceIntent);
                } else {
                    conf.createNetErrorDialog();
                }
            }
        });
    }
/**
     * Adds listener for list item choosing
     */
Adds listener for list item choosing
Adds listener for list item choosing
void addListeners() {
        recentlyPlayedListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> av, View v, final int pos,
                                    long id) {
                if (conf.isNetworkAvailable()) {
                    Toast.makeText(getContext(), "Playing: " + recentlyPlayedVideos.get(pos).getTitle(), Toast.LENGTH_SHORT).show();
                    YouTubeSqlDb.getInstance().videos(YouTubeSqlDb.VIDEOS_TYPE.RECENTLY_WATCHED).create(recentlyPlayedVideos.get(pos));
                    Intent serviceIntent = new Intent(getContext(), BackgroundAudioService.class);
                    serviceIntent.setAction(BackgroundAudioService.ACTION_PLAY);
                    serviceIntent.putExtra(Config.YOUTUBE_TYPE, Config.YOUTUBE_MEDIA_TYPE_VIDEO);
                    serviceIntent.putExtra(Config.YOUTUBE_TYPE_VIDEO, recentlyPlayedVideos.get(pos));
                    getActivity().startService(serviceIntent);
                } else {
                    conf.createNetErrorDialog();
                }
            }
        });
    }
void addListeners ( ) { recentlyPlayedListView . setOnItemClickListener ( new AdapterView . OnItemClickListener ( ) { @ Override public void onItemClick ( AdapterView < ? > av , View v , final int pos , long id ) { if ( conf . isNetworkAvailable ( ) ) { Toast . makeText ( getContext ( ) , "Playing: " + recentlyPlayedVideos . get ( pos ) . getTitle ( ) , Toast . LENGTH_SHORT ) . show ( ) ; YouTubeSqlDb . getInstance ( ) . videos ( YouTubeSqlDb . VIDEOS_TYPE . RECENTLY_WATCHED ) . create ( recentlyPlayedVideos . get ( pos ) ) ; Intent serviceIntent = new Intent ( getContext ( ) , BackgroundAudioService . class ) ; serviceIntent . setAction ( BackgroundAudioService . ACTION_PLAY ) ; serviceIntent . putExtra ( Config . YOUTUBE_TYPE , Config . YOUTUBE_MEDIA_TYPE_VIDEO ) ; serviceIntent . putExtra ( Config . YOUTUBE_TYPE_VIDEO , recentlyPlayedVideos . get ( pos ) ) ; getActivity ( ) . startService ( serviceIntent ) ; } else { conf . createNetErrorDialog ( ) ; } } } ) ; }
Adds listener for list item choosing
Adds listener for list item choosing