Skip to content

Commit

Permalink
Fix bugs with the partial page checker and tablet (#1276)
Browse files Browse the repository at this point in the history
Al7amdulillah, got really lucky here! The parital page checker had a
number of bugs - namely it used the width where it should have used the
tablet width. Consequently, it marks a massive number of pages as "to be
deleted." Due to another bug though (looping over only the pages to
delete instead of all pages to delete), al7amdulillah the pages didn't
actually get deleted in this case. This fixes these bugs.
  • Loading branch information
ahmedre authored Feb 9, 2020
1 parent fe81e95 commit 08c941b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public QuranScreenInfo(@NonNull Context appContext,

height = point.y;
altDimension = point.x;
maxWidth = (point.x > point.y) ? point.x : point.y;
maxWidth = Math.max(point.x, point.y);
orientation = appContext.getResources().getConfiguration().orientation;

this.context = appContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PartialPageCheckingWorker(private val context: Context,
val width = quranScreenInfo.widthParam
val pagesDirectory = quranFileUtils.getQuranImagesDirectory(context, width)
val tabletWidth = quranScreenInfo.tabletWidthParam
val tabletPagesDirectory = quranFileUtils.getQuranImagesDirectory(context, width)
val tabletPagesDirectory = quranFileUtils.getQuranImagesDirectory(context, tabletWidth)

// compute the partial page sets
val partialPages =
Expand All @@ -57,7 +57,7 @@ class PartialPageCheckingWorker(private val context: Context,
quranPartialPageChecker.checkPages(tabletPagesDirectory, numberOfPages, tabletWidth)
.map { PartialPage(tabletWidth, it) }
}
Timber.d("Found %d partial images for tablet width %s", tabletPartialPages.size, width)
Timber.d("Found %d partial images for tablet width %s", tabletPartialPages.size, tabletWidth)

val allPartialPages = partialPages + tabletPartialPages
if (allPartialPages.size > PARTIAL_PAGE_LIMIT) {
Expand All @@ -77,7 +77,7 @@ class PartialPageCheckingWorker(private val context: Context,

val deletionSucceeded = try {
// iterate through each one and delete the partial pages
partialPages.firstOrNull {
allPartialPages.firstOrNull {
val path = if (it.width == width) pagesDirectory else tabletPagesDirectory
!deletePage(path, it.page)
} == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ open class DefaultPageSizeCalculator(displaySize: DisplaySize) : PageSizeCalcula
}

override fun setOverrideParameter(parameter: String) {
if (parameter.isNotBlank()) {
overrideParam = parameter
overrideParam = if (parameter.isNotBlank()) {
parameter
} else {
overrideParam = null
null
}
}
}

0 comments on commit 08c941b

Please sign in to comment.