Fix updates feed
This commit is contained in:
@@ -23,7 +23,7 @@ data class TrackLogWithManga(
|
||||
|
||||
fun toTrackingLogItem() = TrackingLogItem(
|
||||
id = trackLog.id,
|
||||
chapters = trackLog.chapters.split('\n'),
|
||||
chapters = trackLog.chapters.split('\n').filterNot { x -> x.isEmpty() },
|
||||
manga = manga.toManga(tags.map { x -> x.toMangaTag() }.toSet()),
|
||||
createdAt = Date(trackLog.createdAt)
|
||||
)
|
||||
|
||||
@@ -113,7 +113,7 @@ abstract class GroupleRepository(loaderContext: MangaLoaderContext) :
|
||||
a.attr("href")?.withDomain(domain) ?: return@mapIndexedNotNull null
|
||||
MangaChapter(
|
||||
id = href.longHashCode(),
|
||||
name = a.ownText(),
|
||||
name = a.ownText().removePrefix(manga.title).trim(),
|
||||
number = i + 1,
|
||||
url = href,
|
||||
source = source
|
||||
|
||||
@@ -51,22 +51,24 @@ class TrackingRepository : KoinComponent {
|
||||
newChapters: List<MangaChapter>,
|
||||
lastNotifiedChapterId: Long
|
||||
) {
|
||||
val entity = TrackEntity(
|
||||
mangaId = mangaId,
|
||||
newChapters = newChapters.size,
|
||||
lastCheck = System.currentTimeMillis(),
|
||||
lastChapterId = lastChapterId,
|
||||
totalChapters = knownChaptersCount,
|
||||
lastNotifiedChapterId = lastNotifiedChapterId
|
||||
)
|
||||
val logEntity = TrackLogEntity(
|
||||
mangaId = mangaId,
|
||||
chapters = newChapters.joinToString("\n") { x -> x.name },
|
||||
createdAt = System.currentTimeMillis()
|
||||
)
|
||||
db.withTransaction {
|
||||
val entity = TrackEntity(
|
||||
mangaId = mangaId,
|
||||
newChapters = newChapters.size,
|
||||
lastCheck = System.currentTimeMillis(),
|
||||
lastChapterId = lastChapterId,
|
||||
totalChapters = knownChaptersCount,
|
||||
lastNotifiedChapterId = lastNotifiedChapterId
|
||||
)
|
||||
db.tracksDao.upsert(entity)
|
||||
db.trackLogsDao.insert(logEntity)
|
||||
if (newChapters.isNotEmpty()) {
|
||||
val logEntity = TrackLogEntity(
|
||||
mangaId = mangaId,
|
||||
chapters = newChapters.joinToString("\n") { x -> x.name },
|
||||
createdAt = System.currentTimeMillis()
|
||||
)
|
||||
db.trackLogsDao.insert(logEntity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.koitharu.kotatsu.ui.list.favourites.FavouritesContainerFragment
|
||||
import org.koitharu.kotatsu.ui.list.history.HistoryListFragment
|
||||
import org.koitharu.kotatsu.ui.list.local.LocalListFragment
|
||||
import org.koitharu.kotatsu.ui.list.remote.RemoteListFragment
|
||||
import org.koitharu.kotatsu.ui.list.tracklogs.FeedFragment
|
||||
import org.koitharu.kotatsu.ui.list.feed.FeedFragment
|
||||
import org.koitharu.kotatsu.ui.reader.ReaderActivity
|
||||
import org.koitharu.kotatsu.ui.reader.ReaderState
|
||||
import org.koitharu.kotatsu.ui.search.SearchHelper
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.koitharu.kotatsu.ui.list.tracklogs
|
||||
package org.koitharu.kotatsu.ui.list.feed
|
||||
|
||||
import android.view.ViewGroup
|
||||
import org.koitharu.kotatsu.core.model.TrackingLogItem
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.koitharu.kotatsu.ui.list.tracklogs
|
||||
package org.koitharu.kotatsu.ui.list.feed
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.view.View
|
||||
import androidx.core.view.isVisible
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
@@ -25,6 +27,8 @@ class FeedFragment : BaseFragment(R.layout.fragment_tracklogs), FeedView,
|
||||
|
||||
private var adapter: FeedAdapter? = null
|
||||
|
||||
override fun getTitle() = context?.getString(R.string.updates)
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
@@ -44,6 +48,11 @@ class FeedFragment : BaseFragment(R.layout.fragment_tracklogs), FeedView,
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
inflater.inflate(R.menu.opt_feed, menu)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
adapter = null
|
||||
super.onDestroyView()
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.koitharu.kotatsu.ui.list.tracklogs
|
||||
package org.koitharu.kotatsu.ui.list.feed
|
||||
|
||||
import android.text.format.DateUtils
|
||||
import android.view.ViewGroup
|
||||
import coil.api.clear
|
||||
import coil.api.load
|
||||
@@ -7,7 +8,7 @@ import kotlinx.android.synthetic.main.item_tracklog.*
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.model.TrackingLogItem
|
||||
import org.koitharu.kotatsu.ui.common.list.BaseViewHolder
|
||||
import org.koitharu.kotatsu.utils.ext.format
|
||||
import org.koitharu.kotatsu.utils.ext.formatRelative
|
||||
|
||||
class FeedHolder(parent: ViewGroup) :
|
||||
BaseViewHolder<TrackingLogItem, Unit>(parent, R.layout.item_tracklog) {
|
||||
@@ -19,7 +20,17 @@ class FeedHolder(parent: ViewGroup) :
|
||||
error(R.drawable.ic_placeholder)
|
||||
}
|
||||
textView_title.text = data.manga.title
|
||||
textView_subtitle.text = data.createdAt.format("d.m.Y")
|
||||
textView_subtitle.text = buildString {
|
||||
append(data.createdAt.formatRelative(DateUtils.DAY_IN_MILLIS))
|
||||
append(" ")
|
||||
append(
|
||||
context.resources.getQuantityString(
|
||||
R.plurals.new_chapters,
|
||||
data.chapters.size,
|
||||
data.chapters.size
|
||||
)
|
||||
)
|
||||
}
|
||||
textView_chapters.text = data.chapters.joinToString("\n")
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.koitharu.kotatsu.ui.list.tracklogs
|
||||
package org.koitharu.kotatsu.ui.list.feed
|
||||
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.koitharu.kotatsu.ui.list.tracklogs
|
||||
package org.koitharu.kotatsu.ui.list.feed
|
||||
|
||||
import moxy.viewstate.strategy.AddToEndSingleTagStrategy
|
||||
import moxy.viewstate.strategy.AddToEndStrategy
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.koitharu.kotatsu.utils.ext
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.text.format.DateUtils
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
@@ -9,4 +10,8 @@ fun Date.format(pattern: String): String = SimpleDateFormat(pattern).format(this
|
||||
|
||||
fun Date.calendar(): Calendar = Calendar.getInstance().also {
|
||||
it.time = this
|
||||
}
|
||||
}
|
||||
|
||||
fun Date.formatRelative(minResolution: Long): CharSequence = DateUtils.getRelativeTimeSpanString(
|
||||
time, System.currentTimeMillis(), minResolution
|
||||
)
|
||||
@@ -1,18 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
app:cardBackgroundColor="?android:windowBackground"
|
||||
app:cardElevation="0dp"
|
||||
app:cardMaxElevation="0dp"
|
||||
app:strokeColor="?android:colorControlNormal"
|
||||
app:strokeWidth="1px">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:paddingBottom="12dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<org.koitharu.kotatsu.ui.common.widgets.CoverImageView
|
||||
android:layout_width="87dp"
|
||||
android:id="@+id/imageView_cover"
|
||||
android:layout_width="87dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentTop="true" />
|
||||
@@ -21,14 +26,14 @@
|
||||
android:id="@+id/textView_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_toEndOf="@id/imageView_cover"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:layout_toEndOf="@id/imageView_cover"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||
tools:text="@tools:sample/lorem[6]" />
|
||||
|
||||
@@ -36,15 +41,15 @@
|
||||
android:id="@+id/textView_subtitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/textView_title"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:layout_toEndOf="@id/imageView_cover"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
android:layout_toEndOf="@id/imageView_cover"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_below="@id/textView_title"
|
||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
tools:text="@tools:sample/lorem[6]" />
|
||||
@@ -53,23 +58,23 @@
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_toEndOf="@id/imageView_cover"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_below="@id/textView_subtitle"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_toEndOf="@id/imageView_cover"
|
||||
android:background="?android:listDivider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView_chapters"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_below="@id/divider"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="6dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:layout_toEndOf="@id/imageView_cover"
|
||||
android:ellipsize="none"
|
||||
android:gravity="center_vertical"
|
||||
android:requiresFadingEdge="horizontal"
|
||||
android:singleLine="true" />
|
||||
android:paddingBottom="12dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
2
app/src/main/res/menu/opt_feed.xml
Normal file
2
app/src/main/res/menu/opt_feed.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu />
|
||||
Reference in New Issue
Block a user