/** * 当UncaughtException发生时会转入该函数来处理 */ public void UncaughtException(Thread thread, Throwable ex) { if (!handleException(ex) && mDefaultHandler != null) { //如果用户没有处理则让系统默认的异常处理器来处理 mDefaultHandler.UncaughtException(thread, ex); } else { DownloadBookService.cancel(); // 取消任务 LogUtils.i("取消下载任务"); new Thread(() => { Looper.Prepare(); ToastUtils.showSingleToast("哎呀,程序发生异常啦..."); Looper.Loop(); }).Start(); try { Thread.Sleep(3000); } catch (InterruptedException e) { LogUtils.e("CrashHandler.InterruptedException--->" + e.ToString()); } //退出程序 Process.KillProcess(Process.MyPid()); JavaSystem.Exit(1); } }
public void showBookToc(String bookId, List <BookMixAToc.MixToc.Chapters> list) { chaptersList.Clear(); chaptersList.AddRange(list); DownloadBookService.Post(new DownloadQueue(bookId, list, 1, list.Count())); DismissDialog(); }
public void downloadBook(object senderr, EventArgs ee) { gone(rlReadAaSet); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle("缓存多少章?") .SetItems(new String[] { "后面五十章", "后面全部", "全部" }, (sender, e) => { switch (e.Which) { case 0: DownloadBookService.Post(new DownloadQueue(bookId, mChapterList, currentChapter + 1, currentChapter + 50)); break; case 1: DownloadBookService.Post(new DownloadQueue(bookId, mChapterList, currentChapter + 1, mChapterList.Count())); break; case 2: DownloadBookService.Post(new DownloadQueue(bookId, mChapterList, 1, mChapterList.Count())); break; default: break; } }); builder.Show(); }