收藏夹删除时记录位置,不需要从头再来

This commit is contained in:
sonichy 2019-04-13 21:35:16 +08:00
parent 415b896d50
commit 505ec52f41
6 changed files with 41 additions and 38 deletions

BIN
app.apk

Binary file not shown.

View File

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hty.browser"
android:versionCode="4"
android:versionName="4.2">
android:versionName="4.3">
<uses-sdk
android:minSdkVersion="16"

View File

@ -9,7 +9,7 @@ p { text-indent:2em; }
</style>
</head>
<body>
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.2</h2>
<h2 align=center><img src=logo.png><br>海天鹰浏览器 V4.3</h2>
<p>内置扩展的浏览器。</p>
<p>扩展:链接关键字过滤,链接关键字高亮,图片自定义过滤,视频独立播放。</p>
<p>作者:黄颖</p>
@ -22,6 +22,7 @@ p { text-indent:2em; }
<p><a href="https://blog.csdn.net/lowprofile_coding/article/details/77852131" target="_blank">自动安装apk包</a></p>
<p><a href="https://stackoverflow.com/questions/3462582/display-the-android-webviews-favicon" target="_blank">获取网页图标</a></p>
<h3>更新日志:</h3>
<h3>V4.3 (2019-04-11)</h3><ol><li>收藏夹删除收藏时记住位置。</li></ol>
<h3>V4.2 (2019-03-29)</h3><ol><li>下载弹出确认窗口,避免自动下载。</li></ol>
<h3>V4.1 (2019-03-05)</h3><ol><li>链接的 target=_blank 在新窗口中打开。</li><li>淘宝协议自动跳转淘宝APP。</li></ol>
<h3>V4.0 (2019-03-02)</h3><ol><li>实现多窗口。</li></ol>
@ -61,4 +62,4 @@ p { text-indent:2em; }
<h3>V1.1 (2016-01-22)</h3><ol><li>增加支持网页input.file转安卓文件选择器。</li><li>点击加载按钮隐藏输入法。</li><li>增加支持使用内部浏览器下载文件。</li></ol>
<h3>V1.0 (2016-01-21)</h3><ol><li>实现基本的浏览器界面。</li><li>实现第一个扩展[链接转图片]。</li><li>网页JS.alert转安卓Toast。</li></ol>
</body>
</html>
</html>

View File

@ -13,6 +13,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuItem;
@ -40,20 +41,43 @@ public class FavoriteActivity extends Activity {
EditText editText;
InputMethodManager IMM;
ImageButton imageButton_clear;
int position=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_favorite);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
editText = (EditText) findViewById(R.id.editText);
editText.addTextChangedListener(new EditChangedListener());
listView = (ListView) findViewById(R.id.listView1);
IMM = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imageButton_clear = (ImageButton) findViewById(R.id.imageButton_clear);
imageButton_clear.setOnClickListener(new ButtonListener());
imageButton_clear.setVisibility(View.GONE);
editText = (EditText) findViewById(R.id.editText);
editText.addTextChangedListener(new EditChangedListener());
listView = (ListView) findViewById(R.id.listView1);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
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);
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
finish();
}
});
listView.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
@Override
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.setHeaderTitle(title);
menu.add(0, 0, 0, "复制链接");
menu.add(0, 1, 1, "删除");
menu.add(0, 2, 2, "修改");
}
});
search(editText.getText().toString());
IMM = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
}
class ButtonListener implements View.OnClickListener {
@ -78,6 +102,7 @@ public class FavoriteActivity extends Activity {
Toast.makeText(getApplicationContext(), "链接已复制", Toast.LENGTH_SHORT).show();
break;
case 1:
position = listView.getFirstVisiblePosition();
int id = Integer.parseInt(((TextView) menuInfo.targetView.findViewById(R.id.id)).getText().toString());
DBHelper helper = new DBHelper(getApplicationContext());
helper.del(id);
@ -182,7 +207,7 @@ public class FavoriteActivity extends Activity {
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){
//Log.e("L192", view.toString() + columnIndex);
//Log.e(Thread.currentThread().getStackTrace()[2] + "", view.toString() + columnIndex);
if (view.getId() == R.id.imageView_favicon) {
String website = cursor.getString(columnIndex);
if (website.startsWith("https://")) {
@ -200,45 +225,19 @@ public class FavoriteActivity extends Activity {
}
});
listView.setAdapter(adapter);
listView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
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);
IMM.hideSoftInputFromWindow(editText.getWindowToken(), 0);
finish();
}
});
listView.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
@Override
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.setHeaderTitle(title);
menu.add(0, 0, 0, "复制链接");
menu.add(0, 1, 1, "删除");
menu.add(0, 2, 2, "修改");
}
});
Log.e(Thread.currentThread().getStackTrace()[2] + "", position + "");
listView.setSelection(position);
}
class EditChangedListener implements TextWatcher {
@Override
public void beforeTextChanged(CharSequence s, int start, int count,int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if(s.toString().equals("")){

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
@ -86,7 +87,9 @@
android:layout_height="match_parent"
android:layout_row="3"
android:layout_column="1"
android:layout_margin="5dp"/>
android:layout_marginLeft="15dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"/>
</GridLayout>
</LinearLayout>

View File

@ -1 +1 @@
4.2
4.3