Search in sources :

Example 6 with HowaboutApplication

use of io.recom.howabout.HowaboutApplication in project howabout-android by recomio.

the class MusicBottomBarFragment method updateTrack.

protected void updateTrack() {
    HowaboutApplication application = (HowaboutApplication) getActivity().getApplication();
    Track track = application.getPlaylistAdapter().getCurrentItem();
    if (track != null) {
        trackTitle.setText(track.getTrackTitle());
        artistName.setText(track.getArtistName());
        imageLoader.displayImage(track.getThumbnailUrl(), imageView, new ImageLoadingListener() {

            @Override
            public void onLoadingStarted(String imageUri, View view) {
            }

            @Override
            public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            }

            @Override
            public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            }

            @Override
            public void onLoadingCancelled(String imageUri, View view) {
            }
        });
        rootView.setVisibility(View.VISIBLE);
    } else {
        rootView.setVisibility(View.GONE);
    }
    if (MusicPlayerService.isLoading()) {
        isLoading.setVisibility(View.VISIBLE);
        isPlaying.setVisibility(View.GONE);
    } else {
        if (MusicPlayerService.isPlaying()) {
            isPlaying.setImageDrawable(pauseIcon);
        } else {
            isPlaying.setImageDrawable(playIcon);
        }
        isLoading.setVisibility(View.GONE);
        isPlaying.setVisibility(View.VISIBLE);
    }
}
Also used : Bitmap(android.graphics.Bitmap) ImageLoadingListener(com.nostra13.universalimageloader.core.assist.ImageLoadingListener) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) HowaboutApplication(io.recom.howabout.HowaboutApplication) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Track(io.recom.howabout.category.music.model.Track)

Example 7 with HowaboutApplication

use of io.recom.howabout.HowaboutApplication in project howabout-android by recomio.

the class MusicBottomBarFragment method onDestroy.

@Override
public void onDestroy() {
    HowaboutApplication application = (HowaboutApplication) getActivity().getApplication();
    MusicPlaylistAdapter playlistAdapter = application.getPlaylistAdapter();
    playlistAdapter.unregisterDataSetObserver(playlistObserver);
    super.onDestroy();
}
Also used : MusicPlaylistAdapter(io.recom.howabout.category.music.adapter.MusicPlaylistAdapter) HowaboutApplication(io.recom.howabout.HowaboutApplication)

Example 8 with HowaboutApplication

use of io.recom.howabout.HowaboutApplication in project howabout-android by recomio.

the class MusicBottomBarFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = inflater.inflate(R.layout.fragment_music_bottom_bar, container, false);
    rootView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), MusicPlaylistActivity.class);
            Bundle bundle = new Bundle();
            intent.putExtras(bundle);
            intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
            startActivity(intent);
        }
    });
    imageView = (ImageView) rootView.findViewById(R.id.image);
    trackTitle = (TextView) rootView.findViewById(R.id.trackTitle);
    artistName = (TextView) rootView.findViewById(R.id.artistName);
    isLoading = (ProgressBar) rootView.findViewById(R.id.isLoading);
    isPlaying = (ImageView) rootView.findViewById(R.id.isPlaying);
    isPlaying.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            HowaboutApplication application = (HowaboutApplication) getActivity().getApplication();
            MusicPlaylistAdapter playlistAdapter = application.getPlaylistAdapter();
            playlistAdapter.playPauseToggle();
        }
    });
    playlistObserver = new DataSetObserver() {

        @Override
        public void onChanged() {
            updateTrack();
        }

        @Override
        public void onInvalidated() {
            updateTrack();
        }
    };
    HowaboutApplication application = (HowaboutApplication) getActivity().getApplication();
    MusicPlaylistAdapter playlistAdapter = application.getPlaylistAdapter();
    playlistAdapter.registerDataSetObserver(playlistObserver);
    return rootView;
}
Also used : Bundle(android.os.Bundle) MusicPlaylistAdapter(io.recom.howabout.category.music.adapter.MusicPlaylistAdapter) OnClickListener(android.view.View.OnClickListener) Intent(android.content.Intent) MusicPlaylistActivity(io.recom.howabout.category.music.activity.MusicPlaylistActivity) HowaboutApplication(io.recom.howabout.HowaboutApplication) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) DataSetObserver(android.database.DataSetObserver)

Example 9 with HowaboutApplication

use of io.recom.howabout.HowaboutApplication in project howabout-android by recomio.

the class TrackListAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final View trackListItemView;
    if (convertView == null) {
        LayoutInflater inflater = LayoutInflater.from(parent.getContext());
        trackListItemView = inflater.inflate(R.layout.track_list_item, parent, false);
    } else {
        trackListItemView = convertView;
    }
    final ProgressBar progressBar = (ProgressBar) trackListItemView.findViewById(R.id.load);
    final ImageView imageView = (ImageView) trackListItemView.findViewById(R.id.image);
    final TextView trackTitle = (TextView) trackListItemView.findViewById(R.id.trackTitle);
    final TextView artistName = (TextView) trackListItemView.findViewById(R.id.artistName);
    final Track track = trackList.get(position);
    trackTitle.setText(track.getTrackTitle());
    artistName.setText(track.getArtistName());
    String imageUrl = track.getThumbnailUrl();
    imageLoader.displayImage(imageUrl, imageView, new ImageLoadingListener() {

        @Override
        public void onLoadingStarted(String imageUri, View view) {
            progressBar.setVisibility(View.VISIBLE);
            imageView.setVisibility(View.INVISIBLE);
        }

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            imageView.setVisibility(View.VISIBLE);
            progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {
            progressBar.setVisibility(View.GONE);
        }
    });
    final Button listenTrackButton = (Button) trackListItemView.findViewById(R.id.listenTrackButton);
    final Button addTrackButton = (Button) trackListItemView.findViewById(R.id.addTrackButton);
    // when click a 'listen' button.
    listenTrackButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            HowaboutApplication application = (HowaboutApplication) activity.getApplication();
            application.getPlaylistAdapter().play(track);
        }
    });
    // when click an 'add' button.
    addTrackButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            HowaboutApplication application = (HowaboutApplication) activity.getApplication();
            application.getPlaylistAdapter().add(track);
        }
    });
    return trackListItemView;
}
Also used : ImageLoadingListener(com.nostra13.universalimageloader.core.assist.ImageLoadingListener) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) HowaboutApplication(io.recom.howabout.HowaboutApplication) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Bitmap(android.graphics.Bitmap) Button(android.widget.Button) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ImageView(android.widget.ImageView) ProgressBar(android.widget.ProgressBar) Track(io.recom.howabout.category.music.model.Track)

Aggregations

HowaboutApplication (io.recom.howabout.HowaboutApplication)9 View (android.view.View)4 ImageView (android.widget.ImageView)4 TextView (android.widget.TextView)4 Track (io.recom.howabout.category.music.model.Track)4 Bitmap (android.graphics.Bitmap)3 OnClickListener (android.view.View.OnClickListener)3 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)3 ImageLoadingListener (com.nostra13.universalimageloader.core.assist.ImageLoadingListener)3 Intent (android.content.Intent)2 DataSetObserver (android.database.DataSetObserver)2 MusicPlaylistAdapter (io.recom.howabout.category.music.adapter.MusicPlaylistAdapter)2 Notification (android.app.Notification)1 PendingIntent (android.app.PendingIntent)1 Bundle (android.os.Bundle)1 LayoutInflater (android.view.LayoutInflater)1 AdapterView (android.widget.AdapterView)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 OnItemLongClickListener (android.widget.AdapterView.OnItemLongClickListener)1 Button (android.widget.Button)1