Skip to content

Commit eb39135

Browse files
committed
修复了一些可能导致奔溃的问题
1 parent d451fc6 commit eb39135

File tree

4 files changed

+38
-20
lines changed

4 files changed

+38
-20
lines changed

app/src/main/java/com/hippo/app/EditTextDialogBuilder.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ class EditTextDialogBuilder @SuppressLint("InflateParams") constructor(
6161
return mDialog!!
6262
}
6363

64-
override fun onEditorAction(v: TextView, actionId: Int, event: KeyEvent): Boolean {
65-
if (mDialog != null) {
64+
override fun onEditorAction(v: TextView, actionId: Int, event: KeyEvent?): Boolean {
65+
if (event != null && mDialog != null) {
6666
val button = mDialog!!.getButton(DialogInterface.BUTTON_POSITIVE)
6767
button?.performClick()
6868
return true

app/src/main/java/com/hippo/drawable/PreciselyClipDrawable.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ class PreciselyClipDrawable(
9292
override fun draw(canvas: Canvas) {
9393
if (mClip) {
9494
if (!mScale.isEmpty) {
95-
val rect = bounds
96-
canvas.clipRect(rect)
95+
val saveCount = canvas.save()
96+
canvas.clipRect(bounds)
9797
super.draw(canvas)
98+
canvas.restoreToCount(saveCount)
9899
}
99100
} else {
100101
super.draw(canvas)

app/src/main/java/com/hippo/ehviewer/download/DownloadService.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ class DownloadService : Service(), DownloadManager.DownloadListener {
9797
}
9898
}
9999

100-
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
100+
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
101+
if (intent == null) {
102+
// Handle the case where the intent is null
103+
return START_STICKY
104+
}
101105
handleIntent(intent)
102106
return START_STICKY
103107
}

app/src/main/java/com/hippo/lib/image/Image.kt

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,23 +193,36 @@ class Image private constructor(
193193

194194
fun texImage(init: Boolean, offsetX: Int, offsetY: Int, width: Int, height: Int) {
195195
check(!hardware) { "Hardware buffer cannot be used in glgallery" }
196-
val bitmap: Bitmap = if (animated) {
197-
updateBitmap()
198-
mBitmap!!
199-
} else {
200-
if (mObtainedDrawable == null) {
201-
return
196+
try {
197+
val bitmap: Bitmap = if (animated) {
198+
updateBitmap()
199+
mBitmap!!
200+
} else {
201+
if (mObtainedDrawable == null) {
202+
return
203+
}
204+
if (mObtainedDrawable is BitmapDrawable){
205+
(mObtainedDrawable as BitmapDrawable).bitmap
206+
}else{
207+
val stickerBitmap = Bitmap.createBitmap(mObtainedDrawable!!.intrinsicWidth, mObtainedDrawable!!.intrinsicHeight, Bitmap.Config.ARGB_8888)
208+
val canvas = Canvas(stickerBitmap)
209+
mObtainedDrawable!!.setBounds(0, 0, stickerBitmap.width, stickerBitmap.height)
210+
mObtainedDrawable!!.draw(canvas)
211+
stickerBitmap
212+
}
202213
}
203-
(mObtainedDrawable as BitmapDrawable).bitmap
214+
nativeTexImage(
215+
bitmap,
216+
init,
217+
offsetX,
218+
offsetY,
219+
width,
220+
height
221+
)
222+
}catch (e:ClassCastException){
223+
FirebaseCrashlytics.getInstance().recordException(e)
224+
return
204225
}
205-
nativeTexImage(
206-
bitmap,
207-
init,
208-
offsetX,
209-
offsetY,
210-
width,
211-
height
212-
)
213226
}
214227

215228
fun start() {

0 commit comments

Comments
 (0)