mirror of https://github.com/M66B/NetGuard.git
More efficient live update
This commit is contained in:
parent
98aa3c04fb
commit
8cad00d2b1
|
@ -65,8 +65,7 @@ public class ActivityLog extends AppCompatActivity {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
adapter = new LogAdapter(ActivityLog.this, dh.getLog());
|
adapter.changeCursor(dh.getLog());
|
||||||
lvLog.setAdapter(adapter);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -81,10 +80,9 @@ public class ActivityLog extends AppCompatActivity {
|
||||||
getSupportActionBar().setTitle(R.string.menu_log);
|
getSupportActionBar().setTitle(R.string.menu_log);
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
|
|
||||||
dh = new DatabaseHelper(this);
|
|
||||||
|
|
||||||
lvLog = (ListView) findViewById(R.id.lvLog);
|
lvLog = (ListView) findViewById(R.id.lvLog);
|
||||||
|
|
||||||
|
dh = new DatabaseHelper(this);
|
||||||
adapter = new LogAdapter(this, dh.getLog());
|
adapter = new LogAdapter(this, dh.getLog());
|
||||||
lvLog.setAdapter(adapter);
|
lvLog.setAdapter(adapter);
|
||||||
|
|
||||||
|
@ -154,8 +152,7 @@ public class ActivityLog extends AppCompatActivity {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (live) {
|
if (live) {
|
||||||
DatabaseHelper.addLogChangedListener(listener);
|
DatabaseHelper.addLogChangedListener(listener);
|
||||||
adapter = new LogAdapter(ActivityLog.this, dh.getLog());
|
adapter.changeCursor(dh.getLog());
|
||||||
lvLog.setAdapter(adapter);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,9 +207,8 @@ public class ActivityLog extends AppCompatActivity {
|
||||||
item.setChecked(!item.isChecked());
|
item.setChecked(!item.isChecked());
|
||||||
live = item.isChecked();
|
live = item.isChecked();
|
||||||
if (live) {
|
if (live) {
|
||||||
adapter = new LogAdapter(this, dh.getLog());
|
|
||||||
lvLog.setAdapter(adapter);
|
|
||||||
DatabaseHelper.addLogChangedListener(listener);
|
DatabaseHelper.addLogChangedListener(listener);
|
||||||
|
adapter.changeCursor(dh.getLog());
|
||||||
} else
|
} else
|
||||||
DatabaseHelper.removeLocationChangedListener(listener);
|
DatabaseHelper.removeLocationChangedListener(listener);
|
||||||
return true;
|
return true;
|
||||||
|
@ -220,8 +216,7 @@ public class ActivityLog extends AppCompatActivity {
|
||||||
case R.id.menu_log_clear:
|
case R.id.menu_log_clear:
|
||||||
dh.clear();
|
dh.clear();
|
||||||
if (!live) {
|
if (!live) {
|
||||||
adapter = new LogAdapter(this, dh.getLog());
|
adapter.changeCursor(dh.getLog());
|
||||||
lvLog.setAdapter(adapter);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue