fix: random things
This commit is contained in:
parent
3ae59b8d22
commit
903423b842
6 changed files with 56 additions and 56 deletions
|
@ -48,9 +48,11 @@ class ActivityFragment : Fragment() {
|
||||||
userId = it.getInt("userId")
|
userId = it.getInt("userId")
|
||||||
activityId = it.getInt("activityId")
|
activityId = it.getInt("activityId")
|
||||||
}
|
}
|
||||||
binding.titleBar.visibility = if (type == ActivityType.OTHER_USER) View.VISIBLE else View.GONE
|
binding.titleBar.visibility =
|
||||||
binding.titleText.text = if (userId == Anilist.userid) getString(R.string.create_new_activity) else getString(R.string.write_a_message)
|
if (type == ActivityType.OTHER_USER) View.VISIBLE else View.GONE
|
||||||
binding.titleImage.setOnClickListener{handleTitleImageClick() }
|
binding.titleText.text =
|
||||||
|
if (userId == Anilist.userid) getString(R.string.create_new_activity) else getString(R.string.write_a_message)
|
||||||
|
binding.titleImage.setOnClickListener { handleTitleImageClick() }
|
||||||
binding.listRecyclerView.adapter = adapter
|
binding.listRecyclerView.adapter = adapter
|
||||||
binding.listRecyclerView.layoutManager = LinearLayoutManager(context)
|
binding.listRecyclerView.layoutManager = LinearLayoutManager(context)
|
||||||
binding.listProgressBar.isVisible = true
|
binding.listProgressBar.isVisible = true
|
||||||
|
@ -88,6 +90,7 @@ class ActivityFragment : Fragment() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleTitleImageClick() {
|
private fun handleTitleImageClick() {
|
||||||
val intent = Intent(context, ActivityMarkdownCreator::class.java).apply {
|
val intent = Intent(context, ActivityMarkdownCreator::class.java).apply {
|
||||||
putExtra("type", if (userId == Anilist.userid) "activity" else "message")
|
putExtra("type", if (userId == Anilist.userid) "activity" else "message")
|
||||||
|
@ -103,14 +106,14 @@ class ActivityFragment : Fragment() {
|
||||||
ActivityType.OTHER_USER -> getActivities(userId = userId)
|
ActivityType.OTHER_USER -> getActivities(userId = userId)
|
||||||
ActivityType.ONE -> getActivities(activityId = activityId)
|
ActivityType.ONE -> getActivities(activityId = activityId)
|
||||||
}
|
}
|
||||||
adapter.addAll(list.map { ActivityItem(it, ::onActivityClick, adapter ,requireActivity()) })
|
adapter.addAll(list.map { ActivityItem(it, adapter, ::onActivityClick) })
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getActivities(
|
private suspend fun getActivities(
|
||||||
global: Boolean = false,
|
global: Boolean = false,
|
||||||
userId: Int? = null,
|
userId: Int? = null,
|
||||||
activityId: Int? = null,
|
activityId: Int? = null,
|
||||||
filter:Boolean = false
|
filter: Boolean = false
|
||||||
): List<Activity> {
|
): List<Activity> {
|
||||||
val res = Anilist.query.getFeed(userId, global, page, activityId)?.data?.page?.activities
|
val res = Anilist.query.getFeed(userId, global, page, activityId)?.data?.page?.activities
|
||||||
page += 1
|
page += 1
|
||||||
|
@ -133,7 +136,11 @@ class ActivityFragment : Fragment() {
|
||||||
private fun onActivityClick(id: Int, type: String) {
|
private fun onActivityClick(id: Int, type: String) {
|
||||||
val intent = when (type) {
|
val intent = when (type) {
|
||||||
"USER" -> Intent(requireContext(), ProfileActivity::class.java).putExtra("userId", id)
|
"USER" -> Intent(requireContext(), ProfileActivity::class.java).putExtra("userId", id)
|
||||||
"MEDIA" -> Intent(requireContext(), MediaDetailsActivity::class.java).putExtra("mediaId", id)
|
"MEDIA" -> Intent(
|
||||||
|
requireContext(),
|
||||||
|
MediaDetailsActivity::class.java
|
||||||
|
).putExtra("mediaId", id)
|
||||||
|
|
||||||
else -> return
|
else -> return
|
||||||
}
|
}
|
||||||
ContextCompat.startActivity(requireContext(), intent, null)
|
ContextCompat.startActivity(requireContext(), intent, null)
|
||||||
|
@ -149,7 +156,11 @@ class ActivityFragment : Fragment() {
|
||||||
companion object {
|
companion object {
|
||||||
enum class ActivityType { GLOBAL, USER, OTHER_USER, ONE }
|
enum class ActivityType { GLOBAL, USER, OTHER_USER, ONE }
|
||||||
|
|
||||||
fun newInstance(type: ActivityType, userId: Int? = null, activityId: Int? = null): ActivityFragment {
|
fun newInstance(
|
||||||
|
type: ActivityType,
|
||||||
|
userId: Int? = null,
|
||||||
|
activityId: Int? = null
|
||||||
|
): ActivityFragment {
|
||||||
return ActivityFragment().apply {
|
return ActivityFragment().apply {
|
||||||
arguments = Bundle().apply {
|
arguments = Bundle().apply {
|
||||||
putSerializable("type", type)
|
putSerializable("type", type)
|
||||||
|
|
|
@ -29,9 +29,8 @@ import kotlinx.coroutines.withContext
|
||||||
|
|
||||||
class ActivityItem(
|
class ActivityItem(
|
||||||
private val activity: Activity,
|
private val activity: Activity,
|
||||||
val clickCallback: (Int, type: String) -> Unit,
|
|
||||||
private val parentAdapter: GroupieAdapter,
|
private val parentAdapter: GroupieAdapter,
|
||||||
private val fragActivity: FragmentActivity
|
val clickCallback: (Int, type: String) -> Unit,
|
||||||
) : BindableItem<ItemActivityBinding>() {
|
) : BindableItem<ItemActivityBinding>() {
|
||||||
private lateinit var binding: ItemActivityBinding
|
private lateinit var binding: ItemActivityBinding
|
||||||
|
|
||||||
|
@ -54,14 +53,14 @@ class ActivityItem(
|
||||||
}
|
}
|
||||||
binding.activityRepliesContainer.setOnClickListener {
|
binding.activityRepliesContainer.setOnClickListener {
|
||||||
RepliesBottomDialog.newInstance(activity.id)
|
RepliesBottomDialog.newInstance(activity.id)
|
||||||
.show(fragActivity.supportFragmentManager, "replies")
|
.show((context as FragmentActivity).supportFragmentManager, "replies")
|
||||||
}
|
}
|
||||||
binding.replyCount.text = activity.replyCount.toString()
|
binding.replyCount.text = activity.replyCount.toString()
|
||||||
binding.activityReplies.setColorFilter(ContextCompat.getColor(binding.root.context, R.color.bg_opp))
|
binding.activityReplies.setColorFilter(ContextCompat.getColor(binding.root.context, R.color.bg_opp))
|
||||||
binding.activityLikeContainer.setOnLongClickListener {
|
binding.activityLikeContainer.setOnLongClickListener {
|
||||||
UsersDialogFragment().apply {
|
UsersDialogFragment().apply {
|
||||||
userList(userList)
|
userList(userList)
|
||||||
show(fragActivity.supportFragmentManager, "dialog")
|
show((context as FragmentActivity).supportFragmentManager, "dialog")
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import ani.dantotsu.settings.saving.PrefManager
|
||||||
import ani.dantotsu.settings.saving.PrefName
|
import ani.dantotsu.settings.saving.PrefName
|
||||||
import ani.dantotsu.statusBarHeight
|
import ani.dantotsu.statusBarHeight
|
||||||
import ani.dantotsu.themes.ThemeManager
|
import ani.dantotsu.themes.ThemeManager
|
||||||
|
import ani.dantotsu.util.customAlertDialog
|
||||||
|
|
||||||
class UserInterfaceSettingsActivity : AppCompatActivity() {
|
class UserInterfaceSettingsActivity : AppCompatActivity() {
|
||||||
lateinit var binding: ActivityUserInterfaceSettingsBinding
|
lateinit var binding: ActivityUserInterfaceSettingsBinding
|
||||||
|
@ -38,20 +39,21 @@ class UserInterfaceSettingsActivity : AppCompatActivity() {
|
||||||
binding.uiSettingsHomeLayout.setOnClickListener {
|
binding.uiSettingsHomeLayout.setOnClickListener {
|
||||||
val set = PrefManager.getVal<List<Boolean>>(PrefName.HomeLayout).toMutableList()
|
val set = PrefManager.getVal<List<Boolean>>(PrefName.HomeLayout).toMutableList()
|
||||||
val views = resources.getStringArray(R.array.home_layouts)
|
val views = resources.getStringArray(R.array.home_layouts)
|
||||||
val dialog = AlertDialog.Builder(this, R.style.MyPopup)
|
customAlertDialog()
|
||||||
.setTitle(getString(R.string.home_layout_show)).apply {
|
.setTitle(getString(R.string.home_layout_show))
|
||||||
setMultiChoiceItems(
|
.multiChoiceItems(
|
||||||
views,
|
items = views,
|
||||||
PrefManager.getVal<List<Boolean>>(PrefName.HomeLayout).toBooleanArray()
|
checkedItems = PrefManager.getVal<List<Boolean>>(PrefName.HomeLayout).toBooleanArray()
|
||||||
) { _, i, value ->
|
) { selectedItems ->
|
||||||
set[i] = value
|
for (i in selectedItems.indices) {
|
||||||
|
set[i] = selectedItems[i]
|
||||||
}
|
}
|
||||||
setPositiveButton("Done") { _, _ ->
|
}
|
||||||
PrefManager.setVal(PrefName.HomeLayout, set)
|
.setPosButton("Done") {
|
||||||
restartApp()
|
PrefManager.setVal(PrefName.HomeLayout, set)
|
||||||
}
|
restartApp()
|
||||||
}.show()
|
}
|
||||||
dialog.window?.setDimAmount(0.8f)
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.uiSettingsSmallView.isChecked = PrefManager.getVal(PrefName.SmallView)
|
binding.uiSettingsSmallView.isChecked = PrefManager.getVal(PrefName.SmallView)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package ani.dantotsu.util
|
package ani.dantotsu.util
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
@ -21,6 +22,8 @@ class AlertDialogBuilder(private val context: Context) {
|
||||||
private var onItemSelected: ((Int) -> Unit)? = null
|
private var onItemSelected: ((Int) -> Unit)? = null
|
||||||
private var customView: View? = null
|
private var customView: View? = null
|
||||||
private var attach: ((dialog: AlertDialog) -> Unit)? = null
|
private var attach: ((dialog: AlertDialog) -> Unit)? = null
|
||||||
|
private var onDismiss: (() -> Unit)? = null
|
||||||
|
|
||||||
fun setTitle(title: String?): AlertDialogBuilder {
|
fun setTitle(title: String?): AlertDialogBuilder {
|
||||||
this.title = title
|
this.title = title
|
||||||
return this
|
return this
|
||||||
|
@ -52,11 +55,7 @@ class AlertDialogBuilder(private val context: Context) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setPosButton(
|
fun setPosButton(int: Int, formatArgs: Int? = null, onClick: (() -> Unit)? = null): AlertDialogBuilder {
|
||||||
int: Int,
|
|
||||||
formatArgs: Int? = null,
|
|
||||||
onClick: (() -> Unit)? = null
|
|
||||||
): AlertDialogBuilder {
|
|
||||||
this.posButtonTitle = context.getString(int, formatArgs)
|
this.posButtonTitle = context.getString(int, formatArgs)
|
||||||
this.onPositiveButtonClick = onClick
|
this.onPositiveButtonClick = onClick
|
||||||
return this
|
return this
|
||||||
|
@ -68,11 +67,7 @@ class AlertDialogBuilder(private val context: Context) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setNegButton(
|
fun setNegButton(int: Int, formatArgs: Int? = null, onClick: (() -> Unit)? = null): AlertDialogBuilder {
|
||||||
int: Int,
|
|
||||||
formatArgs: Int? = null,
|
|
||||||
onClick: (() -> Unit)? = null
|
|
||||||
): AlertDialogBuilder {
|
|
||||||
this.negButtonTitle = context.getString(int, formatArgs)
|
this.negButtonTitle = context.getString(int, formatArgs)
|
||||||
this.onNegativeButtonClick = onClick
|
this.onNegativeButtonClick = onClick
|
||||||
return this
|
return this
|
||||||
|
@ -84,11 +79,7 @@ class AlertDialogBuilder(private val context: Context) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setNeutralButton(
|
fun setNeutralButton(int: Int, formatArgs: Int? = null, onClick: (() -> Unit)? = null): AlertDialogBuilder {
|
||||||
int: Int,
|
|
||||||
formatArgs: Int? = null,
|
|
||||||
onClick: (() -> Unit)? = null
|
|
||||||
): AlertDialogBuilder {
|
|
||||||
this.neutralButtonTitle = context.getString(int, formatArgs)
|
this.neutralButtonTitle = context.getString(int, formatArgs)
|
||||||
this.onNeutralButtonClick = onClick
|
this.onNeutralButtonClick = onClick
|
||||||
return this
|
return this
|
||||||
|
@ -99,22 +90,19 @@ class AlertDialogBuilder(private val context: Context) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun singleChoiceItems(
|
fun onDismiss(onDismiss: (() -> Unit)? = null): AlertDialogBuilder {
|
||||||
items: Array<String>,
|
this.onDismiss = onDismiss
|
||||||
selectedItemIndex: Int = -1,
|
return this
|
||||||
onItemSelected: (Int) -> Unit
|
}
|
||||||
): AlertDialogBuilder {
|
|
||||||
|
fun singleChoiceItems(items: Array<String>, selectedItemIndex: Int = -1, onItemSelected: (Int) -> Unit): AlertDialogBuilder {
|
||||||
this.items = items
|
this.items = items
|
||||||
this.selectedItemIndex = selectedItemIndex
|
this.selectedItemIndex = selectedItemIndex
|
||||||
this.onItemSelected = onItemSelected
|
this.onItemSelected = onItemSelected
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun multiChoiceItems(
|
fun multiChoiceItems(items: Array<String>, checkedItems: BooleanArray? = null, onItemsSelected: (BooleanArray) -> Unit): AlertDialogBuilder {
|
||||||
items: Array<String>,
|
|
||||||
checkedItems: BooleanArray? = null,
|
|
||||||
onItemsSelected: (BooleanArray) -> Unit
|
|
||||||
): AlertDialogBuilder {
|
|
||||||
this.items = items
|
this.items = items
|
||||||
this.checkedItems = checkedItems ?: BooleanArray(items.size) { false }
|
this.checkedItems = checkedItems ?: BooleanArray(items.size) { false }
|
||||||
this.onItemsSelected = onItemsSelected
|
this.onItemsSelected = onItemsSelected
|
||||||
|
@ -122,6 +110,8 @@ class AlertDialogBuilder(private val context: Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun show() {
|
fun show() {
|
||||||
|
if (context is Activity && context.isFinishing) return // Ensure context is valid
|
||||||
|
|
||||||
val builder = AlertDialog.Builder(context, R.style.MyPopup)
|
val builder = AlertDialog.Builder(context, R.style.MyPopup)
|
||||||
if (title != null) builder.setTitle(title)
|
if (title != null) builder.setTitle(title)
|
||||||
if (message != null) builder.setMessage(message)
|
if (message != null) builder.setMessage(message)
|
||||||
|
@ -160,12 +150,14 @@ class AlertDialogBuilder(private val context: Context) {
|
||||||
builder.setCancelable(false)
|
builder.setCancelable(false)
|
||||||
val dialog = builder.create()
|
val dialog = builder.create()
|
||||||
attach?.invoke(dialog)
|
attach?.invoke(dialog)
|
||||||
|
dialog.setOnDismissListener {
|
||||||
|
onDismiss?.invoke()
|
||||||
|
}
|
||||||
dialog.window?.setDimAmount(0.8f)
|
dialog.window?.setDimAmount(0.8f)
|
||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.customAlertDialog(): AlertDialogBuilder {
|
fun Context.customAlertDialog(): AlertDialogBuilder {
|
||||||
return AlertDialogBuilder(this)
|
return AlertDialogBuilder(this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,6 @@
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
tools:visibility="visible"
|
tools:visibility="visible"
|
||||||
tools:ignore="HardcodedText" />
|
tools:ignore="HardcodedText" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/activityDelete"
|
android:id="@+id/activityDelete"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<!-- Define your preferences here. For example: -->
|
<!-- Define your preferences here. For example: -->
|
||||||
<CheckBoxPreference
|
z
|
||||||
android:defaultValue="true"
|
|
||||||
android:key="some_key"
|
|
||||||
android:title="Some Title" />
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue