Skip to content

Commit

Permalink
Attempt to fix slow/not loading app list
Browse files Browse the repository at this point in the history
  • Loading branch information
M66B committed Jul 2, 2017
1 parent 866d521 commit b4f15e1
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 29 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/eu/faircode/netguard/ActivityDns.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected void onPostExecute(Object result) {
ServiceSinkhole.reload("DNS cleanup", ActivityDns.this);
updateAdapter();
}
}.execute();
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

private void clear() {
Expand All @@ -112,7 +112,7 @@ protected void onPostExecute(Object result) {
ServiceSinkhole.reload("DNS clear", ActivityDns.this);
updateAdapter();
}
}.execute();
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

private void updateAdapter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected void onPostExecute(List<Rule> rules) {
spRuid.setVisibility(View.VISIBLE);
}
};
task.execute();
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

dialog = new AlertDialog.Builder(this)
.setView(view)
Expand Down Expand Up @@ -223,7 +223,7 @@ protected void onPostExecute(Throwable ex) {
} else
Toast.makeText(ActivityForwarding.this, ex.toString(), Toast.LENGTH_LONG).show();
}
}.execute();
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (Throwable ex) {
Toast.makeText(ActivityForwarding.this, ex.toString(), Toast.LENGTH_LONG).show();
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/eu/faircode/netguard/ActivityLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ protected void onPostExecute(Object result) {
if (running)
updateAdapter();
}
}.execute();
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
return true;

case R.id.menu_log_support:
Expand Down Expand Up @@ -620,6 +620,6 @@ protected void onPostExecute(Throwable ex) {
else
Toast.makeText(ActivityLog.this, ex.toString(), Toast.LENGTH_LONG).show();
}
}.execute();
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
}
14 changes: 1 addition & 13 deletions app/src/main/java/eu/faircode/netguard/ActivityMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,6 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences
public static final String EXTRA_METERED = "Metered";
public static final String EXTRA_SIZE = "Size";

private static ExecutorService mExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(),
new PriorityThreadFactory());

private static class PriorityThreadFactory implements ThreadFactory {
@Override
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setPriority(Thread.MAX_PRIORITY);
return t;
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
Log.i(TAG, "Create version=" + Util.getSelfVersionName(this) + "/" + Util.getSelfVersionCode(this));
Expand Down Expand Up @@ -1063,7 +1051,7 @@ protected void onPostExecute(List<Rule> result) {
}
}
}
}.execute(mExecutor);
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

private void updateSearch(String search) {
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/eu/faircode/netguard/ActivitySettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ protected void onPostExecute(Throwable ex) {
else
Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
}
}.execute();
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
return false;
Expand Down Expand Up @@ -376,7 +376,7 @@ public void onException(Throwable ex) {
if (running)
Toast.makeText(ActivitySettings.this, ex.getMessage(), Toast.LENGTH_LONG).show();
}
}).execute();
}).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (MalformedURLException ex) {
Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
}
Expand Down Expand Up @@ -1015,7 +1015,7 @@ protected void onPostExecute(Throwable ex) {
Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
}
}
}.execute();
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

private void handleHosts(final Intent data) {
Expand Down Expand Up @@ -1082,7 +1082,7 @@ protected void onPostExecute(Throwable ex) {
Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
}
}
}.execute();
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

private void handleImport(final Intent data) {
Expand Down Expand Up @@ -1124,7 +1124,7 @@ protected void onPostExecute(Throwable ex) {
Toast.makeText(ActivitySettings.this, ex.toString(), Toast.LENGTH_LONG).show();
}
}
}.execute();
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

private void xmlExport(OutputStream out) throws IOException {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/eu/faircode/netguard/AdapterAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ protected void onPostExecute(String addr) {
" >" + addr + (dport > 0 ? "/" + dport : ""));
ViewCompat.setHasTransientState(tvDest, false);
}
}.execute(daddr);
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, daddr);

if (allowed < 0)
tvDest.setTextColor(colorText);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/eu/faircode/netguard/AdapterLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ protected void onPostExecute(String name) {
tvDaddr.setText(">" + name);
ViewCompat.setHasTransientState(tvDaddr, false);
}
}.execute(daddr);
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, daddr);
} else
tvDaddr.setText(dname);
else
Expand Down Expand Up @@ -299,7 +299,7 @@ protected void onPostExecute(String organization) {
}
ViewCompat.setHasTransientState(tvOrganization, false);
}
}.execute(daddr);
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, daddr);
}

// Show extra data
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/eu/faircode/netguard/AdapterRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ protected void onPostExecute(Long hosts) {
rule.hosts = hosts;
notifyDataSetChanged();
}
}.execute();
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

return result;
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/eu/faircode/netguard/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ protected void onPostExecute(Intent sendEmail) {
}
}
};
task.execute();
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

private static StringBuilder getTrafficLog(Context context) {
Expand Down

0 comments on commit b4f15e1

Please sign in to comment.