diff --git a/.idea/misc.xml b/.idea/misc.xml
index 406ac20..738edfe 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -56,7 +56,7 @@
-
+
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 4fc3268..07c54c0 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -16,6 +16,32 @@
+
+
+
+
+
+
\ No newline at end of file
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
new file mode 100644
index 0000000..d2e909a
--- /dev/null
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/AccessoryContentProvider.java
@@ -0,0 +1,112 @@
+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.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.
+ */
+
+public class AccessoryContentProvider extends ContentProvider {
+
+ private static final String TAG = "AccessoryProvider";
+ 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
+ */
+ public static final Uri CONTENT_URI = Uri.parse("content://" + PROVIDER_NAME + "/accessories");
+
+ private static final UriMatcher uriMatcher;
+
+ static {
+ uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+ 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(final Uri uri) {
+ return null;
+ }
+
+ /**
+ * A callback method which is by the default content uri
+ */
+ @Override
+ public Cursor query(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, null, null);
+ case Constants.KART_LOADER_ID:
+ 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.");
+ return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY, null, null);
+ case Constants.TRACK_LOADER_ID:
+ Log.d(TAG, "query: Getting all Tracks.");
+ return mHandler.getAllTracks(Constants.PROJECTION_TRACK, null, null);
+ case Constants.WHEELS_LOADER_ID:
+ Log.d(TAG, "query: Getting all Wheels.");
+ return mHandler.getAllWheels(Constants.PROJECTION_WHEELS, null, null);
+ default:
+ Log.d(TAG, "query: UriMatcher returned: " + uriMatcher.match(uri));
+ return null;
+ }
+ }
+
+ @Override
+ public int delete(final Uri uri, final String selection, final String[] selectionArgs) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public Uri insert(final Uri uri, final ContentValues values) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int update(final Uri uri, final ContentValues values, final String selection,
+ final String[] selectionArgs) {
+ // TODO Auto-generated method stub
+ 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
new file mode 100644
index 0000000..69b111c
--- /dev/null
+++ b/app/src/main/java/com/de/aldo_apps/aldo/mariokartcircuitselector/CharacterContentProvider.java
@@ -0,0 +1,108 @@
+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.util.Log;
+
+/**
+ * Created by aldo7224 on 16.08.17.
+ */
+
+public class CharacterContentProvider extends ContentProvider {
+
+ private static final String TAG = "CharacterProvider";
+ 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
+ */
+ public static final Uri CONTENT_URI = Uri.parse("content://" + PROVIDER_NAME + "/characters");
+
+ private static final UriMatcher uriMatcher;
+
+ static {
+ uriMatcher = new UriMatcher(UriMatcher.NO_MATCH);
+ 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(final Uri uri) {
+ return null;
+ }
+
+ /**
+ * A callback method which is by the default content uri
+ */
+ @Override
+ public Cursor query(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, null, null);
+ case Constants.KART_LOADER_ID:
+ 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.");
+ return mHandler.getAllAccessories(Constants.PROJECTION_ACCESSORY, null, null);
+ case Constants.TRACK_LOADER_ID:
+ Log.d(TAG, "query: Getting all Tracks.");
+ return mHandler.getAllTracks(Constants.PROJECTION_TRACK, null, null);
+ case Constants.WHEELS_LOADER_ID:
+ Log.d(TAG, "query: Getting all Wheels.");
+ return mHandler.getAllWheels(Constants.PROJECTION_WHEELS, null, null);
+ default:
+ Log.d(TAG, "query: UriMatcher returned: " + uriMatcher.match(uri));
+ return null;
+ }
+ }
+
+ @Override
+ public int delete(final Uri uri, final String selection, final String[] selectionArgs) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public Uri insert(final Uri uri, final ContentValues values) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int update(final Uri uri, final ContentValues values, final String selection,
+ final String[] selectionArgs) {
+ // TODO Auto-generated method stub
+ 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 b78a0f4..a645264 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
@@ -8,164 +8,177 @@ package com.de.aldo_apps.aldo.mariokartcircuitselector;
* @version 0.1
* @since 07.08.2017
*/
-public class Constants {
+public final class Constants {
/**
* The Version Code of the Database.
*/
- static final Integer DATABASE_VERSION = 1;
+ public static final Integer DATABASE_VERSION = 1;
/**
* As SQLite does not have a native boolean value, we use integers to represent true and false.
* This is the value for a true statement.
*/
- public final static Integer TRUE = 1;
+ public static final Integer TRUE = 1;
/**
* 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.
*/
- final static Integer FALSE = 0;
+ public final static Integer FALSE = 0;
+
+ public static final int BASE_LOADER_ID = 0;
+
+ public static final int CHARACTER_LOADER_ID = BASE_LOADER_ID;
+
+ public static final int KART_LOADER_ID = BASE_LOADER_ID + 1;
+
+ public static final int TRACK_LOADER_ID = BASE_LOADER_ID + 2;
+
+ public static final int ACCESSORY_LOADER_ID = BASE_LOADER_ID + 3;
+
+ public static final int WHEELS_LOADER_ID = BASE_LOADER_ID + 4;
+
/**
* The Name of the complete database.
*/
- static final String DATABASE_NAME = "mario_kart_circuit_selector";
+ public static final String DATABASE_NAME = "mario_kart_circuit_selector";
/**
* The name of the table containing all information according accessories.
*/
- static final String TABLE_ACCESSORY = "accessory";
+ public static final String TABLE_ACCESSORY = "accessory";
/**
* The name of the table containing all information according characters.
*/
- static final String TABLE_CHARACTER = "character";
+ public static final String TABLE_CHARACTER = "character";
/**
* The name of the table containing all information according games.
*/
- static final String TABLE_GAME = "game";
+ public static final String TABLE_GAME = "game";
/**
* The name of the table containing all information according karts.
*/
- static final String TABLE_KART = "kart";
+ public static final String TABLE_KART = "kart";
/**
* The name of the table containing all information according rulesets.
*/
- static final String TABLE_RULESET = "ruleset";
+ public static final String TABLE_RULESET = "ruleset";
/**
* The name of the table containing all information according tracks.
*/
- static final String TABLE_TRACK = "track";
+ public static final String TABLE_TRACK = "track";
/**
* The name of the table containing all information according wheels.
*/
- static final String TABLE_WHEELS = "wheels";
+ public static final String TABLE_WHEELS = "wheels";
/**
* The global KEY for the _id field in the database.
*/
- static final String KEY_ID = "_id";
+ public static final String KEY_ID = "_id";
/**
* The global KEY for the name field in the database.
*/
- static final String KEY_NAME = "name";
+ public static final String KEY_NAME = "name";
/**
* The global KEY for the game field in the database.
*/
- static final String KEY_GAME = "game";
+ public static final String KEY_GAME = "game";
/**
* The global KEY for the available field in the database.
*/
- static final String KEY_AVAILABLE = "available";
+ public static final String KEY_AVAILABLE = "available";
/**
* The global KEY for the weight field in the database.
*/
- static final String KEY_WEIGHT = "weight";
+ public static final String KEY_WEIGHT = "weight";
/**
* The global KEY for the cover uri field in the database.
*/
- static final String KEY_COVER_URI = "cover_uri";
+ public static final String KEY_COVER_URI = "cover_uri";
/**
* The global KEY for the wheels field in the database.
*/
- static final String KEY_WHEELS = "wheels";
+ public static final String KEY_WHEELS = "wheels";
/**
* The global KEY for the accessory field in the database.
*/
- static final String KEY_ACCESSORY = "accessory";
+ public static final String KEY_ACCESSORY = "accessory";
/**
* The global KEY for the dedicated driver field in the database.
*/
- static final String KEY_DEDICATED_DRIVER = "dedicated_driver";
+ public static final String KEY_DEDICATED_DRIVER = "dedicated_driver";
/**
* The global KEY for the free for all field in the database.
*/
- static final String KEY_FREE_FOR_ALL = "free_for_all";
+ public static final String KEY_FREE_FOR_ALL = "free_for_all";
/**
* The global KEY for the mirror class field in the database.
*/
- static final String KEY_MIRROR_CLASS = "mirror_class";
+ public static final String KEY_MIRROR_CLASS = "mirror_class";
/**
* The global KEY for the 50 ccm field in the database.
*/
- static final String KEY_50_CCM = "50_ccm";
+ public static final String KEY_50_CCM = "50_ccm";
/**
* The global KEY for the 100 ccm field in the database.
*/
- static final String KEY_100_CCM = "100_ccm";
+ public static final String KEY_100_CCM = "100_ccm";
/**
* The global KEY for the 150 ccm field in the database.
*/
- static final String KEY_150_CCM = "150_ccm";
+ public static final String KEY_150_CCM = "150_ccm";
/**
* The global KEY for the 200 ccm field in the database.
*/
- static final String KEY_200_CCM = "200_ccm";
+ public static final String KEY_200_CCM = "200_ccm";
/**
* The global KEY for the kart free for all field in the database.
*/
- static final String KEY_KART_FREE_FOR_ALL = "kart_free_for_all";
+ public static final String KEY_KART_FREE_FOR_ALL = "kart_free_for_all";
/**
* The global KEY for the bikes field in the database.
*/
- static final String KEY_BIKES = "bikes";
+ public static final String KEY_BIKES = "bikes";
/**
* The global KEY for the package field in the database.
*/
- static final String KEY_PACKAGE = "package";
+ public static final String KEY_PACKAGE = "package";
/**
* The global KEY for the number field in the database.
*/
- static final String KEY_NUMBER = "number";
+ public static final String KEY_NUMBER = "number";
/**
* 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
@@ -174,7 +187,7 @@ public class Constants {
/**
* The Projection to retrieve all Information of a track object from database.
*/
- static final String[] PROJECTION_TRACK = {
+ public static final String[] PROJECTION_TRACK = {
KEY_ID,
KEY_NAME,
KEY_GAME,
@@ -186,7 +199,7 @@ public class Constants {
/**
* The Projection to retrieve all Information of a character object from database.
*/
- static final String[] PROJECTION_CHARACTER = {
+ public static final String[] PROJECTION_CHARACTER = {
KEY_ID,
KEY_NAME,
KEY_GAME,
@@ -194,10 +207,14 @@ public class Constants {
KEY_AVAILABLE
};
+ public static final String[] PROJECTION_TEST = {
+ KEY_NAME
+ };
+
/**
* The Projection to retrieve all Information of a kart object from database.
*/
- static final String[] PROJECTION_KART = {
+ public static final String[] PROJECTION_KART = {
KEY_ID,
KEY_NAME,
KEY_GAME,
@@ -212,7 +229,7 @@ public class Constants {
/**
* The Projection to retrieve all Information of a ruleset object from database.
*/
- static final String[] PROJECTION_RULESET = {
+ public static final String[] PROJECTION_RULESET = {
KEY_ID,
KEY_GAME,
KEY_MIRROR_CLASS,
@@ -227,7 +244,7 @@ public class Constants {
/**
* The Projection to retrieve all Information of a accessory object from database.
*/
- static final String[] PROJECTION_ACCESSORY = {
+ public static final String[] PROJECTION_ACCESSORY = {
KEY_ID,
KEY_NAME,
KEY_GAME,
@@ -237,7 +254,7 @@ public class Constants {
/**
* The Projection to retrieve all Information of a wheels object from database.
*/
- static final String[] PROJECTION_WHEELS = {
+ public static final String[] PROJECTION_WHEELS = {
KEY_ID,
KEY_NAME,
KEY_GAME,
@@ -248,25 +265,25 @@ public class Constants {
/**
* Enum Value defining the position of the Character Tab.
*/
- static final int CHARACTER = 0;
+ public static final int CHARACTER = 0;
/**
* Enum Value defining the position of the Kart Tab.
*/
- static final int KART = 1;
+ public static final int KART = 1;
/**
* Enum Value defining the position of the Track Tab.
*/
- static final int TRACK = 2;
+ public static final int TRACK = 2;
/**
* Enum Value defining the position of the Accessory Tab.
*/
- static final int ACCESSORY = 3;
+ public static final int ACCESSORY = 3;
/**
* Enum Value defining the position of the Wheels Tab.
*/
- static final int WHEELS = 4;
+ 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 4e9d368..054776a 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
@@ -5,6 +5,7 @@ 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;
@@ -194,651 +195,110 @@ public class DatabaseHandler extends SQLiteAssetHelper {
/**
* Retrieves all Tracks from Database. If a Game is provided, all tracks of this specific
* game will be retrieved.
- *
- * @param game The game of which all tracks should be retrieved.
- * @param onlyAvailable If true, only available objects will be returned, otherwise all
*
* @return List containing all Track Objects retrieved from Database.
*/
- public ArrayList