diff --git a/app/build.gradle b/app/build.gradle
index 0d622f3a3..5b70f7d41 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -102,7 +102,7 @@ dependencies {
compile 'com.github.inorichi:junrar-android:634c1f5'
// Android support library
- final support_library_version = '25.1.1'
+ final support_library_version = '25.2.0'
compile "com.android.support:support-v4:$support_library_version"
compile "com.android.support:appcompat-v7:$support_library_version"
compile "com.android.support:cardview-v7:$support_library_version"
@@ -111,7 +111,7 @@ dependencies {
compile "com.android.support:support-annotations:$support_library_version"
compile "com.android.support:customtabs:$support_library_version"
- compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
+ compile 'com.android.support.constraint:constraint-layout:1.0.0'
compile 'com.android.support:multidex:1.0.1'
@@ -127,7 +127,7 @@ dependencies {
compile 'com.squareup.okio:okio:1.11.0'
// REST
- final retrofit_version = '2.1.0'
+ final retrofit_version = '2.2.0'
compile "com.squareup.retrofit2:retrofit:$retrofit_version"
compile "com.squareup.retrofit2:converter-gson:$retrofit_version"
compile "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
@@ -151,13 +151,13 @@ dependencies {
// Job scheduling
compile 'com.evernote:android-job:1.1.6'
- compile 'com.google.android.gms:play-services-gcm:10.0.1'
+ compile 'com.google.android.gms:play-services-gcm:10.2.0'
// Changelog
compile 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0'
// Database
- compile "com.pushtorefresh.storio:sqlite:1.12.2"
+ compile "com.pushtorefresh.storio:sqlite:1.12.3"
// Model View Presenter
final nucleus_version = '3.0.0'
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3881d5b3d..6a536ee6c 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -98,9 +98,6 @@
android:name=".data.download.DownloadService"
android:exported="false" />
-
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Track.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Track.kt
index ce04b5303..5068f899e 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Track.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Track.kt
@@ -22,8 +22,6 @@ interface Track : Serializable {
var status: Int
- var update: Boolean
-
fun copyPersonalFrom(other: Track) {
last_chapter_read = other.last_chapter_read
score = other.score
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/TrackImpl.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/TrackImpl.kt
index f94c85993..4ae4723aa 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/TrackImpl.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/TrackImpl.kt
@@ -20,8 +20,6 @@ class TrackImpl : Track {
override var status: Int = 0
- override var update: Boolean = false
-
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || javaClass != other.javaClass) return false
diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackUpdateService.kt
deleted file mode 100644
index 06609cfc6..000000000
--- a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackUpdateService.kt
+++ /dev/null
@@ -1,74 +0,0 @@
-package eu.kanade.tachiyomi.data.track
-
-import android.app.Service
-import android.content.Context
-import android.content.Intent
-import android.os.IBinder
-import eu.kanade.tachiyomi.data.database.DatabaseHelper
-import eu.kanade.tachiyomi.data.database.models.Track
-import rx.Observable
-import rx.android.schedulers.AndroidSchedulers
-import rx.schedulers.Schedulers
-import rx.subscriptions.CompositeSubscription
-import uy.kohesive.injekt.injectLazy
-
-class TrackUpdateService : Service() {
-
- val trackManager: TrackManager by injectLazy()
- val db: DatabaseHelper by injectLazy()
-
- private lateinit var subscriptions: CompositeSubscription
-
- override fun onCreate() {
- super.onCreate()
- subscriptions = CompositeSubscription()
- }
-
- override fun onDestroy() {
- subscriptions.unsubscribe()
- super.onDestroy()
- }
-
- override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
- val track = intent.getSerializableExtra(EXTRA_TRACK)
- if (track != null) {
- updateLastChapterRead(track as Track, startId)
- return Service.START_REDELIVER_INTENT
- } else {
- stopSelf(startId)
- return Service.START_NOT_STICKY
- }
- }
-
- override fun onBind(intent: Intent): IBinder? {
- return null
- }
-
- private fun updateLastChapterRead(track: Track, startId: Int) {
- val sync = trackManager.getService(track.sync_id)
- if (sync == null) {
- stopSelf(startId)
- return
- }
-
- subscriptions.add(Observable.defer { sync.update(track) }
- .flatMap { db.insertTrack(track).asRxObservable() }
- .subscribeOn(Schedulers.io())
- .observeOn(AndroidSchedulers.mainThread())
- .subscribe({ stopSelf(startId) },
- { stopSelf(startId) }))
- }
-
- companion object {
-
- private val EXTRA_TRACK = "extra_track"
-
- @JvmStatic
- fun start(context: Context, track: Track) {
- val intent = Intent(context, TrackUpdateService::class.java)
- intent.putExtra(EXTRA_TRACK, track)
- context.startService(intent)
- }
- }
-
-}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackFragment.kt
index fa4feb475..017ef8703 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackFragment.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackFragment.kt
@@ -45,7 +45,7 @@ class TrackFragment : BaseRxFragment() {
private fun findSearchFragmentIfNeeded() {
if (dialog == null) {
- dialog = childFragmentManager.findFragmentByTag(searchFragmentTag) as TrackSearchDialog
+ dialog = childFragmentManager.findFragmentByTag(searchFragmentTag) as? TrackSearchDialog
}
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
index 36b121b52..11b27c623 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt
@@ -171,11 +171,11 @@ class ReaderActivity : BaseRxActivity() {
.content(getString(R.string.confirm_update_manga_sync, chapterToUpdate))
.positiveText(android.R.string.yes)
.negativeText(android.R.string.no)
- .onPositive { dialog, which -> presenter.updateTrackLastChapterRead() }
+ .onPositive { dialog, which -> presenter.updateTrackLastChapterRead(chapterToUpdate) }
.onAny { dialog1, which1 -> super.onBackPressed() }
.show()
} else {
- presenter.updateTrackLastChapterRead()
+ presenter.updateTrackLastChapterRead(chapterToUpdate)
super.onBackPressed()
}
} else {
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt
index 860371cf7..56bcdc934 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt
@@ -14,7 +14,6 @@ import eu.kanade.tachiyomi.data.database.models.Track
import eu.kanade.tachiyomi.data.download.DownloadManager
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.track.TrackManager
-import eu.kanade.tachiyomi.data.track.TrackUpdateService
import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.Page
@@ -452,27 +451,31 @@ class ReaderPresenter : BasePresenter() {
Math.floor(chapter.chapter_number.toDouble()).toInt()
else if (prevChapter != null && prevChapter.read)
Math.floor(prevChapter.chapter_number.toDouble()).toInt()
+ else
+ return 0
+
+ return if (trackList.any { lastChapterRead > it.last_chapter_read })
+ lastChapterRead
else
0
-
- trackList.forEach { sync ->
- if (lastChapterRead > sync.last_chapter_read) {
- sync.last_chapter_read = lastChapterRead
- sync.update = true
- }
- }
-
- return if (trackList.any { it.update }) lastChapterRead else 0
}
/**
* Starts the service that updates the last chapter read in sync services
*/
- fun updateTrackLastChapterRead() {
- trackList?.forEach { sync ->
- val service = trackManager.getService(sync.sync_id)
- if (service != null && service.isLogged && sync.update) {
- TrackUpdateService.start(context, sync)
+ fun updateTrackLastChapterRead(lastChapterRead: Int) {
+ trackList?.forEach { track ->
+ val service = trackManager.getService(track.sync_id)
+ if (service != null && service.isLogged && lastChapterRead > track.last_chapter_read) {
+ track.last_chapter_read = lastChapterRead
+
+ // We wan't these to execute even if the presenter is destroyed and leaks for a
+ // while. The view can still be garbage collected.
+ Observable.defer { service.update(track) }
+ .map { db.insertTrack(track).executeAsBlocking() }
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe({}, { Timber.e(it) })
}
}
}
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersAdapter.kt
index 61c4ac3b0..ebd1b7e69 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersAdapter.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersAdapter.kt
@@ -1,9 +1,10 @@
package eu.kanade.tachiyomi.ui.recent_updates
import eu.davidea.flexibleadapter.FlexibleAdapter
+import eu.davidea.flexibleadapter.items.IFlexible
class RecentChaptersAdapter(val fragment: RecentChaptersFragment) :
- FlexibleAdapter(null, fragment, true) {
+ FlexibleAdapter>(null, fragment, true) {
init {
setDisplayHeadersAtStartUp(true)
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersFragment.kt
index db100abf9..607f732b9 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersFragment.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent_updates/RecentChaptersFragment.kt
@@ -9,6 +9,7 @@ import android.support.v7.widget.RecyclerView
import android.view.*
import com.afollestad.materialdialogs.MaterialDialog
import eu.davidea.flexibleadapter.FlexibleAdapter
+import eu.davidea.flexibleadapter.items.IFlexible
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.download.model.Download
import eu.kanade.tachiyomi.data.library.LibraryUpdateService
@@ -116,7 +117,7 @@ class RecentChaptersFragment:
* @return list of selected chapters
*/
fun getSelectedChapters(): List {
- return adapter.selectedPositions.mapNotNull { adapter.getItem(it) }
+ return adapter.selectedPositions.mapNotNull { adapter.getItem(it) as? RecentChapterItem }
}
/**
@@ -125,7 +126,7 @@ class RecentChaptersFragment:
*/
override fun onItemClick(position: Int): Boolean {
// Get item from position
- val item = adapter.getItem(position)
+ val item = adapter.getItem(position) as? RecentChapterItem ?: return false
if (actionMode != null && adapter.mode == FlexibleAdapter.MODE_MULTI) {
toggleSelection(position)
return true
@@ -183,7 +184,7 @@ class RecentChaptersFragment:
* Populate adapter with chapters
* @param chapters list of [Any]
*/
- fun onNextRecentChapters(chapters: List) {
+ fun onNextRecentChapters(chapters: List>) {
(activity as MainActivity).updateEmptyView(chapters.isEmpty(),
R.string.information_no_recent, R.drawable.ic_update_black_128dp)
@@ -291,6 +292,8 @@ class RecentChaptersFragment:
* @param item item from ActionMode.
*/
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
+ if (!isAdded) return true
+
when (item.itemId) {
R.id.action_mark_as_read -> markAsRead(getSelectedChapters())
R.id.action_mark_as_unread -> markAsUnread(getSelectedChapters())
diff --git a/app/src/main/res/layout/item_track.xml b/app/src/main/res/layout/item_track.xml
index 4260f4c0e..d05955c75 100644
--- a/app/src/main/res/layout/item_track.xml
+++ b/app/src/main/res/layout/item_track.xml
@@ -28,7 +28,7 @@
-
+ android:text="@string/title"/>
-
+
-
-
+
-
-
+
-
-
+