收藏夹增加在新窗口打开,简化视频截图代码

This commit is contained in:
sonichy
2021-11-21 15:57:33 +08:00
parent df3f62afed
commit 523181494c
7 changed files with 77 additions and 76 deletions

View File

@@ -76,11 +76,12 @@ public class FavoriteActivity extends Activity {
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
String title = ((TextView) info.targetView.findViewById(R.id.title)).getText().toString();
menu.setHeaderIcon(R.drawable.link);
menu.setHeaderTitle(title);
menu.add(0, 0, 0, "复制链接");
menu.add(0, 1, 1, "删除");
menu.add(0, 2, 2, "修改");
menu.add(0, 3, 3, "分享");
String[] sm = { "在新窗口中打开", "复制链接", "分享", "修改", "删除" };
for (int i=0; i<sm.length; i++) {
menu.add(0, i, i, sm[i]);
}
}
});
listView.setOnTouchListener(new View.OnTouchListener() {
@@ -93,8 +94,6 @@ public class FavoriteActivity extends Activity {
search(editText.getText().toString());
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
String[] sm = { "导出HTML", "导出CSV" };
@@ -140,24 +139,31 @@ public class FavoriteActivity extends Activity {
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo();
position = menuInfo.position;
position = listView.getFirstVisiblePosition();
final String sid = ((TextView) menuInfo.targetView.findViewById(R.id.id)).getText().toString();
final String stitle = ((TextView) menuInfo.targetView.findViewById(R.id.title)).getText().toString();
final String surl = ((TextView) menuInfo.targetView.findViewById(R.id.website)).getText().toString();
switch (item.getItemId()) {
case 0:
ClipboardManager cm = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
String url = ((TextView) menuInfo.targetView.findViewById(R.id.website)).getText().toString();
cm.setPrimaryClip(ClipData.newPlainText("link", url));
Toast.makeText(getApplicationContext(), "链接已复制", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(FavoriteActivity.this, MainActivity.class);
intent.putExtra("url", surl);
intent.putExtra("newWindow", true);
setResult(RESULT_OK, intent);
finish();
break;
case 1:
int id = Integer.parseInt(((TextView) menuInfo.targetView.findViewById(R.id.id)).getText().toString());
DBHelper helper = new DBHelper(getApplicationContext());
helper.del(id);
search(editText.getText().toString());
ClipboardManager CM = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
CM.setPrimaryClip(ClipData.newPlainText("link", surl));
Toast.makeText(getApplicationContext(), "链接已复制", Toast.LENGTH_SHORT).show();
break;
case 2:
final String sid = ((TextView) menuInfo.targetView.findViewById(R.id.id)).getText().toString();
final String stitle = ((TextView) menuInfo.targetView.findViewById(R.id.title)).getText().toString();
final String surl = ((TextView) menuInfo.targetView.findViewById(R.id.website)).getText().toString();
intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, stitle + "\n" + surl);
intent.setType("text/plain");
startActivity(Intent.createChooser(intent, "分享"));
break;
case 3:
LinearLayout layout = new LinearLayout(FavoriteActivity.this);
layout.setOrientation(LinearLayout.VERTICAL);
final EditText ET_title = new EditText(FavoriteActivity.this);
@@ -236,12 +242,11 @@ public class FavoriteActivity extends Activity {
});
builder.create().show();
break;
case 3:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, ((TextView) menuInfo.targetView.findViewById(R.id.title)).getText().toString() + "\n" + ((TextView) menuInfo.targetView.findViewById(R.id.website)).getText().toString());
intent.setType("text/plain");
startActivity(Intent.createChooser(intent, "分享"));
case 4:
int id = Integer.parseInt(((TextView) menuInfo.targetView.findViewById(R.id.id)).getText().toString());
DBHelper helper = new DBHelper(getApplicationContext());
helper.del(id);
search(editText.getText().toString());
break;
}
return true;