Don't call blocking functions from ui thread.
This commit is contained in:
parent
387202d92d
commit
3ffecaa310
2 changed files with 30 additions and 10 deletions
|
@ -42,9 +42,14 @@ public class CertificateAdapter extends ArrayAdapter<Certificate> {
|
|||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mCertificateManager.deleteCertificate(cert);
|
||||
mMovedCertificatesStorage.delete(cert);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
colorRes = R.color.background_system_certificate;
|
||||
}
|
||||
|
@ -53,9 +58,14 @@ public class CertificateAdapter extends ArrayAdapter<Certificate> {
|
|||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mCertificateManager.moveCertificateToSystem(cert);
|
||||
mMovedCertificatesStorage.insert(cert);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
colorRes = R.color.background_user_certificate;
|
||||
}
|
||||
|
|
|
@ -31,8 +31,13 @@ public class MainActivity extends ListActivity {
|
|||
mCertificateAdapter =
|
||||
new CertificateAdapter(this, mCertificateManager, mMovedCertificatesStorage);
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mCertificateAdapter.addAll(mCertificateManager.getCertificates(false));
|
||||
mCertificateAdapter.addAll(mMovedCertificatesStorage.list());
|
||||
}
|
||||
}).start();
|
||||
mListView.setAdapter(mCertificateAdapter);
|
||||
}
|
||||
|
||||
|
@ -50,11 +55,16 @@ public class MainActivity extends ListActivity {
|
|||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Certificate c : list) {
|
||||
c = mCertificateManager.moveCertificateToSystem(c);
|
||||
mMovedCertificatesStorage.insert(c);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
|
|
Reference in a new issue