mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-24 00:11:50 +01:00
Fixing conlficts and build
Fixed searching in Anilist
This commit is contained in:
parent
6ab222bdc8
commit
2e4af629c6
@ -88,7 +88,7 @@ class AnilistApi(val client: OkHttpClient, interceptor: AnilistInterceptor) {
|
||||
val netResponse = authClient.newCall(request).execute()
|
||||
val response = responseToJson(netResponse)
|
||||
|
||||
val media = response["data"]!!.obj["Page"].obj["mediaList"].array
|
||||
val media = response["data"]!!.obj["Page"].obj["media"].array
|
||||
val entries = media.map { jsonToALManga(it.obj) }
|
||||
entries.map { it.toTrack() }
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package eu.kanade.tachiyomi.data.updater
|
||||
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.data.updater.github.GithubUpdateChecker
|
||||
import rx.Observable
|
||||
|
||||
abstract class UpdateChecker {
|
||||
|
||||
@ -11,8 +9,8 @@ abstract class UpdateChecker {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns observable containing release information
|
||||
* Returns suspended result containing release information
|
||||
*/
|
||||
abstract fun checkForUpdate(): Observable<UpdateResult>
|
||||
abstract suspend fun checkForUpdate(): UpdateResult
|
||||
|
||||
}
|
||||
|
@ -9,15 +9,18 @@ import com.evernote.android.job.JobManager
|
||||
import com.evernote.android.job.JobRequest
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import java.util.concurrent.TimeUnit
|
||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class UpdaterJob : Job() {
|
||||
|
||||
override fun onRunJob(params: Params): Result {
|
||||
return UpdateChecker.getUpdateChecker()
|
||||
.checkForUpdate()
|
||||
.map { result ->
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
val result = try { UpdateChecker.getUpdateChecker().checkForUpdate() }
|
||||
catch (e: Exception) { return@launch }
|
||||
if (result is UpdateResult.NewUpdate<*>) {
|
||||
val url = result.release.downloadLink
|
||||
|
||||
@ -31,17 +34,21 @@ class UpdaterJob : Job() {
|
||||
setSmallIcon(android.R.drawable.stat_sys_download_done)
|
||||
color = ContextCompat.getColor(context, R.color.colorAccent)
|
||||
// Download action
|
||||
addAction(android.R.drawable.stat_sys_download_done,
|
||||
addAction(
|
||||
android.R.drawable.stat_sys_download_done,
|
||||
context.getString(R.string.action_download),
|
||||
PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT))
|
||||
PendingIntent.getService(
|
||||
context,
|
||||
0,
|
||||
intent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
Result.SUCCESS
|
||||
}
|
||||
.onErrorReturn { Result.FAILURE }
|
||||
// Sadly, the task needs to be synchronous.
|
||||
.toBlocking()
|
||||
.single()
|
||||
return Result.SUCCESS
|
||||
}
|
||||
|
||||
fun NotificationCompat.Builder.update(block: NotificationCompat.Builder.() -> Unit) {
|
||||
|
@ -3,23 +3,21 @@ package eu.kanade.tachiyomi.data.updater.github
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
import eu.kanade.tachiyomi.data.updater.UpdateChecker
|
||||
import eu.kanade.tachiyomi.data.updater.UpdateResult
|
||||
import rx.Observable
|
||||
|
||||
class GithubUpdateChecker : UpdateChecker() {
|
||||
class GithubUpdateChecker : UpdateChecker() {
|
||||
|
||||
private val service: GithubService = GithubService.create()
|
||||
|
||||
override fun checkForUpdate(): Observable<UpdateResult> {
|
||||
return service.getLatestVersion().map { release ->
|
||||
override suspend fun checkForUpdate(): UpdateResult {
|
||||
val release = service.getLatestVersion()
|
||||
val newVersion = release.version.replace("[^\\d.]".toRegex(), "")
|
||||
|
||||
// Check if latest version is different from current version
|
||||
if (newVersion != BuildConfig.VERSION_NAME) {
|
||||
return if (newVersion != BuildConfig.VERSION_NAME) {
|
||||
GithubUpdateResult.NewUpdate(release)
|
||||
} else {
|
||||
GithubUpdateResult.NoNewUpdate()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,11 +54,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
|
||||
DownloadQueue.DownloadListener,
|
||||
LibraryServiceListener {
|
||||
|
||||
<<<<<<< Updated upstream
|
||||
private var scope = CoroutineScope(Job() + Dispatchers.Default)
|
||||
=======
|
||||
var scope = CoroutineScope(Job() + Dispatchers.Default)
|
||||
>>>>>>> Stashed changes
|
||||
|
||||
var isLockedFromSearch = false
|
||||
var hasRequested = false
|
||||
@ -715,14 +711,12 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
|
||||
|
||||
fun trackSearch(query: String, service: TrackService) {
|
||||
scope.launch(Dispatchers.IO) {
|
||||
<<<<<<< Updated upstream
|
||||
val results = try {service.search(query) }
|
||||
=======
|
||||
val results = try {service.search(query).toBlocking().single() }
|
||||
>>>>>>> Stashed changes
|
||||
catch (e: Exception) {
|
||||
val results = try {
|
||||
service.search(query)
|
||||
} catch (e: Exception) {
|
||||
withContext(Dispatchers.Main) { controller.trackSearchError(e) }
|
||||
null }
|
||||
null
|
||||
}
|
||||
if (!results.isNullOrEmpty()) {
|
||||
withContext(Dispatchers.Main) { controller.onTrackSearchResults(results) }
|
||||
}
|
||||
@ -734,11 +728,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
|
||||
item.manga_id = manga.id!!
|
||||
|
||||
scope.launch {
|
||||
<<<<<<< Updated upstream
|
||||
val binding = try { service.bind(item) }
|
||||
=======
|
||||
val binding = try { service.bind(item).toBlocking().single() }
|
||||
>>>>>>> Stashed changes
|
||||
catch (e: Exception) {
|
||||
trackError(e)
|
||||
null
|
||||
@ -758,11 +748,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
|
||||
|
||||
private fun updateRemote(track: Track, service: TrackService) {
|
||||
scope.launch {
|
||||
<<<<<<< Updated upstream
|
||||
val binding = try { service.update(track) }
|
||||
=======
|
||||
val binding = try { service.update(track).toBlocking().single() }
|
||||
>>>>>>> Stashed changes
|
||||
catch (e: Exception) {
|
||||
trackError(e)
|
||||
null
|
||||
|
@ -95,6 +95,7 @@ class TrackingBottomSheet(private val controller: MangaDetailsController) : Bott
|
||||
|
||||
fun onSearchResultsError(error: Throwable) {
|
||||
Timber.e(error)
|
||||
activity.toast(error.message)
|
||||
getSearchDialog()?.onSearchResultsError()
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import android.app.Dialog
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.preference.PreferenceScreen
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import eu.kanade.tachiyomi.BuildConfig
|
||||
@ -16,11 +15,13 @@ import eu.kanade.tachiyomi.data.updater.UpdateResult
|
||||
import eu.kanade.tachiyomi.data.updater.UpdaterService
|
||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||
import eu.kanade.tachiyomi.ui.main.ChangelogDialogController
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.lang.toTimestampString
|
||||
import rx.Subscription
|
||||
import rx.android.schedulers.AndroidSchedulers
|
||||
import rx.schedulers.Schedulers
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.text.DateFormat
|
||||
@ -43,7 +44,7 @@ class SettingsAboutController : SettingsController() {
|
||||
/**
|
||||
* The subscribtion service of the obtained release object
|
||||
*/
|
||||
private var releaseSubscription: Subscription? = null
|
||||
private val scope = CoroutineScope(Job() + Dispatchers.IO)
|
||||
|
||||
private val isUpdaterEnabled = BuildConfig.INCLUDE_UPDATER
|
||||
|
||||
@ -95,12 +96,6 @@ class SettingsAboutController : SettingsController() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
super.onDestroyView(view)
|
||||
releaseSubscription?.unsubscribe()
|
||||
releaseSubscription = null
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks version and shows a user prompt if an update is available.
|
||||
*/
|
||||
@ -108,27 +103,30 @@ class SettingsAboutController : SettingsController() {
|
||||
if (activity == null) return
|
||||
|
||||
activity?.toast(R.string.update_check_look_for_updates)
|
||||
releaseSubscription?.unsubscribe()
|
||||
releaseSubscription = updateChecker.checkForUpdate()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ result ->
|
||||
scope.launch {
|
||||
val result = try {
|
||||
updateChecker.checkForUpdate()
|
||||
} catch (error: Exception) {
|
||||
activity?.toast(error.message)
|
||||
Timber.e(error)
|
||||
}
|
||||
when (result) {
|
||||
is UpdateResult.NewUpdate<*> -> {
|
||||
val body = result.release.info
|
||||
val url = result.release.downloadLink
|
||||
|
||||
// Create confirmation window
|
||||
withContext(Dispatchers.Main) {
|
||||
NewUpdateDialogController(body, url).showDialog(router)
|
||||
}
|
||||
}
|
||||
is UpdateResult.NoNewUpdate -> {
|
||||
withContext(Dispatchers.Main) {
|
||||
activity?.toast(R.string.update_check_no_new_updates)
|
||||
}
|
||||
}
|
||||
}, { error ->
|
||||
activity?.toast(error.message)
|
||||
Timber.e(error)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
|
Loading…
Reference in New Issue
Block a user