Android Open Source - osu-taste-portable Beatmap Store






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.provider;
// w ww  .j ava 2s.co  m
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.dgsrz.osuTaste.model.Beatmap;

import java.util.List;

/**
 * @author dgsrz (dgsrz@vip.qq.com)
 */
public class BeatmapStore extends SQLiteOpenHelper {

    private static final int VERSION = 1;

    public static final String DBNAME = "osu.db";

    private static BeatmapStore sInstance = null;

    public BeatmapStore(final Context context) {
        super(context, DBNAME, null, VERSION);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE IF NOT EXISTS " + BeatmapColumns.NAME + "("
                + BeatmapColumns.ID + " INTEGER PRIMARY KEY,"
                + BeatmapColumns.FILENAME + " TEXT NOT NULL,"
                + BeatmapColumns.DIRECTORY + " TEXT NOT NULL,"
                + BeatmapColumns.TITLE + " TEXT NOT NULL,"
                + BeatmapColumns.DIFFICULTY + " TEXT NOT NULL,"
                + BeatmapColumns.ARTIST + " TEXT NOT NULL,"
                + BeatmapColumns.MAPPER + " TEXT NOT NULL);");
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void onUpgrade(final SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + BeatmapColumns.NAME);
        onCreate(db);
    }

    public static final synchronized BeatmapStore getInstance(final Context context) {
        if (sInstance == null) {
            sInstance = new BeatmapStore(context.getApplicationContext());
        }
        return sInstance;
    }

    public void addBeatmapCollection(final List<Beatmap> beatmaps) {
        final SQLiteDatabase database = getWritableDatabase();

        database.beginTransaction();

        for (Beatmap beatmap : beatmaps) {
            if (beatmap.mFileName == null || beatmap.mDirectory == null || beatmap.mTitle == null
                    || beatmap.mDifficulty == null || beatmap.mArtist == null || beatmap.mMapper == null) {
                continue;
            }
            final ContentValues values = new ContentValues();
            values.put(BeatmapColumns.FILENAME, beatmap.mFileName);
            values.put(BeatmapColumns.DIRECTORY, beatmap.mDirectory);
            values.put(BeatmapColumns.TITLE, beatmap.mTitle);
            values.put(BeatmapColumns.DIFFICULTY, beatmap.mDifficulty);
            values.put(BeatmapColumns.ARTIST, beatmap.mArtist);
            values.put(BeatmapColumns.MAPPER, beatmap.mMapper);
            database.insert(BeatmapColumns.NAME, null, values);
        }

        database.setTransactionSuccessful();
        database.endTransaction();
    }

    public void deleteDatabase() {
        final SQLiteDatabase database = getWritableDatabase();
        database.delete(BeatmapColumns.NAME, null, null);
    }

    public void removeItem(final long songId) {
        final SQLiteDatabase database = getWritableDatabase();
        database.delete(BeatmapColumns.NAME, BeatmapColumns.ID + " = ?",
                new String[] { String.valueOf(songId) });
    }

    public void removeItems(final List<String> conditions) {
        final SQLiteDatabase database = getWritableDatabase();
        database.beginTransaction();

        for (String arg : conditions) {
            database.delete(BeatmapColumns.NAME, BeatmapColumns.DIRECTORY + " = ?",
                    new String[] { String.valueOf(arg) });
        }

        database.setTransactionSuccessful();
        database.endTransaction();
    }

    public interface BeatmapColumns {
        public static final String ID = "id";
        public static final String NAME = "beatmaps";
        public static final String FILENAME = "filename";
        public static final String DIRECTORY = "directory";
        public static final String TITLE = "title";
        public static final String DIFFICULTY = "difficulty";
        public static final String ARTIST = "artist";
        public static final String MAPPER = "mapper";
    }
}




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