Skip to content

Commit

Permalink
优化 代码结构
Browse files Browse the repository at this point in the history
  • Loading branch information
Fan095 committed Mar 31, 2024
1 parent 11eb4aa commit 657461e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,8 @@ public void onCreate(@Nullable Bundle bundle) {
mMessageTv.setText("作用域: " + "\n\"" + pkg + "\"\n已进入安全模式,点击确定解除,点击取消稍后处理。");
mCrashRecordTv = view.findViewById(R.id.tv_record);
mCrashRecordTv.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);// 下划线并加清晰
mCrashRecordTv.getPaint().setAntiAlias(true);// 抗锯齿
mCrashRecordTv.setOnClickListener(v -> {
new AlertDialog.Builder(v.getContext())
.setCancelable(false)
.setTitle("异常记录")
.setMessage("异常信息: \n" + longMsg + "\n堆栈跟踪: \n" + stackTrace)
.setHapticFeedbackEnabled(true)
.setPositiveButton(android.R.string.ok, (dialog, which) -> dialog.dismiss())
.show();
// Toast.makeText(this, "查看异常记录", Toast.LENGTH_SHORT).show();
});
mCrashRecordTv.getPaint().setAntiAlias(true);
mCrashRecordTv.setOnClickListener(v -> DialogHelper.showCrashMsgDialog(this, longMsg, stackTrace));
DialogHelper.showCrashReportDialog(this, view);
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/sevtinge/hyperceiler/utils/DialogHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,14 @@ public static void showCrashReportDialog(Activity activity, View view) {
.setNegativeButton(android.R.string.cancel, (dialog, which) -> activity.finish())
.show();
}

public static void showCrashMsgDialog(Context context, String longMsg, String stackTrace) {
new AlertDialog.Builder(context)
.setCancelable(false)
.setTitle("异常记录")
.setMessage("异常信息: \n" + longMsg + "\n堆栈跟踪: \n" + stackTrace)
.setHapticFeedbackEnabled(true)
.setPositiveButton(android.R.string.ok, (dialog, which) -> dialog.dismiss())
.show();
}
}

0 comments on commit 657461e

Please sign in to comment.