-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46d8248
commit 49175a9
Showing
7 changed files
with
177 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
app/src/main/java/ani/dantotsu/connections/anilist/api/Feed.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package ani.dantotsu.connections.anilist.api | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class FeedResponse( | ||
@SerialName("data") | ||
val data: Data | ||
) { | ||
@Serializable | ||
data class Data( | ||
@SerialName("Page") | ||
val page: ActivityPage | ||
) | ||
} | ||
|
||
@Serializable | ||
data class ActivityPage( | ||
@SerialName("activities") | ||
val activities: List<Activity> | ||
) | ||
|
||
@Serializable | ||
data class Activity( | ||
@SerialName("__typename") | ||
val typename: String, | ||
@SerialName("id") | ||
val id: Int, | ||
@SerialName("recipientId") | ||
val recipientId: Int?, | ||
@SerialName("messengerId") | ||
val messengerId: Int?, | ||
@SerialName("userId") | ||
val userId: Int?, | ||
@SerialName("type") | ||
val type: String, | ||
@SerialName("replyCount") | ||
val replyCount: Int, | ||
@SerialName("status") | ||
val status: String?, | ||
@SerialName("progress") | ||
val progress: String?, | ||
@SerialName("text") | ||
val text: String?, | ||
@SerialName("message") | ||
val message: String?, | ||
@SerialName("siteUrl") | ||
val siteUrl: String?, | ||
@SerialName("isLocked") | ||
val isLocked: Boolean, | ||
@SerialName("isSubscribed") | ||
val isSubscribed: Boolean, | ||
@SerialName("likeCount") | ||
val likeCount: Int?, | ||
@SerialName("isLiked") | ||
val isLiked: Boolean?, | ||
@SerialName("isPinned") | ||
val isPinned: Boolean?, | ||
@SerialName("isPrivate") | ||
val isPrivate: Boolean?, | ||
@SerialName("createdAt") | ||
val createdAt: Int, | ||
@SerialName("user") | ||
val user: User?, | ||
@SerialName("media") | ||
val media: Media?, | ||
@SerialName("replies") | ||
val replies: List<Reply>?, | ||
@SerialName("likes") | ||
val likes: List<User>?, | ||
) | ||
|
||
@Serializable | ||
data class Reply( | ||
@SerialName("id") | ||
val id: Int, | ||
@SerialName("userId") | ||
val userId: Int, | ||
@SerialName("text") | ||
val text: String, | ||
@SerialName("likeCount") | ||
val likeCount: Int, | ||
@SerialName("isLiked") | ||
val isLiked: Boolean, | ||
@SerialName("createdAt") | ||
val createdAt: Int, | ||
@SerialName("user") | ||
val user: User, | ||
@SerialName("likes") | ||
val likes: List<User>?, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 46 additions & 7 deletions
53
app/src/main/java/ani/dantotsu/profile/activity/ActivityItem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,61 @@ | ||
package ani.dantotsu.profile.activity | ||
|
||
import android.content.Context | ||
import android.view.View | ||
import androidx.core.content.ContextCompat | ||
import ani.dantotsu.R | ||
import ani.dantotsu.databinding.ItemNotificationBinding | ||
import ani.dantotsu.connections.anilist.api.Activity | ||
import ani.dantotsu.databinding.ItemActivityBinding | ||
import ani.dantotsu.loadImage | ||
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.viewbinding.BindableItem | ||
import jp.wasabeef.glide.transformations.BlurTransformation | ||
|
||
class ActivityItem( | ||
): BindableItem<ItemNotificationBinding>() { | ||
private lateinit var binding: ItemNotificationBinding | ||
override fun bind(viewBinding: ItemNotificationBinding, position: Int) { | ||
private val activity: Activity, | ||
val clickCallback: (Int) -> Unit | ||
): BindableItem<ItemActivityBinding>() { | ||
private lateinit var binding: ItemActivityBinding | ||
override fun bind(viewBinding: ItemActivityBinding, position: Int) { | ||
binding = viewBinding | ||
when (activity.typename) { | ||
"ListActivity" ->{ | ||
binding.activityUserName.text = activity.user?.name | ||
binding.activityUserAvatar.loadImage(activity.user?.avatar?.medium) | ||
binding.activityTime.text = ActivityItemBuilder.getDateTime(activity.createdAt) | ||
val color = if (activity.isLiked == true) | ||
ContextCompat.getColor(binding.root.context, R.color.yt_red) | ||
else | ||
ContextCompat.getColor(binding.root.context, R.color.bg_opp) | ||
binding.activityFavorite.setColorFilter(color) | ||
|
||
binding.activityMediaName.text = activity.media?.title?.userPreferred | ||
binding.activityText.text = "${activity.user!!.name} ${activity.status} ${activity.media!!.title!!.userPreferred}" | ||
binding.activityCover.loadImage(activity.media.coverImage?.medium) | ||
val context = binding.root.context | ||
val banner = activity.media.bannerImage | ||
if (banner != null) { | ||
if (!(context as android.app.Activity).isDestroyed) | ||
Glide.with(context as Context) | ||
.load(GlideUrl(banner)) | ||
.diskCacheStrategy(DiskCacheStrategy.ALL).override(400) | ||
.apply(RequestOptions.bitmapTransform(BlurTransformation(2, 2))) | ||
.into(binding.activityBannerImage) | ||
} else { | ||
binding.activityBannerImage.setImageResource(R.drawable.linear_gradient_bg) | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun getLayout(): Int { | ||
return R.layout.item_notification | ||
return R.layout.item_activity | ||
} | ||
|
||
override fun initializeViewBinding(view: View): ItemNotificationBinding { | ||
return ItemNotificationBinding.bind(view) | ||
override fun initializeViewBinding(view: View): ItemActivityBinding { | ||
return ItemActivityBinding.bind(view) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters