fix(social): crash when clicking story
This commit is contained in:
parent
7ecdbfd42f
commit
90e611dc4f
4 changed files with 79 additions and 52 deletions
|
@ -13,6 +13,7 @@ import ani.dantotsu.initActivity
|
|||
import ani.dantotsu.others.getSerialized
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
import ani.dantotsu.home.status.listener.StoriesCallback
|
||||
import ani.dantotsu.media.Media
|
||||
import ani.dantotsu.navBarHeight
|
||||
import ani.dantotsu.profile.User
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
|
@ -32,7 +33,7 @@ class StatusActivity : AppCompatActivity(), StoriesCallback {
|
|||
initActivity(this)
|
||||
binding = ActivityStatusBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
activity = intent.getSerialized("user")!!
|
||||
activity = user
|
||||
position = intent.getIntExtra("position", -1)
|
||||
binding.root.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
topMargin = statusBarHeight
|
||||
|
@ -85,5 +86,7 @@ class StatusActivity : AppCompatActivity(), StoriesCallback {
|
|||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
var user: ArrayList<User> = arrayListOf()
|
||||
}
|
||||
}
|
|
@ -11,22 +11,21 @@ import ani.dantotsu.profile.ProfileActivity
|
|||
import ani.dantotsu.profile.User
|
||||
import ani.dantotsu.setAnimation
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import java.io.Serializable
|
||||
|
||||
class UserStatus(private val user: ArrayList<User>) :
|
||||
RecyclerView.Adapter< UserStatus.UsersViewHolder>() {
|
||||
RecyclerView.Adapter<UserStatus.UsersViewHolder>() {
|
||||
|
||||
inner class UsersViewHolder(val binding: ItemUserStatusBinding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
init {
|
||||
itemView.setOnClickListener {
|
||||
ContextCompat.startActivity(
|
||||
StatusActivity.user = user
|
||||
ContextCompat.startActivity(
|
||||
itemView.context,
|
||||
Intent(
|
||||
itemView.context,
|
||||
StatusActivity::class.java
|
||||
).putExtra("user", user as Serializable)
|
||||
.putExtra("position", bindingAdapterPosition),
|
||||
).putExtra("position", bindingAdapterPosition),
|
||||
null
|
||||
)
|
||||
}
|
||||
|
@ -61,7 +60,8 @@ class UserStatus(private val user: ArrayList<User>) :
|
|||
b.profileUserAvatar.loadImage(user.pfp)
|
||||
b.profileUserName.text = user.name
|
||||
|
||||
val watchedActivityIds = PrefManager.getCustomVal<Set<Int>>("${user.id}_activities", setOf())
|
||||
val watchedActivityIds =
|
||||
PrefManager.getCustomVal<Set<Int>>("${user.id}_activities", setOf())
|
||||
val activityIdToStatusList = user.activity.map { watchedActivityIds.contains(it.id) }
|
||||
b.profileUserStatusIndicator.setParts(user.activity.size, activityIdToStatusList)
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ import ani.dantotsu.profile.User
|
|||
import ani.dantotsu.profile.UsersDialogFragment
|
||||
import ani.dantotsu.profile.activity.ActivityItemBuilder
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.snackString
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -52,6 +53,7 @@ constructor(
|
|||
private lateinit var rightTouchPanel: FrameLayout
|
||||
private lateinit var statusUserContainer: LinearLayout
|
||||
private lateinit var imageContentView: ImageView
|
||||
private lateinit var imageContentViewKen: ImageView
|
||||
private lateinit var loadingView: ProgressBar
|
||||
private lateinit var activityLikeCount: TextView
|
||||
private lateinit var activityLike: ImageView
|
||||
|
@ -84,6 +86,7 @@ constructor(
|
|||
leftTouchPanel = findViewById(R.id.leftTouchPanel)
|
||||
rightTouchPanel = findViewById(R.id.rightTouchPanel)
|
||||
imageContentView = findViewById(R.id.contentImageView)
|
||||
imageContentViewKen = findViewById(R.id.contentImageViewKen)
|
||||
statusUserContainer = findViewById(R.id.statusUserContainer)
|
||||
loadingView = findViewById(R.id.androidStoriesLoadingView)
|
||||
coverImage = findViewById(R.id.coverImage)
|
||||
|
@ -369,7 +372,9 @@ constructor(
|
|||
private fun loadStory(story: Activity) {
|
||||
loadingView.visibility = View.GONE
|
||||
animation.start()
|
||||
blurImage(imageContentView, story.media?.bannerImage ?: story.media?.coverImage?.extraLarge)
|
||||
val bannerAnimations: Boolean = PrefManager.getVal(PrefName.BannerAnimations)
|
||||
|
||||
blurImage(if (bannerAnimations)imageContentViewKen else imageContentView, story.media?.bannerImage ?: story.media?.coverImage?.extraLarge)
|
||||
userAvatar.loadImage(story.user?.avatar?.large)
|
||||
coverImage.loadImage(story.media?.coverImage?.extraLarge)
|
||||
userName.text = story.user?.name
|
||||
|
@ -381,7 +386,12 @@ constructor(
|
|||
else {
|
||||
it.toString()
|
||||
}
|
||||
}} ${story.progress ?: story.media?.title?.userPreferred}"
|
||||
}} ${story.progress ?: story.media?.title?.userPreferred} " +
|
||||
if (story.status?.contains("Completed") != false) {
|
||||
"of ${story.media?.title?.userPreferred}"
|
||||
}else {
|
||||
""
|
||||
}
|
||||
infoText.text = text
|
||||
|
||||
statusUserContainer.setOnClickListener {
|
||||
|
|
|
@ -6,6 +6,14 @@
|
|||
android:layout_height="match_parent"
|
||||
tools:ignore="ContentDescription">
|
||||
|
||||
<com.flaviofaria.kenburnsview.KenBurnsView
|
||||
android:id="@+id/contentImageViewKen"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
tools:ignore="ContentDescription"
|
||||
tools:src="@tools:sample/backgrounds/scenic" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/contentImageView"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -13,6 +21,11 @@
|
|||
android:adjustViewBounds="true"
|
||||
android:scaleType="centerCrop" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:src="@drawable/linear_gradient_bg"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/leftTouchPanel"
|
||||
|
@ -81,6 +94,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:ellipsize="end"
|
||||
android:textColor="@color/bg_opp"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:paddingTop="1dp"
|
||||
android:paddingBottom="0dp"
|
||||
|
@ -111,31 +125,7 @@
|
|||
android:textSize="14sp"
|
||||
tools:ignore="HardcodedText,RtlSymmetry" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/statusUserActions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="24dp"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/activityLike"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_round_favorite_24"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/activityLikeCount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:textSize="15sp"
|
||||
tools:text="12" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -143,10 +133,10 @@
|
|||
android:id="@+id/itemCompactCard"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="124dp"
|
||||
android:translationZ="8dp"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:cardElevation="4dp"
|
||||
android:layout_marginBottom="124dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
@ -163,39 +153,63 @@
|
|||
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:layout_marginTop="124dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:backgroundTint="@color/transparent"
|
||||
app:cardCornerRadius="124dp"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginBottom="32dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/itemCompactCard"
|
||||
app:strokeColor="@color/transparent">
|
||||
app:layout_constraintStart_toStartOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/infoText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/colorSurfaceVariant"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start"
|
||||
android:ellipsize="marquee"
|
||||
android:paddingHorizontal="12dp"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:layout_marginStart="12dp"
|
||||
android:lineSpacingExtra="-8sp"
|
||||
android:maxLines="3"
|
||||
android:textAlignment="center"
|
||||
android:paddingHorizontal="12dp"
|
||||
android:textAlignment="textStart"
|
||||
android:textColor="@color/bg_opp"
|
||||
android:textSize="24dp"
|
||||
android:textSize="16dp"
|
||||
android:transitionName="mediaTitle"
|
||||
tools:ignore="SpUsage"
|
||||
tools:text="@string/slogan" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/statusUserActions"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:paddingHorizontal="24dp"
|
||||
tools:ignore="UseCompoundDrawables">
|
||||
<TextView
|
||||
android:id="@+id/activityLikeCount"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:textSize="15sp"
|
||||
tools:text="12" />
|
||||
<ImageView
|
||||
android:id="@+id/activityLike"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:src="@drawable/ic_round_favorite_24"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/androidStoriesLoadingView"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue