Skip to content

Commit

Permalink
TrackType Bitmaps preloaded into a Bitmap Array
Browse files Browse the repository at this point in the history
  • Loading branch information
GrazianoCapelli committed Mar 29, 2017
1 parent ec04689 commit 0bd8c32
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 28 deletions.
16 changes: 8 additions & 8 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
Expand All @@ -82,6 +74,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
Expand Down
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ dependencies {
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:preference-v7:23.4.0'
compile 'com.android.support:preference-v14:23.4.0'
//compile 'com.squareup.picasso:picasso:2.5.2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,25 @@

class TrackAdapter extends RecyclerView.Adapter<TrackAdapter.TrackHolder> {

private final static int NOT_AVAILABLE = -100000;
private final static String FilesDir = GPSApplication.getInstance().getApplicationContext().getFilesDir().toString();

private ArrayList<Track> dataSet;
private int selectedItem = -1;

private final int[] Icons = {R.mipmap.ic_place_white_24dp, R.mipmap.ic_directions_walk_white_24dp, R.mipmap.ic_terrain_white_24dp,
R.mipmap.ic_directions_run_white_24dp, R.mipmap.ic_directions_bike_white_24dp, R.mipmap.ic_directions_car_white_24dp,
R.mipmap.ic_flight_white_24dp};
//private final int[] Icons = {R.mipmap.ic_place_white_24dp, R.mipmap.ic_directions_walk_white_24dp, R.mipmap.ic_terrain_white_24dp,
// R.mipmap.ic_directions_run_white_24dp, R.mipmap.ic_directions_bike_white_24dp, R.mipmap.ic_directions_car_white_24dp,
// R.mipmap.ic_flight_white_24dp};

private static final Bitmap[] bmpTrackType = {
BitmapFactory.decodeResource(GPSApplication.getInstance().getResources(), R.mipmap.ic_place_white_24dp),
BitmapFactory.decodeResource(GPSApplication.getInstance().getResources(), R.mipmap.ic_directions_walk_white_24dp),
BitmapFactory.decodeResource(GPSApplication.getInstance().getResources(), R.mipmap.ic_terrain_white_24dp),
BitmapFactory.decodeResource(GPSApplication.getInstance().getResources(), R.mipmap.ic_directions_run_white_24dp),
BitmapFactory.decodeResource(GPSApplication.getInstance().getResources(), R.mipmap.ic_directions_bike_white_24dp),
BitmapFactory.decodeResource(GPSApplication.getInstance().getResources(), R.mipmap.ic_directions_car_white_24dp),
BitmapFactory.decodeResource(GPSApplication.getInstance().getResources(), R.mipmap.ic_flight_white_24dp)
};

class TrackHolder extends RecyclerView.ViewHolder {

Expand Down Expand Up @@ -89,19 +101,19 @@ public void onClick(View v) {
}
}
});
itemView.setClickable(true);

this.textViewTrackName = (TextView) itemView.findViewById(R.id.id_textView_card_TrackName);
this.textViewTrackLength = (TextView) itemView.findViewById(R.id.id_textView_card_length);
this.textViewTrackDuration = (TextView) itemView.findViewById(R.id.id_textView_card_duration);
this.textViewTrackAltitudeGap = (TextView) itemView.findViewById(R.id.id_textView_card_altitudegap);
this.textViewTrackMaxSpeed = (TextView) itemView.findViewById(R.id.id_textView_card_maxspeed);
this.textViewTrackAverageSpeed = (TextView) itemView.findViewById(R.id.id_textView_card_averagespeed);
this.textViewTrackGeopoints = (TextView) itemView.findViewById(R.id.id_textView_card_geopoints);
this.textViewTrackPlacemarks = (TextView) itemView.findViewById(R.id.id_textView_card_placemarks);
this.imageViewThumbnail = (ImageView) itemView.findViewById(R.id.id_imageView_card_minimap);
this.imageViewIcon = (ImageView) itemView.findViewById(R.id.id_imageView_card_tracktype);
this.progressBar = (ProgressBar) itemView.findViewById(R.id.id_progressBar_card);
//itemView.setClickable(true);

textViewTrackName = (TextView) itemView.findViewById(R.id.id_textView_card_TrackName);
textViewTrackLength = (TextView) itemView.findViewById(R.id.id_textView_card_length);
textViewTrackDuration = (TextView) itemView.findViewById(R.id.id_textView_card_duration);
textViewTrackAltitudeGap = (TextView) itemView.findViewById(R.id.id_textView_card_altitudegap);
textViewTrackMaxSpeed = (TextView) itemView.findViewById(R.id.id_textView_card_maxspeed);
textViewTrackAverageSpeed = (TextView) itemView.findViewById(R.id.id_textView_card_averagespeed);
textViewTrackGeopoints = (TextView) itemView.findViewById(R.id.id_textView_card_geopoints);
textViewTrackPlacemarks = (TextView) itemView.findViewById(R.id.id_textView_card_placemarks);
imageViewThumbnail = (ImageView) itemView.findViewById(R.id.id_imageView_card_minimap);
imageViewIcon = (ImageView) itemView.findViewById(R.id.id_imageView_card_tracktype);
progressBar = (ProgressBar) itemView.findViewById(R.id.id_progressBar_card);
}

void SetProgress(int newprogress) {
Expand All @@ -111,8 +123,6 @@ void SetProgress(int newprogress) {

void BindTrack(Track trk) {

final int NOT_AVAILABLE = -100000;

track = trk;
numberOfPoints = track.getNumberOfLocations();
textViewTrackName.setText(track.getName());
Expand Down Expand Up @@ -140,10 +150,10 @@ void BindTrack(Track trk) {
TT = track.getTrackType();
if (TT != NOT_AVAILABLE) {
imageViewIcon.setVisibility(View.VISIBLE);
imageViewIcon.setImageResource(Icons[TT]);
imageViewIcon.setImageBitmap(bmpTrackType[TT]);
}
else imageViewIcon.setVisibility(View.INVISIBLE);
String Filename = GPSApplication.getInstance().getApplicationContext().getFilesDir() + "/Thumbnails/" + track.getId() + ".png";
String Filename = FilesDir + "/Thumbnails/" + track.getId() + ".png";
File file = new File(Filename);
if (file.exists ()) {
bmp = BitmapFactory.decodeFile(Filename);
Expand Down

0 comments on commit 0bd8c32

Please sign in to comment.