From 312e85ec5be2897f24439240e4e7897b33c69b65 Mon Sep 17 00:00:00 2001 From: David Glenck Date: Thu, 30 Apr 2015 23:35:56 +0200 Subject: [PATCH] Fix: Colors are set for the wrong calendar #1 --- app/app.iml | 1 + app/build.gradle | 4 ++-- .../java/ch/ihdg/calendarcolor/CalendarListActivity.java | 8 ++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/app.iml b/app/app.iml index 5eedae2..4735144 100644 --- a/app/app.iml +++ b/app/app.iml @@ -58,6 +58,7 @@ + diff --git a/app/build.gradle b/app/build.gradle index 93744fd..9edfd45 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId 'ch.ihdg.calendarcolor' minSdkVersion 14 targetSdkVersion 21 - versionCode 1 - versionName '0.1' + versionCode 2 + versionName '0.2' } buildTypes { release { diff --git a/app/src/main/java/ch/ihdg/calendarcolor/CalendarListActivity.java b/app/src/main/java/ch/ihdg/calendarcolor/CalendarListActivity.java index 6ccbe9a..b14776c 100644 --- a/app/src/main/java/ch/ihdg/calendarcolor/CalendarListActivity.java +++ b/app/src/main/java/ch/ihdg/calendarcolor/CalendarListActivity.java @@ -16,14 +16,14 @@ import android.widget.SimpleCursorAdapter; import android.widget.TextView; -import java.util.Vector; +import java.util.HashMap; public class CalendarListActivity extends ListActivity implements LoaderManager.LoaderCallbacks { SimpleCursorAdapter mAdapter; - Vector calIds = new Vector(); + HashMap calIds = new HashMap(); static final String[] CALENDAR_PROJECTION = new String[] { CalendarContract.Calendars._ID, // 0 @@ -95,7 +95,7 @@ public boolean setViewValue(View view, Cursor cursor, int columnIndex) { return true; } else if (CalendarContract.Calendars._ID.equals(name)) { - calIds.add(cursor.getPosition(), cursor.getInt(columnIndex)); + calIds.put(cursor.getPosition(), cursor.getInt(columnIndex)); return true; } return false; @@ -135,7 +135,7 @@ public void onListItemClick(ListView l, View v, int position, long id) { // open color picker int color = ((ColorDrawable) v.findViewById(R.id.color).getBackground()).getColor(); String name = ((TextView) v.findViewById(R.id.displayname)).getText().toString(); - int cal_id = calIds.elementAt( position ); + int cal_id = calIds.get(position); Intent intent = new Intent(this, ColorPickerActivity.class);