Skip to content

Commit

Permalink
feat: something
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush2622 committed Jun 30, 2024
1 parent b09f26e commit 79742f4
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions app/src/main/java/ani/dantotsu/home/AnimeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 14 additions & 6 deletions app/src/main/java/ani/dantotsu/home/MangaFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 10 additions & 11 deletions app/src/main/java/ani/dantotsu/settings/SubscriptionSource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/item_extension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/item_extension_select.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down

0 comments on commit 79742f4

Please sign in to comment.