Commit 32be4499 authored by Sajal's avatar Sajal

Move null check inside openWebURL

parent 5a474cf5
...@@ -22,9 +22,9 @@ import app.insti.fragment.EventFragment; ...@@ -22,9 +22,9 @@ import app.insti.fragment.EventFragment;
import app.insti.fragment.UserFragment; import app.insti.fragment.UserFragment;
public final class Utils { public final class Utils {
public static UpdatableList<Event> eventCache = new UpdatableList<>();
private static String sessionId; private static String sessionId;
private static RetrofitInterface retrofitInterface; private static RetrofitInterface retrofitInterface;
public static UpdatableList<Event> eventCache = new UpdatableList<>();
public static final void loadImageWithPlaceholder(final ImageView imageView, final String url) { public static final void loadImageWithPlaceholder(final ImageView imageView, final String url) {
Picasso.get() Picasso.get()
...@@ -37,8 +37,10 @@ public final class Utils { ...@@ -37,8 +37,10 @@ public final class Utils {
.placeholder(imageView.getDrawable()) .placeholder(imageView.getDrawable())
.into(imageView); .into(imageView);
} }
@Override @Override
public void onError(Exception ex) {} public void onError(Exception ex) {
}
}); });
} }
...@@ -47,11 +49,15 @@ public final class Utils { ...@@ -47,11 +49,15 @@ public final class Utils {
} }
public static final String resizeImageUrl(String url, Integer dim) { public static final String resizeImageUrl(String url, Integer dim) {
if (url == null) { return url; } if (url == null) {
return url;
}
return url.replace("api.insti.app/static/", "img.insti.app/static/" + dim.toString() + "/"); return url.replace("api.insti.app/static/", "img.insti.app/static/" + dim.toString() + "/");
} }
/** Update the open fragment */ /**
* Update the open fragment
*/
public static final void updateFragment(Fragment fragment, FragmentActivity fragmentActivity) { public static final void updateFragment(Fragment fragment, FragmentActivity fragmentActivity) {
FragmentTransaction ft = fragmentActivity.getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = fragmentActivity.getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right); ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
...@@ -102,7 +108,9 @@ public final class Utils { ...@@ -102,7 +108,9 @@ public final class Utils {
} }
public static void openWebURL(Context context, String URL) { public static void openWebURL(Context context, String URL) {
if (URL != null && !URL.isEmpty()) {
Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(URL)); Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(URL));
context.startActivity(browse); context.startActivity(browse);
} }
}
} }
...@@ -94,10 +94,8 @@ public class NewsArticle implements Clickable { ...@@ -94,10 +94,8 @@ public class NewsArticle implements Clickable {
return new View.OnClickListener() { return new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (link != null && !link.isEmpty()) {
openWebURL(context, link); openWebURL(context, link);
} }
}
}; };
} }
} }
...@@ -82,10 +82,8 @@ public class PlacementBlogPost implements Clickable { ...@@ -82,10 +82,8 @@ public class PlacementBlogPost implements Clickable {
return new View.OnClickListener() { return new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (link != null && !link.isEmpty()) {
openWebURL(context, link); openWebURL(context, link);
} }
}
}; };
} }
} }
...@@ -82,10 +82,8 @@ public class TrainingBlogPost implements Clickable { ...@@ -82,10 +82,8 @@ public class TrainingBlogPost implements Clickable {
return new View.OnClickListener() { return new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (link != null && !link.isEmpty()) {
openWebURL(context, link); openWebURL(context, link);
} }
}
}; };
} }
} }
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