Fixed webtoon page

This commit is contained in:
Bram van de Kerkhof 2016-10-13 15:16:10 +02:00
parent 414b8c9f21
commit 8ff8ab4f27
5 changed files with 37 additions and 41 deletions

View File

@ -64,7 +64,7 @@ class ImageNotifier(private val context: Context) {
}
setContentTitle(context.getString(R.string.picture_saved))
setSmallIcon(R.drawable.ic_insert_photo_black_24dp)
Glide.with(context).load(file).asBitmap().into(object : SimpleTarget<Bitmap>(100, 100) {
Glide.with(context).load(file).asBitmap().into(object : SimpleTarget<Bitmap>(96, 96) {
/**
* The method that will be called when the resource load has finished.
* @param resource the loaded resource.
@ -74,7 +74,7 @@ class ImageNotifier(private val context: Context) {
context.notificationManager.notify(notificationId, notificationBuilder.build())
}
})
Glide.with(context).load(file).asBitmap().into(object : SimpleTarget<Bitmap>(512, 384) {
Glide.with(context).load(file).asBitmap().into(object : SimpleTarget<Bitmap>(720, 1280) {
/**
* The method that will be called when the resource load has finished.
* @param resource the loaded resource.

View File

@ -228,16 +228,16 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
// Ignore
}
fun onLongPress() {
fun onLongPress(page: Page) {
MaterialDialog.Builder(this).apply {
title = "Choose"
items(R.array.reader_image_options)
.itemsIds(R.array.reader_image_options_values)
itemsCallback { materialDialog, view, i, charSequence ->
when (i) {
0 -> presenter.setCover()
1 -> presenter.shareImage()
2 -> presenter.savePage()
0 -> presenter.setCover(page)
1 -> presenter.shareImage(page)
2 -> presenter.savePage(page)
}
}.show()

View File

@ -547,11 +547,10 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
/**
* Update cover with page file.
*/
internal fun setCover() {
chapter.pages?.get(chapter.last_page_read)?.let {
internal fun setCover(page: Page) {
// Update cover to selected file, show error if something went wrong
try {
if (editCoverWithStream(File(it.imagePath).inputStream(), manga)) {
if (editCoverWithStream(File(page.imagePath).inputStream(), manga)) {
context.toast(R.string.cover_updated)
} else {
throw Exception("Stream copy failed")
@ -561,7 +560,6 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
Timber.e(e.message)
}
}
}
/**
* Called to copy image to cache
@ -578,8 +576,7 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
return false
}
fun shareImage() {
chapter.pages?.get(chapter.last_page_read)?.let { page ->
fun shareImage(page: Page) {
val shareIntent = Intent().apply {
action = Intent.ACTION_SEND
putExtra(Intent.EXTRA_STREAM, Uri.parse(page.imagePath))
@ -589,15 +586,13 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
context.startActivity(Intent.createChooser(shareIntent, context.resources.getText(R.string.action_share))
.apply { flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_MULTIPLE_TASK })
}
}
/**
* Save page to local storage
* @throws IOException
*/
@Throws(IOException::class)
internal fun savePage() {
chapter.pages?.get(chapter.last_page_read)?.let { page ->
internal fun savePage(page: Page) {
// Location of image file.
val inputFile = File(page.imagePath)
@ -626,5 +621,4 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() {
}
}
}
}
}

View File

@ -188,7 +188,7 @@ abstract class PagerReader : BaseReader() {
override fun onLongPress(e: MotionEvent?) {
super.onLongPress(e)
readerActivity.onLongPress()
readerActivity.onLongPress(adapter.pages!![pager.currentItem])
}
})
}

View File

@ -141,9 +141,11 @@ class WebtoonReader : BaseReader() {
return true
}
override fun onLongPress(e: MotionEvent?) {
override fun onLongPress(e: MotionEvent) {
super.onLongPress(e)
readerActivity.onLongPress()
val a = recycler.findChildViewUnder(e.rawX, e.rawY)
val i = recycler.getChildAdapterPosition(a)
readerActivity.onLongPress(adapter.getItem(i))
}
})
}