Added GameSelection + Logic
Now First screen is a game selection screen, second screen is the settings screen where characters, karts, etc can be found.
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -56,7 +56,7 @@
|
||||
<ConfirmationsSetting value="0" id="Add" />
|
||||
<ConfirmationsSetting value="0" id="Remove" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
|
||||
@@ -7,8 +7,8 @@ android {
|
||||
applicationId "com.de.aldo_apps.aldo.mariokartcircuitselector"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 25
|
||||
versionCode 12
|
||||
versionName "0.1.12"
|
||||
versionCode 16
|
||||
versionName "0.1.16"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
@@ -32,6 +32,6 @@ dependencies {
|
||||
compile 'devlight.io:navigationtabbar:1.2.5'
|
||||
compile 'com.android.support:cardview-v7:25.3.1'
|
||||
compile 'de.hdodenhof:circleimageview:2.1.0'
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:design:25.3.1'
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.de.aldo_apps.aldo.mariokartcircuitselector">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
@@ -11,7 +11,10 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity android:name=".activities.GameSelection">
|
||||
<activity
|
||||
android:name=".activities.GameSelectionActivity"
|
||||
android:label="@string/title_activity_game_selection"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -19,31 +22,34 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<provider android:name=".CharacterContentProvider"
|
||||
<activity android:name=".activities.GameSettingsActivity"/>
|
||||
|
||||
<provider
|
||||
android:name=".CharacterContentProvider"
|
||||
android:authorities="com.de.aldo_apps.aldo.mariokartcircuitselector"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
/>
|
||||
<provider android:name=".WheelsContentProvider"
|
||||
android:exported="true" />
|
||||
<provider
|
||||
android:name=".WheelsContentProvider"
|
||||
android:authorities="com.de.aldo_apps.aldo.mariokartcircuitselector"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
/>
|
||||
<provider android:name=".TrackContentProvider"
|
||||
android:exported="true" />
|
||||
<provider
|
||||
android:name=".TrackContentProvider"
|
||||
android:authorities="com.de.aldo_apps.aldo.mariokartcircuitselector"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
/>
|
||||
<provider android:name=".KartContentProvider"
|
||||
android:exported="true" />
|
||||
<provider
|
||||
android:name=".KartContentProvider"
|
||||
android:authorities="com.de.aldo_apps.aldo.mariokartcircuitselector"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
/>
|
||||
<provider android:name=".AccessoryContentProvider"
|
||||
android:exported="true" />
|
||||
<provider
|
||||
android:name=".AccessoryContentProvider"
|
||||
android:authorities="com.de.aldo_apps.aldo.mariokartcircuitselector"
|
||||
android:enabled="true"
|
||||
android:exported="true"
|
||||
/>
|
||||
android:exported="true" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
Binary file not shown.
@@ -0,0 +1,60 @@
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:SMK_Sprite_Peach.png" WHERE `_rowid_`='1';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:SMK_Sprite_Mario.png" WHERE `_rowid_`='2';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:SMK_Sprite_Luigi.png" WHERE `_rowid_`='3';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:SMK_Sprite_Toad.png" WHERE `_rowid_`='4';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:SMK_Sprite_Koopa.png" WHERE `_rowid_`='5';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:SMK_Sprite_Bowser.png" WHERE `_rowid_`='6';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:SMK_Sprite_Yoshi.png" WHERE `_rowid_`='7';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:SMK_Sprite_Donkey_Kong_Jr..png" WHERE `_rowid_`='8';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MK64_Artwork_Mario.gif" WHERE `_rowid_`='9';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MK64_Artwork_Luigi.gif" WHERE `_rowid_`='10';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MK64_Artwork_Peach.jpg" WHERE `_rowid_`='11';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MK64_Artwork_Toad.jpg" WHERE `_rowid_`='12';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MK64_Artwork_Yoshi.gif" WHERE `_rowid_`='13';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MK64_Artwork_DK.gif" WHERE `_rowid_`='14';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MK64_Artwork_Wario.jpg" WHERE `_rowid_`='15';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MK64_Artwork_Bowser.gif" WHERE `_rowid_`='16';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKSC_Sprite_Mario.png" WHERE `_rowid_`='17';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKSC_Sprite_Luigi.png" WHERE `_rowid_`='18';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKSC_Sprite_Peach.png" WHERE `_rowid_`='19';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKSC_Sprite_Toad.png" WHERE `_rowid_`='20';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKSC_Sprite_Yoshi.png" WHERE `_rowid_`='21';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKSC_Sprite_Donkey_Kong.png" WHERE `_rowid_`='22';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKSC_Sprite_Wario.png" WHERE `_rowid_`='23';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKSC_Sprite_Bowser.png" WHERE `_rowid_`='24';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Mario.png" WHERE `_rowid_`='25';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Luigi.png" WHERE `_rowid_`='26';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Peach.png" WHERE `_rowid_`='27';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Daisy.png" WHERE `_rowid_`='28';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Yoshi.png" WHERE `_rowid_`='29';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Birdo.png" WHERE `_rowid_`='30';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Baby_Mario.png" WHERE `_rowid_`='31';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Baby_Luigi.png" WHERE `_rowid_`='32';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Toad.png" WHERE `_rowid_`='33';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Toadette.png" WHERE `_rowid_`='34';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Koopa.png" WHERE `_rowid_`='35';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Parakoopa.png" WHERE `_rowid_`='36';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Donkey_Kong.png" WHERE `_rowid_`='37';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Diddy_Kong.png" WHERE `_rowid_`='38';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Bowser.png" WHERE `_rowid_`='39';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Bowser_Jr.png" WHERE `_rowid_`='40';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Wario.png" WHERE `_rowid_`='41';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Waluigi.png" WHERE `_rowid_`='42';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_Mutant-Tyranha.png" WHERE `_rowid_`='43';
|
||||
UPDATE `character` SET `cover_uri`="http://mariowiki.net/wiki/Datei:MKDD_Sprite_König_Buu_Huu.png" WHERE `_rowid_`='44';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/File:MKDS-Mario_Artwork.png" WHERE `_rowid_`='45';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/File:MKDS-Luigi_Artwork.png" WHERE `_rowid_`='46';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/File:MKDS-Peach_Artwork.png" WHERE `_rowid_`='47';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/File:MKDS-Yoshi_Artwork.png" WHERE `_rowid_`='48';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/File:MKDS-Toad_Artwork.png" WHERE `_rowid_`='49';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/File:MKDS-Donkey_Kong_Artwork.png" WHERE `_rowid_`='50';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/File:MKDS-Wario_Artwork.png" WHERE `_rowid_`='51';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/File:MKDS-Bowser_Artwork.png" WHERE `_rowid_`='52';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/images/thumb/2/2d/PrincessDaisyMKDS.png/120px-PrincessDaisyMKDS.png" WHERE `_rowid_`='53';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/images/thumb/5/53/MKDS-Dry_Bones_Artwork.png/120px-MKDS-Dry_Bones_Artwork.png" WHERE `_rowid_`='54';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/images/thumb/b/bb/MKDS-Waluigi_Artwork.png/103px-MKDS-Waluigi_Artwork.png" WHERE `_rowid_`='55';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/images/thumb/b/b5/MKDS-ROB_Artwork.png/120px-MKDS-ROB_Artwork.png" WHERE `_rowid_`='56';
|
||||
UPDATE `character` SET `cover_uri`="https://www.mariowiki.com/images/thumb/6/6b/Shy_Guy_-_MKDS.png/120px-Shy_Guy_-_MKDS.png" WHERE `_rowid_`='57';
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
UPDATE `character` SET `cover_uri`="";
|
||||
|
||||
@@ -41,6 +41,8 @@ public class AccessoryContentProvider extends ContentProvider {
|
||||
|
||||
static {
|
||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "games", Constants.GAME_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "ruleset", Constants.RULESET_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "characters", Constants.CHARACTER_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "tracks", Constants.TRACK_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "karts", Constants.KART_LOADER_ID);
|
||||
@@ -84,19 +86,30 @@ public class AccessoryContentProvider extends ContentProvider {
|
||||
switch (resId) {
|
||||
case Constants.CHARACTER_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Characters.");
|
||||
return mHandler.getAllCharacters(Constants.PROJECTION_CHARACTER, null, null);
|
||||
return mHandler.getAllCharacters(Constants.PROJECTION_CHARACTER,
|
||||
selection, selectionArgs);
|
||||
case Constants.KART_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Karts.");
|
||||
return mHandler.getAllKarts(Constants.PROJECTION_KART, null, null);
|
||||
return mHandler.getAllKarts(Constants.PROJECTION_KART,
|
||||
selection, selectionArgs);
|
||||
case Constants.ACCESSORY_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Accessories.");
|
||||
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY, null, null);
|
||||
Log.d(TAG, "query: Getting all Acessories.");
|
||||
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY,
|
||||
selection, selectionArgs);
|
||||
case Constants.TRACK_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Tracks.");
|
||||
return mHandler.getAllTracks(Constants.PROJECTION_TRACK, null, null);
|
||||
return mHandler.getAllTracks(Constants.PROJECTION_TRACK,
|
||||
selection, selectionArgs);
|
||||
case Constants.WHEELS_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Wheels.");
|
||||
return mHandler.getAllWheels(Constants.PROJECTION_WHEELS, null, null);
|
||||
return mHandler.getAllWheels(Constants.PROJECTION_WHEELS,
|
||||
selection, selectionArgs);
|
||||
case Constants.GAME_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Games.");
|
||||
return mHandler.getAllGames(Constants.PROJECTION_GAME, null, null);
|
||||
case Constants.RULESET_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Rulesets.");
|
||||
return mHandler.getAllRulesets(Constants.PROJECTION_RULESET, null, null);
|
||||
default:
|
||||
Log.d(TAG, "query: UriMatcher returned: " + uriMatcher.match(uri));
|
||||
return null;
|
||||
|
||||
@@ -41,6 +41,8 @@ public class CharacterContentProvider extends ContentProvider {
|
||||
|
||||
static {
|
||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "games", Constants.GAME_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "ruleset", Constants.RULESET_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "characters", Constants.CHARACTER_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "tracks", Constants.TRACK_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "karts", Constants.KART_LOADER_ID);
|
||||
@@ -83,19 +85,30 @@ public class CharacterContentProvider extends ContentProvider {
|
||||
switch (resId) {
|
||||
case Constants.CHARACTER_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Characters.");
|
||||
return mHandler.getAllCharacters(Constants.PROJECTION_CHARACTER, null, null);
|
||||
return mHandler.getAllCharacters(Constants.PROJECTION_CHARACTER,
|
||||
selection, selectionArgs);
|
||||
case Constants.KART_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Karts.");
|
||||
return mHandler.getAllKarts(Constants.PROJECTION_KART, null, null);
|
||||
return mHandler.getAllKarts(Constants.PROJECTION_KART,
|
||||
selection, selectionArgs);
|
||||
case Constants.ACCESSORY_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Acessories.");
|
||||
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY, null, null);
|
||||
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY,
|
||||
selection, selectionArgs);
|
||||
case Constants.TRACK_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Tracks.");
|
||||
return mHandler.getAllTracks(Constants.PROJECTION_TRACK, null, null);
|
||||
return mHandler.getAllTracks(Constants.PROJECTION_TRACK,
|
||||
selection, selectionArgs);
|
||||
case Constants.WHEELS_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Wheels.");
|
||||
return mHandler.getAllWheels(Constants.PROJECTION_WHEELS, null, null);
|
||||
return mHandler.getAllWheels(Constants.PROJECTION_WHEELS,
|
||||
selection, selectionArgs);
|
||||
case Constants.GAME_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Games.");
|
||||
return mHandler.getAllGames(Constants.PROJECTION_GAME, null, null);
|
||||
case Constants.RULESET_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Rulesets.");
|
||||
return mHandler.getAllRulesets(Constants.PROJECTION_RULESET, null, null);
|
||||
default:
|
||||
Log.d(TAG, "query: UriMatcher returned: " + uriMatcher.match(uri));
|
||||
return null;
|
||||
|
||||
@@ -13,7 +13,7 @@ public final class Constants {
|
||||
/**
|
||||
* The Version Code of the Database.
|
||||
*/
|
||||
static final Integer DATABASE_VERSION = 2;
|
||||
static final Integer DATABASE_VERSION = 4;
|
||||
|
||||
/**
|
||||
* As SQLite does not have a native boolean value, we use integers to represent true and false.
|
||||
@@ -57,6 +57,16 @@ public final class Constants {
|
||||
*/
|
||||
public static final int WHEELS_LOADER_ID = BASE_LOADER_ID + 4;
|
||||
|
||||
/**
|
||||
* LoaderID of the game loader.
|
||||
*/
|
||||
public static final int GAME_LOADER_ID = BASE_LOADER_ID + 5;
|
||||
|
||||
/**
|
||||
* LoaderID of the ruleset loader.
|
||||
*/
|
||||
public static final int RULESET_LOADER_ID = BASE_LOADER_ID + 6;
|
||||
|
||||
/**
|
||||
* The Key for the projection being provided via a bundle.
|
||||
*/
|
||||
@@ -202,10 +212,15 @@ public final class Constants {
|
||||
*/
|
||||
public static final String KEY_NUMBER = "number";
|
||||
|
||||
/**
|
||||
* Global constant defining the where game is <game_name> clause.
|
||||
*/
|
||||
public static final String SELECT_WHERE_GAME = " game = ?";
|
||||
|
||||
/**
|
||||
* The Projection to retrieve all Information of a game object from database.
|
||||
*/
|
||||
static final String[] PROJECTION_GAME = {
|
||||
public static final String[] PROJECTION_GAME = {
|
||||
KEY_ID,
|
||||
KEY_NAME,
|
||||
KEY_COVER_URI
|
||||
@@ -236,10 +251,6 @@ public final class Constants {
|
||||
KEY_AVAILABLE
|
||||
};
|
||||
|
||||
public static final String[] PROJECTION_TEST = {
|
||||
KEY_NAME
|
||||
};
|
||||
|
||||
/**
|
||||
* The Projection to retrieve all Information of a kart object from database.
|
||||
*/
|
||||
|
||||
@@ -214,6 +214,7 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
final String[] selectionArgs) {
|
||||
final SQLiteDatabase database = this.getReadableDatabase();
|
||||
|
||||
Log.d(TAG, "getAllAccessories: Creating Cursor for Accessories.");
|
||||
final Cursor cursor = database.query(Constants.TABLE_ACCESSORY,
|
||||
projection, selection, selectionArgs, null, null, null,
|
||||
null);
|
||||
@@ -231,6 +232,7 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
final String[] selectionArgs) {
|
||||
final SQLiteDatabase database = this.getReadableDatabase();
|
||||
|
||||
Log.d(TAG, "getAllWheels: Creating Cursor for Wheels.");
|
||||
final Cursor cursor = database.query(Constants.TABLE_WHEELS, projection, selection,
|
||||
selectionArgs, null, null, null, null);
|
||||
|
||||
@@ -243,61 +245,16 @@ public class DatabaseHandler extends SQLiteAssetHelper {
|
||||
*
|
||||
* @return List containing all Game Objects retrieved from Database.
|
||||
*/
|
||||
public ArrayList<Game> getAllGames() {
|
||||
public Cursor getAllGames(final String[] projection,
|
||||
final String selection,
|
||||
final String[] selectionArgs) {
|
||||
final SQLiteDatabase database = this.getReadableDatabase();
|
||||
|
||||
final Cursor cursor = database.query(Constants.TABLE_GAME, Constants.PROJECTION_GAME, null,
|
||||
null, null, null, null, null);
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
Log.d(TAG, "getAllGames: Moving cursor to first.");
|
||||
} else {
|
||||
Log.d(TAG, "getAllGames: cursor is null or cannot be moved to first.");
|
||||
return null;
|
||||
}
|
||||
Log.d(TAG, "getAllGames: Greating Cursor for Games.");
|
||||
final Cursor cursor = database.query(Constants.TABLE_GAME, projection, selection,
|
||||
selectionArgs, null, null, null, null);
|
||||
|
||||
final ArrayList<Game> allAvailableGames = new ArrayList<>();
|
||||
|
||||
do {
|
||||
final int idIdx = cursor.getColumnIndex(Constants.KEY_ID);
|
||||
final int nameIdx = cursor.getColumnIndex(Constants.KEY_NAME);
|
||||
final int coverUriIdx = cursor.getColumnIndex(Constants.KEY_COVER_URI);
|
||||
|
||||
final Game game = new Game();
|
||||
boolean isValid = true;
|
||||
if (idIdx >= 0) {
|
||||
game.setId(cursor.getInt(idIdx));
|
||||
} else {
|
||||
Log.d(TAG, "getAllGames: No such column [" + Constants.KEY_ID + "]");
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (nameIdx >= 0) {
|
||||
game.setName(cursor.getString(nameIdx));
|
||||
} else {
|
||||
Log.d(TAG, "getAllGames: No such column [" + Constants.KEY_NAME + "]");
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (coverUriIdx >= 0) {
|
||||
game.setCoverUri(cursor.getString(coverUriIdx));
|
||||
} else {
|
||||
Log.d(TAG, "getAllGames: No such column [" + Constants.KEY_COVER_URI + "]");
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (isValid) {
|
||||
allAvailableGames.add(game);
|
||||
} else {
|
||||
Log.d(TAG, "getAllGames: Do not add Game as one or more arguments are invalid.");
|
||||
}
|
||||
|
||||
} while (cursor.moveToNext());
|
||||
|
||||
cursor.close();
|
||||
database.close();
|
||||
|
||||
// return contact
|
||||
return allAvailableGames;
|
||||
return cursor;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.de.aldo_apps.aldo.mariokartcircuitselector;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.content.UriMatcher;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Created by aldo7224 on 18.08.17.
|
||||
*/
|
||||
|
||||
public class GameContentProvider extends ContentProvider {
|
||||
|
||||
/**
|
||||
* Tag for debugging output.
|
||||
*/
|
||||
private static final String TAG = "GameProvider";
|
||||
|
||||
/**
|
||||
* The Provider Name to find the correct Provider and register it in the Android Lifecycle.
|
||||
*/
|
||||
public static final String PROVIDER_NAME
|
||||
= "com.de.aldo_apps.aldo.mariokartcircuitselector";
|
||||
|
||||
/**
|
||||
* A uri to do operations on. A content provider is identified by its uri
|
||||
*/
|
||||
public static final Uri CONTENT_URI = Uri.parse("content://" + PROVIDER_NAME + "/games");
|
||||
|
||||
/**
|
||||
* UriMatcher to check which callback needs to be handled.
|
||||
* TODO: Check whether this is really needed.
|
||||
*/
|
||||
private static final UriMatcher uriMatcher;
|
||||
|
||||
static {
|
||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "games", Constants.GAME_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "ruleset", Constants.RULESET_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "characters", Constants.CHARACTER_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "tracks", Constants.TRACK_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "karts", Constants.KART_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "wheels", Constants.WHEELS_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "accessories", Constants.ACCESSORY_LOADER_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* This content provider does the database operations by this object
|
||||
*/
|
||||
DatabaseHandler mHandler;
|
||||
|
||||
/**
|
||||
* A callback method which is invoked when the content provider is starting up
|
||||
*/
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
mHandler = new DatabaseHandler(getContext());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType(@NonNull final Uri uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback method which is by the default content uri
|
||||
*/
|
||||
@Override
|
||||
public Cursor query(@NonNull final Uri uri,
|
||||
final String[] projection,
|
||||
final String selection,
|
||||
final String[] selectionArgs,
|
||||
final String sortOrder) {
|
||||
Log.d(TAG, "query: Perform Query for [" + uri + "]");
|
||||
|
||||
final int resId = uriMatcher.match(uri);
|
||||
|
||||
switch (resId) {
|
||||
case Constants.CHARACTER_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Characters.");
|
||||
return mHandler.getAllCharacters(Constants.PROJECTION_CHARACTER,
|
||||
selection, selectionArgs);
|
||||
case Constants.KART_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Karts.");
|
||||
return mHandler.getAllKarts(Constants.PROJECTION_KART,
|
||||
selection, selectionArgs);
|
||||
case Constants.ACCESSORY_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Acessories.");
|
||||
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY,
|
||||
selection, selectionArgs);
|
||||
case Constants.TRACK_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Tracks.");
|
||||
return mHandler.getAllTracks(Constants.PROJECTION_TRACK,
|
||||
selection, selectionArgs);
|
||||
case Constants.WHEELS_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Wheels.");
|
||||
return mHandler.getAllWheels(Constants.PROJECTION_WHEELS,
|
||||
selection, selectionArgs);
|
||||
case Constants.GAME_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Games.");
|
||||
return mHandler.getAllGames(Constants.PROJECTION_GAME, null, null);
|
||||
case Constants.RULESET_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Rulesets.");
|
||||
return mHandler.getAllRulesets(Constants.PROJECTION_RULESET, null, null);
|
||||
default:
|
||||
Log.d(TAG, "query: UriMatcher returned: " + uriMatcher.match(uri));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(@NonNull final Uri uri, final String selection, final String[] selectionArgs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri insert(@NonNull final Uri uri, final ContentValues values) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(@NonNull final Uri uri, final ContentValues values, final String selection,
|
||||
final String[] selectionArgs) {
|
||||
final int resId = uriMatcher.match(uri);
|
||||
|
||||
switch (resId) {
|
||||
case Constants.CHARACTER_LOADER_ID:
|
||||
Log.d(TAG, "query: Toggling Characters availability.");
|
||||
return mHandler.changeCharacterAvailability(values, selection, selectionArgs);
|
||||
case Constants.KART_LOADER_ID:
|
||||
Log.d(TAG, "query: Toggling Karts availability.");
|
||||
return mHandler.changeKartAvailability(values, selection, selectionArgs);
|
||||
case Constants.ACCESSORY_LOADER_ID:
|
||||
Log.d(TAG, "query: Toggling Accessories availability.");
|
||||
return mHandler.changeAccessoryAvailability(values, selection, selectionArgs);
|
||||
case Constants.TRACK_LOADER_ID:
|
||||
Log.d(TAG, "query: Toggling Tracks availability.");
|
||||
return mHandler.changeTrackAvailability(values, selection, selectionArgs);
|
||||
case Constants.WHEELS_LOADER_ID:
|
||||
Log.d(TAG, "query: Toggling Wheels availability.");
|
||||
return mHandler.changeWheelsAvailability(values, selection, selectionArgs);
|
||||
default:
|
||||
Log.d(TAG, "query: UriMatcher returned: " + uriMatcher.match(uri));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,8 @@ public class KartContentProvider extends ContentProvider {
|
||||
|
||||
static {
|
||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "games", Constants.GAME_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "ruleset", Constants.RULESET_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "characters", Constants.CHARACTER_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "tracks", Constants.TRACK_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "karts", Constants.KART_LOADER_ID);
|
||||
@@ -83,19 +85,30 @@ public class KartContentProvider extends ContentProvider {
|
||||
switch (resId) {
|
||||
case Constants.CHARACTER_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Characters.");
|
||||
return mHandler.getAllCharacters(Constants.PROJECTION_CHARACTER, null, null);
|
||||
return mHandler.getAllCharacters(Constants.PROJECTION_CHARACTER,
|
||||
selection, selectionArgs);
|
||||
case Constants.KART_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Karts.");
|
||||
return mHandler.getAllKarts(Constants.PROJECTION_KART, null, null);
|
||||
return mHandler.getAllKarts(Constants.PROJECTION_KART,
|
||||
selection, selectionArgs);
|
||||
case Constants.ACCESSORY_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Accessories.");
|
||||
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY, null, null);
|
||||
Log.d(TAG, "query: Getting all Acessories.");
|
||||
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY,
|
||||
selection, selectionArgs);
|
||||
case Constants.TRACK_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Tracks.");
|
||||
return mHandler.getAllTracks(Constants.PROJECTION_TRACK, null, null);
|
||||
return mHandler.getAllTracks(Constants.PROJECTION_TRACK,
|
||||
selection, selectionArgs);
|
||||
case Constants.WHEELS_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Wheels.");
|
||||
return mHandler.getAllWheels(Constants.PROJECTION_WHEELS, null, null);
|
||||
return mHandler.getAllWheels(Constants.PROJECTION_WHEELS,
|
||||
selection, selectionArgs);
|
||||
case Constants.GAME_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Games.");
|
||||
return mHandler.getAllGames(Constants.PROJECTION_GAME, null, null);
|
||||
case Constants.RULESET_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Rulesets.");
|
||||
return mHandler.getAllRulesets(Constants.PROJECTION_RULESET, null, null);
|
||||
default:
|
||||
Log.d(TAG, "query: UriMatcher returned: " + uriMatcher.match(uri));
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.de.aldo_apps.aldo.mariokartcircuitselector;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.content.UriMatcher;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* Created by aldo7224 on 18.08.17.
|
||||
*/
|
||||
|
||||
public class RulesetContentProvider extends ContentProvider {
|
||||
|
||||
/**
|
||||
* Tag for debugging output.
|
||||
*/
|
||||
private static final String TAG = "RulesetProvider";
|
||||
|
||||
/**
|
||||
* The Provider Name to find the correct Provider and register it in the Android Lifecycle.
|
||||
*/
|
||||
public static final String PROVIDER_NAME
|
||||
= "com.de.aldo_apps.aldo.mariokartcircuitselector";
|
||||
|
||||
/**
|
||||
* A uri to do operations on. A content provider is identified by its uri
|
||||
*/
|
||||
public static final Uri CONTENT_URI = Uri.parse("content://" + PROVIDER_NAME + "/ruleset");
|
||||
|
||||
/**
|
||||
* UriMatcher to check which callback needs to be handled.
|
||||
* TODO: Check whether this is really needed.
|
||||
*/
|
||||
private static final UriMatcher uriMatcher;
|
||||
|
||||
static {
|
||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "games", Constants.GAME_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "ruleset", Constants.RULESET_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "characters", Constants.CHARACTER_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "tracks", Constants.TRACK_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "karts", Constants.KART_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "wheels", Constants.WHEELS_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "accessories", Constants.ACCESSORY_LOADER_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
* This content provider does the database operations by this object
|
||||
*/
|
||||
DatabaseHandler mHandler;
|
||||
|
||||
/**
|
||||
* A callback method which is invoked when the content provider is starting up
|
||||
*/
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
mHandler = new DatabaseHandler(getContext());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType(@NonNull final Uri uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback method which is by the default content uri
|
||||
*/
|
||||
@Override
|
||||
public Cursor query(@NonNull final Uri uri,
|
||||
final String[] projection,
|
||||
final String selection,
|
||||
final String[] selectionArgs,
|
||||
final String sortOrder) {
|
||||
Log.d(TAG, "query: Perform Query for [" + uri + "]");
|
||||
|
||||
final int resId = uriMatcher.match(uri);
|
||||
|
||||
switch (resId) {
|
||||
case Constants.CHARACTER_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Characters.");
|
||||
return mHandler.getAllCharacters(Constants.PROJECTION_CHARACTER,
|
||||
selection, selectionArgs);
|
||||
case Constants.KART_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Karts.");
|
||||
return mHandler.getAllKarts(Constants.PROJECTION_KART,
|
||||
selection, selectionArgs);
|
||||
case Constants.ACCESSORY_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Acessories.");
|
||||
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY,
|
||||
selection, selectionArgs);
|
||||
case Constants.TRACK_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Tracks.");
|
||||
return mHandler.getAllTracks(Constants.PROJECTION_TRACK,
|
||||
selection, selectionArgs);
|
||||
case Constants.WHEELS_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Wheels.");
|
||||
return mHandler.getAllWheels(Constants.PROJECTION_WHEELS,
|
||||
selection, selectionArgs);
|
||||
case Constants.GAME_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Games.");
|
||||
return mHandler.getAllGames(Constants.PROJECTION_GAME, null, null);
|
||||
case Constants.RULESET_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Rulesets.");
|
||||
return mHandler.getAllRulesets(Constants.PROJECTION_RULESET, null, null);
|
||||
default:
|
||||
Log.d(TAG, "query: UriMatcher returned: " + uriMatcher.match(uri));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(@NonNull final Uri uri, final String selection, final String[] selectionArgs) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri insert(@NonNull final Uri uri, final ContentValues values) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(@NonNull final Uri uri, final ContentValues values, final String selection,
|
||||
final String[] selectionArgs) {
|
||||
final int resId = uriMatcher.match(uri);
|
||||
|
||||
switch (resId) {
|
||||
case Constants.CHARACTER_LOADER_ID:
|
||||
Log.d(TAG, "query: Toggling Characters availability.");
|
||||
return mHandler.changeCharacterAvailability(values, selection, selectionArgs);
|
||||
case Constants.KART_LOADER_ID:
|
||||
Log.d(TAG, "query: Toggling Karts availability.");
|
||||
return mHandler.changeKartAvailability(values, selection, selectionArgs);
|
||||
case Constants.ACCESSORY_LOADER_ID:
|
||||
Log.d(TAG, "query: Toggling Accessories availability.");
|
||||
return mHandler.changeAccessoryAvailability(values, selection, selectionArgs);
|
||||
case Constants.TRACK_LOADER_ID:
|
||||
Log.d(TAG, "query: Toggling Tracks availability.");
|
||||
return mHandler.changeTrackAvailability(values, selection, selectionArgs);
|
||||
case Constants.WHEELS_LOADER_ID:
|
||||
Log.d(TAG, "query: Toggling Wheels availability.");
|
||||
return mHandler.changeWheelsAvailability(values, selection, selectionArgs);
|
||||
default:
|
||||
Log.d(TAG, "query: UriMatcher returned: " + uriMatcher.match(uri));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,8 @@ public class TrackContentProvider extends ContentProvider {
|
||||
|
||||
static {
|
||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "games", Constants.GAME_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "ruleset", Constants.RULESET_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "characters", Constants.CHARACTER_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "tracks", Constants.TRACK_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "karts", Constants.KART_LOADER_ID);
|
||||
@@ -83,19 +85,30 @@ public class TrackContentProvider extends ContentProvider {
|
||||
switch (resId) {
|
||||
case Constants.CHARACTER_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Characters.");
|
||||
return mHandler.getAllCharacters(Constants.PROJECTION_CHARACTER, null, null);
|
||||
return mHandler.getAllCharacters(Constants.PROJECTION_CHARACTER,
|
||||
selection, selectionArgs);
|
||||
case Constants.KART_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Karts.");
|
||||
return mHandler.getAllKarts(Constants.PROJECTION_KART, null, null);
|
||||
return mHandler.getAllKarts(Constants.PROJECTION_KART,
|
||||
selection, selectionArgs);
|
||||
case Constants.ACCESSORY_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Accessories.");
|
||||
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY, null, null);
|
||||
Log.d(TAG, "query: Getting all Acessories.");
|
||||
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY,
|
||||
selection, selectionArgs);
|
||||
case Constants.TRACK_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Tracks.");
|
||||
return mHandler.getAllTracks(Constants.PROJECTION_TRACK, null, null);
|
||||
return mHandler.getAllTracks(Constants.PROJECTION_TRACK,
|
||||
selection, selectionArgs);
|
||||
case Constants.WHEELS_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Wheels.");
|
||||
return mHandler.getAllWheels(Constants.PROJECTION_WHEELS, null, null);
|
||||
return mHandler.getAllWheels(Constants.PROJECTION_WHEELS,
|
||||
selection, selectionArgs);
|
||||
case Constants.GAME_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Games.");
|
||||
return mHandler.getAllGames(Constants.PROJECTION_GAME, null, null);
|
||||
case Constants.RULESET_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Rulesets.");
|
||||
return mHandler.getAllRulesets(Constants.PROJECTION_RULESET, null, null);
|
||||
default:
|
||||
Log.d(TAG, "query: UriMatcher returned: " + uriMatcher.match(uri));
|
||||
return null;
|
||||
|
||||
@@ -41,6 +41,8 @@ public class WheelsContentProvider extends ContentProvider {
|
||||
|
||||
static {
|
||||
uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "games", Constants.GAME_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "ruleset", Constants.RULESET_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "characters", Constants.CHARACTER_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "tracks", Constants.TRACK_LOADER_ID);
|
||||
uriMatcher.addURI(PROVIDER_NAME, "karts", Constants.KART_LOADER_ID);
|
||||
@@ -83,19 +85,30 @@ public class WheelsContentProvider extends ContentProvider {
|
||||
switch (resId) {
|
||||
case Constants.CHARACTER_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Characters.");
|
||||
return mHandler.getAllCharacters(Constants.PROJECTION_CHARACTER, null, null);
|
||||
return mHandler.getAllCharacters(Constants.PROJECTION_CHARACTER,
|
||||
selection, selectionArgs);
|
||||
case Constants.KART_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Karts.");
|
||||
return mHandler.getAllKarts(Constants.PROJECTION_KART, null, null);
|
||||
return mHandler.getAllKarts(Constants.PROJECTION_KART,
|
||||
selection, selectionArgs);
|
||||
case Constants.ACCESSORY_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Accessories.");
|
||||
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY, null, null);
|
||||
Log.d(TAG, "query: Getting all Acessories.");
|
||||
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY,
|
||||
selection, selectionArgs);
|
||||
case Constants.TRACK_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Tracks.");
|
||||
return mHandler.getAllTracks(Constants.PROJECTION_TRACK, null, null);
|
||||
return mHandler.getAllTracks(Constants.PROJECTION_TRACK,
|
||||
selection, selectionArgs);
|
||||
case Constants.WHEELS_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Wheels.");
|
||||
return mHandler.getAllWheels(Constants.PROJECTION_WHEELS, null, null);
|
||||
return mHandler.getAllWheels(Constants.PROJECTION_WHEELS,
|
||||
selection, selectionArgs);
|
||||
case Constants.GAME_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Games.");
|
||||
return mHandler.getAllGames(Constants.PROJECTION_GAME, null, null);
|
||||
case Constants.RULESET_LOADER_ID:
|
||||
Log.d(TAG, "query: Getting all Rulesets.");
|
||||
return mHandler.getAllRulesets(Constants.PROJECTION_RULESET, null, null);
|
||||
default:
|
||||
Log.d(TAG, "query: UriMatcher returned: " + uriMatcher.match(uri));
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.de.aldo_apps.aldo.mariokartcircuitselector.activities;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.LoaderManager;
|
||||
import android.support.v4.content.CursorLoader;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.support.v4.widget.SimpleCursorAdapter;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.widget.ListView;
|
||||
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.GameContentProvider;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.adapters.GameCursorAdapter;
|
||||
|
||||
public class GameSelectionActivity extends AppCompatActivity
|
||||
implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
||||
private static final String TAG = "GameSelectionActivity";
|
||||
|
||||
private ListView mListView;
|
||||
|
||||
private SimpleCursorAdapter mCursorAdapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_game_selection);
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
mListView = (ListView) findViewById(R.id.all_games_list);
|
||||
|
||||
mCursorAdapter = new GameCursorAdapter(this, R.layout.game_list_item,
|
||||
null, Constants.PROJECTION_GAME, new int[] {}, 0);
|
||||
|
||||
mListView.setAdapter(mCursorAdapter);
|
||||
|
||||
getSupportLoaderManager().initLoader(Constants.GAME_LOADER_ID, null, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CursorLoader onCreateLoader(int id, Bundle args) {
|
||||
return new CursorLoader(GameSelectionActivity.this,
|
||||
GameContentProvider.CONTENT_URI,
|
||||
Constants.PROJECTION_GAME, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader loader, Cursor cursor) {
|
||||
|
||||
Log.d(TAG, "onLoadFinished: Finished Loading for " + loader.getId());
|
||||
// Swapping the cursor makes the Data visible in the corresponding ListView.
|
||||
mCursorAdapter.swapCursor(cursor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(final Loader loader) {
|
||||
mCursorAdapter.swapCursor(null);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.adapters.CursorPagerAdapter;
|
||||
|
||||
@@ -22,12 +23,12 @@ import devlight.io.library.ntb.NavigationTabBar;
|
||||
* @version 0.2
|
||||
* @since 17.08.2017
|
||||
*/
|
||||
public class GameSelection extends AppCompatActivity {
|
||||
public class GameSettingsActivity extends AppCompatActivity {
|
||||
|
||||
/**
|
||||
* Tag for debugging purpose.
|
||||
*/
|
||||
private static final String TAG = "GameSelection";
|
||||
private static final String TAG = "GameSettingsActivity";
|
||||
|
||||
/**
|
||||
* The Custom CursorPagerAdapter which fills the ViewPager with data.
|
||||
@@ -37,10 +38,12 @@ public class GameSelection extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_game_selection);
|
||||
setContentView(R.layout.activity_game_settings);
|
||||
|
||||
final String gameSelected = getIntent().getStringExtra(Constants.KEY_GAME);
|
||||
|
||||
// Initialize the Adapter.
|
||||
mAdapter = new CursorPagerAdapter(getSupportFragmentManager());
|
||||
mAdapter = new CursorPagerAdapter(getSupportFragmentManager(), gameSelected);
|
||||
// Fill the UI.
|
||||
updateUI();
|
||||
}
|
||||
@@ -128,13 +128,17 @@ public class AccessoryCursorAdapter extends SimpleCursorAdapter {
|
||||
nameTextView.setText(name);
|
||||
nameTextView.setVisibility(View.VISIBLE);
|
||||
|
||||
final CircleImageView imageView = (CircleImageView) view.findViewById(R.id.image_view);
|
||||
if (imageUri != null && !imageUri.isEmpty()) {
|
||||
Picasso.with(mContext).load(imageUri).into(imageView);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
Log.d(TAG, "fillViewWithData: No image uri provided. ImageView will not be visible.");
|
||||
}
|
||||
// // Uncomment this if CoverUris are present for accessories and are allowed to be shown.
|
||||
// final CircleImageView imageView = (CircleImageView) view.findViewById(R.id.image_view);
|
||||
// if (imageUri != null && !imageUri.isEmpty()) {
|
||||
// Log.d(TAG, "fillViewWithData: Loading Image for [" + imageUri + "]");
|
||||
// Picasso.with(mContext).load(imageUri).error(R.drawable.unknown_character)
|
||||
// .placeholder(R.drawable.animation_progress).into(imageView);
|
||||
// imageView.setVisibility(View.VISIBLE);
|
||||
// } else {
|
||||
// Log.d(TAG, "fillViewWithData: No image uri provided. ImageView will not be visible.");
|
||||
// imageView.setVisibility(View.GONE);
|
||||
// }
|
||||
|
||||
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.de.aldo_apps.aldo.mariokartcircuitselector.adapters;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.widget.SimpleCursorAdapter;
|
||||
import android.util.Log;
|
||||
@@ -17,7 +19,9 @@ import android.widget.TextView;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.CharacterContentProvider;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
||||
import com.squareup.picasso.Callback;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Target;
|
||||
|
||||
import de.hdodenhof.circleimageview.CircleImageView;
|
||||
|
||||
@@ -135,13 +139,17 @@ public class CharacterCursorAdapter extends SimpleCursorAdapter {
|
||||
= (TextView) view.findViewById(R.id.additional_information_separator);
|
||||
separator.setVisibility(View.GONE);
|
||||
|
||||
final CircleImageView imageView = (CircleImageView) view.findViewById(R.id.image_view);
|
||||
if (imageUri != null && !imageUri.isEmpty()) {
|
||||
Picasso.with(mContext).load(imageUri).into(imageView);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
Log.d(TAG, "fillViewWithData: No image uri provided. ImageView will not be visible.");
|
||||
}
|
||||
// // Uncomment this if CoverUris are present for characters and are allowed to be shown.
|
||||
// final CircleImageView imageView = (CircleImageView) view.findViewById(R.id.image_view);
|
||||
// if (imageUri != null && !imageUri.isEmpty()) {
|
||||
// Log.d(TAG, "fillViewWithData: Loading Image for [" + imageUri + "]");
|
||||
// Picasso.with(mContext).load(imageUri).error(R.drawable.unknown_character)
|
||||
// .placeholder(R.drawable.animation_progress).into(imageView);
|
||||
// imageView.setVisibility(View.VISIBLE);
|
||||
// } else {
|
||||
// Log.d(TAG, "fillViewWithData: No image uri provided. ImageView will not be visible.");
|
||||
// imageView.setVisibility(View.GONE);
|
||||
// }
|
||||
|
||||
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
||||
@@ -27,11 +27,14 @@ public class CursorPagerAdapter extends FragmentPagerAdapter {
|
||||
*/
|
||||
private static final String TAG = "CursorPagerAdapter";
|
||||
|
||||
private String mGame;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public CursorPagerAdapter(final FragmentManager fm) {
|
||||
public CursorPagerAdapter(final FragmentManager fm, final String game) {
|
||||
super(fm);
|
||||
mGame = game;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -69,6 +72,7 @@ public class CursorPagerAdapter extends FragmentPagerAdapter {
|
||||
// Provide Projection and LoaderId via a Bundle.
|
||||
bundle.putStringArray(Constants.PROJECTION_KEY, projection);
|
||||
bundle.putInt(Constants.LOADER_ID_KEY, loaderId);
|
||||
bundle.putString(Constants.KEY_GAME, mGame);
|
||||
|
||||
Log.d(TAG, "getItem: New GenericListFragment with loaderId = [" + loaderId
|
||||
+ "] and projection = [" + Arrays.toString(projection) + "] on position ["
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.de.aldo_apps.aldo.mariokartcircuitselector.adapters;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.widget.SimpleCursorAdapter;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.activities.GameSettingsActivity;
|
||||
|
||||
/**
|
||||
* Created by aldo7224 on 18.08.17.
|
||||
*/
|
||||
|
||||
public class GameCursorAdapter extends SimpleCursorAdapter {
|
||||
|
||||
/**
|
||||
* Tag for debugging purpose.
|
||||
*/
|
||||
private static final String TAG = "GameAdapter";
|
||||
|
||||
/**
|
||||
* The Context where this adapter was assigned.
|
||||
*/
|
||||
private final Context mContext;
|
||||
|
||||
/**
|
||||
* The LayoutInflater used to inflate a new ListItem.
|
||||
*/
|
||||
private final LayoutInflater mInflater;
|
||||
|
||||
/**
|
||||
* The LayoutId of the Layout to be inflated.
|
||||
*/
|
||||
private final int mLayout;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
* @param context The Context from which this class was called.
|
||||
* @param layout The LayoutId to be inflated.
|
||||
* @param cursor The cursor which holds all the data.
|
||||
* @param from The Array Containing all Texts to be added to the view
|
||||
* (not used in custom adapter).
|
||||
* @param to The Array holding all LayoutIds where the texts need to be displayed
|
||||
* (not used in custom adapter).
|
||||
* @param flags Some flags (not used in custom adapter).
|
||||
*/
|
||||
public GameCursorAdapter(final Context context,
|
||||
final int layout,
|
||||
final Cursor cursor,
|
||||
final String[] from,
|
||||
final int[] to,
|
||||
final int flags) {
|
||||
super(context, layout, cursor, from, to, flags);
|
||||
mContext = context;
|
||||
mLayout = layout;
|
||||
mInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View newView(final Context context, final Cursor cursor, final ViewGroup parent) {
|
||||
return mInflater.inflate(mLayout, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindView(final View view, final Context context, final Cursor cursor) {
|
||||
super.bindView(view, context, cursor);
|
||||
|
||||
final int idxId = cursor.getColumnIndex(Constants.KEY_ID);
|
||||
final int idxName = cursor.getColumnIndex(Constants.KEY_NAME);
|
||||
final int idxCoverUri = cursor.getColumnIndex(Constants.KEY_COVER_URI);
|
||||
|
||||
if (idxId > -1 && idxName > -1 ) {
|
||||
final long id = cursor.getLong(idxId);
|
||||
final String name = cursor.getString(idxName);
|
||||
String coverUri = null;
|
||||
if (idxCoverUri > -1) {
|
||||
coverUri = cursor.getString(idxCoverUri);
|
||||
}
|
||||
|
||||
fillViewWithData(view, id, name, coverUri);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to fill the UI-Element with information from retrieved from cursor.
|
||||
*
|
||||
* @param view The view to be filled.
|
||||
* @param id Id to be displayed as a backup into TextView (TextView is INVISIBLE)
|
||||
* @param name Name of the accessory to be displayed.
|
||||
*/
|
||||
private void fillViewWithData(final View view,
|
||||
final long id,
|
||||
final String name,
|
||||
final String imageUri) {
|
||||
|
||||
final TextView idView = (TextView) view.findViewById(R.id.id_view);
|
||||
idView.setText(String.valueOf(id));
|
||||
|
||||
final TextView nameView = (TextView) view.findViewById(R.id.game_name_view);
|
||||
nameView.setText(name);
|
||||
|
||||
// // Uncomment this if CoverUris are present for games and are allowed to be shown.
|
||||
// final ImageView imageView = (ImageView) view.findViewById(R.id.cover_view);
|
||||
// if (imageUri != null && !imageUri.isEmpty()) {
|
||||
// Log.d(TAG, "fillViewWithData: Loading Image for [" + imageUri + "]");
|
||||
// Picasso.with(mContext).load(imageUri).error(R.drawable.unknown_character)
|
||||
// .placeholder(R.drawable.animation_progress).into(imageView);
|
||||
// imageView.setVisibility(View.VISIBLE);
|
||||
// } else {
|
||||
// Log.d(TAG, "fillViewWithData: No image uri provided. ImageView will not be visible.");
|
||||
// imageView.setVisibility(View.GONE);
|
||||
// }
|
||||
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(final View view) {
|
||||
final Intent intent = new Intent(mContext, GameSettingsActivity.class);
|
||||
intent.putExtra(Constants.KEY_GAME, name);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -140,13 +140,17 @@ public class KartCursorAdapter extends SimpleCursorAdapter {
|
||||
= (TextView) view.findViewById(R.id.additional_info_second);
|
||||
dedicatedDriverTextView.setText(dedicatedDriver);
|
||||
|
||||
final CircleImageView imageView = (CircleImageView) view.findViewById(R.id.image_view);
|
||||
if (imageUri != null && !imageUri.isEmpty()) {
|
||||
Picasso.with(mContext).load(imageUri).into(imageView);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
Log.d(TAG, "fillViewWithData: No image uri provided. ImageView will not be visible.");
|
||||
}
|
||||
// // Uncomment this if CoverUris are present for karts and are allowed to be shown.
|
||||
// final CircleImageView imageView = (CircleImageView) view.findViewById(R.id.image_view);
|
||||
// if (imageUri != null && !imageUri.isEmpty()) {
|
||||
// Log.d(TAG, "fillViewWithData: Loading Image for [" + imageUri + "]");
|
||||
// Picasso.with(mContext).load(imageUri).error(R.drawable.unknown_character)
|
||||
// .placeholder(R.drawable.animation_progress).into(imageView);
|
||||
// imageView.setVisibility(View.VISIBLE);
|
||||
// } else {
|
||||
// Log.d(TAG, "fillViewWithData: No image uri provided. ImageView will not be visible.");
|
||||
// imageView.setVisibility(View.GONE);
|
||||
// }
|
||||
|
||||
|
||||
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@@ -140,13 +140,17 @@ public class TrackCursorAdapter extends SimpleCursorAdapter {
|
||||
final TextView numberTextView = (TextView) view.findViewById(R.id.additional_info_second);
|
||||
numberTextView.setText(number);
|
||||
|
||||
final CircleImageView imageView = (CircleImageView) view.findViewById(R.id.image_view);
|
||||
if (imageUri != null && !imageUri.isEmpty()) {
|
||||
Picasso.with(mContext).load(imageUri).into(imageView);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
Log.d(TAG, "fillViewWithData: No image uri provided. ImageView will not be visible.");
|
||||
}
|
||||
// // Uncomment this if CoverUris are present for tracks and are allowed to be shown.
|
||||
// final CircleImageView imageView = (CircleImageView) view.findViewById(R.id.image_view);
|
||||
// if (imageUri != null && !imageUri.isEmpty()) {
|
||||
// Log.d(TAG, "fillViewWithData: Loading Image for [" + imageUri + "]");
|
||||
// Picasso.with(mContext).load(imageUri).error(R.drawable.unknown_character)
|
||||
// .placeholder(R.drawable.animation_progress).into(imageView);
|
||||
// imageView.setVisibility(View.VISIBLE);
|
||||
// } else {
|
||||
// Log.d(TAG, "fillViewWithData: No image uri provided. ImageView will not be visible.");
|
||||
// imageView.setVisibility(View.GONE);
|
||||
// }
|
||||
|
||||
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
||||
@@ -128,13 +128,17 @@ public class WheelsCursorAdapter extends SimpleCursorAdapter {
|
||||
nameTextView.setText(name);
|
||||
nameTextView.setVisibility(View.VISIBLE);
|
||||
|
||||
final CircleImageView imageView = (CircleImageView) view.findViewById(R.id.image_view);
|
||||
if (imageUri != null && !imageUri.isEmpty()) {
|
||||
Picasso.with(mContext).load(imageUri).into(imageView);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
Log.d(TAG, "fillViewWithData: No image uri provided. ImageView will not be visible.");
|
||||
}
|
||||
// // Uncomment this if CoverUris are present for wheels and are allowed to be shown.
|
||||
// final CircleImageView imageView = (CircleImageView) view.findViewById(R.id.image_view);
|
||||
// if (imageUri != null && !imageUri.isEmpty()) {
|
||||
// Log.d(TAG, "fillViewWithData: Loading Image for [" + imageUri + "]");
|
||||
// Picasso.with(mContext).load(imageUri).error(R.drawable.unknown_character)
|
||||
// .placeholder(R.drawable.animation_progress).into(imageView);
|
||||
// imageView.setVisibility(View.VISIBLE);
|
||||
// } else {
|
||||
// Log.d(TAG, "fillViewWithData: No image uri provided. ImageView will not be visible.");
|
||||
// imageView.setVisibility(View.GONE);
|
||||
// }
|
||||
|
||||
|
||||
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@@ -45,6 +45,10 @@ public class GenericListFragment extends ListFragment
|
||||
*/
|
||||
private SimpleCursorAdapter mCursorAdapter;
|
||||
|
||||
private String mGame;
|
||||
|
||||
private String[] mSelectionArgs;
|
||||
|
||||
@Override
|
||||
public void onCreate(final Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
@@ -55,6 +59,10 @@ public class GenericListFragment extends ListFragment
|
||||
// Get Projection and LoaderId from arguments.
|
||||
final String[] projection = arguments.getStringArray(Constants.PROJECTION_KEY);
|
||||
final int loaderId = arguments.getInt(Constants.LOADER_ID_KEY);
|
||||
mGame = arguments.getString(Constants.KEY_GAME);
|
||||
if (mGame != null) {
|
||||
mSelectionArgs = new String[]{mGame};
|
||||
}
|
||||
final int[] to = new int[]{};
|
||||
Log.d(TAG, "onCreate: New GenericListFragment with loaderId = [" + loaderId
|
||||
+ "] and projection = [" + Arrays.toString(projection) + "]");
|
||||
@@ -112,27 +120,32 @@ public class GenericListFragment extends ListFragment
|
||||
Log.d(TAG, "onCreateLoader: Creating character loader");
|
||||
return new CursorLoader(getContext(),
|
||||
CharacterContentProvider.CONTENT_URI,
|
||||
Constants.PROJECTION_CHARACTER, null, null, null);
|
||||
Constants.PROJECTION_CHARACTER,
|
||||
Constants.SELECT_WHERE_GAME, mSelectionArgs, null);
|
||||
case Constants.KART_LOADER_ID:
|
||||
Log.d(TAG, "onCreateLoader: Creating kart loader");
|
||||
return new CursorLoader(getContext(),
|
||||
KartContentProvider.CONTENT_URI,
|
||||
Constants.PROJECTION_KART, null, null, null);
|
||||
Constants.PROJECTION_KART,
|
||||
Constants.SELECT_WHERE_GAME, mSelectionArgs, null);
|
||||
case Constants.WHEELS_LOADER_ID:
|
||||
Log.d(TAG, "onCreateLoader: Creating kart loader");
|
||||
return new CursorLoader(getContext(),
|
||||
WheelsContentProvider.CONTENT_URI,
|
||||
Constants.PROJECTION_WHEELS, null, null, null);
|
||||
Constants.PROJECTION_WHEELS,
|
||||
Constants.SELECT_WHERE_GAME, mSelectionArgs, null);
|
||||
case Constants.ACCESSORY_LOADER_ID:
|
||||
Log.d(TAG, "onCreateLoader: Creating kart loader");
|
||||
return new CursorLoader(getContext(),
|
||||
AccessoryContentProvider.CONTENT_URI,
|
||||
Constants.PROJECTION_ACCESSORY, null, null, null);
|
||||
Constants.PROJECTION_ACCESSORY,
|
||||
Constants.SELECT_WHERE_GAME, mSelectionArgs, null);
|
||||
case Constants.TRACK_LOADER_ID:
|
||||
Log.d(TAG, "onCreateLoader: Creating kart loader");
|
||||
return new CursorLoader(getContext(),
|
||||
TrackContentProvider.CONTENT_URI,
|
||||
Constants.PROJECTION_TRACK, null, null, null);
|
||||
Constants.PROJECTION_TRACK,
|
||||
Constants.SELECT_WHERE_GAME, mSelectionArgs, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
5
app/src/main/res/drawable/animation_progress.xml
Normal file
5
app/src/main/res/drawable/animation_progress.xml
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:drawable="@drawable/progress_image"
|
||||
android:pivotX="50%"
|
||||
android:pivotY="50%"/>
|
||||
BIN
app/src/main/res/drawable/progress_image.png
Normal file
BIN
app/src/main/res/drawable/progress_image.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 232 B |
BIN
app/src/main/res/drawable/unknown_character.png
Normal file
BIN
app/src/main/res/drawable/unknown_character.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 567 B |
@@ -1,26 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.de.aldo_apps.aldo.mariokartcircuitselector.activities.GameSelection"
|
||||
>
|
||||
tools:context="com.de.aldo_apps.aldo.mariokartcircuitselector.activities.GameSelectionActivity">
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/vp_horizontal_ntb"
|
||||
<android.support.design.widget.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/ntb_vertical"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<devlight.io.library.ntb.NavigationTabBar
|
||||
app:ntb_title_mode="all"
|
||||
app:ntb_titled="true"
|
||||
app:ntb_title_size="14sp"
|
||||
android:id="@+id/ntb_vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:ntb_preview_colors="@array/vertical_ntb"/>
|
||||
<android.support.v7.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</RelativeLayout>
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
||||
<include layout="@layout/content_game_selection" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
26
app/src/main/res/layout/activity_game_settings.xml
Normal file
26
app/src/main/res/layout/activity_game_settings.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context="com.de.aldo_apps.aldo.mariokartcircuitselector.activities.GameSettingsActivity"
|
||||
>
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/vp_horizontal_ntb"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/ntb_vertical"/>
|
||||
|
||||
<devlight.io.library.ntb.NavigationTabBar
|
||||
app:ntb_title_mode="all"
|
||||
app:ntb_titled="true"
|
||||
app:ntb_title_size="14sp"
|
||||
android:id="@+id/ntb_vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
app:ntb_preview_colors="@array/vertical_ntb"/>
|
||||
|
||||
</RelativeLayout>
|
||||
16
app/src/main/res/layout/content_game_selection.xml
Normal file
16
app/src/main/res/layout/content_game_selection.xml
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
tools:context="com.de.aldo_apps.aldo.mariokartcircuitselector.activities.GameSelectionActivity"
|
||||
tools:showIn="@layout/activity_game_selection">
|
||||
|
||||
<ListView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/all_games_list" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
39
app/src/main/res/layout/game_list_item.xml
Normal file
39
app/src/main/res/layout/game_list_item.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v7.widget.CardView xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
app:cardCornerRadius="5dp"
|
||||
app:cardElevation="14dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cover_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/id_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/game_name_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="@android:style/TextAppearance.Large" />
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="separator_margin">10dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
|
||||
|
||||
</resources>
|
||||
@@ -8,5 +8,6 @@
|
||||
<string name="title_kart">Karts</string>
|
||||
<string name="title_accessory">Sonstiges</string>
|
||||
<string name="title_wheels">Reifen</string>
|
||||
<string name="title_activity_game_selection">GameSelectionActivity</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -8,4 +8,13 @@
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user