chore: code cleanup
This commit is contained in:
parent
386e02a564
commit
24147e746a
198 changed files with 1367 additions and 965 deletions
|
@ -1,6 +1,5 @@
|
|||
package ani.dantotsu.profile.activity
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
|
@ -18,13 +17,8 @@ import ani.dantotsu.profile.UsersDialogFragment
|
|||
import ani.dantotsu.setAnimation
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.util.AniMarkdown.Companion.getBasicAniHTML
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.load.model.GlideUrl
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.xwray.groupie.GroupieAdapter
|
||||
import com.xwray.groupie.viewbinding.BindableItem
|
||||
import jp.wasabeef.glide.transformations.BlurTransformation
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
|
@ -108,11 +102,12 @@ class ActivityItem(
|
|||
}
|
||||
val context = binding.root.context
|
||||
val userList = arrayListOf<User>()
|
||||
activity.likes?.forEach{ i ->
|
||||
activity.likes?.forEach { i ->
|
||||
userList.add(User(i.id, i.name.toString(), i.avatar?.medium, i.bannerImage))
|
||||
}
|
||||
binding.activityLike.setOnLongClickListener{
|
||||
UsersDialogFragment().apply { userList(userList)
|
||||
binding.activityLike.setOnLongClickListener {
|
||||
UsersDialogFragment().apply {
|
||||
userList(userList)
|
||||
show(fragActivity.supportFragmentManager, "dialog")
|
||||
}
|
||||
true
|
||||
|
@ -126,8 +121,10 @@ class ActivityItem(
|
|||
binding.activityContent.visibility = View.GONE
|
||||
binding.activityBannerContainer.visibility = View.VISIBLE
|
||||
binding.activityMediaName.text = activity.media?.title?.userPreferred
|
||||
val activityText = "${activity.user!!.name} ${activity.status} ${activity.progress
|
||||
?: activity.media?.title?.userPreferred}"
|
||||
val activityText = "${activity.user!!.name} ${activity.status} ${
|
||||
activity.progress
|
||||
?: activity.media?.title?.userPreferred
|
||||
}"
|
||||
binding.activityText.text = activityText
|
||||
binding.activityCover.loadImage(cover)
|
||||
blurImage(binding.activityBannerImage, banner ?: cover)
|
||||
|
|
|
@ -5,6 +5,7 @@ import ani.dantotsu.connections.anilist.api.NotificationType
|
|||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
class ActivityItemBuilder {
|
||||
|
||||
companion object {
|
||||
|
@ -109,6 +110,7 @@ class ActivityItemBuilder {
|
|||
else -> "Just now"
|
||||
}
|
||||
}
|
||||
|
||||
1L -> "1 day ago"
|
||||
in 2..6 -> "$daysDifference days ago"
|
||||
else -> SimpleDateFormat("dd MMM yyyy", Locale.getDefault()).format(targetDate)
|
||||
|
|
|
@ -31,7 +31,8 @@ class FeedActivity : AppCompatActivity() {
|
|||
setContentView(binding.root)
|
||||
navBar = binding.feedNavBar
|
||||
val navBarMargin = if (resources.configuration.orientation ==
|
||||
Configuration.ORIENTATION_LANDSCAPE) 0 else navBarHeight
|
||||
Configuration.ORIENTATION_LANDSCAPE
|
||||
) 0 else navBarHeight
|
||||
navBar.updateLayoutParams<ViewGroup.MarginLayoutParams> { bottomMargin = navBarMargin }
|
||||
val personalTab = navBar.createTab(R.drawable.ic_round_person_24, "Following")
|
||||
val globalTab = navBar.createTab(R.drawable.ic_globe_24, "Global")
|
||||
|
@ -67,10 +68,12 @@ class FeedActivity : AppCompatActivity() {
|
|||
|
||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
val margin = if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) 0 else navBarHeight
|
||||
val params : ViewGroup.MarginLayoutParams =
|
||||
val margin =
|
||||
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) 0 else navBarHeight
|
||||
val params: ViewGroup.MarginLayoutParams =
|
||||
binding.feedViewPager.layoutParams as ViewGroup.MarginLayoutParams
|
||||
val paramsNav : ViewGroup.MarginLayoutParams = navBar.layoutParams as ViewGroup.MarginLayoutParams
|
||||
val paramsNav: ViewGroup.MarginLayoutParams =
|
||||
navBar.layoutParams as ViewGroup.MarginLayoutParams
|
||||
params.updateMargins(bottom = margin)
|
||||
paramsNav.updateMargins(bottom = margin)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import ani.dantotsu.databinding.FragmentFeedBinding
|
|||
import ani.dantotsu.media.MediaDetailsActivity
|
||||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.setBaseline
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.util.Logger
|
||||
import com.xwray.groupie.GroupieAdapter
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -57,7 +56,7 @@ class FeedFragment : Fragment() {
|
|||
|
||||
val navBar = if (userId != null) {
|
||||
(activity as ProfileActivity).navBar
|
||||
}else{
|
||||
} else {
|
||||
(activity as FeedActivity).navBar
|
||||
}
|
||||
binding.listRecyclerView.setBaseline(navBar)
|
||||
|
@ -74,7 +73,7 @@ class FeedFragment : Fragment() {
|
|||
binding.root.requestLayout()
|
||||
val navBar = if (userId != null) {
|
||||
(activity as ProfileActivity).navBar
|
||||
}else{
|
||||
} else {
|
||||
(activity as FeedActivity).navBar
|
||||
}
|
||||
binding.listRecyclerView.setBaseline(navBar)
|
||||
|
@ -85,10 +84,17 @@ class FeedFragment : Fragment() {
|
|||
withContext(Dispatchers.Main) {
|
||||
res?.data?.page?.activities?.let { activities ->
|
||||
activityList = activities
|
||||
val filtered = activityList.filterNot { //filter out messages that are not directed to the user
|
||||
it.recipient?.id != null && it.recipient.id != Anilist.userid
|
||||
}
|
||||
adapter.update(filtered.map { ActivityItem(it, ::onActivityClick,requireActivity()) })
|
||||
val filtered =
|
||||
activityList.filterNot { //filter out messages that are not directed to the user
|
||||
it.recipient?.id != null && it.recipient.id != Anilist.userid
|
||||
}
|
||||
adapter.update(filtered.map {
|
||||
ActivityItem(
|
||||
it,
|
||||
::onActivityClick,
|
||||
requireActivity()
|
||||
)
|
||||
})
|
||||
}
|
||||
binding.listProgressBar.visibility = ViewGroup.GONE
|
||||
val scrollView = binding.listRecyclerView
|
||||
|
@ -134,7 +140,13 @@ class FeedFragment : Fragment() {
|
|||
val filtered = activities.filterNot {
|
||||
it.recipient?.id != null && it.recipient.id != Anilist.userid
|
||||
}
|
||||
adapter.addAll(filtered.map { ActivityItem(it, ::onActivityClick,requireActivity()) })
|
||||
adapter.addAll(filtered.map {
|
||||
ActivityItem(
|
||||
it,
|
||||
::onActivityClick,
|
||||
requireActivity()
|
||||
)
|
||||
})
|
||||
}
|
||||
binding.feedSwipeRefresh.isRefreshing = false
|
||||
onFinish()
|
||||
|
@ -150,6 +162,7 @@ class FeedFragment : Fragment() {
|
|||
.putExtra("userId", id), null
|
||||
)
|
||||
}
|
||||
|
||||
"MEDIA" -> {
|
||||
ContextCompat.startActivity(
|
||||
activity, Intent(activity, MediaDetailsActivity::class.java)
|
||||
|
|
|
@ -22,7 +22,6 @@ import ani.dantotsu.notifications.comment.CommentStore
|
|||
import ani.dantotsu.profile.ProfileActivity
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.snackString
|
||||
import ani.dantotsu.statusBarHeight
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.util.Logger
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package ani.dantotsu.profile.activity
|
||||
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.blurImage
|
||||
import ani.dantotsu.connections.anilist.api.Notification
|
||||
|
@ -60,7 +58,8 @@ class NotificationItem(
|
|||
}
|
||||
binding.notificationBannerImage.layoutParams.height = userHeight
|
||||
binding.notificationGradiant.layoutParams.height = userHeight
|
||||
(binding.notificationTextContainer.layoutParams as ViewGroup.MarginLayoutParams).marginStart = userHeight
|
||||
(binding.notificationTextContainer.layoutParams as ViewGroup.MarginLayoutParams).marginStart =
|
||||
userHeight
|
||||
} else {
|
||||
binding.notificationCover.visibility = View.VISIBLE
|
||||
binding.notificationCoverUser.visibility = View.VISIBLE
|
||||
|
@ -68,7 +67,8 @@ class NotificationItem(
|
|||
binding.notificationCover.loadImage(notification.media?.coverImage?.large)
|
||||
binding.notificationBannerImage.layoutParams.height = defaultHeight
|
||||
binding.notificationGradiant.layoutParams.height = defaultHeight
|
||||
(binding.notificationTextContainer.layoutParams as ViewGroup.MarginLayoutParams).marginStart = textMarginStart
|
||||
(binding.notificationTextContainer.layoutParams as ViewGroup.MarginLayoutParams).marginStart =
|
||||
textMarginStart
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,9 @@ class NotificationItem(
|
|||
if (notification.commentId != null && notification.mediaId != null) {
|
||||
binding.notificationBannerImage.setOnClickListener {
|
||||
clickCallback(
|
||||
notification.mediaId, notification.commentId, NotificationClickType.COMMENT
|
||||
notification.mediaId,
|
||||
notification.commentId,
|
||||
NotificationClickType.COMMENT
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue