diff --git a/app/build.gradle b/app/build.gradle index bf6d68a..c42f230 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -92,7 +92,7 @@ dependencies { kapt "androidx.hilt:hilt-compiler:1.0.0" //firebase - implementation 'com.google.firebase:firebase-crashlytics:18.3.0' + implementation 'com.google.firebase:firebase-crashlytics:18.3.1' implementation 'com.google.firebase:firebase-analytics:21.2.0' implementation 'com.google.firebase:firebase-messaging-ktx:23.1.0' @@ -102,8 +102,9 @@ dependencies { //youtube library implementation files('libs/YouTubeAndroidPlayerApi.jar') - //expandable textview + //expandable textview and time ago implementation 'io.github.glailton.expandabletextview:expandabletextview:1.0.2' + implementation 'com.github.marlonlom:timeago:4.0.3' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' diff --git a/app/src/main/java/com/yohannes/dev/app/okami/adapters/PostPagedAdapter.kt b/app/src/main/java/com/yohannes/dev/app/okami/adapters/PostPagedAdapter.kt index a682b32..4bb5d09 100644 --- a/app/src/main/java/com/yohannes/dev/app/okami/adapters/PostPagedAdapter.kt +++ b/app/src/main/java/com/yohannes/dev/app/okami/adapters/PostPagedAdapter.kt @@ -1,5 +1,6 @@ package com.yohannes.dev.app.okami.adapters +import android.annotation.SuppressLint import android.os.Build import android.text.Html import android.util.Log @@ -9,8 +10,12 @@ import androidx.paging.PagingDataAdapter import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.RecyclerView import coil.load +import com.github.marlonlom.utilities.timeago.TimeAgo import com.github.yohannestz.kraw.models.PostData import com.yohannes.dev.app.okami.databinding.PostListingItemBinding +import java.text.DateFormat +import java.text.SimpleDateFormat +import java.util.* class PostPagedAdapter: PagingDataAdapter(diffCallback) { @@ -19,7 +24,7 @@ class PostPagedAdapter: PagingDataAdapter() { override fun areItemsTheSame(oldItem: PostData, newItem: PostData): Boolean { - return oldItem == newItem + return oldItem.postId == newItem.postId } override fun areContentsTheSame(oldItem: PostData, newItem: PostData): Boolean { @@ -28,20 +33,42 @@ class PostPagedAdapter: PagingDataAdapter= Build.VERSION_CODES.N) { + Html.fromHtml(post?.contentFormatted, Html.FROM_HTML_MODE_COMPACT) + } else { + Html.fromHtml(post?.contentFormatted) + } + postItemUserProfile.load(user?.coverImage?.tiny) { + crossfade(true) + crossfade(500) + } + } } override fun onCreateViewHolder( diff --git a/app/src/main/res/layout/post_listing_item.xml b/app/src/main/res/layout/post_listing_item.xml index f02c0c7..c7fe46d 100644 --- a/app/src/main/res/layout/post_listing_item.xml +++ b/app/src/main/res/layout/post_listing_item.xml @@ -9,7 +9,7 @@ android:layout_height="wrap_content" android:layout_margin="5dp" app:cardCornerRadius="8dp" - card_view:cardElevation="5dp"> + card_view:cardElevation="2dp"> + + + + + + + + + @@ -87,7 +114,8 @@ android:id="@+id/postItemLikeButton" android:layout_width="wrap_content" android:layout_height="wrap_content" - style="@style/Widget.AppCompat.Button.Borderless.Colored" + tools:style="" + style="@style/ClickableButton" android:layout_weight="1" android:text="Like" android:textSize="16sp" @@ -97,12 +125,13 @@ diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 32a48d6..e99ce9c 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -44,6 +44,12 @@ true + +