Search in sources :

Example 1 with MusicPlaylistAdapter

use of io.recom.howabout.category.music.adapter.MusicPlaylistAdapter 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 2 with MusicPlaylistAdapter

use of io.recom.howabout.category.music.adapter.MusicPlaylistAdapter 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 3 with MusicPlaylistAdapter

use of io.recom.howabout.category.music.adapter.MusicPlaylistAdapter in project howabout-android by recomio.

the class HowaboutApplication method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    // initialze universal image loader.
    DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder().cacheInMemory().cacheOnDisc().build();
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).defaultDisplayImageOptions(defaultOptions).build();
    ImageLoader.getInstance().init(config);
    // saved playlist.
    String prefsName = getString(R.string.prefs_name);
    SharedPreferences prefs = getSharedPreferences(prefsName, 0);
    String trackListJson = prefs.getString("trackListJson", null);
    // initialize playlistAdapter to use globally.
    if (trackListJson == null) {
        playlistAdapter = new MusicPlaylistAdapter(this);
    } else {
        Gson gson = new Gson();
        TrackList trackList = gson.fromJson(trackListJson, TrackList.class);
        playlistAdapter = new MusicPlaylistAdapter(this, trackList);
    }
    MusicPlayerService.setPlaylistAdapter(playlistAdapter);
}
Also used : SharedPreferences(android.content.SharedPreferences) MusicPlaylistAdapter(io.recom.howabout.category.music.adapter.MusicPlaylistAdapter) TrackList(io.recom.howabout.category.music.model.TrackList) Gson(com.google.gson.Gson) ImageLoaderConfiguration(com.nostra13.universalimageloader.core.ImageLoaderConfiguration) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions)

Aggregations

MusicPlaylistAdapter (io.recom.howabout.category.music.adapter.MusicPlaylistAdapter)3 HowaboutApplication (io.recom.howabout.HowaboutApplication)2 Intent (android.content.Intent)1 SharedPreferences (android.content.SharedPreferences)1 DataSetObserver (android.database.DataSetObserver)1 Bundle (android.os.Bundle)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Gson (com.google.gson.Gson)1 DisplayImageOptions (com.nostra13.universalimageloader.core.DisplayImageOptions)1 ImageLoaderConfiguration (com.nostra13.universalimageloader.core.ImageLoaderConfiguration)1 MusicPlaylistActivity (io.recom.howabout.category.music.activity.MusicPlaylistActivity)1 TrackList (io.recom.howabout.category.music.model.TrackList)1