mirror of
https://github.com/M66B/NetGuard.git
synced 2024-12-26 09:48:46 +00:00
Refresh application list when needed only
This commit is contained in:
parent
fbd758140b
commit
ee692d9e27
2 changed files with 20 additions and 12 deletions
|
@ -80,6 +80,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
private static final int MIN_SDK = Build.VERSION_CODES.ICE_CREAM_SANDWICH;
|
||||
|
||||
public static final String ACTION_RULES_CHANGED = "eu.faircode.netguard.ACTION_RULES_CHANGED";
|
||||
public static final String EXTRA_REFRESH = "Refresh";
|
||||
public static final String EXTRA_SEARCH = "Search";
|
||||
public static final String EXTRA_APPROVE = "Approve";
|
||||
public static final String EXTRA_LOGCAT = "Logcat";
|
||||
|
@ -296,7 +297,10 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
super.onNewIntent(intent);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= MIN_SDK) {
|
||||
updateApplicationList(intent.getStringExtra(EXTRA_SEARCH));
|
||||
if (intent.hasExtra(EXTRA_REFRESH))
|
||||
updateApplicationList(intent.getStringExtra(EXTRA_SEARCH));
|
||||
else
|
||||
updateSearch(intent.getStringExtra(EXTRA_SEARCH));
|
||||
checkExtras(intent);
|
||||
}
|
||||
}
|
||||
|
@ -511,17 +515,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
if (running) {
|
||||
if (adapter != null) {
|
||||
adapter.set(result);
|
||||
|
||||
if (menuSearch != null) {
|
||||
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuSearch);
|
||||
if (search == null) {
|
||||
if (menuSearch.isActionViewExpanded())
|
||||
adapter.getFilter().filter(searchView.getQuery().toString());
|
||||
} else {
|
||||
MenuItemCompat.expandActionView(menuSearch);
|
||||
searchView.setQuery(search, true);
|
||||
}
|
||||
}
|
||||
updateSearch(search);
|
||||
}
|
||||
|
||||
if (swipeRefresh != null) {
|
||||
|
@ -533,6 +527,19 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
|
|||
}.execute();
|
||||
}
|
||||
|
||||
private void updateSearch(String search) {
|
||||
if (menuSearch != null) {
|
||||
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuSearch);
|
||||
if (search == null) {
|
||||
if (menuSearch.isActionViewExpanded())
|
||||
adapter.getFilter().filter(searchView.getQuery().toString());
|
||||
} else {
|
||||
MenuItemCompat.expandActionView(menuSearch);
|
||||
searchView.setQuery(search, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
if (Build.VERSION.SDK_INT < MIN_SDK)
|
||||
|
|
|
@ -116,6 +116,7 @@ public class Receiver extends BroadcastReceiver {
|
|||
|
||||
// Build notification
|
||||
Intent main = new Intent(context, ActivityMain.class);
|
||||
main.putExtra(ActivityMain.EXTRA_REFRESH, true);
|
||||
main.putExtra(ActivityMain.EXTRA_SEARCH, Integer.toString(uid));
|
||||
PendingIntent pi = PendingIntent.getActivity(context, uid, main, PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
|
|
Loading…
Reference in a new issue