use of androidx.annotation.Nullable in project MovieGuide by esoxjem.
the class MoviesListingAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
holder.itemView.setOnClickListener(holder);
holder.movie = movies.get(position);
holder.name.setText(holder.movie.getTitle());
RequestOptions options = new RequestOptions().centerCrop().diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).priority(Priority.HIGH);
Glide.with(context).asBitmap().load(Api.getPosterPath(holder.movie.getPosterPath())).apply(options).into(new BitmapImageViewTarget(holder.poster) {
@Override
public void onResourceReady(Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
super.onResourceReady(bitmap, transition);
Palette.from(bitmap).generate(palette -> setBackgroundColor(palette, holder));
}
});
}
use of androidx.annotation.Nullable in project fresco by facebook.
the class HierarcherImpl method buildProgressDrawable.
@Override
@Nullable
public Drawable buildProgressDrawable(Resources resources, ImageOptions imageOptions) {
if (FrescoSystrace.isTracing()) {
FrescoSystrace.beginSection("HierarcherImpl#buildProgressDrawable");
}
try {
if (imageOptions.getProgressRes() == 0 && imageOptions.getProgressDrawable() == null) {
return null;
}
Drawable progressDrawable = imageOptions.getProgressDrawable();
if (progressDrawable == null) {
progressDrawable = resources.getDrawable(imageOptions.getProgressRes());
}
if (progressDrawable == null) {
return null;
}
progressDrawable.setLevel(0);
if (imageOptions.getProgressScaleType() != null) {
return new ScaleTypeDrawable(progressDrawable, imageOptions.getProgressScaleType());
}
return progressDrawable;
} finally {
if (FrescoSystrace.isTracing()) {
FrescoSystrace.endSection();
}
}
}
use of androidx.annotation.Nullable in project fresco by facebook.
the class FrescoDrawable2 method setOverlayDrawable.
@Override
@Nullable
public Drawable setOverlayDrawable(@Nullable Drawable drawable) {
Drawable result = setDrawable(OVERLAY_DRAWABLE_INDEX, drawable);
showLayerImmediately(OVERLAY_DRAWABLE_INDEX);
return result;
}
use of androidx.annotation.Nullable in project Lightning-Browser by anthonycr.
the class ArticleTextExtractor method determineImageSource.
@Nullable
private static Element determineImageSource(@NonNull Element el, @NonNull List<ImageResult> images) {
int maxWeight = 0;
Element maxNode = null;
Elements els = el.select("img");
if (els.isEmpty())
els = el.parent().select("img");
double score = 1;
for (Element e : els) {
String sourceUrl = e.attr("src");
if (sourceUrl.isEmpty() || isAdImage(sourceUrl))
continue;
int weight = 0;
int height = 0;
try {
height = Integer.parseInt(e.attr("height"));
if (height >= 50)
weight += 20;
else
weight -= 20;
} catch (Exception ignored) {
}
int width = 0;
try {
width = Integer.parseInt(e.attr("width"));
if (width >= 50)
weight += 20;
else
weight -= 20;
} catch (Exception ignored) {
}
String alt = e.attr("alt");
if (alt.length() > 35)
weight += 20;
String title = e.attr("title");
if (title.length() > 35)
weight += 20;
String rel;
boolean noFollow = false;
if (e.parent() != null) {
rel = e.parent().attr("rel");
if (rel != null && rel.contains("nofollow")) {
noFollow = rel.contains("nofollow");
weight -= 40;
}
}
weight = (int) (weight * score);
if (weight > maxWeight) {
maxWeight = weight;
maxNode = e;
score = score / 2;
}
ImageResult image = new ImageResult(sourceUrl, weight, title, height, width, alt, noFollow);
images.add(image);
}
Collections.sort(images, new ImageComparator());
return maxNode;
}
use of androidx.annotation.Nullable in project Lightning-Browser by anthonycr.
the class ArticleTextExtractor method getBestMatchElement.
// Returns the best node match based on the weights (see getWeight for strategy)
@Nullable
private Element getBestMatchElement(@NonNull Collection<Element> nodes) {
// why -200 now instead of 0?
int maxWeight = -200;
Element bestMatchElement = null;
for (Element entry : nodes) {
int currentWeight = getWeight(entry, false);
if (currentWeight > maxWeight) {
maxWeight = currentWeight;
bestMatchElement = entry;
/*
// NOTE: This optimization fails with large pages that
contains chunks of text that can be mistaken by articles, since we
want the best accuracy possible, I am disabling it for now. AP.
// The original code had a limit of 200, the intention was that
// if a node had a weight greater than it, then it most likely
// it was the main content.
// However this assumption fails when the amount of text in the
// children (or grandchildren) is too large. If we detect this
// case then the limit is ignored and we try all the nodes to select
// the one with the absolute maximum weight.
if (maxWeight > 500){
ignoreMaxWeightLimit = true;
continue;
}
// formerly 200, increased to 250 to account for the fact
// we are not adding the weights of the grand children to the
// tally.
if (maxWeight > 250 && !ignoreMaxWeightLimit)
break;
*/
}
}
return bestMatchElement;
}
Aggregations