Prepared usage of images (fully working with http-uri)
This commit is contained in:
@@ -7,8 +7,8 @@ android {
|
|||||||
applicationId "com.de.aldo_apps.aldo.mariokartcircuitselector"
|
applicationId "com.de.aldo_apps.aldo.mariokartcircuitselector"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
versionCode 11
|
versionCode 12
|
||||||
versionName "0.1.11"
|
versionName "0.1.12"
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
@@ -27,9 +27,11 @@ dependencies {
|
|||||||
compile 'com.android.support:appcompat-v7:25.3.1'
|
compile 'com.android.support:appcompat-v7:25.3.1'
|
||||||
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
compile 'com.android.support.constraint:constraint-layout:1.0.2'
|
||||||
compile 'com.afollestad.material-dialogs:core:0.9.4.3'
|
compile 'com.afollestad.material-dialogs:core:0.9.4.3'
|
||||||
|
compile 'com.squareup.picasso:picasso:2.5.2'
|
||||||
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
|
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
|
||||||
compile 'devlight.io:navigationtabbar:1.2.5'
|
compile 'devlight.io:navigationtabbar:1.2.5'
|
||||||
compile 'com.android.support:cardview-v7:25.3.1'
|
compile 'com.android.support:cardview-v7:25.3.1'
|
||||||
|
compile 'de.hdodenhof:circleimageview:2.1.0'
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
compile 'com.android.support:design:25.3.1'
|
compile 'com.android.support:design:25.3.1'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.de.aldo_apps.aldo.mariokartcircuitselector">
|
package="com.de.aldo_apps.aldo.mariokartcircuitselector">
|
||||||
|
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
|||||||
|
ALTER TABLE track ADD cover_uri TEXT;
|
||||||
|
ALTER TABLE wheels ADD cover_uri TEXT;
|
||||||
|
ALTER TABLE kart ADD cover_uri TEXT;
|
||||||
|
ALTER TABLE accessory ADD cover_uri TEXT;
|
||||||
|
ALTER TABLE character ADD cover_uri TEXT;
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ public final class Constants {
|
|||||||
/**
|
/**
|
||||||
* The Version Code of the Database.
|
* The Version Code of the Database.
|
||||||
*/
|
*/
|
||||||
static final Integer DATABASE_VERSION = 1;
|
static final Integer DATABASE_VERSION = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* As SQLite does not have a native boolean value, we use integers to represent true and false.
|
* As SQLite does not have a native boolean value, we use integers to represent true and false.
|
||||||
@@ -220,6 +220,7 @@ public final class Constants {
|
|||||||
KEY_GAME,
|
KEY_GAME,
|
||||||
KEY_PACKAGE,
|
KEY_PACKAGE,
|
||||||
KEY_NUMBER,
|
KEY_NUMBER,
|
||||||
|
KEY_COVER_URI,
|
||||||
KEY_AVAILABLE
|
KEY_AVAILABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -231,6 +232,7 @@ public final class Constants {
|
|||||||
KEY_NAME,
|
KEY_NAME,
|
||||||
KEY_GAME,
|
KEY_GAME,
|
||||||
KEY_WEIGHT,
|
KEY_WEIGHT,
|
||||||
|
KEY_COVER_URI,
|
||||||
KEY_AVAILABLE
|
KEY_AVAILABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -250,6 +252,7 @@ public final class Constants {
|
|||||||
KEY_ACCESSORY,
|
KEY_ACCESSORY,
|
||||||
KEY_DEDICATED_DRIVER,
|
KEY_DEDICATED_DRIVER,
|
||||||
KEY_FREE_FOR_ALL,
|
KEY_FREE_FOR_ALL,
|
||||||
|
KEY_COVER_URI,
|
||||||
KEY_AVAILABLE
|
KEY_AVAILABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -275,6 +278,7 @@ public final class Constants {
|
|||||||
KEY_ID,
|
KEY_ID,
|
||||||
KEY_NAME,
|
KEY_NAME,
|
||||||
KEY_GAME,
|
KEY_GAME,
|
||||||
|
KEY_COVER_URI,
|
||||||
KEY_AVAILABLE
|
KEY_AVAILABLE
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -285,6 +289,7 @@ public final class Constants {
|
|||||||
KEY_ID,
|
KEY_ID,
|
||||||
KEY_NAME,
|
KEY_NAME,
|
||||||
KEY_GAME,
|
KEY_GAME,
|
||||||
|
KEY_COVER_URI,
|
||||||
KEY_AVAILABLE
|
KEY_AVAILABLE
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.de.aldo_apps.aldo.mariokartcircuitselector.adapters;
|
|||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
import android.support.v4.widget.SimpleCursorAdapter;
|
import android.support.v4.widget.SimpleCursorAdapter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -16,6 +17,9 @@ import android.widget.TextView;
|
|||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.AccessoryContentProvider;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.AccessoryContentProvider;
|
||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
||||||
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
import de.hdodenhof.circleimageview.CircleImageView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom CursorAdapter which populates the ListView with accessory data from cursor.
|
* Custom CursorAdapter which populates the ListView with accessory data from cursor.
|
||||||
@@ -81,14 +85,19 @@ public class AccessoryCursorAdapter extends SimpleCursorAdapter {
|
|||||||
|
|
||||||
final int idxId = cursor.getColumnIndex(Constants.KEY_ID);
|
final int idxId = cursor.getColumnIndex(Constants.KEY_ID);
|
||||||
final int idxName = cursor.getColumnIndex(Constants.KEY_NAME);
|
final int idxName = cursor.getColumnIndex(Constants.KEY_NAME);
|
||||||
|
final int idxCoverUri = cursor.getColumnIndex(Constants.KEY_COVER_URI);
|
||||||
final int idxAvailable = cursor.getColumnIndex(Constants.KEY_AVAILABLE);
|
final int idxAvailable = cursor.getColumnIndex(Constants.KEY_AVAILABLE);
|
||||||
|
|
||||||
if (idxId > -1 && idxName > -1 && idxAvailable > -1) {
|
if (idxId > -1 && idxName > -1 && idxAvailable > -1) {
|
||||||
final long id = cursor.getLong(idxId);
|
final long id = cursor.getLong(idxId);
|
||||||
final String name = cursor.getString(idxName);
|
final String name = cursor.getString(idxName);
|
||||||
|
String coverUri = null;
|
||||||
|
if (idxCoverUri > -1) {
|
||||||
|
coverUri = cursor.getString(idxCoverUri);
|
||||||
|
}
|
||||||
final boolean available = cursor.getInt(idxAvailable) == Constants.TRUE;
|
final boolean available = cursor.getInt(idxAvailable) == Constants.TRUE;
|
||||||
|
|
||||||
fillViewWithData(view, id, name, available);
|
fillViewWithData(view, id, name, coverUri, available);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,6 +112,7 @@ public class AccessoryCursorAdapter extends SimpleCursorAdapter {
|
|||||||
private void fillViewWithData(final View view,
|
private void fillViewWithData(final View view,
|
||||||
final long id,
|
final long id,
|
||||||
final String name,
|
final String name,
|
||||||
|
final String imageUri,
|
||||||
final boolean available) {
|
final boolean available) {
|
||||||
final CheckBox availabilityCheckBox
|
final CheckBox availabilityCheckBox
|
||||||
= (CheckBox) view.findViewById(R.id.availability_checkbox);
|
= (CheckBox) view.findViewById(R.id.availability_checkbox);
|
||||||
@@ -118,6 +128,13 @@ public class AccessoryCursorAdapter extends SimpleCursorAdapter {
|
|||||||
nameTextView.setText(name);
|
nameTextView.setText(name);
|
||||||
nameTextView.setVisibility(View.VISIBLE);
|
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.");
|
||||||
|
}
|
||||||
|
|
||||||
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.de.aldo_apps.aldo.mariokartcircuitselector.adapters;
|
|||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
import android.support.v4.widget.SimpleCursorAdapter;
|
import android.support.v4.widget.SimpleCursorAdapter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -16,6 +17,9 @@ import android.widget.TextView;
|
|||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.CharacterContentProvider;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.CharacterContentProvider;
|
||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
||||||
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
import de.hdodenhof.circleimageview.CircleImageView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom CursorAdapter which populates the ListView with character data from cursor.
|
* Custom CursorAdapter which populates the ListView with character data from cursor.
|
||||||
@@ -82,15 +86,20 @@ public class CharacterCursorAdapter extends SimpleCursorAdapter {
|
|||||||
final int idxId = cursor.getColumnIndex(Constants.KEY_ID);
|
final int idxId = cursor.getColumnIndex(Constants.KEY_ID);
|
||||||
final int idxName = cursor.getColumnIndex(Constants.KEY_NAME);
|
final int idxName = cursor.getColumnIndex(Constants.KEY_NAME);
|
||||||
final int idxWeight = cursor.getColumnIndex(Constants.KEY_WEIGHT);
|
final int idxWeight = cursor.getColumnIndex(Constants.KEY_WEIGHT);
|
||||||
|
final int idxCoverUri = cursor.getColumnIndex(Constants.KEY_COVER_URI);
|
||||||
final int idxAvailable = cursor.getColumnIndex(Constants.KEY_AVAILABLE);
|
final int idxAvailable = cursor.getColumnIndex(Constants.KEY_AVAILABLE);
|
||||||
|
|
||||||
if (idxId > -1 && idxName > -1 && idxWeight > -1 && idxAvailable > -1) {
|
if (idxId > -1 && idxName > -1 && idxWeight > -1 && idxAvailable > -1) {
|
||||||
final long id = cursor.getLong(idxId);
|
final long id = cursor.getLong(idxId);
|
||||||
final String name = cursor.getString(idxName);
|
final String name = cursor.getString(idxName);
|
||||||
final String weight = cursor.getString(idxWeight);
|
final String weight = cursor.getString(idxWeight);
|
||||||
|
String coverUri = null;
|
||||||
|
if (idxCoverUri > -1) {
|
||||||
|
coverUri = cursor.getString(idxCoverUri);
|
||||||
|
}
|
||||||
final boolean available = cursor.getInt(idxAvailable) == Constants.TRUE;
|
final boolean available = cursor.getInt(idxAvailable) == Constants.TRUE;
|
||||||
|
|
||||||
fillViewWithData(view, id, name, weight, available);
|
fillViewWithData(view, id, name, weight, coverUri, available);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +116,7 @@ public class CharacterCursorAdapter extends SimpleCursorAdapter {
|
|||||||
final long id,
|
final long id,
|
||||||
final String name,
|
final String name,
|
||||||
final String weight,
|
final String weight,
|
||||||
|
final String imageUri,
|
||||||
final boolean available) {
|
final boolean available) {
|
||||||
final CheckBox availabilityCheckBox
|
final CheckBox availabilityCheckBox
|
||||||
= (CheckBox) view.findViewById(R.id.availability_checkbox);
|
= (CheckBox) view.findViewById(R.id.availability_checkbox);
|
||||||
@@ -125,7 +135,13 @@ public class CharacterCursorAdapter extends SimpleCursorAdapter {
|
|||||||
= (TextView) view.findViewById(R.id.additional_information_separator);
|
= (TextView) view.findViewById(R.id.additional_information_separator);
|
||||||
separator.setVisibility(View.GONE);
|
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.");
|
||||||
|
}
|
||||||
|
|
||||||
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.de.aldo_apps.aldo.mariokartcircuitselector.adapters;
|
|||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
import android.support.v4.widget.SimpleCursorAdapter;
|
import android.support.v4.widget.SimpleCursorAdapter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -16,6 +17,9 @@ import android.widget.TextView;
|
|||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.KartContentProvider;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.KartContentProvider;
|
||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
||||||
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
import de.hdodenhof.circleimageview.CircleImageView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom CursorAdapter which populates the ListView with kart data from cursor.
|
* Custom CursorAdapter which populates the ListView with kart data from cursor.
|
||||||
@@ -83,6 +87,7 @@ public class KartCursorAdapter extends SimpleCursorAdapter {
|
|||||||
final int idxName = cursor.getColumnIndex(Constants.KEY_NAME);
|
final int idxName = cursor.getColumnIndex(Constants.KEY_NAME);
|
||||||
final int idxWeight = cursor.getColumnIndex(Constants.KEY_WEIGHT);
|
final int idxWeight = cursor.getColumnIndex(Constants.KEY_WEIGHT);
|
||||||
final int idxDedicatedDriver = cursor.getColumnIndex(Constants.KEY_DEDICATED_DRIVER);
|
final int idxDedicatedDriver = cursor.getColumnIndex(Constants.KEY_DEDICATED_DRIVER);
|
||||||
|
final int idxCoverUri = cursor.getColumnIndex(Constants.KEY_COVER_URI);
|
||||||
final int idxAvailable = cursor.getColumnIndex(Constants.KEY_AVAILABLE);
|
final int idxAvailable = cursor.getColumnIndex(Constants.KEY_AVAILABLE);
|
||||||
|
|
||||||
if (idxId > -1 && idxName > -1 && idxDedicatedDriver > -1 && idxWeight > -1
|
if (idxId > -1 && idxName > -1 && idxDedicatedDriver > -1 && idxWeight > -1
|
||||||
@@ -91,9 +96,13 @@ public class KartCursorAdapter extends SimpleCursorAdapter {
|
|||||||
final String name = cursor.getString(idxName);
|
final String name = cursor.getString(idxName);
|
||||||
final String weight = cursor.getString(idxDedicatedDriver);
|
final String weight = cursor.getString(idxDedicatedDriver);
|
||||||
final String dedicatedDriver = cursor.getString(idxWeight);
|
final String dedicatedDriver = cursor.getString(idxWeight);
|
||||||
|
String coverUri = null;
|
||||||
|
if (idxCoverUri > -1) {
|
||||||
|
coverUri = cursor.getString(idxCoverUri);
|
||||||
|
}
|
||||||
final boolean available = cursor.getInt(idxAvailable) == Constants.TRUE;
|
final boolean available = cursor.getInt(idxAvailable) == Constants.TRUE;
|
||||||
|
|
||||||
fillViewWithData(view, id, name, weight, dedicatedDriver, available);
|
fillViewWithData(view, id, name, weight, dedicatedDriver, coverUri, available);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +121,7 @@ public class KartCursorAdapter extends SimpleCursorAdapter {
|
|||||||
final String name,
|
final String name,
|
||||||
final String weight,
|
final String weight,
|
||||||
final String dedicatedDriver,
|
final String dedicatedDriver,
|
||||||
|
final String imageUri,
|
||||||
final boolean available) {
|
final boolean available) {
|
||||||
final CheckBox availabilityCheckBox
|
final CheckBox availabilityCheckBox
|
||||||
= (CheckBox) view.findViewById(R.id.availability_checkbox);
|
= (CheckBox) view.findViewById(R.id.availability_checkbox);
|
||||||
@@ -130,6 +140,14 @@ public class KartCursorAdapter extends SimpleCursorAdapter {
|
|||||||
= (TextView) view.findViewById(R.id.additional_info_second);
|
= (TextView) view.findViewById(R.id.additional_info_second);
|
||||||
dedicatedDriverTextView.setText(dedicatedDriver);
|
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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.de.aldo_apps.aldo.mariokartcircuitselector.adapters;
|
|||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.net.Uri;
|
||||||
import android.support.v4.widget.SimpleCursorAdapter;
|
import android.support.v4.widget.SimpleCursorAdapter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -16,6 +18,9 @@ import android.widget.TextView;
|
|||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.TrackContentProvider;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.TrackContentProvider;
|
||||||
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
import de.hdodenhof.circleimageview.CircleImageView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom CursorAdapter which populates the ListView with track data from cursor.
|
* Custom CursorAdapter which populates the ListView with track data from cursor.
|
||||||
@@ -83,6 +88,7 @@ public class TrackCursorAdapter extends SimpleCursorAdapter {
|
|||||||
final int idxName = cursor.getColumnIndex(Constants.KEY_NAME);
|
final int idxName = cursor.getColumnIndex(Constants.KEY_NAME);
|
||||||
final int idxPackage = cursor.getColumnIndex(Constants.KEY_PACKAGE);
|
final int idxPackage = cursor.getColumnIndex(Constants.KEY_PACKAGE);
|
||||||
final int idxNumber = cursor.getColumnIndex(Constants.KEY_NUMBER);
|
final int idxNumber = cursor.getColumnIndex(Constants.KEY_NUMBER);
|
||||||
|
final int idxCoverUri = cursor.getColumnIndex(Constants.KEY_COVER_URI);
|
||||||
final int idxAvailable = cursor.getColumnIndex(Constants.KEY_AVAILABLE);
|
final int idxAvailable = cursor.getColumnIndex(Constants.KEY_AVAILABLE);
|
||||||
|
|
||||||
if (idxId > -1 && idxName > -1 && idxNumber > -1 && idxPackage > -1 && idxAvailable > -1) {
|
if (idxId > -1 && idxName > -1 && idxNumber > -1 && idxPackage > -1 && idxAvailable > -1) {
|
||||||
@@ -90,9 +96,13 @@ public class TrackCursorAdapter extends SimpleCursorAdapter {
|
|||||||
final String name = cursor.getString(idxName);
|
final String name = cursor.getString(idxName);
|
||||||
final String number = cursor.getString(idxNumber);
|
final String number = cursor.getString(idxNumber);
|
||||||
final String packageName = cursor.getString(idxPackage);
|
final String packageName = cursor.getString(idxPackage);
|
||||||
|
String coverUri = null;
|
||||||
|
if (idxCoverUri > -1) {
|
||||||
|
coverUri = cursor.getString(idxCoverUri);
|
||||||
|
}
|
||||||
final boolean available = cursor.getInt(idxAvailable) == Constants.TRUE;
|
final boolean available = cursor.getInt(idxAvailable) == Constants.TRUE;
|
||||||
|
|
||||||
fillViewWithData(view, id, name, packageName, number, available);
|
fillViewWithData(view, id, name, packageName, number, coverUri, available);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,6 +114,7 @@ public class TrackCursorAdapter extends SimpleCursorAdapter {
|
|||||||
* @param name Name of the track to be displayed.
|
* @param name Name of the track to be displayed.
|
||||||
* @param packageName Name of the package where this track is available to be displayed.
|
* @param packageName Name of the package where this track is available to be displayed.
|
||||||
* @param number Number of the track to be displayed.
|
* @param number Number of the track to be displayed.
|
||||||
|
* @param imageUri The String (uri) pointing to the image location.
|
||||||
* @param available Current AvailabilityState of the track.
|
* @param available Current AvailabilityState of the track.
|
||||||
*/
|
*/
|
||||||
private void fillViewWithData(final View view,
|
private void fillViewWithData(final View view,
|
||||||
@@ -111,6 +122,7 @@ public class TrackCursorAdapter extends SimpleCursorAdapter {
|
|||||||
final String name,
|
final String name,
|
||||||
final String packageName,
|
final String packageName,
|
||||||
final String number,
|
final String number,
|
||||||
|
final String imageUri,
|
||||||
final boolean available) {
|
final boolean available) {
|
||||||
final CheckBox availabilityCheckBox
|
final CheckBox availabilityCheckBox
|
||||||
= (CheckBox) view.findViewById(R.id.availability_checkbox);
|
= (CheckBox) view.findViewById(R.id.availability_checkbox);
|
||||||
@@ -128,6 +140,13 @@ public class TrackCursorAdapter extends SimpleCursorAdapter {
|
|||||||
final TextView numberTextView = (TextView) view.findViewById(R.id.additional_info_second);
|
final TextView numberTextView = (TextView) view.findViewById(R.id.additional_info_second);
|
||||||
numberTextView.setText(number);
|
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.");
|
||||||
|
}
|
||||||
|
|
||||||
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.de.aldo_apps.aldo.mariokartcircuitselector.adapters;
|
|||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
import android.support.v4.widget.SimpleCursorAdapter;
|
import android.support.v4.widget.SimpleCursorAdapter;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -16,6 +17,9 @@ import android.widget.TextView;
|
|||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.Constants;
|
||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.R;
|
||||||
import com.de.aldo_apps.aldo.mariokartcircuitselector.WheelsContentProvider;
|
import com.de.aldo_apps.aldo.mariokartcircuitselector.WheelsContentProvider;
|
||||||
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
import de.hdodenhof.circleimageview.CircleImageView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom CursorAdapter which populates the ListView with wheels data from cursor.
|
* Custom CursorAdapter which populates the ListView with wheels data from cursor.
|
||||||
@@ -81,14 +85,19 @@ public class WheelsCursorAdapter extends SimpleCursorAdapter {
|
|||||||
|
|
||||||
final int idxId = cursor.getColumnIndex(Constants.KEY_ID);
|
final int idxId = cursor.getColumnIndex(Constants.KEY_ID);
|
||||||
final int idxName = cursor.getColumnIndex(Constants.KEY_NAME);
|
final int idxName = cursor.getColumnIndex(Constants.KEY_NAME);
|
||||||
|
final int idxCoverUri = cursor.getColumnIndex(Constants.KEY_COVER_URI);
|
||||||
final int idxAvailable = cursor.getColumnIndex(Constants.KEY_AVAILABLE);
|
final int idxAvailable = cursor.getColumnIndex(Constants.KEY_AVAILABLE);
|
||||||
|
|
||||||
if (idxId > -1 && idxName > -1 && idxAvailable > -1) {
|
if (idxId > -1 && idxName > -1 && idxAvailable > -1) {
|
||||||
final long id = cursor.getLong(idxId);
|
final long id = cursor.getLong(idxId);
|
||||||
final String name = cursor.getString(idxName);
|
final String name = cursor.getString(idxName);
|
||||||
|
String coverUri = null;
|
||||||
|
if (idxCoverUri > -1) {
|
||||||
|
coverUri = cursor.getString(idxCoverUri);
|
||||||
|
}
|
||||||
final boolean available = cursor.getInt(idxAvailable) == Constants.TRUE;
|
final boolean available = cursor.getInt(idxAvailable) == Constants.TRUE;
|
||||||
|
|
||||||
fillViewWithData(view, id, name, available);
|
fillViewWithData(view, id, name, coverUri, available);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,6 +112,7 @@ public class WheelsCursorAdapter extends SimpleCursorAdapter {
|
|||||||
private void fillViewWithData(final View view,
|
private void fillViewWithData(final View view,
|
||||||
final long id,
|
final long id,
|
||||||
final String name,
|
final String name,
|
||||||
|
final String imageUri,
|
||||||
final boolean available) {
|
final boolean available) {
|
||||||
final CheckBox availabilityCheckBox
|
final CheckBox availabilityCheckBox
|
||||||
= (CheckBox) view.findViewById(R.id.availability_checkbox);
|
= (CheckBox) view.findViewById(R.id.availability_checkbox);
|
||||||
@@ -118,6 +128,14 @@ public class WheelsCursorAdapter extends SimpleCursorAdapter {
|
|||||||
nameTextView.setText(name);
|
nameTextView.setText(name);
|
||||||
nameTextView.setVisibility(View.VISIBLE);
|
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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
availabilityCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -83,5 +83,14 @@
|
|||||||
android:textAppearance="@android:style/TextAppearance.Large"
|
android:textAppearance="@android:style/TextAppearance.Large"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<de.hdodenhof.circleimageview.CircleImageView
|
||||||
|
android:layout_width="50dp"
|
||||||
|
android:layout_height="50dp"
|
||||||
|
android:id="@+id/image_view"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
|
||||||
|
/>
|
||||||
</android.support.v7.widget.CardView>
|
</android.support.v7.widget.CardView>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
Reference in New Issue
Block a user