Android Open Source - osu-taste-portable Album Fragment






From Project

Back to project page osu-taste-portable.

License

The source code is released under:

Apache License

If you think the Android project osu-taste-portable listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.dgsrz.osuTaste.fragments;
/*from  w  w w . j  ava 2 s.  c om*/
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.Loader;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import com.dgsrz.osuTaste.R;
import com.dgsrz.osuTaste.loaders.BeatmapLoader;
import com.dgsrz.osuTaste.model.Beatmap;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author dgsrz (dgsrz@vip.qq.com)
 */
public final class AlbumFragment extends Fragment implements LoaderCallbacks<List<Beatmap>> {

    private final static String MUSIC_SERVICE = "com.dgsrz.osuTaste.services.BassService";

    private final static String OPERATE_PLAY = "play";

    private static final int LOADER = 0;

    public static AlbumFragment getInstance() {
        return new AlbumFragment();
    }

    SimpleAdapter mAdapter;

    ListView listView;

    List<Beatmap> mBeatmapList;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.list_view, container, false);
        listView = (ListView)v.findViewById(R.id.listView);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Beatmap beatmap = mBeatmapList.get(position);
                Intent intent = new Intent();
                intent.setAction(MUSIC_SERVICE);
                intent.putExtra(OPERATE_PLAY, beatmap.mDirectory + "/" + beatmap.mFileName);
                getActivity().sendBroadcast(intent);
            }
        });
        return v;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void onActivityCreated(final Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        getLoaderManager().initLoader(LOADER, null, this);
    }

    @Override
    public Loader<List<Beatmap>> onCreateLoader(final int id, final Bundle arg) {
        return new BeatmapLoader(getActivity());
    }

    @Override
    public void onLoadFinished(final Loader<List<Beatmap>> loader, final List<Beatmap> data) {
        if (data.isEmpty()) {
            return;
        }
        mBeatmapList = data;
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
        for (final Beatmap beatmap : data) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("name", beatmap.mFileName);
            map.put("album", R.drawable.music);
            map.put("info", beatmap.mArtist);
            list.add(map);
        }
        mAdapter = new SimpleAdapter(getActivity(),
                list,
                R.layout.list_item_normal,
                new String[] { "album", "name", "info" },
                new int[] { R.id.imageView, R.id.name, R.id.info });
        mAdapter.notifyDataSetChanged();
        listView.setAdapter(mAdapter);
    }

    @Override
    public void onLoaderReset(Loader<List<Beatmap>> listLoader) {
        mAdapter.notifyDataSetChanged();
    }
}




Java Source Code List

com.dgsrz.osuTaste.activities.BaseActivity.java
com.dgsrz.osuTaste.activities.HomeActivity.java
com.dgsrz.osuTaste.activities.SearchActivity.java
com.dgsrz.osuTaste.activities.SettingsActivity.java
com.dgsrz.osuTaste.activities.SplashActivity.java
com.dgsrz.osuTaste.adapters.PagerAdapter.java
com.dgsrz.osuTaste.beatmap.BeatmapParser.java
com.dgsrz.osuTaste.beatmap.HitObjectType.java
com.dgsrz.osuTaste.beatmap.HitObject.java
com.dgsrz.osuTaste.beatmap.InheritedTimingPoint.java
com.dgsrz.osuTaste.beatmap.TimingPoint.java
com.dgsrz.osuTaste.exception.BeatmapParsingException.java
com.dgsrz.osuTaste.fragments.AlbumFragment.java
com.dgsrz.osuTaste.loaders.BeatmapLoader.java
com.dgsrz.osuTaste.loaders.WrappedAsyncTaskLoader.java
com.dgsrz.osuTaste.model.Beatmap.java
com.dgsrz.osuTaste.provider.BeatmapStore.java
com.dgsrz.osuTaste.services.BassInterface.java
com.dgsrz.osuTaste.services.BassService.java
com.dgsrz.osuTaste.services.SampleProvider.java
com.dgsrz.osuTaste.services.StreamProvider.java
com.dgsrz.osuTaste.utils.ApplicationUtils.java
com.dgsrz.osuTaste.utils.Lists.java
com.dgsrz.osuTaste.utils.MusicUtils.java
com.dgsrz.osuTaste.utils.NavUtils.java
com.dgsrz.osuTaste.utils.PreferenceUtils.java
com.un4seen.bass.BASS.java