Skip to content

Commit

Permalink
修复了一些可能导致奔溃的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaojieonly committed Nov 22, 2024
1 parent d451fc6 commit eb39135
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/hippo/app/EditTextDialogBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class EditTextDialogBuilder @SuppressLint("InflateParams") constructor(
return mDialog!!
}

override fun onEditorAction(v: TextView, actionId: Int, event: KeyEvent): Boolean {
if (mDialog != null) {
override fun onEditorAction(v: TextView, actionId: Int, event: KeyEvent?): Boolean {
if (event != null && mDialog != null) {
val button = mDialog!!.getButton(DialogInterface.BUTTON_POSITIVE)
button?.performClick()
return true
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/hippo/drawable/PreciselyClipDrawable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ class PreciselyClipDrawable(
override fun draw(canvas: Canvas) {
if (mClip) {
if (!mScale.isEmpty) {
val rect = bounds
canvas.clipRect(rect)
val saveCount = canvas.save()
canvas.clipRect(bounds)
super.draw(canvas)
canvas.restoreToCount(saveCount)
}
} else {
super.draw(canvas)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ class DownloadService : Service(), DownloadManager.DownloadListener {
}
}

override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
if (intent == null) {
// Handle the case where the intent is null
return START_STICKY
}
handleIntent(intent)
return START_STICKY
}
Expand Down
43 changes: 28 additions & 15 deletions app/src/main/java/com/hippo/lib/image/Image.kt
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,36 @@ class Image private constructor(

fun texImage(init: Boolean, offsetX: Int, offsetY: Int, width: Int, height: Int) {
check(!hardware) { "Hardware buffer cannot be used in glgallery" }
val bitmap: Bitmap = if (animated) {
updateBitmap()
mBitmap!!
} else {
if (mObtainedDrawable == null) {
return
try {
val bitmap: Bitmap = if (animated) {
updateBitmap()
mBitmap!!
} else {
if (mObtainedDrawable == null) {
return
}
if (mObtainedDrawable is BitmapDrawable){
(mObtainedDrawable as BitmapDrawable).bitmap
}else{
val stickerBitmap = Bitmap.createBitmap(mObtainedDrawable!!.intrinsicWidth, mObtainedDrawable!!.intrinsicHeight, Bitmap.Config.ARGB_8888)
val canvas = Canvas(stickerBitmap)
mObtainedDrawable!!.setBounds(0, 0, stickerBitmap.width, stickerBitmap.height)
mObtainedDrawable!!.draw(canvas)
stickerBitmap
}
}
(mObtainedDrawable as BitmapDrawable).bitmap
nativeTexImage(
bitmap,
init,
offsetX,
offsetY,
width,
height
)
}catch (e:ClassCastException){
FirebaseCrashlytics.getInstance().recordException(e)
return
}
nativeTexImage(
bitmap,
init,
offsetX,
offsetY,
width,
height
)
}

fun start() {
Expand Down

0 comments on commit eb39135

Please sign in to comment.