Skip to content

Commit

Permalink
添加选择应用
Browse files Browse the repository at this point in the history
  • Loading branch information
YiuChoi committed May 3, 2016
1 parent c305caa commit 05d257d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions app/src/main/java/name/caiyao/fakegps/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,20 @@ public void onTextChanged(CharSequence s, int start, int before, int count) {

@Override
public void afterTextChanged(Editable s) {
if (TextUtils.isEmpty(s)) {
String key = s.toString();
if (TextUtils.isEmpty(key)) {
mAppInfos.clear();
mAppInfos.addAll(mAllAppInfos);
mAppAdapter.notifyDataSetChanged();
return;
}
for (int i = 0; i < mAppInfos.size(); i++) {
AppInfo appInfo = mAppInfos.get(i);
if (!appInfo.getAppName().contains(s) && !appInfo.getPackageName().contains(s)) {
mAppInfos.remove(appInfo);
mAppAdapter.notifyItemRemoved(i);
mAppInfos.clear();
mAppAdapter.notifyDataSetChanged();
for (int i = 0; i < mAllAppInfos.size(); i++) {
AppInfo appInfo = mAllAppInfos.get(i);
if (appInfo.getAppName().contains(key)||appInfo.getPackageName().contains(key)) {
mAppInfos.add(appInfo);
mAppAdapter.notifyItemInserted(mAllAppInfos.size()-1);
}
}
}
Expand Down

0 comments on commit 05d257d

Please sign in to comment.