Commit e39640f0 authored by Varun Patil's avatar Varun Patil

Refactore resizeImageUrl into Helpers

parent 40fa5576
......@@ -53,9 +53,4 @@ public class Constants {
public static final double MAP_Xn = 19.134417, MAP_Yn = 72.901229, MAP_Zn = 1757, MAP_Zyn = 501;
public static final double[] MAP_WEIGHTS_X = {-11.392001766454612, -36.31634553309953, 73.91269388324432, -24.14021153064087, 3.4508817531539115, -0.1462262375477863, 5.532505074667804, -1.542391995870977, 36.14211738142935};
public static final double[] MAP_WEIGHTS_Y = {0.09738953520399705, -4.519868444089616, 62.38493718381985, 16.664561869057696, -2.168377988768651, 0.0919143297622087, 0.32304266159540823, 0.21688067854428716, -12.81393255320748};
public static final String resizeImageUrl(String url, Integer dim) {
if (url == null) { return url; }
return url.replace("api.insti.app/static/", "img.insti.app/static/" + dim.toString() + "/");
}
}
......@@ -10,7 +10,7 @@ import java.time.Instant;
public final class Helpers {
public static final void loadImageWithPlaceholder(final ImageView imageView, final String url) {
Picasso.get()
.load(Constants.resizeImageUrl(url, 200))
.load(resizeImageUrl(url))
.into(imageView, new Callback() {
@Override
public void onSuccess() {
......@@ -23,4 +23,13 @@ public final class Helpers {
public void onError(Exception ex) {}
});
}
public static final String resizeImageUrl(String url) {
return resizeImageUrl(url, 200);
}
public static final String resizeImageUrl(String url, Integer dim) {
if (url == null) { return url; }
return url.replace("api.insti.app/static/", "img.insti.app/static/" + dim.toString() + "/");
}
}
......@@ -138,7 +138,7 @@ public class InstiAppFirebaseMessagingService extends FirebaseMessagingService {
Bitmap largeIcon = null;
if (largeIconUrl != null) {
largeIcon = getCroppedBitmap(
Picasso.get().load(Constants.resizeImageUrl(largeIconUrl, 200)).get(), 200);
Picasso.get().load(Helpers.resizeImageUrl(largeIconUrl)).get(), 200);
}
bitmaps = new Bitmap[]{image, largeIcon};
} catch (IOException e) {
......
......@@ -17,6 +17,7 @@ import com.squareup.picasso.Picasso;
import java.util.List;
import app.insti.Constants;
import app.insti.Helpers;
import app.insti.R;
import app.insti.api.model.Body;
import app.insti.fragment.BodyFragment;
......@@ -72,7 +73,7 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> {
holder.name.setText(body.getBodyName());
holder.description.setText(body.getBodyShortDescription());
Picasso.get().load(
Constants.resizeImageUrl(body.getBodyImageURL(), 200)
Helpers.resizeImageUrl(body.getBodyImageURL())
).into(holder.image);
}
......
......@@ -137,7 +137,7 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
Helpers.loadImageWithPlaceholder(viewHolder.eventBigPicture, currentEvent.getEventImageURL());
} else {
Picasso.get().load(
Constants.resizeImageUrl(currentEvent.getEventImageURL(), 200)
Helpers.resizeImageUrl(currentEvent.getEventImageURL())
).into(viewHolder.eventPicture);
}
}
......
......@@ -14,6 +14,7 @@ import com.squareup.picasso.Picasso;
import java.util.List;
import app.insti.Constants;
import app.insti.Helpers;
import app.insti.interfaces.ItemClickListener;
import app.insti.R;
import app.insti.api.model.Event;
......@@ -55,13 +56,13 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
if (appNotification.getNotificationActorType().contains("event")) {
Event event = gson.fromJson(gson.toJson(appNotification.getNotificationActor()), Event.class);
Picasso.get().load(
Constants.resizeImageUrl(event.getEventImageURL(), 200)
Helpers.resizeImageUrl(event.getEventImageURL())
).into(viewholder.notificationPicture);
viewholder.notificationTitle.setText(event.getEventName());
} else if (appNotification.getNotificationActorType().contains("newsentry")) {
NewsArticle article = gson.fromJson(gson.toJson(appNotification.getNotificationActor()), NewsArticle.class);
Picasso.get().load(
Constants.resizeImageUrl(article.getBody().getBodyImageURL(), 200)
Helpers.resizeImageUrl(article.getBody().getBodyImageURL())
).into(viewholder.notificationPicture);
viewholder.notificationTitle.setText(article.getTitle());
} else if (appNotification.getNotificationActorType().contains("blogentry")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment