This commit is contained in:
rebelonion 2024-01-18 20:16:56 -06:00
commit 4f07421df7
4 changed files with 49 additions and 70 deletions

View file

@ -69,6 +69,7 @@ class OfflineAnimeFragment : Fragment(), OfflineAnimeSearchListener {
private var downloads: List<OfflineAnimeModel> = listOf()
private lateinit var gridView: GridView
private lateinit var adapter: OfflineAnimeAdapter
private lateinit var total : TextView
private var uiSettings: UserInterfaceSettings =
loadData("ui_settings") ?: UserInterfaceSettings()
@ -142,9 +143,6 @@ class OfflineAnimeFragment : Fragment(), OfflineAnimeSearchListener {
?.putInt("offline_view", style!!)?.apply()
gridView.visibility = View.GONE
gridView = view.findViewById(R.id.gridView)
gridView.adapter = adapter
gridView.scheduleLayoutAnimation()
gridView.visibility = View.VISIBLE
adapter.notifyNewGrid()
grid()
}
@ -156,37 +154,30 @@ class OfflineAnimeFragment : Fragment(), OfflineAnimeSearchListener {
?.putInt("offline_view", style!!)?.apply()
gridView.visibility = View.GONE
gridView = view.findViewById(R.id.gridView1)
gridView.adapter = adapter
gridView.scheduleLayoutAnimation()
gridView.visibility = View.VISIBLE
adapter.notifyNewGrid()
grid()
}
gridView =
if (style == 0) view.findViewById(R.id.gridView) else view.findViewById(R.id.gridView1)
gridView.visibility = View.VISIBLE
getDownloads()
val fadeIn = AlphaAnimation(0f, 1f)
fadeIn.duration = 200 // animations pog
val animation = LayoutAnimationController(fadeIn)
gridView.layoutAnimation = animation
adapter = OfflineAnimeAdapter(requireContext(), downloads, this)
gridView.adapter = adapter
gridView.scheduleLayoutAnimation()
gridView = if (style == 0) view.findViewById(R.id.gridView) else view.findViewById(R.id.gridView1)
total = view.findViewById(R.id.total)
grid()
val total = view.findViewById<TextView>(R.id.total)
total.text = if (gridView.count > 0) "Anime (${gridView.count})" else "Empty List"
return view
}
@OptIn(UnstableApi::class)
private fun grid() {
gridView.setOnItemClickListener { parent, view, position, id ->
gridView.visibility = View.VISIBLE
getDownloads()
val fadeIn = AlphaAnimation(0f, 1f)
fadeIn.duration = 300 // animations pog
gridView.layoutAnimation = LayoutAnimationController(fadeIn)
adapter = OfflineAnimeAdapter(requireContext(), downloads, this)
gridView.adapter = adapter
gridView.scheduleLayoutAnimation()
total.text = if (gridView.count > 0) "Anime (${gridView.count})" else "Empty List"
gridView.setOnItemClickListener { _, _, position, _ ->
// Get the OfflineAnimeModel that was clicked
val item = adapter.getItem(position) as OfflineAnimeModel
val downloads = downloadManager.animeDownloadedTypes
val media =
downloadManager.animeDownloadedTypes.firstOrNull { it.title == item.title }
media?.let {
@ -204,7 +195,7 @@ class OfflineAnimeFragment : Fragment(), OfflineAnimeSearchListener {
snackString("no media found")
}
}
gridView.setOnItemLongClickListener { parent, view, position, id ->
gridView.setOnItemLongClickListener { _, _, position, _ ->
// Get the OfflineAnimeModel that was clicked
val item = adapter.getItem(position) as OfflineAnimeModel
val type: DownloadedType.Type =
@ -231,6 +222,7 @@ class OfflineAnimeFragment : Fragment(), OfflineAnimeSearchListener {
}
getDownloads()
adapter.setItems(downloads)
total.text = if (gridView.count > 0) "Anime (${gridView.count})" else "Empty List"
}
builder.setNegativeButton("No") { _, _ ->
// Do nothing

View file

@ -62,6 +62,7 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener {
private var downloads: List<OfflineMangaModel> = listOf()
private lateinit var gridView: GridView
private lateinit var adapter: OfflineMangaAdapter
private lateinit var total : TextView
private var uiSettings: UserInterfaceSettings =
loadData("ui_settings") ?: UserInterfaceSettings()
@ -131,13 +132,9 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener {
layoutList.setOnClickListener {
selected(it as ImageView)
style = 0
context?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)?.edit()
?.putInt("offline_view", style!!)?.apply()
requireContext().getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putInt("offline_view", style!!).apply()
gridView.visibility = View.GONE
gridView = view.findViewById(R.id.gridView)
gridView.adapter = adapter
gridView.scheduleLayoutAnimation()
gridView.visibility = View.VISIBLE
adapter.notifyNewGrid()
grid()
@ -146,39 +143,29 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener {
layoutcompact.setOnClickListener {
selected(it as ImageView)
style = 1
context?.getSharedPreferences("Dantotsu", Context.MODE_PRIVATE)?.edit()
?.putInt("offline_view", style!!)?.apply()
requireContext().getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit().putInt("offline_view", style!!).apply()
gridView.visibility = View.GONE
gridView = view.findViewById(R.id.gridView1)
gridView.adapter = adapter
gridView.scheduleLayoutAnimation()
gridView.visibility = View.VISIBLE
adapter.notifyNewGrid()
grid()
}
gridView =
if (style == 0) view.findViewById(R.id.gridView) else view.findViewById(R.id.gridView1)
gridView.visibility = View.VISIBLE
getDownloads()
val fadeIn = AlphaAnimation(0f, 1f)
fadeIn.duration = 200 // animations pog
val animation = LayoutAnimationController(fadeIn)
gridView.layoutAnimation = animation
adapter = OfflineMangaAdapter(requireContext(), downloads, this)
gridView.adapter = adapter
gridView.scheduleLayoutAnimation()
gridView = if (style == 0) view.findViewById(R.id.gridView) else view.findViewById(R.id.gridView1)
total = view.findViewById(R.id.total)
grid()
val total = view.findViewById<TextView>(R.id.total)
total.text =
if (gridView.count > 0) "Manga and Novels (${gridView.count})" else "Empty List"
return view
}
private fun grid() {
gridView.setOnItemClickListener { parent, view, position, id ->
gridView.visibility = View.VISIBLE
getDownloads()
val fadeIn = AlphaAnimation(0f, 1f)
fadeIn.duration = 300 // animations pog
gridView.layoutAnimation = LayoutAnimationController(fadeIn)
adapter = OfflineMangaAdapter(requireContext(), downloads, this)
gridView.adapter = adapter
gridView.scheduleLayoutAnimation()
total.text = if (gridView.count > 0) "Manga and Novels (${gridView.count})" else "Empty List"
gridView.setOnItemClickListener { _, _, position, _ ->
// Get the OfflineMangaModel that was clicked
val item = adapter.getItem(position) as OfflineMangaModel
val media =
@ -195,7 +182,7 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener {
}
}
gridView.setOnItemLongClickListener { parent, view, position, id ->
gridView.setOnItemLongClickListener { _, _, position, _ ->
// Get the OfflineMangaModel that was clicked
val item = adapter.getItem(position) as OfflineMangaModel
val type: DownloadedType.Type =
@ -213,6 +200,7 @@ class OfflineMangaFragment : Fragment(), OfflineMangaSearchListener {
downloadManager.removeMedia(item.title, type)
getDownloads()
adapter.setItems(downloads)
total.text = if (gridView.count > 0) "Manga and Novels (${gridView.count})" else "Empty List"
}
builder.setNegativeButton("No") { _, _ ->
// Do nothing

View file

@ -275,22 +275,21 @@
</LinearLayout>
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardBackgroundColor="@color/nav_bg_inv"
app:cardCornerRadius="16dp"
app:cardElevation="0dp">
<ImageButton
android:id="@+id/animeWebViewTop"
<LinearLayout
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_height="48dp">
<ImageView
android:id="@+id/animeWebViewTop"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center|center_horizontal"
android:layout_marginStart="12dp"
android:background="?android:attr/selectableItemBackground"
app:srcCompat="@drawable/ic_internet"
app:tint="?attr/colorOnBackground"
tools:ignore="ContentDescription,ImageContrastCheck" />
</androidx.cardview.widget.CardView>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -304,10 +304,10 @@
<color name="md_theme_light_5_onTertiary">#00FF00</color>
<color name="md_theme_light_5_tertiaryContainer">#00FF00</color>
<color name="md_theme_light_5_onTertiaryContainer">#00FF00</color>
<color name="md_theme_light_5_error">#00FF00</color>
<color name="md_theme_light_5_errorContainer">#00FF00</color>
<color name="md_theme_light_5_onError">#00FF00</color>
<color name="md_theme_light_5_onErrorContainer">#00FF00</color>
<color name="md_theme_light_5_error">#BA1A1A</color>
<color name="md_theme_light_5_errorContainer">#FFDAD6</color>
<color name="md_theme_light_5_onError">#FFFFFF</color>
<color name="md_theme_light_5_onErrorContainer">#410002</color>
<color name="md_theme_light_5_background">#EEEEEE</color>
<color name="md_theme_light_5_onBackground">#000000</color>
<color name="md_theme_light_5_surface">#EEEEEE</color>
@ -338,10 +338,10 @@
<color name="md_theme_dark_5_onTertiary">#00FF00</color>
<color name="md_theme_dark_5_tertiaryContainer">#00FF00</color>
<color name="md_theme_dark_5_onTertiaryContainer">#00FF00</color>
<color name="md_theme_dark_5_error">#00FF00</color>
<color name="md_theme_dark_5_errorContainer">#00FF00</color>
<color name="md_theme_dark_5_onError">#00FF00</color>
<color name="md_theme_dark_5_onErrorContainer">#00FF00</color>
<color name="md_theme_dark_5_error">#FFB4AB</color>
<color name="md_theme_dark_5_errorContainer">#93000A</color>
<color name="md_theme_dark_5_onError">#690005</color>
<color name="md_theme_dark_5_onErrorContainer">#FFDAD6</color>
<color name="md_theme_dark_5_background">#1C1B1E</color>
<color name="md_theme_dark_5_onBackground">#EEEEEE</color>
<color name="md_theme_dark_5_surface">#1C1B20</color>