|
@@ -2,9 +2,13 @@ package me.yoqi.android.appmanager;
|
|
|
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
+import android.text.Editable;
|
|
|
|
+import android.text.TextWatcher;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
|
+import android.widget.EditText;
|
|
import android.widget.ListView;
|
|
import android.widget.ListView;
|
|
import android.widget.RadioButton;
|
|
import android.widget.RadioButton;
|
|
|
|
+import android.widget.RadioGroup;
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
import androidx.appcompat.app.AppCompatActivity;
|
|
@@ -25,11 +29,11 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
RadioButton allApp, dsfApp;
|
|
RadioButton allApp, dsfApp;
|
|
ListView listView;
|
|
ListView listView;
|
|
TextView tvLoad;
|
|
TextView tvLoad;
|
|
-
|
|
+ EditText edtSearch;
|
|
AppInfoAdapter adapter;
|
|
AppInfoAdapter adapter;
|
|
- List<AppInfo> mdatas = new ArrayList<>();
|
|
+ List<AppInfo> mdatas = new ArrayList<>();
|
|
- List<AppInfo> appInfos = new ArrayList<>();
|
|
+ List<AppInfo> appInfos = new ArrayList<>();
|
|
- List<AppInfo> dsfappInfos = new ArrayList<>();
|
|
+ List<AppInfo> dsfappInfos = new ArrayList<>();
|
|
Context mContext;
|
|
Context mContext;
|
|
SimplexToast simplexToast;
|
|
SimplexToast simplexToast;
|
|
SPUtils spUtils;
|
|
SPUtils spUtils;
|
|
@@ -48,9 +52,27 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
dsfApp = findViewById(R.id.dsfApp);
|
|
dsfApp = findViewById(R.id.dsfApp);
|
|
tvLoad = findViewById(R.id.tvLoad);
|
|
tvLoad = findViewById(R.id.tvLoad);
|
|
listView = findViewById(R.id.listView);
|
|
listView = findViewById(R.id.listView);
|
|
|
|
+ edtSearch = findViewById(R.id.edt_search);
|
|
|
|
+ edtSearch.addTextChangedListener(new 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) {
|
|
|
|
+ String searchWord = edtSearch.getText().toString().trim();
|
|
|
|
+ searchApp(searchWord);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void afterTextChanged(Editable s) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ });
|
|
allApp.setOnClickListener(this);
|
|
allApp.setOnClickListener(this);
|
|
dsfApp.setOnClickListener(this);
|
|
dsfApp.setOnClickListener(this);
|
|
- simplexToast = new SimplexToast(mContext);
|
|
+ simplexToast = SimplexToast.getInstance(mContext);
|
|
spUtils = new SPUtils(mContext);
|
|
spUtils = new SPUtils(mContext);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -75,7 +97,29 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}).start();
|
|
}).start();
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+
|
|
|
|
+ * 通过关键词搜索app
|
|
|
|
+ *
|
|
|
|
+ * @param keyword
|
|
|
|
+ */
|
|
|
|
+ private void searchApp(String keyword) {
|
|
|
|
+ mdatas.clear();
|
|
|
|
+ if (allApp.isChecked()) {
|
|
|
|
+ for (int i = 0; i < appInfos.size(); i++) {
|
|
|
|
+ if (appInfos.get(i).getAppName().toLowerCase().contains(keyword) || appInfos.get(i).getPackageName().toLowerCase().contains(keyword)) {
|
|
|
|
+ mdatas.add(appInfos.get(i));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (dsfApp.isChecked()) {
|
|
|
|
+ for (int i = 0; i < dsfappInfos.size(); i++) {
|
|
|
|
+ if (dsfappInfos.get(i).getAppName().toLowerCase().contains(keyword) || dsfappInfos.get(i).getPackageName().toLowerCase().contains(keyword)) {
|
|
|
|
+ mdatas.add(dsfappInfos.get(i));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ adapter.notifyDataSetChanged();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|