mirror of
https://github.com/accelforce/Yuito
synced 2024-12-25 23:32:38 +01:00
upgrade glide (#1489)
This commit is contained in:
parent
85843320d1
commit
fd1fcf3b97
@ -152,9 +152,8 @@ dependencies {
|
|||||||
implementation 'androidx.paging:paging-runtime-ktx:2.1.0'
|
implementation 'androidx.paging:paging-runtime-ktx:2.1.0'
|
||||||
|
|
||||||
//Glide
|
//Glide
|
||||||
implementation 'com.github.bumptech.glide:glide:4.9.0'
|
implementation 'com.github.bumptech.glide:glide:4.10.0'
|
||||||
implementation 'com.github.bumptech.glide:okhttp3-integration:4.9.0'
|
implementation 'com.github.bumptech.glide:okhttp3-integration:4.10.0'
|
||||||
implementation 'jp.wasabeef:glide-transformations:3.1.1' // intentionally use 3.x version because of 2mb smaller apk
|
|
||||||
|
|
||||||
//Add some useful extensions
|
//Add some useful extensions
|
||||||
implementation 'androidx.core:core-ktx:1.2.0-alpha01'
|
implementation 'androidx.core:core-ktx:1.2.0-alpha01'
|
||||||
|
@ -18,6 +18,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.GranularRoundedCorners;
|
||||||
import com.keylesspalace.tusky.R;
|
import com.keylesspalace.tusky.R;
|
||||||
import com.keylesspalace.tusky.entity.Card;
|
import com.keylesspalace.tusky.entity.Card;
|
||||||
import com.keylesspalace.tusky.entity.Status;
|
import com.keylesspalace.tusky.entity.Status;
|
||||||
@ -29,12 +30,9 @@ import com.keylesspalace.tusky.viewdata.StatusViewData;
|
|||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
|
|
||||||
|
|
||||||
class StatusDetailedViewHolder extends StatusBaseViewHolder {
|
class StatusDetailedViewHolder extends StatusBaseViewHolder {
|
||||||
private TextView reblogs;
|
private TextView reblogs;
|
||||||
private TextView favourites;
|
private TextView favourites;
|
||||||
@ -172,7 +170,13 @@ class StatusDetailedViewHolder extends StatusBaseViewHolder {
|
|||||||
|
|
||||||
if (!TextUtils.isEmpty(card.getImage())) {
|
if (!TextUtils.isEmpty(card.getImage())) {
|
||||||
|
|
||||||
RoundedCornersTransformation.CornerType cornertype;
|
int topLeftRadius = 0;
|
||||||
|
int topRightRadius = 0;
|
||||||
|
int bottomRightRadius = 0;
|
||||||
|
int bottomLeftRadius = 0;
|
||||||
|
|
||||||
|
int radius = cardImage.getContext().getResources()
|
||||||
|
.getDimensionPixelSize(R.dimen.card_radius);
|
||||||
|
|
||||||
if (card.getWidth() > card.getHeight()) {
|
if (card.getWidth() > card.getHeight()) {
|
||||||
cardView.setOrientation(LinearLayout.VERTICAL);
|
cardView.setOrientation(LinearLayout.VERTICAL);
|
||||||
@ -182,7 +186,8 @@ class StatusDetailedViewHolder extends StatusBaseViewHolder {
|
|||||||
cardImage.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
|
cardImage.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
cardInfo.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
|
cardInfo.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
cardInfo.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
|
cardInfo.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||||
cornertype = RoundedCornersTransformation.CornerType.TOP;
|
topLeftRadius = radius;
|
||||||
|
topRightRadius = radius;
|
||||||
} else {
|
} else {
|
||||||
cardView.setOrientation(LinearLayout.HORIZONTAL);
|
cardView.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
cardImage.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
|
cardImage.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
@ -190,15 +195,18 @@ class StatusDetailedViewHolder extends StatusBaseViewHolder {
|
|||||||
.getDimensionPixelSize(R.dimen.card_image_horizontal_width);
|
.getDimensionPixelSize(R.dimen.card_image_horizontal_width);
|
||||||
cardInfo.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
cardInfo.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||||
cardInfo.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
|
cardInfo.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||||
cornertype = RoundedCornersTransformation.CornerType.LEFT;
|
topLeftRadius = radius;
|
||||||
|
bottomLeftRadius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
int radius = cardImage.getContext().getResources()
|
|
||||||
.getDimensionPixelSize(R.dimen.card_radius);
|
|
||||||
|
|
||||||
Glide.with(cardImage)
|
Glide.with(cardImage)
|
||||||
.load(card.getImage())
|
.load(card.getImage())
|
||||||
.transform(new CenterCrop(), new RoundedCornersTransformation(radius, 0, cornertype))
|
.transform(
|
||||||
|
new CenterCrop(),
|
||||||
|
new GranularRoundedCorners(topLeftRadius, topRightRadius, bottomRightRadius, bottomLeftRadius)
|
||||||
|
)
|
||||||
.into(cardImage);
|
.into(cardImage);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user