修复收藏夹长按崩溃
This commit is contained in:
parent
39d2e86c46
commit
1a13cf5e82
|
@ -74,7 +74,7 @@ public class FavoriteActivity extends Activity {
|
|||
listView.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
|
||||
String url = ((TextView) arg1.findViewById(R.id.group_count)).getText().toString();
|
||||
String url = ((TextView) arg1.findViewById(R.id.website)).getText().toString();
|
||||
Intent intent = new Intent(FavoriteActivity.this, MainActivity.class);
|
||||
intent.putExtra("url", url);
|
||||
setResult(RESULT_OK, intent);
|
||||
|
@ -87,7 +87,7 @@ public class FavoriteActivity extends Activity {
|
|||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
|
||||
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
|
||||
String title = ((TextView) info.targetView.findViewById(R.id.group_name)).getText().toString();
|
||||
String title = ((TextView) info.targetView.findViewById(R.id.title)).getText().toString();
|
||||
menu.setHeaderIcon(R.drawable.link);
|
||||
menu.setHeaderTitle(title);
|
||||
String[] sm = { "在新窗口中打开", "复制链接", "分享", "修改", "删除" };
|
||||
|
@ -251,8 +251,8 @@ public class FavoriteActivity extends Activity {
|
|||
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
|
||||
position = listView.getFirstVisiblePosition();
|
||||
final String sid = ((TextView) menuInfo.targetView.findViewById(R.id.id)).getText().toString();
|
||||
final String title = ((TextView) menuInfo.targetView.findViewById(R.id.group_name)).getText().toString();
|
||||
final String url = ((TextView) menuInfo.targetView.findViewById(R.id.group_count)).getText().toString();
|
||||
final String title = ((TextView) menuInfo.targetView.findViewById(R.id.title)).getText().toString();
|
||||
final String url = ((TextView) menuInfo.targetView.findViewById(R.id.website)).getText().toString();
|
||||
final String category = ((TextView) menuInfo.targetView.findViewById(R.id.category)).getText().toString();
|
||||
switch (item.getItemId()) {
|
||||
case 0:
|
||||
|
@ -421,7 +421,7 @@ public class FavoriteActivity extends Activity {
|
|||
int count = cursor1.getCount();
|
||||
setTitle("收藏夹 - " + s + " " + count);
|
||||
String[] from = { "_id", "title", "website", "category", "website" };
|
||||
int[] to = { R.id.id, R.id.group_name, R.id.group_count, R.id.category, R.id.imageView_favicon };
|
||||
int[] to = { R.id.id, R.id.title, R.id.website, R.id.category, R.id.imageView_favicon };
|
||||
adapter = new SimpleCursorAdapter(this, R.layout.favorite_row, cursor1, from, to, 0);
|
||||
adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder(){
|
||||
public boolean setViewValue(View view, Cursor cursor, int columnIndex){
|
||||
|
|
|
@ -62,7 +62,7 @@ public class FavoriteActivity1 extends Activity {
|
|||
ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
|
||||
int type = ExpandableListView.getPackedPositionType(info.packedPosition);
|
||||
if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
|
||||
String title = ((TextView) info.targetView.findViewById(android.R.id.text1)).getText().toString();
|
||||
String title = ((TextView) info.targetView.findViewById(R.id.group_name)).getText().toString();
|
||||
menu.setHeaderIcon(android.R.drawable.edit_text);
|
||||
menu.setHeaderTitle("分类:" + title);
|
||||
String[] sm = { "修改", "删除" };
|
||||
|
@ -70,7 +70,7 @@ public class FavoriteActivity1 extends Activity {
|
|||
menu.add(0, i, i, sm[i]);
|
||||
}
|
||||
} else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
|
||||
String title = ((TextView) info.targetView.findViewById(R.id.group_name)).getText().toString();
|
||||
String title = ((TextView) info.targetView.findViewById(R.id.title)).getText().toString();
|
||||
menu.setHeaderIcon(R.drawable.link);
|
||||
menu.setHeaderTitle(title);
|
||||
String[] sm = { "在新窗口中打开", "复制链接", "分享", "修改", "删除" };
|
||||
|
@ -230,15 +230,15 @@ public class FavoriteActivity1 extends Activity {
|
|||
position = expandableListView.getFirstVisiblePosition();
|
||||
switch (item.getGroupId()) {
|
||||
case 0:
|
||||
final String category0 = ((TextView) menuInfo.targetView.findViewById(android.R.id.text1)).getText().toString();
|
||||
final String group_name = ((TextView) menuInfo.targetView.findViewById(R.id.group_name)).getText().toString();
|
||||
switch (item.getItemId()) {
|
||||
case 0:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(FavoriteActivity1.this);
|
||||
builder.setIcon(android.R.drawable.ic_menu_edit);
|
||||
builder.setTitle("分类:" + category0);
|
||||
builder.setTitle("分类:" + group_name);
|
||||
final EditText editText_rename = new EditText(FavoriteActivity1.this);
|
||||
editText_rename.setText(category0);
|
||||
editText_rename.setSelection(category0.length());
|
||||
editText_rename.setText(group_name);
|
||||
editText_rename.setSelection(group_name.length());
|
||||
builder.setView(editText_rename);
|
||||
builder.setPositiveButton("重命名", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
|
@ -248,8 +248,8 @@ public class FavoriteActivity1 extends Activity {
|
|||
ContentValues values = new ContentValues();
|
||||
String category = editText_rename.getText().toString();
|
||||
values.put("category", category);
|
||||
db.update("category", values, "category = '" + category0 + "'", null);
|
||||
db.update(helper.TableName, values, "category = '" + category0 + "'", null);
|
||||
db.update("category", values, "category = '" + group_name + "'", null);
|
||||
db.update(helper.TableName, values, "category = '" + group_name + "'", null);
|
||||
onCreate(null);
|
||||
}
|
||||
});
|
||||
|
@ -259,18 +259,18 @@ public class FavoriteActivity1 extends Activity {
|
|||
case 1:
|
||||
DBHelper helper = new DBHelper(getApplicationContext());
|
||||
SQLiteDatabase db = helper.getWritableDatabase();
|
||||
db.delete("category", "category=?", new String[] { category0 });
|
||||
db.delete("category", "category=?", new String[] { group_name });
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("category", "");
|
||||
db.update(helper.TableName, values, "category = '" + category0 + "'", null);
|
||||
db.update(helper.TableName, values, "category = '" + group_name + "'", null);
|
||||
onCreate(null);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
final String sid = ((TextView) menuInfo.targetView.findViewById(R.id.id)).getText().toString();
|
||||
final String title = ((TextView) menuInfo.targetView.findViewById(R.id.group_name)).getText().toString();
|
||||
final String url = ((TextView) menuInfo.targetView.findViewById(R.id.group_count)).getText().toString();
|
||||
final String title = ((TextView) menuInfo.targetView.findViewById(R.id.title)).getText().toString();
|
||||
final String url = ((TextView) menuInfo.targetView.findViewById(R.id.website)).getText().toString();
|
||||
final String category = ((TextView) menuInfo.targetView.findViewById(R.id.category)).getText().toString();
|
||||
switch (item.getItemId()) {
|
||||
case 0:
|
||||
|
@ -307,7 +307,6 @@ public class FavoriteActivity1 extends Activity {
|
|||
layout.addView(editText_url);
|
||||
final Spinner spinner = new Spinner(this);
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add("");
|
||||
DBHelper helper = new DBHelper(this);
|
||||
Cursor cursor = helper.category();
|
||||
if (cursor != null) {
|
||||
|
|
|
@ -717,7 +717,6 @@ public class MainActivity extends Activity {
|
|||
layout.addView(editText_url);
|
||||
final Spinner spinner = new Spinner(MainActivity.this);
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add("");
|
||||
DBHelper helper = new DBHelper(MainActivity.this);
|
||||
Cursor cursor = helper.category();
|
||||
if (cursor != null) {
|
||||
|
|
Loading…
Reference in New Issue