-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for Crash on generating AnnotationPreviews on PdfScreen. “width a…
…nd height must be > 0” Issue #206 Upping versionCode to 126
- Loading branch information
1 parent
b45d6e7
commit 86f86b4
Showing
6 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...rg/zotero/android/database/requests/FixSquareAnnotationsWithZeroWidthOrHeightDbRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.zotero.android.database.requests | ||
|
||
import io.realm.Realm | ||
import io.realm.kotlin.where | ||
import org.zotero.android.database.DbRequest | ||
import org.zotero.android.database.objects.AnnotationType | ||
import org.zotero.android.database.objects.ItemTypes | ||
import org.zotero.android.database.objects.RItem | ||
|
||
class FixSquareAnnotationsWithZeroWidthOrHeightDbRequest : DbRequest { | ||
override val needsWrite: Boolean | ||
get() = true | ||
|
||
override fun process(database: Realm) { | ||
val targetTypes = listOf(AnnotationType.image.name) | ||
val results = database.where<RItem>() | ||
.item(type = ItemTypes.annotation) | ||
.deleted(false) | ||
.`in`("annotationType", targetTypes.toTypedArray()) | ||
.findAll() | ||
|
||
for (rItem in results) { | ||
val rect = rItem.rects.getOrNull(0) ?: continue | ||
val libraryId = rItem.libraryId ?: continue | ||
val width = rect.maxX - rect.minX | ||
val height = rect.maxY - rect.minY | ||
if (width == 0.0 || height == 0.0) { | ||
MarkObjectsAsDeletedDbRequest( | ||
clazz = RItem::class, | ||
keys = listOf(rItem.key), | ||
libraryId = libraryId | ||
).process(database) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters