Rolled back to old style image loading and mosaic
This commit is contained in:
parent
d6a961a977
commit
397f42a54a
76 changed files with 1560 additions and 1452 deletions
|
@ -21,8 +21,9 @@ import android.util.AttributeSet;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.glide.GlideApp;
|
||||
|
||||
/**
|
||||
* @author Hemanth S (h4h13).
|
||||
|
@ -49,7 +50,7 @@ public class NetworkImageView extends CircularImageView {
|
|||
}
|
||||
|
||||
public void setImageUrl(@NonNull Context context, @NonNull String imageUrl) {
|
||||
GlideApp.with(context)
|
||||
Glide.with(context)
|
||||
.load(imageUrl)
|
||||
.error(R.drawable.ic_account_white_24dp)
|
||||
.placeholder(R.drawable.ic_account_white_24dp)
|
||||
|
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.views;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.bumptech.glide.request.Request;
|
||||
import com.bumptech.glide.request.target.SizeReadyCallback;
|
||||
import com.bumptech.glide.request.target.Target;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import code.name.monkey.retromusic.R;
|
||||
import code.name.monkey.retromusic.glide.GlideApp;
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil;
|
||||
|
||||
import static code.name.monkey.retromusic.Constants.USER_PROFILE;
|
||||
|
||||
public class UserImageView extends CircularImageView implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public UserImageView(@NonNull Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public UserImageView(@NonNull Context context, @NonNull AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public UserImageView(@NonNull Context context, @NonNull AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context);
|
||||
}
|
||||
|
||||
void init(@NonNull Context context) {
|
||||
resetImage(context);
|
||||
}
|
||||
|
||||
private void resetImage(@NonNull Context context) {
|
||||
GlideApp.with(context)
|
||||
.asDrawable()
|
||||
.placeholder(R.drawable.ic_account_white_24dp)
|
||||
.fallback(R.drawable.ic_account_white_24dp)
|
||||
.load(new File(PreferenceUtil.getInstance(context).getProfileImage(), USER_PROFILE))
|
||||
.into(new Target<Drawable>() {
|
||||
@Override
|
||||
public void onLoadStarted(@Nullable Drawable placeholder) {
|
||||
setImageDrawable(placeholder);
|
||||
setBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
setImageDrawable(errorDrawable);
|
||||
setBackgroundColor(Color.TRANSPARENT);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
|
||||
setImageDrawable(resource);
|
||||
setBackgroundColor(Color.TRANSPARENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSize(@NonNull SizeReadyCallback cb) {
|
||||
cb.onSizeReady(96, 96);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCallback(@NonNull SizeReadyCallback cb) {
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Request getRequest() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRequest(@Nullable Request request) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
PreferenceManager.getDefaultSharedPreferences(getContext()).unregisterOnSharedPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(@NonNull SharedPreferences sharedPreferences, @NonNull String key) {
|
||||
if (key.equals(PreferenceUtil.PROFILE_IMAGE_PATH)) {
|
||||
resetImage(getContext());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue