Unexpected error handling

This commit is contained in:
M66B
2018-09-15 05:49:54 +00:00
parent d9384a8dfe
commit 1cc3d79ce9
15 changed files with 44 additions and 43 deletions

View File

@@ -52,6 +52,8 @@ import javax.mail.Address;
import javax.mail.FolderClosedException;
import javax.mail.internet.InternetAddress;
import androidx.appcompat.app.AlertDialog;
import static android.os.Process.THREAD_PRIORITY_BACKGROUND;
public class Helper {
@@ -122,6 +124,14 @@ public class Helper {
return sb.toString();
}
static void unexpectedError(Context context, Throwable ex) {
new AlertDialog.Builder(context)
.setTitle(R.string.title_unexpected_error)
.setMessage(ex.toString())
.setPositiveButton(android.R.string.cancel, null)
.show();
}
static String humanReadableByteCount(long bytes, boolean si) {
int unit = si ? 1000 : 1024;
if (bytes < unit) return bytes + " B";