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
fun renderPage(page: Int, ready: ((bitmap: Bitmap?, currentPage: Int) -> Unit)? = null) { | |
if (page >= getPDFPagePage()) return | |
buildBitmap(page) { | |
launch { | |
synchronized(this@PdfCore){ | |
ready?.invoke(it, page) } | |
} | |
} | |
} |
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
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | |
class PdfCore(private val context: Context, pdfFile: File) : CoroutineScope by PdfScope() { | |
. | |
. | |
fun renderPage(page: Int, ready: ((bitmap: Bitmap?, currentPage: Int) -> Unit)? = null) { | |
if (page >= getPDFPagePage()) return | |
buildBitmap(page) { | |
launch { |
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
class PdfScope : CoroutineScope, LifecycleObserver { | |
private val job = SupervisorJob() | |
override val coroutineContext: CoroutineContext | |
get() = job + Dispatchers.Main | |
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) | |
fun destory() = coroutineContext.cancel() | |
} |
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
package com.themovies.presentation.ui.movies | |
import androidx.annotation.StringRes | |
import androidx.lifecycle.LiveData | |
import androidx.lifecycle.MutableLiveData | |
import com.themovies.domain.entitiy.DomainEntityMovie | |
import com.themovies.domain.usecase.MovieUseCase | |
import com.themovies.presentation.BaseViewModel | |
import com.themovies.presentation.R |
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
package com.themovies.domain.usecase | |
import com.themovies.domain.MovieRepository | |
import com.themovies.domain.SingleUseCase | |
import com.themovies.domain.entitiy.DomainEntityMovie | |
import io.reactivex.Single | |
import javax.inject.Inject | |
class MovieUseCase @Inject constructor( |
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
package com.themovies.data | |
import com.themovies.common.networkThreadWithMainThread | |
import com.themovies.data.mapper.MoviesMapper | |
import com.themovies.domain.MovieRepository | |
import com.themovies.domain.entitiy.DomainEntityMovie | |
import io.reactivex.Single | |
import javax.inject.Inject | |
class MovieRepositoryImpl @Inject constructor( |