mirror of
https://gitlab.shinice.net/pixeldroid/PixelDroid
synced 2025-02-03 17:07:31 +01:00
Better sensitive profiles (#230)
Stop using the sensitive icon as the placeholder for every post, but only load it for actually sensitive posts.
This commit is contained in:
parent
34f3d12dbc
commit
b01922126f
@ -1,14 +1,16 @@
|
||||
package com.h.pixeldroid.adapters
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.content.res.AppCompatResources.getDrawable
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.h.pixeldroid.PostActivity
|
||||
import com.h.pixeldroid.R
|
||||
import com.h.pixeldroid.objects.Status
|
||||
import com.h.pixeldroid.utils.ImageConverter.Companion.setSquareImageFromDrawable
|
||||
import com.h.pixeldroid.utils.ImageConverter.Companion.setSquareImageFromURL
|
||||
|
||||
/**
|
||||
@ -33,7 +35,7 @@ class ProfilePostsRecyclerViewAdapter: RecyclerView.Adapter<ProfilePostsRecycler
|
||||
val post = posts[position]
|
||||
|
||||
if (post.sensitive!!)
|
||||
setSquareImageFromURL(holder.postView, null, holder.postPreview)
|
||||
setSquareImageFromDrawable(holder.postView, getDrawable(holder.postView.context, R.drawable.ic_sensitive), holder.postPreview)
|
||||
else
|
||||
setSquareImageFromURL(holder.postView, post.getPostPreviewURL(), holder.postPreview)
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.h.pixeldroid.utils
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@ -8,6 +9,7 @@ import androidx.fragment.app.FragmentActivity
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.h.pixeldroid.R
|
||||
import java.io.File
|
||||
|
||||
class ImageConverter {
|
||||
companion object {
|
||||
@ -70,6 +72,18 @@ class ImageConverter {
|
||||
*/
|
||||
fun setSquareImageFromURL(view : View, url : String?, image : ImageView) {
|
||||
Glide.with(view).load(url).apply(RequestOptions().centerCrop()).into(image)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Loads a given image (via url) as a square image into a given image view
|
||||
* @param view, the view in which this is happening
|
||||
* @param drawable, the drawable of the image
|
||||
* @param image, the imageView into which we will load the image
|
||||
*/
|
||||
fun setSquareImageFromDrawable(view : View, drawable : Drawable?, image : ImageView) {
|
||||
Glide.with(view).load(drawable).apply(RequestOptions().centerCrop()).into(image)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
5
app/src/main/res/drawable/ic_sensitive.xml
Normal file
5
app/src/main/res/drawable/ic_sensitive.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#E60600"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M1,21h22L12,2 1,21zM13,18h-2v-2h2v2zM13,14h-2v-4h2v4z"/>
|
||||
</vector>
|
@ -14,10 +14,6 @@
|
||||
android:id="@+id/postPreview"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_gravity="center"
|
||||
android:adjustViewBounds="false"
|
||||
android:background="@android:drawable/stat_sys_warning"
|
||||
android:backgroundTint="#780000"
|
||||
android:contentDescription="TODO" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
Loading…
x
Reference in New Issue
Block a user