feat: something

This commit is contained in:
aayush262 2024-06-30 22:29:30 +05:30
parent b09f26ed34
commit 79742f415b
8 changed files with 40 additions and 29 deletions

View file

@ -191,6 +191,7 @@ object Anilist {
)
val remaining = json.headers["X-RateLimit-Remaining"]?.toIntOrNull() ?: -1
Logger.log("Remaining requests: $remaining")
println("Remaining requests: $remaining")
if (json.code == 429) {
val retry = json.headers["Retry-After"]?.toIntOrNull() ?: -1
val passedLimitReset = json.headers["X-RateLimit-Reset"]?.toLongOrNull() ?: 0

View file

@ -38,6 +38,7 @@ import ani.dantotsu.snackString
import ani.dantotsu.statusBarHeight
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@ -289,15 +290,20 @@ class AnimeFragment : Fragment() {
}
}
}
model.loaded = true
model.loadTrending(1)
model.loadAll()
}
model.loaded = true
val loadTrending = async(Dispatchers.IO) { model.loadTrending(1) }
val loadAll = async(Dispatchers.IO) { model.loadAll() }
val loadPopular = async(Dispatchers.IO) {
model.loadPopular(
"ANIME", sort = Anilist.sortBy[1], onList = PrefManager.getVal(
PrefName.PopularAnimeList
)
"ANIME",
sort = Anilist.sortBy[1],
onList = PrefManager.getVal(PrefName.PopularAnimeList)
)
}
loadTrending.await()
loadAll.await()
loadPopular.await()
live.postValue(false)
_binding?.animeRefresh?.isRefreshing = false
running = false

View file

@ -35,6 +35,7 @@ import ani.dantotsu.snackString
import ani.dantotsu.statusBarHeight
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@ -274,15 +275,22 @@ class MangaFragment : Fragment() {
}
}
}
model.loaded = true
model.loadTrending()
model.loadAll()
}
model.loaded = true
val loadTrending = async(Dispatchers.IO) { model.loadTrending() }
val loadAll = async(Dispatchers.IO) { model.loadAll() }
val loadPopular = async(Dispatchers.IO) {
model.loadPopular(
"MANGA", sort = Anilist.sortBy[1], onList = PrefManager.getVal(
PrefName.PopularMangaList
)
"MANGA",
sort = Anilist.sortBy[1],
onList = PrefManager.getVal(PrefName.PopularAnimeList)
)
}
loadTrending.await()
loadAll.await()
loadPopular.await()
live.postValue(false)
_binding?.mangaRefresh?.isRefreshing = false
running = false

View file

@ -79,8 +79,8 @@ class NotificationActivity : AppCompatActivity() {
override fun getItemCount(): Int = if (id != -1) 1 else 4
override fun createFragment(position: Int): Fragment = when (position) {
0 -> newInstance(USER)
1 -> newInstance(if (id != -1) ONE else MEDIA, id)
0 -> newInstance(if (id != -1) ONE else USER, id)
1 -> newInstance(MEDIA)
2 -> newInstance(SUBSCRIPTION)
3 -> newInstance(COMMENT)
else -> newInstance(MEDIA)

View file

@ -8,6 +8,7 @@ import android.view.ViewGroup
import ani.dantotsu.R
import ani.dantotsu.databinding.ItemExtensionBinding
import ani.dantotsu.notifications.subscription.SubscriptionHelper
import ani.dantotsu.util.customAlertDialog
import com.xwray.groupie.GroupieAdapter
import com.xwray.groupie.viewbinding.BindableItem
@ -26,14 +27,13 @@ class SubscriptionSource(
binding.extensionNameTextView.text = parserName
updateSubscriptionCount()
binding.extensionSubscriptions.visibility = View.VISIBLE
binding.extensionSubscriptions.setOnClickListener(null)
binding.root.setOnClickListener {
isExpanded = !isExpanded
toggleSubscriptions()
}
binding.subscriptionCount.setOnClickListener {
binding.root.setOnLongClickListener {
showRemoveAllSubscriptionsDialog(it.context)
true
}
binding.extensionIconImageView.visibility = View.VISIBLE
val layoutParams = binding.extensionIconImageView.layoutParams as ViewGroup.MarginLayoutParams
@ -58,14 +58,13 @@ class SubscriptionSource(
}
private fun showRemoveAllSubscriptionsDialog(context: Context) {
AlertDialog.Builder(context, R.style.MyPopup)
.setTitle(R.string.remove_all_subscriptions)
.setMessage(context.getString(R.string.remove_all_subscriptions_desc, parserName))
.setPositiveButton(R.string.apply) { _, _ ->
removeAllSubscriptions()
}
.setNegativeButton(R.string.cancel, null)
.show()
context.customAlertDialog().apply{
setTitle(R.string.remove_all_subscriptions)
setMessage(R.string.remove_all_subscriptions_desc, parserName)
setPosButton(R.string.ok) { removeAllSubscriptions() }
setNegButton(R.string.cancel)
show()
}
}
private fun removeAllSubscriptions() {

View file

@ -314,10 +314,9 @@
android:id="@+id/homeUserStatusContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="100dp"
android:minHeight="120dp"
android:layout_marginVertical="8dp"
android:visibility="gone">
<ProgressBar
android:id="@+id/homeUserStatusProgressBar"
style="?android:attr/progressBarStyle"

View file

@ -5,7 +5,6 @@
android:id="@+id/extensionCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">

View file

@ -4,7 +4,6 @@
android:id="@+id/extensionCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface"
android:orientation="horizontal"
android:paddingTop="10dp"
android:paddingBottom="10dp">