Android Open Source - osu-taste-portable Beatmap Loader






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.loaders;
//from www .  j a  v a  2 s.  c o  m
import android.content.Context;
import android.database.Cursor;
import com.dgsrz.osuTaste.model.Beatmap;
import com.dgsrz.osuTaste.provider.BeatmapStore;
import com.dgsrz.osuTaste.provider.BeatmapStore.BeatmapColumns;
import com.dgsrz.osuTaste.utils.Lists;

import java.util.ArrayList;
import java.util.List;

/**
 * @author dgsrz (dgsrz@vip.qq.com)
 */
public class BeatmapLoader extends WrappedAsyncTaskLoader<List<Beatmap>> {

    private final ArrayList<Beatmap> mBeatmapList = Lists.newArrayList();

    private Cursor mCursor;

    public BeatmapLoader(final Context context) {
        super(context);
    }

    @Override
    public List<Beatmap> loadInBackground() {
        mCursor = makeBeatmapCursor(getContext());
        if (mCursor != null && mCursor.moveToFirst()) {
            do {
                final int id = mCursor.getInt(0);
                final String fileName = mCursor.getString(1);
                final String directory = mCursor.getString(2);
                final String title = mCursor.getString(3);
                final String difficulty = mCursor.getString(4);
                final String artist = mCursor.getString(5);
                final String mapper = mCursor.getString(6);
                Beatmap beatmap = new Beatmap(
                        id,
                        fileName,
                        directory,
                        title,
                        difficulty,
                        artist,
                        mapper
                );
                mBeatmapList.add(beatmap);
            } while (mCursor.moveToNext());
        }
        if (mCursor != null) {
            mCursor.close();
            mCursor = null;
        }
        return mBeatmapList;
    }

    public static final Cursor makeBeatmapCursor(final Context context) {
        return BeatmapStore
                .getInstance(context)
                .getReadableDatabase()
                .query(BeatmapColumns.NAME,
                        new String[] {
                                BeatmapColumns.ID + " as _id",
                                BeatmapColumns.FILENAME,
                                BeatmapColumns.DIRECTORY,
                                BeatmapColumns.TITLE,
                                BeatmapColumns.DIFFICULTY,
                                BeatmapColumns.ARTIST,
                                BeatmapColumns.MAPPER
                        }, null, null, null, null, null);
    }
}




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