replace UIL with Glide
This commit is contained in:
parent
e45c7adda6
commit
edc1b66f70
@ -28,7 +28,8 @@ dependencies {
|
|||||||
compile project(':taskerlocaleapi')
|
compile project(':taskerlocaleapi')
|
||||||
compile files('libs/dashclock-api-r1.1.jar')
|
compile files('libs/dashclock-api-r1.1.jar')
|
||||||
compile 'org.jsoup:jsoup:1.10.2'
|
compile 'org.jsoup:jsoup:1.10.2'
|
||||||
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
|
compile 'com.github.bumptech.glide:glide:3.8.0'
|
||||||
|
compile 'jp.wasabeef:glide-transformations:2.0.2'
|
||||||
compile 'com.android.support:cardview-v7:25.3.1'
|
compile 'com.android.support:cardview-v7:25.3.1'
|
||||||
compile 'com.android.support:support-v4:25.3.1'
|
compile 'com.android.support:support-v4:25.3.1'
|
||||||
compile 'com.android.support:appcompat-v7:25.3.1'
|
compile 'com.android.support:appcompat-v7:25.3.1'
|
||||||
|
@ -26,11 +26,12 @@ import android.widget.PopupMenu;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
import com.ToxicBakery.viewpager.transforms.DepthPageTransformer;
|
import com.ToxicBakery.viewpager.transforms.DepthPageTransformer;
|
||||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
import com.bumptech.glide.Glide;
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
import com.nostra13.universalimageloader.core.assist.FailReason;
|
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
||||||
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
import com.bumptech.glide.request.RequestListener;
|
||||||
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
|
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
|
||||||
|
import com.bumptech.glide.request.target.Target;
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
@ -39,6 +40,7 @@ import org.jsoup.select.Elements;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import it.sephiroth.android.library.imagezoom.ImageViewTouch;
|
import it.sephiroth.android.library.imagezoom.ImageViewTouch;
|
||||||
import me.relex.circleindicator.CircleIndicator;
|
import me.relex.circleindicator.CircleIndicator;
|
||||||
@ -140,48 +142,40 @@ public class ArticleImagesPagerActivity extends CommonActivity implements Gestur
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
DisplayImageOptions options = new DisplayImageOptions.Builder()
|
|
||||||
.cacheInMemory(true)
|
|
||||||
.resetViewBeforeLoading(true)
|
|
||||||
.cacheOnDisk(true)
|
|
||||||
.displayer(new FadeInBitmapDisplayer(200))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.flavor_image_progress);
|
final ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.flavor_image_progress);
|
||||||
final View errorMessage = view.findViewById(R.id.flavor_image_error);
|
final View errorMessage = view.findViewById(R.id.flavor_image_error);
|
||||||
|
|
||||||
ImageLoader.getInstance().displayImage(url, imgView, options, new ImageLoadingListener() {
|
final GlideDrawableImageViewTarget glideImage = new GlideDrawableImageViewTarget(imgView);
|
||||||
@Override
|
|
||||||
public void onLoadingStarted(String s, View view) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadingFailed(String s, View view, FailReason failReason) {
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
errorMessage.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadingComplete(String s, View view, Bitmap bitmap) {
|
|
||||||
if (bitmap != null) {
|
|
||||||
view.setTag(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoadingCancelled(String s, View view) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
container.addView(view, 0);
|
container.addView(view, 0);
|
||||||
|
|
||||||
if (position == 0) {
|
Glide.with(ArticleImagesPagerActivity.this)
|
||||||
|
.load(url)
|
||||||
|
.dontAnimate()
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
|
.skipMemoryCache(false)
|
||||||
|
.listener(new RequestListener<String, GlideDrawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
errorMessage.setVisibility(View.VISIBLE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
errorMessage.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
ActivityCompat.startPostponedEnterTransition(ArticleImagesPagerActivity.this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into(glideImage);
|
||||||
|
|
||||||
|
/*if (position == 0) {
|
||||||
ActivityCompat.startPostponedEnterTransition(ArticleImagesPagerActivity.this);
|
ActivityCompat.startPostponedEnterTransition(ArticleImagesPagerActivity.this);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@ -203,18 +197,32 @@ public class ArticleImagesPagerActivity extends CommonActivity implements Gestur
|
|||||||
|
|
||||||
//Log.d(TAG, "checking: " + url);
|
//Log.d(TAG, "checking: " + url);
|
||||||
|
|
||||||
DisplayImageOptions options = new DisplayImageOptions.Builder()
|
/*DisplayImageOptions options = new DisplayImageOptions.Builder()
|
||||||
.cacheInMemory(true)
|
.cacheInMemory(true)
|
||||||
.cacheOnDisk(true)
|
.cacheOnDisk(true)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
Bitmap bmp = ImageLoader.getInstance().loadImageSync(url, options);
|
Bitmap bmp = ImageLoader.getInstance().loadImageSync(url, options); */
|
||||||
|
|
||||||
if (bmp != null && bmp.getWidth() > 128 && bmp.getHeight() > 128) {
|
try {
|
||||||
publishProgress(url, String.valueOf(position));
|
Bitmap bmp = Glide.with(ArticleImagesPagerActivity.this)
|
||||||
} else {
|
.load(url)
|
||||||
publishProgress(null, String.valueOf(position));
|
.asBitmap()
|
||||||
|
.into(-1, -1)
|
||||||
|
.get();
|
||||||
|
|
||||||
|
if (bmp != null && bmp.getWidth() > 128 && bmp.getHeight() > 128) {
|
||||||
|
publishProgress(url, String.valueOf(position));
|
||||||
|
} else {
|
||||||
|
publishProgress(null, String.valueOf(position));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,11 +32,6 @@ import android.view.View;
|
|||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiscCache;
|
|
||||||
import com.nostra13.universalimageloader.core.DefaultConfigurationFactory;
|
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
||||||
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
|
|
||||||
|
|
||||||
import org.fox.ttrss.util.DatabaseHelper;
|
import org.fox.ttrss.util.DatabaseHelper;
|
||||||
import org.fox.ttrss.widget.SmallWidgetProvider;
|
import org.fox.ttrss.widget.SmallWidgetProvider;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
@ -171,7 +166,7 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc
|
|||||||
|
|
||||||
CustomTabsClient.bindCustomTabsService(this, "com.android.chrome", m_customTabServiceConnection);
|
CustomTabsClient.bindCustomTabsService(this, "com.android.chrome", m_customTabServiceConnection);
|
||||||
|
|
||||||
if (!ImageLoader.getInstance().isInited()) {
|
/*if (!ImageLoader.getInstance().isInited()) {
|
||||||
ImageLoaderConfiguration config;
|
ImageLoaderConfiguration config;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -186,7 +181,7 @@ public class CommonActivity extends ActionBarActivity implements SharedPreferenc
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
ImageLoader.getInstance().init(config);
|
ImageLoader.getInstance().init(config);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,12 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
|
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
||||||
|
import com.bumptech.glide.request.RequestListener;
|
||||||
|
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
|
||||||
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.nhaarman.listviewanimations.appearance.AnimationAdapter;
|
import com.nhaarman.listviewanimations.appearance.AnimationAdapter;
|
||||||
import com.nhaarman.listviewanimations.appearance.simple.SwingBottomInAnimationAdapter;
|
import com.nhaarman.listviewanimations.appearance.simple.SwingBottomInAnimationAdapter;
|
||||||
@ -64,15 +70,6 @@ import com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.Dismissable
|
|||||||
import com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.OnDismissCallback;
|
import com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.OnDismissCallback;
|
||||||
import com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.undo.TimedUndoAdapter;
|
import com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.undo.TimedUndoAdapter;
|
||||||
import com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.undo.UndoAdapter;
|
import com.nhaarman.listviewanimations.itemmanipulation.swipedismiss.undo.UndoAdapter;
|
||||||
import com.nostra13.universalimageloader.core.DisplayImageOptions;
|
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
||||||
import com.nostra13.universalimageloader.core.assist.FailReason;
|
|
||||||
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
|
|
||||||
import com.nostra13.universalimageloader.core.display.RoundedBitmapDisplayer;
|
|
||||||
import com.nostra13.universalimageloader.core.imageaware.ImageAware;
|
|
||||||
import com.nostra13.universalimageloader.core.imageaware.ImageViewAware;
|
|
||||||
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
|
|
||||||
import com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener;
|
|
||||||
import com.shamanland.fab.FloatingActionButton;
|
import com.shamanland.fab.FloatingActionButton;
|
||||||
import com.shamanland.fab.ShowHideOnScroll;
|
import com.shamanland.fab.ShowHideOnScroll;
|
||||||
|
|
||||||
@ -89,6 +86,8 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
|
import jp.wasabeef.glide.transformations.CropCircleTransformation;
|
||||||
|
|
||||||
public class HeadlinesFragment extends Fragment implements OnItemClickListener, OnScrollListener {
|
public class HeadlinesFragment extends Fragment implements OnItemClickListener, OnScrollListener {
|
||||||
public enum ArticlesSelection { ALL, NONE, UNREAD }
|
public enum ArticlesSelection { ALL, NONE, UNREAD }
|
||||||
|
|
||||||
@ -122,7 +121,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
private boolean m_compactLayoutMode = false;
|
private boolean m_compactLayoutMode = false;
|
||||||
private int m_listPreviousVisibleItem;
|
private int m_listPreviousVisibleItem;
|
||||||
private DynamicListView m_list;
|
private DynamicListView m_list;
|
||||||
private ImageLoader m_imageLoader = ImageLoader.getInstance();
|
//private ImageLoader m_imageLoader = ImageLoader.getInstance();
|
||||||
private View m_listLoadingView;
|
private View m_listLoadingView;
|
||||||
private View m_topChangedView;
|
private View m_topChangedView;
|
||||||
private View m_amrFooterView;
|
private View m_amrFooterView;
|
||||||
@ -728,7 +727,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
private ColorGenerator m_colorGenerator = ColorGenerator.DEFAULT;
|
private ColorGenerator m_colorGenerator = ColorGenerator.DEFAULT;
|
||||||
private TextDrawable.IBuilder m_drawableBuilder = TextDrawable.builder().round();
|
private TextDrawable.IBuilder m_drawableBuilder = TextDrawable.builder().round();
|
||||||
private final DisplayImageOptions displayImageOptions;
|
//private final DisplayImageOptions displayImageOptions;
|
||||||
boolean showFlavorImage;
|
boolean showFlavorImage;
|
||||||
private int m_minimumHeightToEmbed;
|
private int m_minimumHeightToEmbed;
|
||||||
boolean m_youtubeInstalled;
|
boolean m_youtubeInstalled;
|
||||||
@ -750,12 +749,12 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
theme.resolveAttribute(R.attr.headlineTitleHighScoreUnreadTextColor, tv, true);
|
theme.resolveAttribute(R.attr.headlineTitleHighScoreUnreadTextColor, tv, true);
|
||||||
titleHighScoreUnreadColor = tv.data;
|
titleHighScoreUnreadColor = tv.data;
|
||||||
|
|
||||||
displayImageOptions = new DisplayImageOptions.Builder()
|
/*displayImageOptions = new DisplayImageOptions.Builder()
|
||||||
.cacheInMemory(true)
|
.cacheInMemory(true)
|
||||||
.resetViewBeforeLoading(true)
|
.resetViewBeforeLoading(true)
|
||||||
.cacheOnDisk(true)
|
.cacheOnDisk(true)
|
||||||
.displayer(new FadeInBitmapDisplayer(500))
|
.displayer(new FadeInBitmapDisplayer(500))
|
||||||
.build();
|
.build();*/
|
||||||
|
|
||||||
List<ApplicationInfo> packages = m_activity.getPackageManager().getInstalledApplications(0);
|
List<ApplicationInfo> packages = m_activity.getPackageManager().getInstalledApplications(0);
|
||||||
for (ApplicationInfo pi : packages) {
|
for (ApplicationInfo pi : packages) {
|
||||||
@ -790,22 +789,51 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
if (article.selected) {
|
if (article.selected) {
|
||||||
holder.textImage.setImageDrawable(m_drawableBuilder.build(" ", 0xff616161));
|
holder.textImage.setImageDrawable(m_drawableBuilder.build(" ", 0xff616161));
|
||||||
holder.textImage.setTag(null);
|
//holder.textImage.setTag(null);
|
||||||
|
|
||||||
holder.textChecked.setVisibility(View.VISIBLE);
|
holder.textChecked.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
final Drawable textDrawable = m_drawableBuilder.build(tmp, m_colorGenerator.getColor(article.title));
|
final Drawable textDrawable = m_drawableBuilder.build(tmp, m_colorGenerator.getColor(article.title));
|
||||||
|
|
||||||
holder.textImage.setImageDrawable(textDrawable);
|
holder.textImage.setImageDrawable(textDrawable);
|
||||||
holder.textImage.setTag(null);
|
//holder.textImage.setTag(null);
|
||||||
|
|
||||||
//holder.textChecked.setVisibility(View.GONE);
|
//holder.textChecked.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (!showFlavorImage || article.flavorImage == null) {
|
if (!showFlavorImage || article.flavorImage == null) {
|
||||||
holder.textImage.setImageDrawable(textDrawable);
|
holder.textImage.setImageDrawable(textDrawable);
|
||||||
holder.textImage.setTag(null);
|
//holder.textImage.setTag(null);
|
||||||
} else {
|
} else {
|
||||||
if (!article.flavorImageUri.equals(holder.textImage.getTag())) {
|
|
||||||
|
//final GlideDrawableImageViewTarget glideImage = new GlideDrawableImageViewTarget(holder.textImage);
|
||||||
|
|
||||||
|
Glide.with(HeadlinesFragment.this)
|
||||||
|
.load(article.flavorImageUri)
|
||||||
|
.placeholder(textDrawable)
|
||||||
|
.bitmapTransform(new CropCircleTransformation(getActivity()))
|
||||||
|
.dontAnimate()
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
|
.skipMemoryCache(false)
|
||||||
|
.listener(new RequestListener<String, GlideDrawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||||
|
|
||||||
|
if (resource.getIntrinsicWidth() < THUMB_IMG_MIN_SIZE || resource.getIntrinsicHeight() < THUMB_IMG_MIN_SIZE) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into(holder.textImage);
|
||||||
|
|
||||||
|
|
||||||
|
/* if (!article.flavorImageUri.equals(holder.textImage.getTag())) {
|
||||||
|
|
||||||
ImageAware imageAware = new ImageViewAware(holder.textImage, false);
|
ImageAware imageAware = new ImageViewAware(holder.textImage, false);
|
||||||
|
|
||||||
@ -833,7 +861,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
@Override
|
@Override
|
||||||
public void onLoadingComplete(String imageUri, View view, Bitmap bitmap) {
|
public void onLoadingComplete(String imageUri, View view, Bitmap bitmap) {
|
||||||
if (position == holder.position && bitmap != null) {
|
if (position == holder.position && bitmap != null) {
|
||||||
holder.textImage.setTag(article.flavorImageUri);
|
//holder.textImage.setTag(article.flavorImageUri);
|
||||||
|
|
||||||
if (bitmap.getWidth() < THUMB_IMG_MIN_SIZE || bitmap.getHeight() < THUMB_IMG_MIN_SIZE) {
|
if (bitmap.getWidth() < THUMB_IMG_MIN_SIZE || bitmap.getHeight() < THUMB_IMG_MIN_SIZE) {
|
||||||
holder.textImage.setImageDrawable(textDrawable);
|
holder.textImage.setImageDrawable(textDrawable);
|
||||||
@ -848,7 +876,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.textChecked.setVisibility(View.GONE);
|
holder.textChecked.setVisibility(View.GONE);
|
||||||
@ -1143,79 +1171,53 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!article.flavorImageUri.equals(holder.flavorImageView.getTag())) {
|
//Log.d(TAG, "IMG: " + article.flavorImageUri + " STREAM: " + article.flavorStreamUri);
|
||||||
|
|
||||||
//Log.d(TAG, "IMG: " + article.flavorImageUri + " STREAM: " + article.flavorStreamUri);
|
holder.flavorImageLoadingBar.setVisibility(View.VISIBLE);
|
||||||
|
holder.flavorImageLoadingBar.setIndeterminate(true);
|
||||||
|
|
||||||
ImageAware imageAware = new ImageViewAware(holder.flavorImageView, false);
|
holder.flavorImageView.setVisibility(View.VISIBLE);
|
||||||
|
holder.flavorImageView.setImageDrawable(null);
|
||||||
|
|
||||||
m_imageLoader.displayImage(article.flavorImageUri, imageAware, displayImageOptions, new ImageLoadingListener() {
|
final GlideDrawableImageViewTarget glideImage = new GlideDrawableImageViewTarget(holder.flavorImageView);
|
||||||
@Override
|
|
||||||
public void onLoadingStarted(String s, View view) {
|
|
||||||
holder.flavorImageLoadingBar.setVisibility(View.VISIBLE);
|
|
||||||
holder.flavorImageLoadingBar.setIndeterminate(false);
|
|
||||||
holder.flavorImageLoadingBar.setProgress(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
Glide.with(HeadlinesFragment.this)
|
||||||
public void onLoadingFailed(String s, View view, FailReason failReason) {
|
.load(article.flavorImageUri)
|
||||||
holder.flavorImageLoadingBar.setVisibility(View.GONE);
|
.dontAnimate()
|
||||||
}
|
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
|
.skipMemoryCache(false)
|
||||||
|
.listener(new RequestListener<String, GlideDrawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||||
|
|
||||||
@Override
|
holder.flavorImageLoadingBar.setVisibility(View.GONE);
|
||||||
public void onLoadingComplete(String imageUri, View view, Bitmap bitmap) {
|
holder.flavorImageView.setVisibility(View.GONE);
|
||||||
if (position == holder.position && bitmap != null) {
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||||
|
|
||||||
holder.flavorImageLoadingBar.setVisibility(View.GONE);
|
holder.flavorImageLoadingBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (bitmap.getWidth() > FLAVOR_IMG_MIN_SIZE && bitmap.getHeight() > FLAVOR_IMG_MIN_SIZE) {
|
holder.flavorImageOverflow.setVisibility(View.VISIBLE);
|
||||||
holder.flavorImageView.setTag(article.flavorImageUri);
|
|
||||||
|
if (resource.getIntrinsicWidth() > FLAVOR_IMG_MIN_SIZE && resource.getIntrinsicHeight() > FLAVOR_IMG_MIN_SIZE) {
|
||||||
|
|
||||||
holder.flavorImageView.setVisibility(View.VISIBLE);
|
holder.flavorImageView.setVisibility(View.VISIBLE);
|
||||||
holder.flavorImageOverflow.setVisibility(View.VISIBLE);
|
holder.flavorImageOverflow.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
maybeRepositionFlavorImage(view, bitmap, holder);
|
maybeRepositionFlavorImage(holder.flavorImageView, resource, holder);
|
||||||
adjustVideoKindView(holder, article);
|
adjustVideoKindView(holder, article);
|
||||||
|
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
holder.flavorImageView.setImageDrawable(null);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
.into(glideImage);
|
||||||
@Override
|
|
||||||
public void onLoadingCancelled(String s, View view) {
|
|
||||||
holder.flavorImageLoadingBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}, new ImageLoadingProgressListener() {
|
|
||||||
@Override
|
|
||||||
public void onProgressUpdate(String s, View view, int current, int total) {
|
|
||||||
if (total != 0) {
|
|
||||||
int p = (int) ((float) current / total * 100);
|
|
||||||
|
|
||||||
holder.flavorImageLoadingBar.setIndeterminate(false);
|
|
||||||
holder.flavorImageLoadingBar.setProgress(p);
|
|
||||||
} else {
|
|
||||||
holder.flavorImageLoadingBar.setIndeterminate(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} else { // already tagged
|
|
||||||
holder.flavorImageView.setVisibility(View.VISIBLE);
|
|
||||||
holder.flavorImageOverflow.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
adjustVideoKindView(holder, article);
|
|
||||||
|
|
||||||
if (holder.flavorImageEmbedded) {
|
|
||||||
TypedValue tv = new TypedValue();
|
|
||||||
if (m_activity.getTheme().resolveAttribute(R.attr.headlineHeaderBackground, tv, true)) {
|
|
||||||
holder.headlineHeader.setBackgroundColor(tv.data);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
holder.headlineHeader.setBackgroundDrawable(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
holder.flavorImageView.setOnClickListener(new OnClickListener() {
|
holder.flavorImageView.setOnClickListener(new OnClickListener() {
|
||||||
@ -1388,16 +1390,16 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
return px;
|
return px;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeRepositionFlavorImage(View view, Bitmap bitmap, HeadlineViewHolder holder) {
|
private void maybeRepositionFlavorImage(View view, GlideDrawable resource, HeadlineViewHolder holder) {
|
||||||
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) view.getLayoutParams();
|
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) view.getLayoutParams();
|
||||||
|
|
||||||
int w = bitmap.getWidth();
|
int w = resource.getIntrinsicWidth();
|
||||||
int h = bitmap.getHeight();
|
int h = resource.getIntrinsicHeight();
|
||||||
float r = h != 0 ? (float)w/h : 0;
|
float r = h != 0 ? (float)w/h : 0;
|
||||||
|
|
||||||
//Log.d(TAG, "XYR: " + pxToDp(w) + " " + pxToDp(h) + " " + r);
|
//Log.d(TAG, "XYR: " + pxToDp(w) + " " + pxToDp(h) + " " + r);
|
||||||
|
|
||||||
if (bitmap.getHeight() < m_minimumHeightToEmbed || r >= 1.2) {
|
if (h < m_minimumHeightToEmbed || r >= 1.2) {
|
||||||
|
|
||||||
lp.addRule(RelativeLayout.BELOW, R.id.headline_header);
|
lp.addRule(RelativeLayout.BELOW, R.id.headline_header);
|
||||||
|
|
||||||
@ -1565,12 +1567,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||||
if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING || scrollState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
|
|
||||||
m_imageLoader.pause();
|
|
||||||
} else {
|
|
||||||
m_imageLoader.resume();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scrollState == SCROLL_STATE_IDLE && m_prefs.getBoolean("headlines_mark_read_scroll", false)) {
|
if (scrollState == SCROLL_STATE_IDLE && m_prefs.getBoolean("headlines_mark_read_scroll", false)) {
|
||||||
if (!m_readArticles.isEmpty()) {
|
if (!m_readArticles.isEmpty()) {
|
||||||
m_activity.toggleArticlesUnread(m_readArticles);
|
m_activity.toggleArticlesUnread(m_readArticles);
|
||||||
|
@ -7,6 +7,7 @@ import android.app.Dialog;
|
|||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
@ -19,8 +20,8 @@ import android.view.Gravity;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
|
||||||
|
|
||||||
import org.fox.ttrss.types.Article;
|
import org.fox.ttrss.types.Article;
|
||||||
import org.fox.ttrss.types.ArticleList;
|
import org.fox.ttrss.types.ArticleList;
|
||||||
@ -241,7 +242,7 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList
|
|||||||
|
|
||||||
public void onFeedSelected(Feed feed, final boolean selectedByUser) {
|
public void onFeedSelected(Feed feed, final boolean selectedByUser) {
|
||||||
|
|
||||||
ImageLoader.getInstance().clearMemoryCache();
|
//ImageLoader.getInstance().clearMemoryCache();
|
||||||
|
|
||||||
FragmentTransaction ft = getSupportFragmentManager()
|
FragmentTransaction ft = getSupportFragmentManager()
|
||||||
.beginTransaction();
|
.beginTransaction();
|
||||||
@ -486,6 +487,16 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList
|
|||||||
|
|
||||||
Date date = new Date();
|
Date date = new Date();
|
||||||
|
|
||||||
|
if (isFinishing()) {
|
||||||
|
AsyncTask.execute(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Glide.get(MasterActivity.this).clearDiskCache();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (isFinishing() || date.getTime() - m_lastWidgetRefresh > 60*1000) {
|
if (isFinishing() || date.getTime() - m_lastWidgetRefresh > 60*1000) {
|
||||||
m_lastWidgetRefresh = date.getTime();
|
m_lastWidgetRefresh = date.getTime();
|
||||||
|
|
||||||
|
@ -22,9 +22,11 @@ import android.widget.ImageView;
|
|||||||
import android.widget.MediaController;
|
import android.widget.MediaController;
|
||||||
import android.widget.PopupMenu;
|
import android.widget.PopupMenu;
|
||||||
|
|
||||||
import com.nostra13.universalimageloader.core.ImageLoader;
|
import com.bumptech.glide.Glide;
|
||||||
import com.nostra13.universalimageloader.core.assist.FailReason;
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
||||||
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
|
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
||||||
|
import com.bumptech.glide.request.RequestListener;
|
||||||
|
import com.bumptech.glide.request.target.Target;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -71,7 +73,27 @@ public class VideoPlayerActivity extends CommonActivity {
|
|||||||
|
|
||||||
ViewCompat.setTransitionName(coverView, "gallery:" + m_coverUri);
|
ViewCompat.setTransitionName(coverView, "gallery:" + m_coverUri);
|
||||||
|
|
||||||
ImageLoader imageLoader = ImageLoader.getInstance();
|
Glide.with(this)
|
||||||
|
.load(m_coverUri)
|
||||||
|
.diskCacheStrategy(DiskCacheStrategy.ALL)
|
||||||
|
.skipMemoryCache(false)
|
||||||
|
.listener(new RequestListener<String, GlideDrawable>() {
|
||||||
|
@Override
|
||||||
|
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
|
||||||
|
ActivityCompat.startPostponedEnterTransition(VideoPlayerActivity.this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
|
||||||
|
ActivityCompat.startPostponedEnterTransition(VideoPlayerActivity.this);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.into(coverView);
|
||||||
|
|
||||||
|
|
||||||
|
/*ImageLoader imageLoader = ImageLoader.getInstance();
|
||||||
imageLoader.displayImage(m_coverUri, coverView, new ImageLoadingListener() {
|
imageLoader.displayImage(m_coverUri, coverView, new ImageLoadingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLoadingStarted(String s, View view) {
|
public void onLoadingStarted(String s, View view) {
|
||||||
@ -92,7 +114,7 @@ public class VideoPlayerActivity extends CommonActivity {
|
|||||||
public void onLoadingCancelled(String s, View view) {
|
public void onLoadingCancelled(String s, View view) {
|
||||||
ActivityCompat.startPostponedEnterTransition(VideoPlayerActivity.this);
|
ActivityCompat.startPostponedEnterTransition(VideoPlayerActivity.this);
|
||||||
}
|
}
|
||||||
});
|
});*/
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
android:max="100"
|
android:max="100"
|
||||||
android:indeterminate="false" />
|
android:indeterminate="false" />
|
||||||
|
|
||||||
<org.fox.ttrss.util.EnlargingImageView
|
<ImageView
|
||||||
android:id="@+id/flavor_image"
|
android:id="@+id/flavor_image"
|
||||||
android:foreground="@drawable/ripple"
|
android:foreground="@drawable/ripple"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
android:max="100"
|
android:max="100"
|
||||||
android:indeterminate="false" />
|
android:indeterminate="false" />
|
||||||
|
|
||||||
<org.fox.ttrss.util.EnlargingImageView
|
<ImageView
|
||||||
android:id="@+id/flavor_image"
|
android:id="@+id/flavor_image"
|
||||||
android:foreground="@drawable/ripple"
|
android:foreground="@drawable/ripple"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Loading…
Reference in New Issue
Block a user