Skip to content

Commit

Permalink
lil tweaks (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush2622 authored Jan 18, 2024
1 parent 91b1f47 commit 8eadd20
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()
}
Expand All @@ -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 = if (style == 0) view.findViewById(R.id.gridView) else view.findViewById(R.id.gridView1)
total = view.findViewById(R.id.total)
grid()
return view
}

@OptIn(UnstableApi::class)
private fun grid() {
gridView.visibility = View.VISIBLE
getDownloads()
val fadeIn = AlphaAnimation(0f, 1f)
fadeIn.duration = 200 // animations pog
val animation = LayoutAnimationController(fadeIn)
gridView.layoutAnimation = animation
fadeIn.duration = 300 // animations pog
gridView.layoutAnimation = LayoutAnimationController(fadeIn)
adapter = OfflineAnimeAdapter(requireContext(), downloads, this)
gridView.adapter = adapter
gridView.scheduleLayoutAnimation()
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.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 {
Expand All @@ -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 =
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand All @@ -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 = if (style == 0) view.findViewById(R.id.gridView) else view.findViewById(R.id.gridView1)
total = view.findViewById(R.id.total)
grid()
return view
}

private fun grid() {
gridView.visibility = View.VISIBLE
getDownloads()

val fadeIn = AlphaAnimation(0f, 1f)
fadeIn.duration = 200 // animations pog
val animation = LayoutAnimationController(fadeIn)

gridView.layoutAnimation = animation
fadeIn.duration = 300 // animations pog
gridView.layoutAnimation = LayoutAnimationController(fadeIn)
adapter = OfflineMangaAdapter(requireContext(), downloads, this)
gridView.adapter = adapter
gridView.scheduleLayoutAnimation()
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 ->
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 =
Expand All @@ -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 =
Expand All @@ -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
Expand Down
19 changes: 9 additions & 10 deletions app/src/main/res/layout/dialog_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<LinearLayout
android:layout_width="48dp"
android:layout_height="48dp">

<ImageButton
<ImageView
android:id="@+id/animeWebViewTop"
android:layout_width="48dp"
android:layout_height="48dp"
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>
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down

0 comments on commit 8eadd20

Please sign in to comment.