diff --git a/.idea/misc.xml b/.idea/misc.xml
index 738edfe..406ac20 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -56,7 +56,7 @@
-
+
diff --git a/app/build.gradle b/app/build.gradle
index b6331b6..2df85b7 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -7,8 +7,8 @@ android {
applicationId "com.de.aldo_apps.aldo.mariokartcircuitselector"
minSdkVersion 16
targetSdkVersion 25
- versionCode 7
- versionName "0.1.7"
+ versionCode 8
+ versionName "0.1.8"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -27,7 +27,7 @@ dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.afollestad.material-dialogs:core:0.9.4.3'
- compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
+ compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
compile 'devlight.io:navigationtabbar:1.2.5'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.3.1'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 07c54c0..dc5ccd3 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -9,7 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
-
+
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/AccessoryContentProvider.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/AccessoryContentProvider.java
index d2e909a..63d76ab 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/AccessoryContentProvider.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/AccessoryContentProvider.java
@@ -5,26 +5,38 @@ 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;
-import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
-import com.de.aldo_apps.aldo.mariokartcircuitselector.DatabaseHandler;
-
/**
- * Created by aldo7224 on 16.08.17.
+ * The ContentProvider which retrieves the Accessory Data.
+ *
+ * @author aldo7224
+ * @version 0.1
+ * @since 17.08.2017
*/
-
public class AccessoryContentProvider extends ContentProvider {
+ /**
+ * Tag for debugging output.
+ */
private static final String TAG = "AccessoryProvider";
+
+ /**
+ * 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 cust_master table. A content provider is identified by its uri
+ * 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 + "/accessories");
+ /**
+ * UriMatcher to check which callback needs to be handled.
+ * TODO: Check whether this is really needed.
+ */
private static final UriMatcher uriMatcher;
static {
@@ -52,7 +64,7 @@ public class AccessoryContentProvider extends ContentProvider {
}
@Override
- public String getType(final Uri uri) {
+ public String getType(@NonNull final Uri uri) {
return null;
}
@@ -60,7 +72,7 @@ public class AccessoryContentProvider extends ContentProvider {
* A callback method which is by the default content uri
*/
@Override
- public Cursor query(final Uri uri,
+ public Cursor query(@NonNull final Uri uri,
final String[] projection,
final String selection,
final String[] selectionArgs,
@@ -77,7 +89,7 @@ public class AccessoryContentProvider extends ContentProvider {
Log.d(TAG, "query: Getting all Karts.");
return mHandler.getAllKarts(Constants.PROJECTION_KART, null, null);
case Constants.ACCESSORY_LOADER_ID:
- Log.d(TAG, "query: Getting all Acessories.");
+ Log.d(TAG, "query: Getting all Accessories.");
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY, null, null);
case Constants.TRACK_LOADER_ID:
Log.d(TAG, "query: Getting all Tracks.");
@@ -92,21 +104,19 @@ public class AccessoryContentProvider extends ContentProvider {
}
@Override
- public int delete(final Uri uri, final String selection, final String[] selectionArgs) {
- // TODO Auto-generated method stub
+ public int delete(@NonNull final Uri uri, final String selection, final String[] selectionArgs) {
return 0;
}
@Override
- public Uri insert(final Uri uri, final ContentValues values) {
- // TODO Auto-generated method stub
+ public Uri insert(@NonNull final Uri uri, final ContentValues values) {
return null;
}
@Override
- public int update(final Uri uri, final ContentValues values, final String selection,
+ public int update(@NonNull final Uri uri, final ContentValues values, final String selection,
final String[] selectionArgs) {
- // TODO Auto-generated method stub
+ // TODO Add update method here?
return 0;
}
}
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/CharacterContentProvider.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/CharacterContentProvider.java
index 69b111c..914ae6f 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/CharacterContentProvider.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/CharacterContentProvider.java
@@ -5,23 +5,38 @@ 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 16.08.17.
+ * The ContentProvider which retrieves the Character Data.
+ *
+ * @author aldo7224
+ * @version 0.1
+ * @since 17.08.2017
*/
-
public class CharacterContentProvider extends ContentProvider {
+ /**
+ * Tag for debugging output.
+ */
private static final String TAG = "CharacterProvider";
+
+ /**
+ * 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 cust_master table. A content provider is identified by its uri
+ * 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 + "/characters");
+ /**
+ * UriMatcher to check which callback needs to be handled.
+ * TODO: Check whether this is really needed.
+ */
private static final UriMatcher uriMatcher;
static {
@@ -48,7 +63,7 @@ public class CharacterContentProvider extends ContentProvider {
}
@Override
- public String getType(final Uri uri) {
+ public String getType(@NonNull final Uri uri) {
return null;
}
@@ -56,7 +71,7 @@ public class CharacterContentProvider extends ContentProvider {
* A callback method which is by the default content uri
*/
@Override
- public Cursor query(final Uri uri,
+ public Cursor query(@NonNull final Uri uri,
final String[] projection,
final String selection,
final String[] selectionArgs,
@@ -88,21 +103,19 @@ public class CharacterContentProvider extends ContentProvider {
}
@Override
- public int delete(final Uri uri, final String selection, final String[] selectionArgs) {
- // TODO Auto-generated method stub
+ public int delete(@NonNull final Uri uri, final String selection, final String[] selectionArgs) {
return 0;
}
@Override
- public Uri insert(final Uri uri, final ContentValues values) {
- // TODO Auto-generated method stub
+ public Uri insert(@NonNull final Uri uri, final ContentValues values) {
return null;
}
@Override
- public int update(final Uri uri, final ContentValues values, final String selection,
+ public int update(@NonNull final Uri uri, final ContentValues values, final String selection,
final String[] selectionArgs) {
- // TODO Auto-generated method stub
+ // TODO Add update method here?
return 0;
}
}
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/Constants.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/Constants.java
index a645264..50d9422 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/Constants.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/Constants.java
@@ -5,15 +5,15 @@ package com.de.aldo_apps.aldo.mariokartcircuitselector;
* centralized class.
*
* @author aldo7224
- * @version 0.1
- * @since 07.08.2017
+ * @version 0.2
+ * @since 17.08.2017
*/
public final class Constants {
/**
* The Version Code of the Database.
*/
- public static final Integer DATABASE_VERSION = 1;
+ static final Integer DATABASE_VERSION = 1;
/**
* As SQLite does not have a native boolean value, we use integers to represent true and false.
@@ -25,160 +25,187 @@ public final class Constants {
* As SQLite does not have a native boolean value, we use integers to represent true and false.
* This is the value for a false statement.
*/
- public final static Integer FALSE = 0;
+ final static Integer FALSE = 0;
+ /**
+ * The Base LoaderID.
+ */
public static final int BASE_LOADER_ID = 0;
+ /**
+ * LoaderID of the character loader.
+ */
public static final int CHARACTER_LOADER_ID = BASE_LOADER_ID;
+ /**
+ * LoaderID of the kart loader.
+ */
public static final int KART_LOADER_ID = BASE_LOADER_ID + 1;
+ /**
+ * LoaderID of the track loader.
+ */
public static final int TRACK_LOADER_ID = BASE_LOADER_ID + 2;
+ /**
+ * LoaderID of the accessory loader.
+ */
public static final int ACCESSORY_LOADER_ID = BASE_LOADER_ID + 3;
+ /**
+ * LoaderID of the wheels loader.
+ */
public static final int WHEELS_LOADER_ID = BASE_LOADER_ID + 4;
+ /**
+ * The Key for the projection being provided via a bundle.
+ */
+ public static final String PROJECTION_KEY = "projection";
+
+ /**
+ * The Key for the loaderId being provided via a bundle.
+ */
+ public static final String LOADER_ID_KEY = "loader_id";
/**
* The Name of the complete database.
*/
- public static final String DATABASE_NAME = "mario_kart_circuit_selector";
+ static final String DATABASE_NAME = "mario_kart_circuit_selector";
/**
* The name of the table containing all information according accessories.
*/
- public static final String TABLE_ACCESSORY = "accessory";
+ static final String TABLE_ACCESSORY = "accessory";
/**
* The name of the table containing all information according characters.
*/
- public static final String TABLE_CHARACTER = "character";
+ static final String TABLE_CHARACTER = "character";
/**
* The name of the table containing all information according games.
*/
- public static final String TABLE_GAME = "game";
+ static final String TABLE_GAME = "game";
/**
* The name of the table containing all information according karts.
*/
- public static final String TABLE_KART = "kart";
+ static final String TABLE_KART = "kart";
/**
* The name of the table containing all information according rulesets.
*/
- public static final String TABLE_RULESET = "ruleset";
+ static final String TABLE_RULESET = "ruleset";
/**
* The name of the table containing all information according tracks.
*/
- public static final String TABLE_TRACK = "track";
+ static final String TABLE_TRACK = "track";
/**
* The name of the table containing all information according wheels.
*/
- public static final String TABLE_WHEELS = "wheels";
+ static final String TABLE_WHEELS = "wheels";
/**
* The global KEY for the _id field in the database.
*/
- public static final String KEY_ID = "_id";
+ static final String KEY_ID = "_id";
/**
* The global KEY for the name field in the database.
*/
- public static final String KEY_NAME = "name";
+ static final String KEY_NAME = "name";
/**
* The global KEY for the game field in the database.
*/
- public static final String KEY_GAME = "game";
+ static final String KEY_GAME = "game";
/**
* The global KEY for the available field in the database.
*/
- public static final String KEY_AVAILABLE = "available";
+ static final String KEY_AVAILABLE = "available";
/**
* The global KEY for the weight field in the database.
*/
- public static final String KEY_WEIGHT = "weight";
+ static final String KEY_WEIGHT = "weight";
/**
* The global KEY for the cover uri field in the database.
*/
- public static final String KEY_COVER_URI = "cover_uri";
+ static final String KEY_COVER_URI = "cover_uri";
/**
* The global KEY for the wheels field in the database.
*/
- public static final String KEY_WHEELS = "wheels";
+ static final String KEY_WHEELS = "wheels";
/**
* The global KEY for the accessory field in the database.
*/
- public static final String KEY_ACCESSORY = "accessory";
+ static final String KEY_ACCESSORY = "accessory";
/**
* The global KEY for the dedicated driver field in the database.
*/
- public static final String KEY_DEDICATED_DRIVER = "dedicated_driver";
+ static final String KEY_DEDICATED_DRIVER = "dedicated_driver";
/**
* The global KEY for the free for all field in the database.
*/
- public static final String KEY_FREE_FOR_ALL = "free_for_all";
+ static final String KEY_FREE_FOR_ALL = "free_for_all";
/**
* The global KEY for the mirror class field in the database.
*/
- public static final String KEY_MIRROR_CLASS = "mirror_class";
+ private static final String KEY_MIRROR_CLASS = "mirror_class";
/**
* The global KEY for the 50 ccm field in the database.
*/
- public static final String KEY_50_CCM = "50_ccm";
+ private static final String KEY_50_CCM = "50_ccm";
/**
* The global KEY for the 100 ccm field in the database.
*/
- public static final String KEY_100_CCM = "100_ccm";
+ private static final String KEY_100_CCM = "100_ccm";
/**
* The global KEY for the 150 ccm field in the database.
*/
- public static final String KEY_150_CCM = "150_ccm";
+ private static final String KEY_150_CCM = "150_ccm";
/**
* The global KEY for the 200 ccm field in the database.
*/
- public static final String KEY_200_CCM = "200_ccm";
+ private static final String KEY_200_CCM = "200_ccm";
/**
* The global KEY for the kart free for all field in the database.
*/
- public static final String KEY_KART_FREE_FOR_ALL = "kart_free_for_all";
+ private static final String KEY_KART_FREE_FOR_ALL = "kart_free_for_all";
/**
* The global KEY for the bikes field in the database.
*/
- public static final String KEY_BIKES = "bikes";
+ private static final String KEY_BIKES = "bikes";
/**
* The global KEY for the package field in the database.
*/
- public static final String KEY_PACKAGE = "package";
+ static final String KEY_PACKAGE = "package";
/**
* The global KEY for the number field in the database.
*/
- public static final String KEY_NUMBER = "number";
+ static final String KEY_NUMBER = "number";
/**
* The Projection to retrieve all Information of a game object from database.
*/
- public static final String[] PROJECTION_GAME = {
+ static final String[] PROJECTION_GAME = {
KEY_ID,
KEY_NAME,
KEY_COVER_URI
@@ -260,30 +287,4 @@ public final class Constants {
KEY_GAME,
KEY_AVAILABLE
};
-
-
- /**
- * Enum Value defining the position of the Character Tab.
- */
- public static final int CHARACTER = 0;
-
- /**
- * Enum Value defining the position of the Kart Tab.
- */
- public static final int KART = 1;
-
- /**
- * Enum Value defining the position of the Track Tab.
- */
- public static final int TRACK = 2;
-
- /**
- * Enum Value defining the position of the Accessory Tab.
- */
- public static final int ACCESSORY = 3;
-
- /**
- * Enum Value defining the position of the Wheels Tab.
- */
- public static final int WHEELS = 4;
}
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/DatabaseHandler.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/DatabaseHandler.java
index 054776a..2ce7863 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/DatabaseHandler.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/DatabaseHandler.java
@@ -3,17 +3,13 @@ package com.de.aldo_apps.aldo.mariokartcircuitselector;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
-import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteDatabase;
-import android.net.Uri;
-import android.support.annotation.Nullable;
import android.util.Log;
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Accessory;
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Character;
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Game;
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Kart;
-import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Ruleset;
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Track;
import com.de.aldo_apps.aldo.mariokartcircuitselector.database_models.Wheels;
import com.readystatesoftware.sqliteasset.SQLiteAssetHelper;
@@ -60,7 +56,6 @@ public class DatabaseHandler extends SQLiteAssetHelper {
*
* @param track The track which should be marked as available/unavailable.
* @param isAvailable The status of availability to be set.
- *
* @return The result code of the update function.
*/
public int changeTrackAvailability(final Track track,
@@ -87,7 +82,6 @@ public class DatabaseHandler extends SQLiteAssetHelper {
*
* @param character The character which should be marked as available/unavailable.
* @param isAvailable The status of availability to be set.
- *
* @return The result code of the update function.
*/
public int changeCharacterAvailability(final Character character,
@@ -113,7 +107,6 @@ public class DatabaseHandler extends SQLiteAssetHelper {
*
* @param kart The kart which should be marked as available/unavailable.
* @param isAvailable The status of availability to be set.
- *
* @return The result code of the update function.
*/
public int changeKartAvailability(final Kart kart,
@@ -143,7 +136,6 @@ public class DatabaseHandler extends SQLiteAssetHelper {
*
* @param accessory The accessory which should be marked as available/unavailable.
* @param isAvailable The status of availability to be set.
- *
* @return The result code of the update function.
*/
public int changeAccessoryAvailability(final Accessory accessory,
@@ -168,7 +160,6 @@ public class DatabaseHandler extends SQLiteAssetHelper {
*
* @param wheels The wheels which should be marked as available/unavailable.
* @param isAvailable The status of availability to be set.
- *
* @return The result code of the update function.
*/
public int changeWheelsAvailability(final Wheels wheels,
@@ -195,12 +186,12 @@ public class DatabaseHandler extends SQLiteAssetHelper {
/**
* Retrieves all Tracks from Database. If a Game is provided, all tracks of this specific
* game will be retrieved.
- *
+ *
* @return List containing all Track Objects retrieved from Database.
*/
public Cursor getAllTracks(final String[] projection,
- final String selection,
- final String[] selectionArgs) {
+ final String selection,
+ final String[] selectionArgs) {
final SQLiteDatabase database = this.getReadableDatabase();
Log.d(TAG, "getAllTracks: Creating Cursor for Tracks.");
@@ -216,8 +207,8 @@ public class DatabaseHandler extends SQLiteAssetHelper {
* @return List containing all Kart Objects retrieved from Database.
*/
public Cursor getAllKarts(final String[] projection,
- final String selection,
- final String[] selectionArgs) {
+ final String selection,
+ final String[] selectionArgs) {
final SQLiteDatabase database = this.getReadableDatabase();
Log.d(TAG, "getAllKarts: Creating Cursor for Karts.");
@@ -230,15 +221,14 @@ public class DatabaseHandler extends SQLiteAssetHelper {
* Retrieves all Characters from Database. If a Game is provided, all characters of this
* specific game will be retrieved.
*
- * @param projection The character projection.
- * @param selection The selection clause.
+ * @param projection The character projection.
+ * @param selection The selection clause.
* @param selectionArgs The selection arguments.
- *
* @return Cursor containing all Character Objects retrieved from Database.
*/
public Cursor getAllCharacters(final String[] projection,
- final String selection,
- final String[] selectionArgs) {
+ final String selection,
+ final String[] selectionArgs) {
final SQLiteDatabase database = this.getReadableDatabase();
Log.d(TAG, "getAllCharacters: Creating Cursor for Characters.");
@@ -256,8 +246,8 @@ public class DatabaseHandler extends SQLiteAssetHelper {
* @return List containing all Ruleset Objects retrieved from Database.
*/
public Cursor getAllRulesets(final String[] projection,
- final String selection,
- final String[] selectionArgs) {
+ final String selection,
+ final String[] selectionArgs) {
final SQLiteDatabase database = this.getReadableDatabase();
Log.d(TAG, "getAllRulesets: Creating Cursor for Rulesets.");
@@ -273,8 +263,8 @@ public class DatabaseHandler extends SQLiteAssetHelper {
* @return List containing all Accessory Objects retrieved from Database.
*/
public Cursor getAllAccessories(final String[] projection,
- final String selection,
- final String[] selectionArgs) {
+ final String selection,
+ final String[] selectionArgs) {
final SQLiteDatabase database = this.getReadableDatabase();
final Cursor cursor = database.query(Constants.TABLE_ACCESSORY,
@@ -367,59 +357,4 @@ public class DatabaseHandler extends SQLiteAssetHelper {
// ------------------------------ T E S T F U N C T I O N S -------------------------------
// -------------------------------------------------------------------------------------------
- // TODO: This is only an intermediate state and can be removed later on
- public Track testDBConnection(final int id) {
- Log.d(TAG, "testDBConnection: Opening Readable Database.");
- final SQLiteDatabase database = this.getReadableDatabase();
-
- Log.d(TAG, "testDBConnection: Query a single track for id = [" + id + "]");
- final Cursor cursor = database.query(Constants.TABLE_TRACK, new String[]{Constants.KEY_ID,
- Constants.KEY_NAME, Constants.KEY_GAME, Constants.KEY_AVAILABLE},
- Constants.KEY_ID + "=?", new String[]{String.valueOf(id)}, null, null, null, null);
- if (cursor != null) {
- Log.d(TAG, "testDBConnection: Moving cursor to first.");
- cursor.moveToFirst();
- } else {
- Log.d(TAG, "testDBConnection: cursor is null");
- return null;
- }
-
- DatabaseUtils.dumpCursor(cursor);
-
- final int nameIdx = cursor.getColumnIndex(Constants.KEY_NAME);
- final int gameIdx = cursor.getColumnIndex(Constants.KEY_GAME);
- final int idIdx = cursor.getColumnIndex(Constants.KEY_ID);
- final int availableIdx = cursor.getColumnIndex(Constants.KEY_AVAILABLE);
-
- if (nameIdx < 0) {
- Log.d(TAG, "testDBConnection: No such column [" + Constants.KEY_NAME + "]");
- }
- if (gameIdx < 0) {
- Log.d(TAG, "testDBConnection: No such column [" + Constants.KEY_GAME + "]");
- }
- if (idIdx < 0) {
- Log.d(TAG, "testDBConnection: No such column [" + Constants.KEY_ID + "]");
- }
- if (availableIdx < 0) {
- Log.d(TAG, "testDBConnection: No such column [" + Constants.KEY_AVAILABLE + "]");
- }
-
- if (availableIdx >= 0 && idIdx >= 0 && gameIdx >= 0 && nameIdx >= 0) {
- final Track track = new Track();
- track.setName(cursor.getString(nameIdx));
- track.setGame(cursor.getString(gameIdx));
- track.setId(Integer.parseInt(cursor.getString(idIdx)));
- track.setAvailable(Integer.parseInt(cursor.getString(availableIdx)));
- database.close();
-
- // return contact
- return track;
-
- }
- cursor.close();
- database.close();
-
- // return contact
- return null;
- }
}
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/KartContentProvider.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/KartContentProvider.java
index 12fa659..3240c6a 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/KartContentProvider.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/KartContentProvider.java
@@ -5,26 +5,38 @@ 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;
-import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
-import com.de.aldo_apps.aldo.mariokartcircuitselector.DatabaseHandler;
-
/**
- * Created by aldo7224 on 16.08.17.
+ * The ContentProvider which retrieves the Kart Data.
+ *
+ * @author aldo7224
+ * @version 0.1
+ * @since 17.08.2017
*/
-
public class KartContentProvider extends ContentProvider {
+ /**
+ * Tag for debugging output.
+ */
private static final String TAG = "KartProvider";
+
+ /**
+ * 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 cust_master table. A content provider is identified by its uri
+ * 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 + "/karts");
+ /**
+ * UriMatcher to check which callback needs to be handled.
+ * TODO: Check whether this is really needed.
+ */
private static final UriMatcher uriMatcher;
static {
@@ -51,7 +63,7 @@ public class KartContentProvider extends ContentProvider {
}
@Override
- public String getType(final Uri uri) {
+ public String getType(@NonNull final Uri uri) {
return null;
}
@@ -59,7 +71,7 @@ public class KartContentProvider extends ContentProvider {
* A callback method which is by the default content uri
*/
@Override
- public Cursor query(final Uri uri,
+ public Cursor query(@NonNull final Uri uri,
final String[] projection,
final String selection,
final String[] selectionArgs,
@@ -76,7 +88,7 @@ public class KartContentProvider extends ContentProvider {
Log.d(TAG, "query: Getting all Karts.");
return mHandler.getAllKarts(Constants.PROJECTION_KART, null, null);
case Constants.ACCESSORY_LOADER_ID:
- Log.d(TAG, "query: Getting all Acessories.");
+ Log.d(TAG, "query: Getting all Accessories.");
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY, null, null);
case Constants.TRACK_LOADER_ID:
Log.d(TAG, "query: Getting all Tracks.");
@@ -91,21 +103,19 @@ public class KartContentProvider extends ContentProvider {
}
@Override
- public int delete(final Uri uri, final String selection, final String[] selectionArgs) {
- // TODO Auto-generated method stub
+ public int delete(@NonNull final Uri uri, final String selection, final String[] selectionArgs) {
return 0;
}
@Override
- public Uri insert(final Uri uri, final ContentValues values) {
- // TODO Auto-generated method stub
+ public Uri insert(@NonNull final Uri uri, final ContentValues values) {
return null;
}
@Override
- public int update(final Uri uri, final ContentValues values, final String selection,
+ public int update(@NonNull final Uri uri, final ContentValues values, final String selection,
final String[] selectionArgs) {
- // TODO Auto-generated method stub
+ // TODO Add update method here?
return 0;
}
}
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/PagerType.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/PagerType.java
index 1492b5a..67ff41f 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/PagerType.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/PagerType.java
@@ -1,13 +1,35 @@
package com.de.aldo_apps.aldo.mariokartcircuitselector;
/**
- * Created by aldo7224 on 16.08.17.
+ * Enum holding the different PagerTypes which are displayed in the NavigationTabBar.
+ *
+ * @author aldo7224
+ * @version 0.1
+ * @since 17.08.2017
*/
-
public enum PagerType {
+ /**
+ * Character tab.
+ */
CHARACTER,
+
+ /**
+ * Kart tab.
+ */
KART,
+
+ /**
+ * Track tab.
+ */
TRACK,
+
+ /**
+ * Accessory tab.
+ */
ACCESSORY,
+
+ /**
+ * Wheels tab.
+ */
WHEEL
}
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/TrackContentProvider.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/TrackContentProvider.java
index 29aa560..fd0fb59 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/TrackContentProvider.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/TrackContentProvider.java
@@ -5,18 +5,26 @@ 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;
-import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
-import com.de.aldo_apps.aldo.mariokartcircuitselector.DatabaseHandler;
-
/**
- * Created by aldo7224 on 16.08.17.
+ * The ContentProvider which retrieves the Track Data.
+ *
+ * @author aldo7224
+ * @version 0.1
+ * @since 17.08.2017
*/
-
public class TrackContentProvider extends ContentProvider {
+ /**
+ * Tag for debugging output.
+ */
private static final String TAG = "TrackProvider";
+
+ /**
+ * 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";
@@ -25,6 +33,10 @@ public class TrackContentProvider extends ContentProvider {
*/
public static final Uri CONTENT_URI = Uri.parse("content://" + PROVIDER_NAME + "/tracks");
+ /**
+ * UriMatcher to check which callback needs to be handled.
+ * TODO: Check whether this is really needed.
+ */
private static final UriMatcher uriMatcher;
static {
@@ -33,7 +45,8 @@ public class TrackContentProvider extends ContentProvider {
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); }
+ uriMatcher.addURI(PROVIDER_NAME, "accessories", Constants.ACCESSORY_LOADER_ID);
+ }
/**
* This content provider does the database operations by this object
@@ -50,7 +63,7 @@ public class TrackContentProvider extends ContentProvider {
}
@Override
- public String getType(final Uri uri) {
+ public String getType(@NonNull final Uri uri) {
return null;
}
@@ -58,7 +71,7 @@ public class TrackContentProvider extends ContentProvider {
* A callback method which is by the default content uri
*/
@Override
- public Cursor query(final Uri uri,
+ public Cursor query(@NonNull final Uri uri,
final String[] projection,
final String selection,
final String[] selectionArgs,
@@ -75,7 +88,7 @@ public class TrackContentProvider extends ContentProvider {
Log.d(TAG, "query: Getting all Karts.");
return mHandler.getAllKarts(Constants.PROJECTION_KART, null, null);
case Constants.ACCESSORY_LOADER_ID:
- Log.d(TAG, "query: Getting all Acessories.");
+ Log.d(TAG, "query: Getting all Accessories.");
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY, null, null);
case Constants.TRACK_LOADER_ID:
Log.d(TAG, "query: Getting all Tracks.");
@@ -90,21 +103,19 @@ public class TrackContentProvider extends ContentProvider {
}
@Override
- public int delete(final Uri uri, final String selection, final String[] selectionArgs) {
- // TODO Auto-generated method stub
+ public int delete(@NonNull final Uri uri, final String selection, final String[] selectionArgs) {
return 0;
}
@Override
- public Uri insert(final Uri uri, final ContentValues values) {
- // TODO Auto-generated method stub
+ public Uri insert(@NonNull final Uri uri, final ContentValues values) {
return null;
}
@Override
- public int update(final Uri uri, final ContentValues values, final String selection,
+ public int update(@NonNull final Uri uri, final ContentValues values, final String selection,
final String[] selectionArgs) {
- // TODO Auto-generated method stub
+ // TODO Add update method here?
return 0;
}
}
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/WheelsContentProvider.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/WheelsContentProvider.java
index 596574c..b5ae541 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/WheelsContentProvider.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/WheelsContentProvider.java
@@ -5,18 +5,26 @@ 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;
-import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
-import com.de.aldo_apps.aldo.mariokartcircuitselector.DatabaseHandler;
-
/**
- * Created by aldo7224 on 16.08.17.
+ * The ContentProvider which retrieves the Wheels Data.
+ *
+ * @author aldo7224
+ * @version 0.1
+ * @since 17.08.2017
*/
-
public class WheelsContentProvider extends ContentProvider {
+ /**
+ * Tag for debugging output.
+ */
private static final String TAG = "WheelsProvider";
+
+ /**
+ * 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";
@@ -25,6 +33,10 @@ public class WheelsContentProvider extends ContentProvider {
*/
public static final Uri CONTENT_URI = Uri.parse("content://" + PROVIDER_NAME + "/wheels");
+ /**
+ * UriMatcher to check which callback needs to be handled.
+ * TODO: Check whether this is really needed.
+ */
private static final UriMatcher uriMatcher;
static {
@@ -51,7 +63,7 @@ public class WheelsContentProvider extends ContentProvider {
}
@Override
- public String getType(final Uri uri) {
+ public String getType(@NonNull final Uri uri) {
return null;
}
@@ -59,7 +71,7 @@ public class WheelsContentProvider extends ContentProvider {
* A callback method which is by the default content uri
*/
@Override
- public Cursor query(final Uri uri,
+ public Cursor query(@NonNull final Uri uri,
final String[] projection,
final String selection,
final String[] selectionArgs,
@@ -76,7 +88,7 @@ public class WheelsContentProvider extends ContentProvider {
Log.d(TAG, "query: Getting all Karts.");
return mHandler.getAllKarts(Constants.PROJECTION_KART, null, null);
case Constants.ACCESSORY_LOADER_ID:
- Log.d(TAG, "query: Getting all Acessories.");
+ Log.d(TAG, "query: Getting all Accessories.");
return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY, null, null);
case Constants.TRACK_LOADER_ID:
Log.d(TAG, "query: Getting all Tracks.");
@@ -91,21 +103,19 @@ public class WheelsContentProvider extends ContentProvider {
}
@Override
- public int delete(final Uri uri, final String selection, final String[] selectionArgs) {
- // TODO Auto-generated method stub
+ public int delete(@NonNull final Uri uri, final String selection, final String[] selectionArgs) {
return 0;
}
@Override
- public Uri insert(final Uri uri, final ContentValues values) {
- // TODO Auto-generated method stub
+ public Uri insert(@NonNull final Uri uri, final ContentValues values) {
return null;
}
@Override
- public int update(final Uri uri, final ContentValues values, final String selection,
+ public int update(@NonNull final Uri uri, final ContentValues values, final String selection,
final String[] selectionArgs) {
- // TODO Auto-generated method stub
+ // TODO Add update method here?
return 0;
}
}
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/GameSelection.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/activities/GameSelection.java
similarity index 65%
rename from app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/GameSelection.java
rename to app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/activities/GameSelection.java
index 2febea7..c534048 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/GameSelection.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/activities/GameSelection.java
@@ -1,23 +1,37 @@
-package com.de.aldo_apps.aldo.mariokartcircuitselector;
+package com.de.aldo_apps.aldo.mariokartcircuitselector.activities;
import android.graphics.Color;
+import android.os.Bundle;
+import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
-import android.os.Bundle;
import android.util.Log;
+import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
import com.de.aldo_apps.aldo.mariokartcircuitselector.adapters.CursorPagerAdapter;
import java.util.ArrayList;
import devlight.io.library.ntb.NavigationTabBar;
+/**
+ * The Activity which handles the Main-Game Selection.
+ * TODO: Currently the DB-Logic is here, which needs to be handled in an additional screen.
+ *
+ * @author aldo7224
+ * @version 0.2
+ * @since 17.08.2017
+ */
public class GameSelection extends AppCompatActivity {
+ /**
+ * Tag for debugging purpose.
+ */
private static final String TAG = "GameSelection";
- private DatabaseHandler mDbHandler;
-
+ /**
+ * The Custom CursorPagerAdapter which fills the ViewPager with data.
+ */
private CursorPagerAdapter mAdapter;
@Override
@@ -25,24 +39,43 @@ public class GameSelection extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game_selection);
- mDbHandler = new DatabaseHandler(this);
-
+ // Initialize the Adapter.
mAdapter = new CursorPagerAdapter(getSupportFragmentManager());
+ // Fill the UI.
updateUI();
}
+ /**
+ * Helper method which handles UI updates.
+ */
public void updateUI() {
+ // Get the colors for the ViewPager Items.
final String[] colors = getResources().getStringArray(R.array.vertical_ntb);
+ // get the ViewPager and assign adapter to it.
final ViewPager viewPager = (ViewPager) findViewById(R.id.vp_horizontal_ntb);
viewPager.setAdapter(mAdapter);
+ // Get the NavigationBar and assign the models to it.
+ initNavBar(colors, viewPager);
+
+ }
+
+ /**
+ * Helper method which initializes the NavigationTabBar and adds functionality.
+ *
+ * @param colors The Array of colors to apply to the different Tabs.
+ * @param viewPager The ViewPager which should be assigned to the tabBar.
+ * @return The fully inflated and initialized NavigationTabbar.
+ */
+ private NavigationTabBar initNavBar(final String[] colors, final ViewPager viewPager) {
final NavigationTabBar navigationTabBar
= (NavigationTabBar) findViewById(R.id.ntb_vertical);
final ArrayList models = new ArrayList<>();
models.add(
new NavigationTabBar.Model.Builder(
- getResources().getDrawable(R.drawable.character_50_dark_grey),
+ ResourcesCompat.getDrawable(getResources(),
+ R.drawable.character_50_dark_grey, null),
Color.parseColor(colors[0])
).title(getString(R.string.title_character))
.badgeTitle("NTB")
@@ -50,7 +83,8 @@ public class GameSelection extends AppCompatActivity {
);
models.add(
new NavigationTabBar.Model.Builder(
- getResources().getDrawable(R.drawable.kart_50_dark_grey),
+ ResourcesCompat.getDrawable(getResources(),
+ R.drawable.kart_50_dark_grey, null),
Color.parseColor(colors[1])
).title(getString(R.string.title_kart))
.badgeTitle("with")
@@ -58,7 +92,8 @@ public class GameSelection extends AppCompatActivity {
);
models.add(
new NavigationTabBar.Model.Builder(
- getResources().getDrawable(R.drawable.track_50_dark_grey),
+ ResourcesCompat.getDrawable(getResources(),
+ R.drawable.track_50_dark_grey, null),
Color.parseColor(colors[2])
).title(getString(R.string.title_track))
.badgeTitle("state")
@@ -66,7 +101,8 @@ public class GameSelection extends AppCompatActivity {
);
models.add(
new NavigationTabBar.Model.Builder(
- getResources().getDrawable(R.drawable.accessory_50_dark_grey),
+ ResourcesCompat.getDrawable(getResources(),
+ R.drawable.accessory_50_dark_grey, null),
Color.parseColor(colors[3])
).title(getString(R.string.title_accessory))
.badgeTitle("icon")
@@ -74,7 +110,8 @@ public class GameSelection extends AppCompatActivity {
);
models.add(
new NavigationTabBar.Model.Builder(
- getResources().getDrawable(R.drawable.wheels_50_dark_grey),
+ ResourcesCompat.getDrawable(getResources(),
+ R.drawable.wheels_50_dark_grey, null),
Color.parseColor(colors[4])
).title(getString(R.string.title_wheels))
.badgeTitle("777")
@@ -83,6 +120,7 @@ public class GameSelection extends AppCompatActivity {
navigationTabBar.setModels(models);
navigationTabBar.setViewPager(viewPager);
+ // Assign a OnPageChangedListener to assure correct functionality while swiping.
navigationTabBar.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(final int position,
@@ -119,5 +157,7 @@ public class GameSelection extends AppCompatActivity {
}
}
}, 500);
+
+ return navigationTabBar;
}
}
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/adapters/CursorPagerAdapter.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/adapters/CursorPagerAdapter.java
index 1d32cc1..9598bae 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/adapters/CursorPagerAdapter.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/adapters/CursorPagerAdapter.java
@@ -10,20 +10,36 @@ import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
import com.de.aldo_apps.aldo.mariokartcircuitselector.PagerType;
import com.de.aldo_apps.aldo.mariokartcircuitselector.fragments.GenericListFragment;
+import java.util.Arrays;
+
+/**
+ * The custom FragmentPagerAdapter which handles data provided via a cursor so the data retrieved
+ * from DB can be directly accessed and displayed.
+ *
+ * @author aldo7224
+ * @version 0.1
+ * @since 17.08.2017
+ */
public class CursorPagerAdapter extends FragmentPagerAdapter {
/**
- * default constructor.
+ * Tag for debugging purpose.
+ */
+ private static final String TAG = "CursorPagerAdapter";
+
+ /**
+ * Default constructor.
*/
public CursorPagerAdapter(final FragmentManager fm) {
super(fm);
}
@Override
- public Fragment getItem(int position) {
+ public Fragment getItem(final int position) {
final Bundle bundle = new Bundle();
final String[] projection;
final int loaderId;
+ // Get the PagerType of the position, so that the correct Loader is initialized.
switch (PagerType.values()[position]) {
case CHARACTER:
projection = Constants.PROJECTION_CHARACTER;
@@ -50,11 +66,12 @@ public class CursorPagerAdapter extends FragmentPagerAdapter {
loaderId = Constants.BASE_LOADER_ID;
}
- bundle.putStringArray("FOO", projection);
- bundle.putInt("BAR", loaderId);
+ // Provide Projection and LoaderId via a Bundle.
+ bundle.putStringArray(Constants.PROJECTION_KEY, projection);
+ bundle.putInt(Constants.LOADER_ID_KEY, loaderId);
- Log.d("#####", "getItem: New GenericListFragment with loaderId = [" + loaderId
- + "] and projection = [" + projection.toString() + "] on position ["
+ Log.d(TAG, "getItem: New GenericListFragment with loaderId = [" + loaderId
+ + "] and projection = [" + Arrays.toString(projection) + "] on position ["
+ position + "]");
final GenericListFragment genericListFragment = new GenericListFragment();
genericListFragment.setArguments(bundle);
@@ -64,7 +81,6 @@ public class CursorPagerAdapter extends FragmentPagerAdapter {
@Override
public int getCount() {
- // TODO Auto-generated method stub
return PagerType.values().length;
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Character.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Character.java
index 0d52b8c..2c57e51 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Character.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Character.java
@@ -46,7 +46,8 @@ public class Character {
/**
* Empty default constructor.
*/
- public Character() {}
+ public Character() {
+ }
/**
* The constructor of this character object.
@@ -60,7 +61,7 @@ public class Character {
public Character(final int id, final String name, final String game,
final String weight, final int available) {
Log.d(TAG, "Character: New Character created with _id = [" + id + "], name = ["
- + name + "], game = [" + game + "], weight = [" + weight
+ + name + "], game = [" + game + "], weight = [" + weight
+ "], available = [" + available + "]");
mId = id;
mName = name;
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Kart.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Kart.java
index 565895e..6ea9e01 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Kart.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Kart.java
@@ -67,7 +67,8 @@ public class Kart {
/**
* Empty default constructor.
*/
- public Kart() {}
+ public Kart() {
+ }
/**
* The constructor of this kart object.
@@ -187,7 +188,7 @@ public class Kart {
*
* @param wheels the availability state of wheels for this kart object.
*/
- public void setWheels(int wheels) {
+ public void setWheels(final int wheels) {
mWheels = wheels;
}
@@ -205,7 +206,7 @@ public class Kart {
*
* @param accessory the availability state of accessory for this kart object.
*/
- public void setAccessory(int accessory) {
+ public void setAccessory(final int accessory) {
mAccessory = accessory;
}
@@ -223,7 +224,7 @@ public class Kart {
*
* @param dedicatedDriver the dedicated driver for this kart.
*/
- public void setDedicatedDriver(String dedicatedDriver) {
+ public void setDedicatedDriver(final String dedicatedDriver) {
mDedicatedDriver = dedicatedDriver;
}
@@ -242,7 +243,7 @@ public class Kart {
* @param freeForAll the availability state of this kart for other characters than the
* dedicated driver.
*/
- public void setFreeForAll(int freeForAll) {
+ public void setFreeForAll(final int freeForAll) {
mFreeForAll = freeForAll;
}
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Ruleset.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Ruleset.java
index 2496c57..17c16c0 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Ruleset.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Ruleset.java
@@ -64,29 +64,30 @@ public class Ruleset {
/**
* Empty default constructor.
*/
- public Ruleset() {}
+ public Ruleset() {
+ }
/**
* The constructor of this ruleset object.
*
- * @param id The database ID of this ruleset object.
- * @param game The name of the game where this ruleset object is available.
+ * @param id The database ID of this ruleset object.
+ * @param game The name of the game where this ruleset object is available.
* @param mirrorClassAvailable The availability state of a mirror class.
- * @param ccm50Available The availability state of a 50 ccm class.
- * @param ccm100Available The availability state of a 100 ccm class.
- * @param ccm150Available The availability state of a 150 ccm class.
- * @param ccm200Available The availability state of a 200 ccm class.
- * @param kartsFreeForAll The availability state of a karts for all characters by default.
- * @param bikesAvailable The availability state of a bikes.
+ * @param ccm50Available The availability state of a 50 ccm class.
+ * @param ccm100Available The availability state of a 100 ccm class.
+ * @param ccm150Available The availability state of a 150 ccm class.
+ * @param ccm200Available The availability state of a 200 ccm class.
+ * @param kartsFreeForAll The availability state of a karts for all characters by default.
+ * @param bikesAvailable The availability state of a bikes.
*/
public Ruleset(final int id, final String game, final int mirrorClassAvailable,
final int ccm50Available, final int ccm100Available, final int ccm150Available,
final int ccm200Available, final int kartsFreeForAll, final int bikesAvailable) {
- Log.d(TAG, "Ruleset: New Ruleset created with _id = [" + id + "], game = [" + game
- + "], mirror available = [" + mirrorClassAvailable + "], 50 ccm available = ["
- + ccm50Available + "], 100 ccm available = [" + ccm100Available
- + "], 150 ccm available = [" + ccm150Available + "], 200 ccm available = ["
- + ccm200Available + "], karts free for all = [" + kartsFreeForAll
+ Log.d(TAG, "Ruleset: New Ruleset created with _id = [" + id + "], game = [" + game
+ + "], mirror available = [" + mirrorClassAvailable + "], 50 ccm available = ["
+ + ccm50Available + "], 100 ccm available = [" + ccm100Available
+ + "], 150 ccm available = [" + ccm150Available + "], 200 ccm available = ["
+ + ccm200Available + "], karts free for all = [" + kartsFreeForAll
+ "], bikes available = [" + bikesAvailable + "]");
mId = id;
mGame = game;
@@ -149,7 +150,7 @@ public class Ruleset {
*
* @param ccm50Available the availability of a 50 ccm class.
*/
- public void set50CcmAvailable(int ccm50Available) {
+ public void set50CcmAvailable(final int ccm50Available) {
m50CcmAvailable = ccm50Available;
}
@@ -167,7 +168,7 @@ public class Ruleset {
*
* @param ccm100Available the availability of a 100 ccm class.
*/
- public void set100CcmAvailable(int ccm100Available) {
+ public void set100CcmAvailable(final int ccm100Available) {
m100CcmAvailable = ccm100Available;
}
@@ -185,7 +186,7 @@ public class Ruleset {
*
* @param ccm150Available the availability of a 150 ccm class.
*/
- public void set150CcmAvailable(int ccm150Available) {
+ public void set150CcmAvailable(final int ccm150Available) {
m150CcmAvailable = ccm150Available;
}
@@ -203,7 +204,7 @@ public class Ruleset {
*
* @param ccm200Available the availability of a 200 ccm class.
*/
- public void set200CcmAvailable(int ccm200Available) {
+ public void set200CcmAvailable(final int ccm200Available) {
m200CcmAvailable = ccm200Available;
}
@@ -221,7 +222,7 @@ public class Ruleset {
*
* @param mirrorClassAvailable the availability of a mirror class.
*/
- public void setMirrorClassAvailable(int mirrorClassAvailable) {
+ public void setMirrorClassAvailable(final int mirrorClassAvailable) {
mMirrorClassAvailable = mirrorClassAvailable;
}
@@ -239,7 +240,7 @@ public class Ruleset {
*
* @param kartsFreeForAll the availability of all karts for all characters.
*/
- public void setKartsFreeForAll(int kartsFreeForAll) {
+ public void setKartsFreeForAll(final int kartsFreeForAll) {
mKartsFreeForAll = kartsFreeForAll;
}
@@ -257,7 +258,7 @@ public class Ruleset {
*
* @param bikesAvailable the availability of bikes.
*/
- public void setBikesAvailable(int bikesAvailable) {
+ public void setBikesAvailable(final int bikesAvailable) {
mBikesAvailable = bikesAvailable;
}
}
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Track.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Track.java
index 13a2746..c8f370b 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Track.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/database_models/Track.java
@@ -51,7 +51,8 @@ public class Track {
/**
* Empty default constructor.
*/
- public Track() {}
+ public Track() {
+ }
/**
* The constructor of this track object.
@@ -141,9 +142,10 @@ public class Track {
/**
* Sets the package name where this track is part of.
+ *
* @param packageName the package name where this track is part of.
*/
- public void setPackage(String packageName) {
+ public void setPackage(final String packageName) {
mPackage = packageName;
}
@@ -161,7 +163,7 @@ public class Track {
*
* @param number the number of the track within the package.
*/
- public void setNumber(int number) {
+ public void setNumber(final int number) {
mNumber = number;
}
diff --git a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/fragments/GenericListFragment.java b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/fragments/GenericListFragment.java
index 9a4dd2b..ffa2c89 100644
--- a/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/fragments/GenericListFragment.java
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/fragments/GenericListFragment.java
@@ -17,62 +17,83 @@ import com.de.aldo_apps.aldo.mariokartcircuitselector.TrackContentProvider;
import com.de.aldo_apps.aldo.mariokartcircuitselector.WheelsContentProvider;
/**
- * Created by aldo7224 on 16.08.17.
+ * The ListFragment which is initialized in each PagerView and gets populated with data retrieved
+ * from database via cursor loader.
+ *
+ * @author aldo7224
+ * @version 0.1
+ * @since 17.08.2017
*/
+public class GenericListFragment extends ListFragment
+ implements LoaderManager.LoaderCallbacks {
-public class GenericListFragment extends ListFragment implements LoaderManager.LoaderCallbacks {
+ /**
+ * Tag for debugging purpose.
+ */
+ private static final String TAG = "GenericListFragment";
+ /**
+ * The SimpleCursorAdapter which populates the ListView.
+ * TODO: Needs to be replaced with Custom Adapter.
+ */
private SimpleCursorAdapter mCursorAdapter;
@Override
public void onCreate(final Bundle bundle) {
super.onCreate(bundle);
- final Bundle bundle2 = getArguments();
- if (bundle2 != null) {
- final String[] projection = bundle2.getStringArray("FOO");
- final int loaderId = bundle2.getInt("BAR");
- Log.d("#####", "onCreate: New GenericListFragment with loaderId = [" + loaderId
+ // Get Arguments from previous Class.
+ final Bundle arguments = getArguments();
+ if (arguments != null) {
+ // Get Projection and LoaderId from arguments.
+ final String[] projection = arguments.getStringArray(Constants.PROJECTION_KEY);
+ final int loaderId = arguments.getInt(Constants.LOADER_ID_KEY);
+ Log.d(TAG, "onCreate: New GenericListFragment with loaderId = [" + loaderId
+ "] and projection = [" + projection.toString() + "]");
- final int[] values = new int[] {android.R.id.text1};
+ // TODO: Replace with real ViewIds as soon as we use custom layout.
+ final int[] values = new int[]{android.R.id.text1};
+ // TODO: Replace with custom Layout and Adapter.
mCursorAdapter = new SimpleCursorAdapter(getContext(),
android.R.layout.simple_list_item_1,
- null, Constants.PROJECTION_TEST, values, 0);
+ null, projection, values, 0);
+ // Set the ListAdapter to the ListView.
setListAdapter(mCursorAdapter);
+ // initialize Loader for specified LoaderId.
getLoaderManager().initLoader(loaderId, null, this);
+ } else {
+ Log.d(TAG, "onCreate: No Arguments where provided. Skip Loader Creation.");
}
-
-
}
@Override
- public CursorLoader onCreateLoader(int id, Bundle args) {
- Log.d("########", "onCreateLoader: Creating Loader for ID [" + id + "]");
+ public CursorLoader onCreateLoader(final int id, final Bundle args) {
+ Log.d(TAG, "onCreateLoader: Creating Loader for ID [" + id + "]");
+ // Create CursorLoader for provided LoaderId.
switch (id) {
case Constants.CHARACTER_LOADER_ID:
- Log.d("####", "onCreateLoader: Creating character loader");
+ Log.d(TAG, "onCreateLoader: Creating character loader");
return new CursorLoader(getContext(),
CharacterContentProvider.CONTENT_URI,
Constants.PROJECTION_CHARACTER, null, null, null);
case Constants.KART_LOADER_ID:
- Log.d("####", "onCreateLoader: Creating kart loader");
+ Log.d(TAG, "onCreateLoader: Creating kart loader");
return new CursorLoader(getContext(),
KartContentProvider.CONTENT_URI,
Constants.PROJECTION_KART, null, null, null);
case Constants.WHEELS_LOADER_ID:
- Log.d("####", "onCreateLoader: Creating kart loader");
+ Log.d(TAG, "onCreateLoader: Creating kart loader");
return new CursorLoader(getContext(),
WheelsContentProvider.CONTENT_URI,
Constants.PROJECTION_WHEELS, null, null, null);
case Constants.ACCESSORY_LOADER_ID:
- Log.d("####", "onCreateLoader: Creating kart loader");
+ Log.d(TAG, "onCreateLoader: Creating kart loader");
return new CursorLoader(getContext(),
AccessoryContentProvider.CONTENT_URI,
Constants.PROJECTION_ACCESSORY, null, null, null);
case Constants.TRACK_LOADER_ID:
- Log.d("####", "onCreateLoader: Creating kart loader");
+ Log.d(TAG, "onCreateLoader: Creating kart loader");
return new CursorLoader(getContext(),
TrackContentProvider.CONTENT_URI,
Constants.PROJECTION_TRACK, null, null, null);
@@ -81,13 +102,14 @@ public class GenericListFragment extends ListFragment implements LoaderManager.L
}
@Override
- public void onLoadFinished(Loader loader, Cursor cursor) {
- Log.d("#####", "onLoadFinished: Finished Loading for " + loader.getId());
+ public void onLoadFinished(final Loader loader, final 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(Loader loader) {
+ public void onLoaderReset(final Loader loader) {
mCursorAdapter.swapCursor(null);
}
}
diff --git a/app/src/main/res/layout/activity_game_selection.xml b/app/src/main/res/layout/activity_game_selection.xml
index 38bec06..02f324a 100644
--- a/app/src/main/res/layout/activity_game_selection.xml
+++ b/app/src/main/res/layout/activity_game_selection.xml
@@ -4,7 +4,7 @@
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.GameSelection"
+ tools:context="com.de.aldo_apps.aldo.mariokartcircuitselector.activities.GameSelection"
>