X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/11117ace1530d2cfd21b85f9dcd6804938b5f341..9aab2d26da38f26e7ff03a0b5db3bd01b51bce05:/src/com/owncloud/android/ui/activity/AccountSelectActivity.java
diff --git a/src/com/owncloud/android/ui/activity/AccountSelectActivity.java b/src/com/owncloud/android/ui/activity/AccountSelectActivity.java
index 50f76258..b99283e1 100644
--- a/src/com/owncloud/android/ui/activity/AccountSelectActivity.java
+++ b/src/com/owncloud/android/ui/activity/AccountSelectActivity.java
@@ -1,3 +1,21 @@
+/* ownCloud Android client application
+ * Copyright (C) 2012 Bartek Przybylski
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
package com.owncloud.android.ui.activity;
import java.util.HashMap;
@@ -19,9 +37,7 @@ import android.view.ContextMenu;
import android.view.View;
import android.view.ViewGroup;
import android.view.ContextMenu.ContextMenuInfo;
-import android.widget.AdapterView;
import android.widget.AdapterView.AdapterContextMenuInfo;
-import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.CheckedTextView;
import android.widget.ListView;
import android.widget.SimpleAdapter;
@@ -40,6 +56,8 @@ import com.owncloud.android.R;
public class AccountSelectActivity extends SherlockListActivity implements
AccountManagerCallback {
+ private static final String TAG = "AccountSelectActivity";
+
private static final String PREVIOUS_ACCOUNT_KEY = "ACCOUNT";
private final Handler mHandler = new Handler();
@@ -124,13 +142,20 @@ public class AccountSelectActivity extends SherlockListActivity implements
return false;
}
+ @SuppressWarnings("unchecked")
@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
int index = info.position;
- HashMap map = (HashMap) getListAdapter()
- .getItem(index);
+ HashMap map = null;
+ try {
+ map = (HashMap) getListAdapter().getItem(index);
+ } catch (ClassCastException e) {
+ Log.wtf(TAG, "getitem(index) from list adapter did not return hashmap, bailing out");
+ return false;
+ }
+
String accountName = map.get("NAME");
AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE);
Account accounts[] = am