Commit 92783298 authored by Sajal Narang's avatar Sajal Narang Committed by GitHub

Merge branch 'master' into patch26

parents e7aa0434 54ed0f93
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
...@@ -11,7 +11,6 @@ android { ...@@ -11,7 +11,6 @@ android {
versionCode 17 versionCode 17
versionName "1.0.12-beta" versionName "1.0.12-beta"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resValue "string", "google_maps_key", (project.findProperty("GOOGLE_MAPS_API_KEY") ?: "")
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
} }
buildTypes { buildTypes {
......
...@@ -53,9 +53,4 @@ public class Constants { ...@@ -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_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_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 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() + "/");
}
} }
...@@ -138,7 +138,7 @@ public class InstiAppFirebaseMessagingService extends FirebaseMessagingService { ...@@ -138,7 +138,7 @@ public class InstiAppFirebaseMessagingService extends FirebaseMessagingService {
Bitmap largeIcon = null; Bitmap largeIcon = null;
if (largeIconUrl != null) { if (largeIconUrl != null) {
largeIcon = getCroppedBitmap( largeIcon = getCroppedBitmap(
Picasso.get().load(Constants.resizeImageUrl(largeIconUrl, 200)).get(), 200); Picasso.get().load(Utils.resizeImageUrl(largeIconUrl)).get(), 200);
} }
bitmaps = new Bitmap[]{image, largeIcon}; bitmaps = new Bitmap[]{image, largeIcon};
} catch (IOException e) { } catch (IOException e) {
......
package app.insti;
import java.util.ArrayList;
import java.util.List;
public class UpdatableList<T> extends ArrayList<T> {
private List<T> cache = new ArrayList<>();
public List<T> getCache() {
return cache;
}
public void setCache(List<T> mCache) {
cache = mCache;
}
/** Update existing or add */
public void updateCache(T t) {
for (int i = 0; i < cache.size(); i++) {
T cachedT = cache.get(i);
if (cachedT.equals(t)) {
cache.set(i, t);
return;
}
}
cache.add(t);
}
}
package app.insti;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.widget.ImageView;
import com.google.gson.Gson;
import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;
import app.insti.api.RetrofitInterface;
import app.insti.api.model.Body;
import app.insti.api.model.Event;
import app.insti.api.model.User;
import app.insti.fragment.BodyFragment;
import app.insti.fragment.EventFragment;
import app.insti.fragment.UserFragment;
public final class Utils {
private static String sessionId;
private static RetrofitInterface retrofitInterface;
public static UpdatableList<Event> eventCache = new UpdatableList<>();
public static final void loadImageWithPlaceholder(final ImageView imageView, final String url) {
Picasso.get()
.load(resizeImageUrl(url))
.into(imageView, new Callback() {
@Override
public void onSuccess() {
Picasso.get()
.load(url)
.placeholder(imageView.getDrawable())
.into(imageView);
}
@Override
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() + "/");
}
/** Update the open fragment */
public static final void updateFragment(Fragment fragment, FragmentActivity fragmentActivity) {
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.replace(R.id.framelayout_for_fragment, fragment, fragment.getTag());
ft.addToBackStack(fragment.getTag());
ft.commit();
}
public static void openBodyFragment(Body body, FragmentActivity fragmentActivity) {
Bundle bundle = new Bundle();
bundle.putString(Constants.BODY_JSON, new Gson().toJson(body));
BodyFragment bodyFragment = new BodyFragment();
bodyFragment.setArguments(bundle);
updateFragment(bodyFragment, fragmentActivity);
}
public static void openEventFragment(Event event, FragmentActivity fragmentActivity) {
String eventJson = new Gson().toJson(event);
Bundle bundle = new Bundle();
bundle.putString(Constants.EVENT_JSON, eventJson);
EventFragment eventFragment = new EventFragment();
eventFragment.setArguments(bundle);
updateFragment(eventFragment, fragmentActivity);
}
public static void openUserFragment(User user, FragmentActivity fragmentActivity) {
Bundle bundle = new Bundle();
bundle.putString(Constants.USER_ID, user.getUserID());
UserFragment userFragment = new UserFragment();
userFragment.setArguments(bundle);
updateFragment(userFragment, fragmentActivity);
}
public static void setSessionId(String sessionId1) {
sessionId = sessionId1;
}
public static String getSessionIDHeader() {
return "sessionid=" + sessionId;
}
public static RetrofitInterface getRetrofitInterface() {
return retrofitInterface;
}
public static void setRetrofitInterface(RetrofitInterface retrofitInterface) {
Utils.retrofitInterface = retrofitInterface;
}
}
...@@ -15,6 +15,7 @@ import android.os.Bundle; ...@@ -15,6 +15,7 @@ import android.os.Bundle;
import android.support.design.widget.NavigationView; import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat; import android.support.v4.view.GravityCompat;
...@@ -43,6 +44,7 @@ import java.util.List; ...@@ -43,6 +44,7 @@ import java.util.List;
import app.insti.Constants; import app.insti.Constants;
import app.insti.R; import app.insti.R;
import app.insti.SessionManager; import app.insti.SessionManager;
import app.insti.Utils;
import app.insti.api.EmptyCallback; import app.insti.api.EmptyCallback;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.ServiceGenerator; import app.insti.api.ServiceGenerator;
...@@ -95,10 +97,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -95,10 +97,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
/** which menu item should be checked on activity start */ /** which menu item should be checked on activity start */
private int initMenuChecked = R.id.nav_feed; private int initMenuChecked = R.id.nav_feed;
public RetrofitInterface getRetrofitInterface() {
return retrofitInterface;
}
public static void hideKeyboard(Activity activity) { public static void hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
//Find the currently focused view, so we can grab the correct window token from it. //Find the currently focused view, so we can grab the correct window token from it.
...@@ -115,7 +113,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -115,7 +113,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ServiceGenerator serviceGenerator = new ServiceGenerator(getApplicationContext()); ServiceGenerator serviceGenerator = new ServiceGenerator(getApplicationContext());
this.retrofitInterface = serviceGenerator.getRetrofitInterface(); Utils.setRetrofitInterface(serviceGenerator.getRetrofitInterface());
/* Make notification channel on oreo */ /* Make notification channel on oreo */
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
...@@ -159,8 +157,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -159,8 +157,8 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
// Get from network // Get from network
RetrofitInterface retrofitInterface = getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getNotifications(getSessionIDHeader()).enqueue(new EmptyCallback<List<Notification>>() { retrofitInterface.getNotifications(Utils.getSessionIDHeader()).enqueue(new EmptyCallback<List<Notification>>() {
@Override @Override
public void onResponse(Call<List<Notification>> call, Response<List<Notification>> response) { public void onResponse(Call<List<Notification>> call, Response<List<Notification>> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -194,7 +192,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -194,7 +192,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
private void checkLatestVersion() { private void checkLatestVersion() {
final int versionCode = getCurrentVersion(); final int versionCode = getCurrentVersion();
if (versionCode == 0) { return; } if (versionCode == 0) { return; }
RetrofitInterface retrofitInterface = getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getLatestVersion().enqueue(new EmptyCallback<JsonObject>() { retrofitInterface.getLatestVersion().enqueue(new EmptyCallback<JsonObject>() {
@Override @Override
public void onResponse(Call<JsonObject> call, Response<JsonObject> response) { public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
...@@ -260,7 +258,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -260,7 +258,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
/* Mark the notification read */ /* Mark the notification read */
final String notificationId = bundle.getString(FCM_BUNDLE_NOTIFICATION_ID); final String notificationId = bundle.getString(FCM_BUNDLE_NOTIFICATION_ID);
if (notificationId != null) { if (notificationId != null) {
getRetrofitInterface().markNotificationRead(getSessionIDHeader(), notificationId).enqueue(new EmptyCallback<Void>()); Utils.getRetrofitInterface().markNotificationRead(Utils.getSessionIDHeader(), notificationId).enqueue(new EmptyCallback<Void>());
} }
/* Follow the notification */ /* Follow the notification */
...@@ -329,22 +327,17 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -329,22 +327,17 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
/** Open the body fragment from given id */ /** Open the body fragment from given id */
private void openBodyFragment(String id) { private void openBodyFragment(String id) {
Body body = new Body(id); Utils.openBodyFragment(new Body(id), this);
BodyFragment bodyFragment = BodyFragment.newInstance(body);
updateFragment(bodyFragment);
} }
/** Open the event fragment from the provided id */ /** Open the event fragment from the provided id */
private void openEventFragment(String id) { private void openEventFragment(String id) {
RetrofitInterface retrofitInterface = getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getEvent(getSessionIDHeader(), id).enqueue(new EmptyCallback<Event>() { final FragmentActivity self = this;
retrofitInterface.getEvent(Utils.getSessionIDHeader(), id).enqueue(new EmptyCallback<Event>() {
@Override @Override
public void onResponse(Call<Event> call, Response<Event> response) { public void onResponse(Call<Event> call, Response<Event> response) {
EventFragment eventFragment = new EventFragment(); Utils.openEventFragment(response.body(), self);
Bundle bundle = new Bundle();
bundle.putString(Constants.EVENT_JSON, response.body().toString());
eventFragment.setArguments(bundle);
updateFragment(eventFragment);
} }
}); });
} }
...@@ -379,6 +372,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -379,6 +372,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
super.onStart(); super.onStart();
initNavigationView(); initNavigationView();
if (session.isLoggedIn()) { if (session.isLoggedIn()) {
Utils.setSessionId(session.getSessionID());
currentUser = User.fromString(session.pref.getString(Constants.CURRENT_USER, "")); currentUser = User.fromString(session.pref.getString(Constants.CURRENT_USER, ""));
updateNavigationView(); updateNavigationView();
updateFCMId(); updateFCMId();
...@@ -393,9 +387,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -393,9 +387,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
@Override @Override
public void onSuccess(InstanceIdResult instanceIdResult) { public void onSuccess(InstanceIdResult instanceIdResult) {
final String fcmId = instanceIdResult.getToken(); final String fcmId = instanceIdResult.getToken();
RetrofitInterface retrofitInterface = getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.patchUserMe(getSessionIDHeader(), new UserFCMPatchRequest(fcmId, getCurrentVersion())).enqueue(new EmptyCallback<User>() { retrofitInterface.patchUserMe(Utils.getSessionIDHeader(), new UserFCMPatchRequest(fcmId, getCurrentVersion())).enqueue(new EmptyCallback<User>() {
@Override @Override
public void onResponse(Call<User> call, Response<User> response) { public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -424,11 +418,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -424,11 +418,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
header.setOnClickListener(new View.OnClickListener() { header.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Bundle bundle = new Bundle(); openUserFragment(currentUser.getUserID());
bundle.putString(Constants.USER_ID, currentUser.getUserID());
UserFragment userFragment = new UserFragment();
userFragment.setArguments(bundle);
updateFragment(userFragment);
DrawerLayout drawer = findViewById(R.id.drawer_layout); DrawerLayout drawer = findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START); drawer.closeDrawer(GravityCompat.START);
} }
...@@ -609,10 +599,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On ...@@ -609,10 +599,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
} }
public String getSessionIDHeader() {
return "sessionid=" + session.getSessionID();
}
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
......
package app.insti.adapter; package app.insti.adapter;
import android.content.Context; import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -12,21 +13,20 @@ import com.squareup.picasso.Picasso; ...@@ -12,21 +13,20 @@ import com.squareup.picasso.Picasso;
import java.util.List; import java.util.List;
import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.Utils;
import app.insti.api.model.Body; import app.insti.api.model.Body;
public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> { public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> {
private List<Body> bodyList; private List<Body> bodyList;
private ItemClickListener itemClickListener;
private Context context; private Context context;
private Fragment fragment;
public BodyAdapter(List<Body> bodyList, ItemClickListener itemClickListener) { public BodyAdapter(List<Body> bodyList, Fragment mFragment) {
this.bodyList = bodyList; this.bodyList = bodyList;
this.itemClickListener = itemClickListener; fragment = mFragment;
} }
@Override @Override
...@@ -39,7 +39,7 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> { ...@@ -39,7 +39,7 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> {
v.setOnClickListener(new View.OnClickListener() { v.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
itemClickListener.onItemClick(view, postViewHolder.getAdapterPosition()); Utils.openBodyFragment(bodyList.get(postViewHolder.getAdapterPosition()), fragment.getActivity());
} }
}); });
...@@ -53,7 +53,7 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> { ...@@ -53,7 +53,7 @@ public class BodyAdapter extends RecyclerView.Adapter<BodyAdapter.ViewHolder> {
holder.name.setText(body.getBodyName()); holder.name.setText(body.getBodyName());
holder.description.setText(body.getBodyShortDescription()); holder.description.setText(body.getBodyShortDescription());
Picasso.get().load( Picasso.get().load(
Constants.resizeImageUrl(body.getBodyImageURL(), 200) Utils.resizeImageUrl(body.getBodyImageURL())
).into(holder.image); ).into(holder.image);
} }
......
package app.insti.adapter; package app.insti.adapter;
import android.content.Context; import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -12,14 +13,12 @@ import com.squareup.picasso.Picasso; ...@@ -12,14 +13,12 @@ import com.squareup.picasso.Picasso;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Calendar;
import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.Utils;
import app.insti.api.model.Event; import app.insti.api.model.Event;
import app.insti.api.model.Venue; import app.insti.api.model.Venue;
...@@ -27,11 +26,11 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -27,11 +26,11 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
private List<Event> events; private List<Event> events;
private Context context; private Context context;
private ItemClickListener itemClickListener; private Fragment mFragment;
public FeedAdapter(List<Event> events, ItemClickListener itemClickListener) { public FeedAdapter(List<Event> events, Fragment fragment) {
this.events = events; this.events = events;
this.itemClickListener = itemClickListener; mFragment = fragment;
} }
public void getSubtitle(ViewHolder viewHolder, Event currentEvent) public void getSubtitle(ViewHolder viewHolder, Event currentEvent)
...@@ -48,18 +47,18 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -48,18 +47,18 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
subtitle += "Event ended | "; subtitle += "Event ended | ";
else if(eventStarted) else if(eventStarted)
{ {
int difference = (int) (endTime.getTime() - timeNow.getTime()); long difference = endTime.getTime() - timeNow.getTime();
int minutes = difference / (60 * 1000 ) % 60; long minutes = difference / (60 * 1000 ) % 60;
int hours = difference / (60 * 60 * 1000) % 24; long hours = difference / (60 * 60 * 1000) % 24;
int days = (int) difference / (24 * 60 * 60 * 1000); long days = difference / (24 * 60 * 60 * 1000);
String timeDiff = ""; String timeDiff = "";
if (days > 0) if (days > 0)
timeDiff += Integer.toString(days) + "D "; timeDiff += Long.toString(days) + "D ";
if (hours > 0) if (hours > 0)
timeDiff += Integer.toString(hours) + "H "; timeDiff += Long.toString(hours) + "H ";
timeDiff += Integer.toString(minutes) + "M"; timeDiff += Long.toString(minutes) + "M";
subtitle += "Ends in " + timeDiff + " | " ; subtitle += "Ends in " + timeDiff + " | " ;
} }
...@@ -90,7 +89,7 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -90,7 +89,7 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
} }
@Override @Override
public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { public ViewHolder onCreateViewHolder(ViewGroup viewGroup, final int i) {
context = viewGroup.getContext(); context = viewGroup.getContext();
LayoutInflater inflater = LayoutInflater.from(context); LayoutInflater inflater = LayoutInflater.from(context);
View postView = inflater.inflate(R.layout.feed_card, viewGroup, false); View postView = inflater.inflate(R.layout.feed_card, viewGroup, false);
...@@ -98,8 +97,8 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -98,8 +97,8 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
final ViewHolder postViewHolder = new ViewHolder(postView); final ViewHolder postViewHolder = new ViewHolder(postView);
postView.setOnClickListener(new View.OnClickListener() { postView.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View view) {
itemClickListener.onItemClick(v, postViewHolder.getAdapterPosition()); Utils.openEventFragment(events.get(postViewHolder.getAdapterPosition()), mFragment.getActivity());
} }
}); });
...@@ -116,10 +115,10 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> { ...@@ -116,10 +115,10 @@ public class FeedAdapter extends RecyclerView.Adapter<FeedAdapter.ViewHolder> {
if (currentEvent.isEventBigImage()) { if (currentEvent.isEventBigImage()) {
viewHolder.eventBigPicture.setVisibility(View.VISIBLE); viewHolder.eventBigPicture.setVisibility(View.VISIBLE);
viewHolder.eventPicture.setVisibility(View.GONE); viewHolder.eventPicture.setVisibility(View.GONE);
Picasso.get().load(currentEvent.getEventImageURL()).into(viewHolder.eventBigPicture); Utils.loadImageWithPlaceholder(viewHolder.eventBigPicture, currentEvent.getEventImageURL());
} else { } else {
Picasso.get().load( Picasso.get().load(
Constants.resizeImageUrl(currentEvent.getEventImageURL(), 200) Utils.resizeImageUrl(currentEvent.getEventImageURL())
).into(viewHolder.eventPicture); ).into(viewHolder.eventPicture);
} }
} }
......
...@@ -16,12 +16,12 @@ import java.util.Date; ...@@ -16,12 +16,12 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.interfaces.Readable;
import app.insti.interfaces.Writable;
import app.insti.api.model.NewsArticle; import app.insti.api.model.NewsArticle;
import app.insti.fragment.NewsFragment; import app.insti.fragment.NewsFragment;
import app.insti.interfaces.ItemClickListener;
import app.insti.interfaces.Readable;
import app.insti.interfaces.Writable;
import ru.noties.markwon.Markwon; import ru.noties.markwon.Markwon;
public class NewsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Readable<NewsArticle>,Writable<NewsArticle> { public class NewsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Readable<NewsArticle>,Writable<NewsArticle> {
......
...@@ -13,13 +13,13 @@ import com.squareup.picasso.Picasso; ...@@ -13,13 +13,13 @@ import com.squareup.picasso.Picasso;
import java.util.List; import java.util.List;
import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.Utils;
import app.insti.api.model.Event; import app.insti.api.model.Event;
import app.insti.api.model.NewsArticle; import app.insti.api.model.NewsArticle;
import app.insti.api.model.Notification; import app.insti.api.model.Notification;
import app.insti.api.model.PlacementBlogPost; import app.insti.api.model.PlacementBlogPost;
import app.insti.interfaces.ItemClickListener;
public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdapter.Viewholder> { public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdapter.Viewholder> {
private List<Notification> notifications; private List<Notification> notifications;
...@@ -55,13 +55,13 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap ...@@ -55,13 +55,13 @@ public class NotificationsAdapter extends RecyclerView.Adapter<NotificationsAdap
if (appNotification.getNotificationActorType().contains("event")) { if (appNotification.getNotificationActorType().contains("event")) {
Event event = gson.fromJson(gson.toJson(appNotification.getNotificationActor()), Event.class); Event event = gson.fromJson(gson.toJson(appNotification.getNotificationActor()), Event.class);
Picasso.get().load( Picasso.get().load(
Constants.resizeImageUrl(event.getEventImageURL(), 200) Utils.resizeImageUrl(event.getEventImageURL())
).into(viewholder.notificationPicture); ).into(viewholder.notificationPicture);
viewholder.notificationTitle.setText(event.getEventName()); viewholder.notificationTitle.setText(event.getEventName());
} else if (appNotification.getNotificationActorType().contains("newsentry")) { } else if (appNotification.getNotificationActorType().contains("newsentry")) {
NewsArticle article = gson.fromJson(gson.toJson(appNotification.getNotificationActor()), NewsArticle.class); NewsArticle article = gson.fromJson(gson.toJson(appNotification.getNotificationActor()), NewsArticle.class);
Picasso.get().load( Picasso.get().load(
Constants.resizeImageUrl(article.getBody().getBodyImageURL(), 200) Utils.resizeImageUrl(article.getBody().getBodyImageURL())
).into(viewholder.notificationPicture); ).into(viewholder.notificationPicture);
viewholder.notificationTitle.setText(article.getTitle()); viewholder.notificationTitle.setText(article.getTitle());
} else if (appNotification.getNotificationActorType().contains("blogentry")) { } else if (appNotification.getNotificationActorType().contains("blogentry")) {
......
...@@ -15,10 +15,10 @@ import java.util.Date; ...@@ -15,10 +15,10 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.api.model.PlacementBlogPost; import app.insti.api.model.PlacementBlogPost;
import app.insti.fragment.PlacementBlogFragment; import app.insti.fragment.PlacementBlogFragment;
import app.insti.interfaces.ItemClickListener;
import app.insti.interfaces.Readable; import app.insti.interfaces.Readable;
import app.insti.interfaces.Writable; import app.insti.interfaces.Writable;
import ru.noties.markwon.Markwon; import ru.noties.markwon.Markwon;
......
...@@ -13,10 +13,10 @@ import com.squareup.picasso.Picasso; ...@@ -13,10 +13,10 @@ import com.squareup.picasso.Picasso;
import java.util.List; import java.util.List;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.api.model.Body; import app.insti.api.model.Body;
import app.insti.api.model.Role; import app.insti.api.model.Role;
import app.insti.interfaces.ItemClickListener;
public class RoleAdapter extends RecyclerView.Adapter<RoleAdapter.ViewHolder> { public class RoleAdapter extends RecyclerView.Adapter<RoleAdapter.ViewHolder> {
......
...@@ -15,10 +15,10 @@ import java.util.Date; ...@@ -15,10 +15,10 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.api.model.TrainingBlogPost; import app.insti.api.model.TrainingBlogPost;
import app.insti.fragment.TrainingBlogFragment; import app.insti.fragment.TrainingBlogFragment;
import app.insti.interfaces.ItemClickListener;
import app.insti.interfaces.Readable; import app.insti.interfaces.Readable;
import app.insti.interfaces.Writable; import app.insti.interfaces.Writable;
import ru.noties.markwon.Markwon; import ru.noties.markwon.Markwon;
......
package app.insti.adapter; package app.insti.adapter;
import android.content.Context; import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -12,19 +13,19 @@ import com.squareup.picasso.Picasso; ...@@ -12,19 +13,19 @@ import com.squareup.picasso.Picasso;
import java.util.List; import java.util.List;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.Utils;
import app.insti.api.model.User; import app.insti.api.model.User;
public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> { public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> {
private List<User> userList; private List<User> userList;
private ItemClickListener itemClickListener;
private Context context; private Context context;
private Fragment fragment;
public UserAdapter(List<User> userList, ItemClickListener itemClickListener) { public UserAdapter(List<User> userList, Fragment mFragment) {
this.userList = userList; this.userList = userList;
this.itemClickListener = itemClickListener; fragment = mFragment;
} }
@Override @Override
...@@ -37,7 +38,7 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> { ...@@ -37,7 +38,7 @@ public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> {
v.setOnClickListener(new View.OnClickListener() { v.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
itemClickListener.onItemClick(view, postViewHolder.getAdapterPosition()); Utils.openUserFragment(userList.get(postViewHolder.getAdapterPosition()), fragment.getActivity());
} }
}); });
......
...@@ -4,14 +4,6 @@ import com.google.gson.JsonObject; ...@@ -4,14 +4,6 @@ import com.google.gson.JsonObject;
import java.util.List; import java.util.List;
import app.insti.api.request.EventCreateRequest;
import app.insti.api.response.EventCreateResponse;
import app.insti.api.response.ExploreResponse;
import app.insti.api.request.ImageUploadRequest;
import app.insti.api.response.ImageUploadResponse;
import app.insti.api.response.LoginResponse;
import app.insti.api.response.NewsFeedResponse;
import app.insti.api.request.UserFCMPatchRequest;
import app.insti.api.model.Event; import app.insti.api.model.Event;
import app.insti.api.model.HostelMessMenu; import app.insti.api.model.HostelMessMenu;
import app.insti.api.model.NewsArticle; import app.insti.api.model.NewsArticle;
...@@ -20,6 +12,14 @@ import app.insti.api.model.PlacementBlogPost; ...@@ -20,6 +12,14 @@ import app.insti.api.model.PlacementBlogPost;
import app.insti.api.model.TrainingBlogPost; import app.insti.api.model.TrainingBlogPost;
import app.insti.api.model.User; import app.insti.api.model.User;
import app.insti.api.model.Venue; import app.insti.api.model.Venue;
import app.insti.api.request.EventCreateRequest;
import app.insti.api.request.ImageUploadRequest;
import app.insti.api.request.UserFCMPatchRequest;
import app.insti.api.response.EventCreateResponse;
import app.insti.api.response.ExploreResponse;
import app.insti.api.response.ImageUploadResponse;
import app.insti.api.response.LoginResponse;
import app.insti.api.response.NewsFeedResponse;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.GET; import retrofit2.http.GET;
......
...@@ -7,6 +7,7 @@ import com.google.gson.annotations.SerializedName; ...@@ -7,6 +7,7 @@ import com.google.gson.annotations.SerializedName;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.List; import java.util.List;
import java.util.Objects;
public class Event { public class Event {
@NonNull() @NonNull()
...@@ -223,4 +224,17 @@ public class Event { ...@@ -223,4 +224,17 @@ public class Event {
public void setEventBigImage(boolean eventBigImage) { public void setEventBigImage(boolean eventBigImage) {
this.eventBigImage = eventBigImage; this.eventBigImage = eventBigImage;
} }
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Event event = (Event) o;
return Objects.equals(eventID, event.eventID);
}
@Override
public int hashCode() {
return Objects.hash(eventID);
}
} }
...@@ -26,7 +26,7 @@ import com.google.gson.Gson; ...@@ -26,7 +26,7 @@ import com.google.gson.Gson;
import app.insti.Constants; import app.insti.Constants;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity; import app.insti.Utils;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.model.Body; import app.insti.api.model.Body;
import app.insti.api.model.Event; import app.insti.api.model.Event;
...@@ -77,7 +77,7 @@ public class AddEventFragment extends BaseFragment { ...@@ -77,7 +77,7 @@ public class AddEventFragment extends BaseFragment {
webView.setWebViewClient(new MyWebViewClient()); webView.setWebViewClient(new MyWebViewClient());
CookieManager cookieManager = CookieManager.getInstance(); CookieManager cookieManager = CookieManager.getInstance();
String cookieString = ((MainActivity) getActivity()).getSessionIDHeader(); String cookieString = Utils.getSessionIDHeader();
cookieManager.setCookie(host, cookieString); cookieManager.setCookie(host, cookieString);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
CookieManager.getInstance().flush(); CookieManager.getInstance().flush();
...@@ -166,8 +166,8 @@ public class AddEventFragment extends BaseFragment { ...@@ -166,8 +166,8 @@ public class AddEventFragment extends BaseFragment {
if (url.contains("/event/")) { if (url.contains("/event/")) {
url = url.substring(url.lastIndexOf("/") + 1); url = url.substring(url.lastIndexOf("/") + 1);
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getEvent(((MainActivity) getActivity()).getSessionIDHeader(), url).enqueue(new Callback<Event>() { retrofitInterface.getEvent(Utils.getSessionIDHeader(), url).enqueue(new Callback<Event>() {
@Override @Override
public void onResponse(Call<Event> call, Response<Event> response) { public void onResponse(Call<Event> call, Response<Event> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -184,8 +184,8 @@ public class AddEventFragment extends BaseFragment { ...@@ -184,8 +184,8 @@ public class AddEventFragment extends BaseFragment {
} else if (url.contains("/org/")) { } else if (url.contains("/org/")) {
url = url.substring(url.lastIndexOf("/") + 1); url = url.substring(url.lastIndexOf("/") + 1);
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getBody(((MainActivity) getActivity()).getSessionIDHeader(), url).enqueue(new Callback<Body>() { retrofitInterface.getBody(Utils.getSessionIDHeader(), url).enqueue(new Callback<Body>() {
@Override @Override
public void onResponse(Call<Body> call, Response<Body> response) { public void onResponse(Call<Body> call, Response<Body> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
......
...@@ -13,7 +13,6 @@ import android.net.Uri; ...@@ -13,7 +13,6 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.NestedScrollView; import android.support.v4.widget.NestedScrollView;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
...@@ -30,15 +29,14 @@ import android.widget.TextView; ...@@ -30,15 +29,14 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.squareup.picasso.Picasso;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import app.insti.Constants; import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.ShareURLMaker; import app.insti.ShareURLMaker;
import app.insti.Utils;
import app.insti.activity.MainActivity; import app.insti.activity.MainActivity;
import app.insti.adapter.BodyAdapter; import app.insti.adapter.BodyAdapter;
import app.insti.adapter.FeedAdapter; import app.insti.adapter.FeedAdapter;
...@@ -148,8 +146,8 @@ public class BodyFragment extends BackHandledFragment { ...@@ -148,8 +146,8 @@ public class BodyFragment extends BackHandledFragment {
} }
private void updateBody() { private void updateBody() {
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getBody(((MainActivity) getActivity()).getSessionIDHeader(), min_body.getBodyID()).enqueue(new Callback<Body>() { retrofitInterface.getBody(Utils.getSessionIDHeader(), min_body.getBodyID()).enqueue(new Callback<Body>() {
@Override @Override
public void onResponse(Call<Body> call, Response<Body> response) { public void onResponse(Call<Body> call, Response<Body> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -200,7 +198,7 @@ public class BodyFragment extends BackHandledFragment { ...@@ -200,7 +198,7 @@ public class BodyFragment extends BackHandledFragment {
/* Set body information */ /* Set body information */
bodyName.setText(body.getBodyName()); bodyName.setText(body.getBodyName());
Picasso.get().load(body.getBodyImageURL()).into(bodyPicture); Utils.loadImageWithPlaceholder(bodyPicture, body.getBodyImageURL());
bodyPicture.setOnClickListener(new View.OnClickListener() { bodyPicture.setOnClickListener(new View.OnClickListener() {
@Override @Override
...@@ -225,8 +223,8 @@ public class BodyFragment extends BackHandledFragment { ...@@ -225,8 +223,8 @@ public class BodyFragment extends BackHandledFragment {
followButton.setOnClickListener(new View.OnClickListener() { followButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.updateBodyFollowing(((MainActivity) getActivity()).getSessionIDHeader(), body.getBodyID(), body.getBodyUserFollows() ? 0 : 1).enqueue(new Callback<Void>() { retrofitInterface.updateBodyFollowing(Utils.getSessionIDHeader(), body.getBodyID(), body.getBodyUserFollows() ? 0 : 1).enqueue(new Callback<Void>() {
@Override @Override
public void onResponse(Call<Void> call, Response<Void> response) { public void onResponse(Call<Void> call, Response<Void> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -276,21 +274,7 @@ public class BodyFragment extends BackHandledFragment { ...@@ -276,21 +274,7 @@ public class BodyFragment extends BackHandledFragment {
/* Initialize events */ /* Initialize events */
final List<Event> eventList = body.getBodyEvents(); final List<Event> eventList = body.getBodyEvents();
RecyclerView eventRecyclerView = (RecyclerView) getActivity().findViewById(R.id.event_card_recycler_view); RecyclerView eventRecyclerView = (RecyclerView) getActivity().findViewById(R.id.event_card_recycler_view);
FeedAdapter eventAdapter = new FeedAdapter(eventList, new ItemClickListener() { FeedAdapter eventAdapter = new FeedAdapter(eventList, this);
@Override
public void onItemClick(View v, int position) {
Event event = eventList.get(position);
Bundle bundle = new Bundle();
bundle.putString(Constants.EVENT_JSON, new Gson().toJson(event));
EventFragment eventFragment = new EventFragment();
eventFragment.setArguments(bundle);
FragmentTransaction ft = getActivity().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.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag());
ft.addToBackStack(eventFragment.getTag());
ft.commit();
}
});
eventRecyclerView.setAdapter(eventAdapter); eventRecyclerView.setAdapter(eventAdapter);
eventRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); eventRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
...@@ -308,43 +292,19 @@ public class BodyFragment extends BackHandledFragment { ...@@ -308,43 +292,19 @@ public class BodyFragment extends BackHandledFragment {
/* Initialize People */ /* Initialize People */
RecyclerView userRecyclerView = (RecyclerView) getActivity().findViewById(R.id.people_card_recycler_view); RecyclerView userRecyclerView = (RecyclerView) getActivity().findViewById(R.id.people_card_recycler_view);
UserAdapter userAdapter = new UserAdapter(users, new ItemClickListener() { UserAdapter userAdapter = new UserAdapter(users, this);
@Override
public void onItemClick(View v, int position) {
User user = users.get(position);
Bundle bundle = new Bundle();
bundle.putString(Constants.USER_ID, user.getUserID());
UserFragment userFragment = new UserFragment();
userFragment.setArguments(bundle);
FragmentTransaction ft = getActivity().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.replace(R.id.framelayout_for_fragment, userFragment, userFragment.getTag());
ft.addToBackStack(userFragment.getTag());
ft.commit();
}
});
userRecyclerView.setAdapter(userAdapter); userRecyclerView.setAdapter(userAdapter);
userRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); userRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
/* Initialize Parent bodies */ /* Initialize Parent bodies */
RecyclerView parentsRecyclerView = (RecyclerView) getActivity().findViewById(R.id.parentorg_card_recycler_view); RecyclerView parentsRecyclerView = (RecyclerView) getActivity().findViewById(R.id.parentorg_card_recycler_view);
BodyAdapter parentAdapter = new BodyAdapter(body.getBodyParents(), new ItemClickListener() { BodyAdapter parentAdapter = new BodyAdapter(body.getBodyParents(), this);
@Override
public void onItemClick(View v, int position) {
openBody(body.getBodyParents().get(position));
}
});
parentsRecyclerView.setAdapter(parentAdapter); parentsRecyclerView.setAdapter(parentAdapter);
parentsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); parentsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
/* Initialize child bodies */ /* Initialize child bodies */
RecyclerView childrenRecyclerView = (RecyclerView) getActivity().findViewById(R.id.org_card_recycler_view); RecyclerView childrenRecyclerView = (RecyclerView) getActivity().findViewById(R.id.org_card_recycler_view);
BodyAdapter childrenAdapter = new BodyAdapter(body.getBodyChildren(), new ItemClickListener() { BodyAdapter childrenAdapter = new BodyAdapter(body.getBodyChildren(), this);
@Override
public void onItemClick(View v, int position) {
openBody(body.getBodyChildren().get(position));
}
});
childrenRecyclerView.setAdapter(childrenAdapter); childrenRecyclerView.setAdapter(childrenAdapter);
childrenRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); childrenRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
...@@ -353,7 +313,7 @@ public class BodyFragment extends BackHandledFragment { ...@@ -353,7 +313,7 @@ public class BodyFragment extends BackHandledFragment {
/* Show update button if role */ /* Show update button if role */
if (((MainActivity) getActivity()).editBodyAccess(body)) { if (((MainActivity) getActivity()).editBodyAccess(body)) {
final FloatingActionButton fab = (FloatingActionButton) getView().findViewById(R.id.edit_fab); final FloatingActionButton fab = (FloatingActionButton) getView().findViewById(R.id.edit_fab);
fab.setVisibility(View.VISIBLE); fab.show();
NestedScrollView nsv = (NestedScrollView) getView().findViewById(R.id.body_scrollview); NestedScrollView nsv = (NestedScrollView) getView().findViewById(R.id.body_scrollview);
nsv.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() { nsv.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override @Override
...@@ -376,21 +336,6 @@ public class BodyFragment extends BackHandledFragment { ...@@ -376,21 +336,6 @@ public class BodyFragment extends BackHandledFragment {
} }
} }
/**
* Open body fragment for a body
*/
private void openBody(Body body) {
Bundle bundle = new Bundle();
bundle.putString(Constants.BODY_JSON, new Gson().toJson(body));
BodyFragment bodyFragment = new BodyFragment();
bodyFragment.setArguments(bundle);
FragmentTransaction ft = getActivity().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.replace(R.id.framelayout_for_fragment, bodyFragment, bodyFragment.getTag());
ft.addToBackStack(bodyFragment.getTag());
ft.commit();
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
......
...@@ -3,7 +3,6 @@ package app.insti.fragment; ...@@ -3,7 +3,6 @@ package app.insti.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -16,7 +15,6 @@ import com.google.gson.reflect.TypeToken; ...@@ -16,7 +15,6 @@ import com.google.gson.reflect.TypeToken;
import java.util.List; import java.util.List;
import app.insti.Constants; import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.adapter.BodyAdapter; import app.insti.adapter.BodyAdapter;
import app.insti.api.model.Body; import app.insti.api.model.Body;
...@@ -65,21 +63,7 @@ public class BodyRecyclerViewFragment extends Fragment { ...@@ -65,21 +63,7 @@ public class BodyRecyclerViewFragment extends Fragment {
super.onStart(); super.onStart();
recyclerView = (RecyclerView) getActivity().findViewById(R.id.body_recycler_view); recyclerView = (RecyclerView) getActivity().findViewById(R.id.body_recycler_view);
bodyAdapter = new BodyAdapter(bodyList, new ItemClickListener() { bodyAdapter = new BodyAdapter(bodyList, this);
@Override
public void onItemClick(View v, int position) {
Body body = bodyList.get(position);
BodyFragment bodyFragment = new BodyFragment();
Bundle arguments = getArguments();
arguments.putString(Constants.BODY_JSON, new Gson().toJson(body));
bodyFragment.setArguments(getArguments());
FragmentTransaction ft = getActivity().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.replace(R.id.framelayout_for_fragment, bodyFragment, bodyFragment.getTag());
ft.addToBackStack(bodyFragment.getTag());
ft.commit();
}
});
recyclerView.setAdapter(bodyAdapter); recyclerView.setAdapter(bodyAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
......
...@@ -4,7 +4,6 @@ package app.insti.fragment; ...@@ -4,7 +4,6 @@ package app.insti.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
...@@ -15,8 +14,6 @@ import android.widget.CalendarView; ...@@ -15,8 +14,6 @@ import android.widget.CalendarView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.gson.Gson;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
...@@ -27,14 +24,13 @@ import java.util.Date; ...@@ -27,14 +24,13 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.Utils;
import app.insti.activity.MainActivity; import app.insti.activity.MainActivity;
import app.insti.adapter.FeedAdapter; import app.insti.adapter.FeedAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.response.NewsFeedResponse;
import app.insti.api.model.Event; import app.insti.api.model.Event;
import app.insti.api.response.NewsFeedResponse;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
...@@ -46,9 +42,10 @@ public class CalendarFragment extends BaseFragment { ...@@ -46,9 +42,10 @@ public class CalendarFragment extends BaseFragment {
FloatingActionButton fab; FloatingActionButton fab;
private View view; private View view;
private Toast toast; private FeedAdapter feedAdapter = null;
private List<Event> events; private List<Event> events;
public CalendarFragment() { public CalendarFragment() {
// Required empty public constructor // Required empty public constructor
} }
...@@ -92,7 +89,7 @@ public class CalendarFragment extends BaseFragment { ...@@ -92,7 +89,7 @@ public class CalendarFragment extends BaseFragment {
} }
}); });
if (((MainActivity) getActivity()).createEventAccess()) { if (((MainActivity) getActivity()).createEventAccess()) {
fab.setVisibility(View.VISIBLE); fab.show();
} }
updateEvents(); updateEvents();
...@@ -116,8 +113,8 @@ public class CalendarFragment extends BaseFragment { ...@@ -116,8 +113,8 @@ public class CalendarFragment extends BaseFragment {
final String oneMonthBack = isoFormatter.format(oneMonthBackDate).toString(); final String oneMonthBack = isoFormatter.format(oneMonthBackDate).toString();
final String oneMonthOn = isoFormatter.format(oneMonthOnDate).toString(); final String oneMonthOn = isoFormatter.format(oneMonthOnDate).toString();
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getEventsBetweenDates(((MainActivity) getActivity()).getSessionIDHeader(), oneMonthBack, oneMonthOn).enqueue(new Callback<NewsFeedResponse>() { retrofitInterface.getEventsBetweenDates(Utils.getSessionIDHeader(), oneMonthBack, oneMonthOn).enqueue(new Callback<NewsFeedResponse>() {
@Override @Override
public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) { public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -165,23 +162,20 @@ public class CalendarFragment extends BaseFragment { ...@@ -165,23 +162,20 @@ public class CalendarFragment extends BaseFragment {
} }
RecyclerView eventRecyclerView = (RecyclerView) getActivity().findViewById(R.id.calendar_event_card_recycler_view); RecyclerView eventRecyclerView = (RecyclerView) getActivity().findViewById(R.id.calendar_event_card_recycler_view);
FeedAdapter eventAdapter = new FeedAdapter(filteredEvents, new ItemClickListener() {
@Override // Initialize or refresh adapter
public void onItemClick(View v, int position) { if (feedAdapter == null) {
Event event = filteredEvents.get(position); feedAdapter = new FeedAdapter(filteredEvents, this);
Bundle bundle = new Bundle(); } else {
bundle.putString(Constants.EVENT_JSON, new Gson().toJson(event)); feedAdapter.setEvents(filteredEvents);
EventFragment eventFragment = new EventFragment(); feedAdapter.notifyDataSetChanged();
eventFragment.setArguments(bundle); }
FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
ft.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right); // Initialize recycler view
ft.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag()); if (eventRecyclerView.getAdapter() != feedAdapter) {
ft.addToBackStack(eventFragment.getTag()); eventRecyclerView.setAdapter(feedAdapter);
ft.commit(); eventRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
} }
});
eventRecyclerView.setAdapter(eventAdapter);
eventRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE); getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
} }
......
...@@ -13,7 +13,6 @@ import android.net.Uri; ...@@ -13,7 +13,6 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.NestedScrollView; import android.support.v4.widget.NestedScrollView;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
...@@ -34,7 +33,6 @@ import android.widget.TextView; ...@@ -34,7 +33,6 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.squareup.picasso.Picasso;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -42,9 +40,9 @@ import java.util.Date; ...@@ -42,9 +40,9 @@ import java.util.Date;
import java.util.List; import java.util.List;
import app.insti.Constants; import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.ShareURLMaker; import app.insti.ShareURLMaker;
import app.insti.Utils;
import app.insti.activity.MainActivity; import app.insti.activity.MainActivity;
import app.insti.adapter.BodyAdapter; import app.insti.adapter.BodyAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
...@@ -154,7 +152,8 @@ public class EventFragment extends BackHandledFragment { ...@@ -154,7 +152,8 @@ public class EventFragment extends BackHandledFragment {
webEventButton = getActivity().findViewById(R.id.web_event_button); webEventButton = getActivity().findViewById(R.id.web_event_button);
shareEventButton = getActivity().findViewById(R.id.share_event_button); shareEventButton = getActivity().findViewById(R.id.share_event_button);
Picasso.get().load(event.getEventImageURL()).into(eventPicture); Utils.loadImageWithPlaceholder(eventPicture, event.getEventImageURL());
eventTitle.setText(event.getEventName()); eventTitle.setText(event.getEventName());
Markwon.setMarkdown(eventDescription, event.getEventDescription()); Markwon.setMarkdown(eventDescription, event.getEventDescription());
Timestamp timestamp = event.getEventStartTime(); Timestamp timestamp = event.getEventStartTime();
...@@ -171,18 +170,7 @@ public class EventFragment extends BackHandledFragment { ...@@ -171,18 +170,7 @@ public class EventFragment extends BackHandledFragment {
final List<Body> bodyList = event.getEventBodies(); final List<Body> bodyList = event.getEventBodies();
bodyRecyclerView = (RecyclerView) getActivity().findViewById(R.id.body_card_recycler_view); bodyRecyclerView = (RecyclerView) getActivity().findViewById(R.id.body_card_recycler_view);
BodyAdapter bodyAdapter = new BodyAdapter(bodyList, new ItemClickListener() { BodyAdapter bodyAdapter = new BodyAdapter(bodyList, this);
@Override
public void onItemClick(View v, int position) {
Body body = bodyList.get(position);
BodyFragment bodyFragment = BodyFragment.newInstance(body);
FragmentTransaction ft = getActivity().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.replace(R.id.framelayout_for_fragment, bodyFragment, bodyFragment.getTag());
ft.addToBackStack(bodyFragment.getTag());
ft.commit();
}
});
bodyRecyclerView.setAdapter(bodyAdapter); bodyRecyclerView.setAdapter(bodyAdapter);
bodyRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); bodyRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
...@@ -250,7 +238,7 @@ public class EventFragment extends BackHandledFragment { ...@@ -250,7 +238,7 @@ public class EventFragment extends BackHandledFragment {
final FloatingActionButton fab = (FloatingActionButton) getView().findViewById(R.id.edit_fab); final FloatingActionButton fab = (FloatingActionButton) getView().findViewById(R.id.edit_fab);
if (((MainActivity) getActivity()).editEventAccess(event)) { if (((MainActivity) getActivity()).editEventAccess(event)) {
fab.setVisibility(View.VISIBLE); fab.show();
NestedScrollView nsv = (NestedScrollView) getView().findViewById(R.id.event_scrollview); NestedScrollView nsv = (NestedScrollView) getView().findViewById(R.id.event_scrollview);
nsv.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() { nsv.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override @Override
...@@ -287,8 +275,8 @@ public class EventFragment extends BackHandledFragment { ...@@ -287,8 +275,8 @@ public class EventFragment extends BackHandledFragment {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
final int endStatus = event.getEventUserUes() == status ? 0 : status; final int endStatus = event.getEventUserUes() == status ? 0 : status;
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.updateUserEventStatus(((MainActivity) getActivity()).getSessionIDHeader(), event.getEventID(), endStatus).enqueue(new Callback<Void>() { retrofitInterface.updateUserEventStatus(Utils.getSessionIDHeader(), event.getEventID(), endStatus).enqueue(new Callback<Void>() {
@Override @Override
public void onResponse(Call<Void> call, Response<Void> response) { public void onResponse(Call<Void> call, Response<Void> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -318,6 +306,9 @@ public class EventFragment extends BackHandledFragment { ...@@ -318,6 +306,9 @@ public class EventFragment extends BackHandledFragment {
event.setEventUserUes(endStatus); event.setEventUserUes(endStatus);
setFollowButtonColors(endStatus); setFollowButtonColors(endStatus);
// Update global memory cache
Utils.eventCache.updateCache(event);
} }
} }
......
...@@ -2,7 +2,6 @@ package app.insti.fragment; ...@@ -2,7 +2,6 @@ package app.insti.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -15,7 +14,6 @@ import com.google.gson.reflect.TypeToken; ...@@ -15,7 +14,6 @@ import com.google.gson.reflect.TypeToken;
import java.util.List; import java.util.List;
import app.insti.Constants; import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.adapter.FeedAdapter; import app.insti.adapter.FeedAdapter;
import app.insti.api.model.Event; import app.insti.api.model.Event;
...@@ -63,21 +61,7 @@ public class EventRecyclerViewFragment extends Fragment { ...@@ -63,21 +61,7 @@ public class EventRecyclerViewFragment extends Fragment {
super.onStart(); super.onStart();
recyclerView = (RecyclerView) getActivity().findViewById(R.id.event_recycler_view); recyclerView = (RecyclerView) getActivity().findViewById(R.id.event_recycler_view);
feedAdapter = new FeedAdapter(eventList, new ItemClickListener() { feedAdapter = new FeedAdapter(eventList, this);
@Override
public void onItemClick(View v, int position) {
Event event = eventList.get(position);
EventFragment eventFragment = new EventFragment();
Bundle arguments = getArguments();
arguments.putString(Constants.EVENT_JSON, new Gson().toJson(event));
eventFragment.setArguments(getArguments());
FragmentTransaction ft = getActivity().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.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag());
ft.addToBackStack(eventFragment.getTag());
ft.commit();
}
});
recyclerView.setAdapter(feedAdapter); recyclerView.setAdapter(feedAdapter);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
......
...@@ -3,7 +3,6 @@ package app.insti.fragment; ...@@ -3,7 +3,6 @@ package app.insti.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
...@@ -14,25 +13,21 @@ import android.view.View; ...@@ -14,25 +13,21 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.EditText; import android.widget.EditText;
import com.google.gson.Gson;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity; import app.insti.Utils;
import app.insti.adapter.BodyAdapter; import app.insti.adapter.BodyAdapter;
import app.insti.adapter.FeedAdapter; import app.insti.adapter.FeedAdapter;
import app.insti.adapter.UserAdapter; import app.insti.adapter.UserAdapter;
import app.insti.api.EmptyCallback;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.response.ExploreResponse;
import app.insti.api.model.Body; import app.insti.api.model.Body;
import app.insti.api.model.Event; import app.insti.api.model.Event;
import app.insti.api.model.User; import app.insti.api.model.User;
import app.insti.api.response.ExploreResponse;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
/** /**
...@@ -43,15 +38,17 @@ import retrofit2.Response; ...@@ -43,15 +38,17 @@ import retrofit2.Response;
public class ExploreFragment extends Fragment { public class ExploreFragment extends Fragment {
private String sessionId; private String sessionId;
private List<Body> allBodies = new ArrayList<>(); private static List<Body> allBodies = new ArrayList<>();
private List<Body> bodies = new ArrayList<>(); private static List<Body> bodies = new ArrayList<>();
private List<Event> events = new ArrayList<>(); private static List<Event> events = new ArrayList<>();
private List<User> users = new ArrayList<>(); private static List<User> users = new ArrayList<>();
private BodyAdapter bodyAdapter; private BodyAdapter bodyAdapter;
private FeedAdapter eventsAdapter; private FeedAdapter eventsAdapter;
private UserAdapter userAdapter; private UserAdapter userAdapter;
private String currentQuery = null;
public ExploreFragment() { public ExploreFragment() {
// Required empty public constructor // Required empty public constructor
} }
...@@ -78,7 +75,7 @@ public class ExploreFragment extends Fragment { ...@@ -78,7 +75,7 @@ public class ExploreFragment extends Fragment {
super.onStart(); super.onStart();
// Initialize // Initialize
sessionId = ((MainActivity) getActivity()).getSessionIDHeader(); sessionId = Utils.getSessionIDHeader();
initRecyclerViews(); initRecyclerViews();
Toolbar toolbar = getActivity().findViewById(R.id.toolbar); Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
...@@ -86,20 +83,17 @@ public class ExploreFragment extends Fragment { ...@@ -86,20 +83,17 @@ public class ExploreFragment extends Fragment {
// Get all bodies // Get all bodies
if (allBodies.size() == 0) { if (allBodies.size() == 0) {
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getAllBodies(sessionId).enqueue(new Callback<List<Body>>() { retrofitInterface.getAllBodies(sessionId).enqueue(new EmptyCallback<List<Body>>() {
@Override @Override
public void onResponse(Call<List<Body>> call, Response<List<Body>> response) { public void onResponse(Call<List<Body>> call, Response<List<Body>> response) {
allBodies = response.body(); allBodies = response.body();
bodies = allBodies; bodies = allBodies;
updateAdapters(bodies, new ArrayList<Event>(), new ArrayList<User>()); updateAdapters(allBodies, new ArrayList<Event>(), new ArrayList<User>());
}
@Override
public void onFailure(Call<List<Body>> call, Throwable t) {
} }
}); });
} else { } else {
updateAdapters(bodies, events, users);
getView().findViewById(R.id.loadingPanel).setVisibility(View.GONE); getView().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
} }
...@@ -107,20 +101,17 @@ public class ExploreFragment extends Fragment { ...@@ -107,20 +101,17 @@ public class ExploreFragment extends Fragment {
final EditText searchEditText = getView().findViewById(R.id.explore_search); final EditText searchEditText = getView().findViewById(R.id.explore_search);
searchEditText.addTextChangedListener(new TextWatcher() { searchEditText.addTextChangedListener(new TextWatcher() {
@Override @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) { public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
}
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {}
}
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
if (searchEditText.getText().length() >= 3) { if (searchEditText.getText().length() >= 3) {
doSearch(searchEditText.getText().toString()); doSearch(searchEditText.getText().toString());
} else if (searchEditText.getText().length() == 0) { } else if (searchEditText.getText().length() == 0) {
bodies = allBodies; updateAdapters(allBodies, new ArrayList<Event>(), new ArrayList<User>());
updateAdapters(bodies, new ArrayList<Event>(), new ArrayList<User>());
} }
} }
}); });
...@@ -133,28 +124,31 @@ public class ExploreFragment extends Fragment { ...@@ -133,28 +124,31 @@ public class ExploreFragment extends Fragment {
return inflater.inflate(R.layout.fragment_explore, container, false); return inflater.inflate(R.layout.fragment_explore, container, false);
} }
public void doSearch(String query) { public void doSearch(final String query) {
if (getActivity() == null || getView() == null) return; if (getActivity() == null || getView() == null) return;
// Show loading spinner // Show loading spinner
getView().findViewById(R.id.loadingPanel).setVisibility(View.VISIBLE); getView().findViewById(R.id.loadingPanel).setVisibility(View.VISIBLE);
// Set the lastest query
currentQuery = query;
// Make request // Make request
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.search(sessionId, query).enqueue(new Callback<ExploreResponse>() { retrofitInterface.search(sessionId, query).enqueue(new EmptyCallback<ExploreResponse>() {
@Override @Override
public void onResponse(Call<ExploreResponse> call, Response<ExploreResponse> response) { public void onResponse(Call<ExploreResponse> call, Response<ExploreResponse> response) {
// Check if we already have a new query pending
if (!currentQuery.equals(query)) {
return;
}
// Get data // Get data
bodies = response.body().getBodies(); bodies = response.body().getBodies();
events = response.body().getEvents(); events = response.body().getEvents();
users = response.body().getUsers(); users = response.body().getUsers();
updateAdapters(bodies, events, users); updateAdapters(bodies, events, users);
} }
@Override
public void onFailure(Call<ExploreResponse> call, Throwable t) {
// Request failed
}
}); });
} }
...@@ -178,53 +172,20 @@ public class ExploreFragment extends Fragment { ...@@ -178,53 +172,20 @@ public class ExploreFragment extends Fragment {
if (getActivity() == null || getView() == null) return; if (getActivity() == null || getView() == null) return;
// Bodies // Bodies
RecyclerView bodiesRecyclerView = getView().findViewById(R.id.explore_body_recycler_view); RecyclerView bodiesRecyclerView = getView().findViewById(R.id.explore_body_recycler_view);
bodyAdapter = new BodyAdapter(bodies, new ItemClickListener() { bodyAdapter = new BodyAdapter(bodies, this);
@Override
public void onItemClick(View v, int position) {
Bundle bundle = new Bundle();
bundle.putString(Constants.BODY_JSON, new Gson().toJson(bodies.get(position)));
updateFragment(new BodyFragment(), bundle);
}
});
bodiesRecyclerView.setAdapter(bodyAdapter); bodiesRecyclerView.setAdapter(bodyAdapter);
bodiesRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); bodiesRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// Events // Events
RecyclerView eventsRecyclerView = getView().findViewById(R.id.explore_event_recycler_view); RecyclerView eventsRecyclerView = getView().findViewById(R.id.explore_event_recycler_view);
eventsAdapter = new FeedAdapter(events, new ItemClickListener() { eventsAdapter = new FeedAdapter(events, this);
@Override
public void onItemClick(View v, int position) {
Event event = events.get(position);
Bundle bundle = new Bundle();
bundle.putString(Constants.EVENT_JSON, new Gson().toJson(event));
updateFragment(new EventFragment(), bundle);
}
});
eventsRecyclerView.setAdapter(eventsAdapter); eventsRecyclerView.setAdapter(eventsAdapter);
eventsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); eventsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// Users // Users
RecyclerView usersRecyclerView = getView().findViewById(R.id.explore_user_recycler_view); RecyclerView usersRecyclerView = getView().findViewById(R.id.explore_user_recycler_view);
userAdapter = new UserAdapter(users, new ItemClickListener() { userAdapter = new UserAdapter(users, this);
@Override
public void onItemClick(View v, int position) {
User user = users.get(position);
Bundle bundle = new Bundle();
bundle.putString(Constants.USER_ID, user.getUserID());
updateFragment(new UserFragment(), bundle);
}
});
usersRecyclerView.setAdapter(userAdapter); usersRecyclerView.setAdapter(userAdapter);
usersRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); usersRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
} }
public void updateFragment(Fragment fragment, Bundle bundle) {
MainActivity.hideKeyboard(getActivity());
fragment.setArguments(bundle);
FragmentTransaction ft = getActivity().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.replace(R.id.framelayout_for_fragment, fragment, fragment.getTag());
ft.addToBackStack(fragment.getTag());
ft.commit();
}
} }
...@@ -5,8 +5,6 @@ import android.app.Activity; ...@@ -5,8 +5,6 @@ import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
...@@ -15,19 +13,16 @@ import android.view.LayoutInflater; ...@@ -15,19 +13,16 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.google.gson.Gson;
import java.util.List; import java.util.List;
import app.insti.ActivityBuffer; import app.insti.ActivityBuffer;
import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.Utils;
import app.insti.activity.MainActivity; import app.insti.activity.MainActivity;
import app.insti.adapter.FeedAdapter; import app.insti.adapter.FeedAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.response.NewsFeedResponse;
import app.insti.api.model.Event; import app.insti.api.model.Event;
import app.insti.api.response.NewsFeedResponse;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
...@@ -40,14 +35,14 @@ public class FeedFragment extends BaseFragment { ...@@ -40,14 +35,14 @@ public class FeedFragment extends BaseFragment {
private RecyclerView feedRecyclerView; private RecyclerView feedRecyclerView;
private SwipeRefreshLayout feedSwipeRefreshLayout; private SwipeRefreshLayout feedSwipeRefreshLayout;
private FloatingActionButton fab; private FloatingActionButton fab;
private boolean freshEventsDisplayed = false;
LinearLayoutManager mLayoutManager; LinearLayoutManager mLayoutManager;
public static int index = -1, top = -1; public static int index = -1, top = -1;
private FeedAdapter feedAdapter = null;
public FeedFragment() { public FeedFragment() {
// Required empty public constructor // Required empty public constructor
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
...@@ -74,8 +69,14 @@ public class FeedFragment extends BaseFragment { ...@@ -74,8 +69,14 @@ public class FeedFragment extends BaseFragment {
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
fab = (FloatingActionButton) getView().findViewById(R.id.fab); fab = getView().findViewById(R.id.fab);
updateFeed();
// Initialize the feed
if (Utils.eventCache.getCache() == null || Utils.eventCache.getCache().size() == 0) {
updateFeed();
} else {
displayEvents(Utils.eventCache.getCache());
}
} }
...@@ -92,23 +93,20 @@ public class FeedFragment extends BaseFragment { ...@@ -92,23 +93,20 @@ public class FeedFragment extends BaseFragment {
public void onResume() public void onResume()
{ {
super.onResume(); super.onResume();
if(index != -1) if(index != -1) {
{
mLayoutManager.scrollToPositionWithOffset( index, top); mLayoutManager.scrollToPositionWithOffset( index, top);
} }
} }
private void updateFeed() { private void updateFeed() {
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getNewsFeed("sessionid=" + getArguments().getString(Constants.SESSION_ID)).enqueue(new Callback<NewsFeedResponse>() { retrofitInterface.getNewsFeed(Utils.getSessionIDHeader()).enqueue(new Callback<NewsFeedResponse>() {
@Override @Override
public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) { public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
NewsFeedResponse newsFeedResponse = response.body(); Utils.eventCache.setCache(response.body().getEvents());
List<Event> events = newsFeedResponse.getEvents(); displayEvents(Utils.eventCache.getCache());
freshEventsDisplayed = true;
displayEvents(events);
} }
//Server Error //Server Error
feedSwipeRefreshLayout.setRefreshing(false); feedSwipeRefreshLayout.setRefreshing(false);
...@@ -122,12 +120,10 @@ public class FeedFragment extends BaseFragment { ...@@ -122,12 +120,10 @@ public class FeedFragment extends BaseFragment {
}); });
} }
private void displayEvents(final List<Event> events) { /** Initialize the add event fab if the user has permission */
/* Skip if we're already destroyed */ private void initFab() {
if (getActivity() == null || getView() == null) return;
if (((MainActivity) getActivity()).createEventAccess()) { if (((MainActivity) getActivity()).createEventAccess()) {
fab.setVisibility(View.VISIBLE); fab.show();
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
...@@ -145,43 +141,48 @@ public class FeedFragment extends BaseFragment { ...@@ -145,43 +141,48 @@ public class FeedFragment extends BaseFragment {
} }
}); });
} }
}
private void displayEvents(final List<Event> events) {
/* Skip if we're already destroyed */
if (getActivity() == null || getView() == null) return;
/* Initialize */
initFab();
/* Make first event image big */ /* Make first event image big */
if (events.size() > 1) { if (events.size() > 1) {
events.get(0).setEventBigImage(true); events.get(0).setEventBigImage(true);
} }
final FeedAdapter feedAdapter = new FeedAdapter(events, new ItemClickListener() { // Initialize adapter
@Override if (feedAdapter == null) {
public void onItemClick(View v, int position) { feedAdapter = new FeedAdapter(events, this);
String eventJson = new Gson().toJson(events.get(position)); } else {
Bundle bundle = getArguments(); feedAdapter.setEvents(events);
if (bundle == null) feedAdapter.notifyDataSetChanged();
bundle = new Bundle(); }
bundle.putString(Constants.EVENT_JSON, eventJson);
EventFragment eventFragment = new EventFragment(); // Initialize RecyclerView if necessary
eventFragment.setArguments(bundle); if (feedRecyclerView.getAdapter() != feedAdapter) {
FragmentManager manager = getActivity().getSupportFragmentManager(); initRecyclerView();
FragmentTransaction transaction = manager.beginTransaction(); }
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
transaction.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag()); View view = getActivity().findViewById(R.id.loadingPanel);
transaction.addToBackStack(eventFragment.getTag()).commit(); if (view != null)
} view.setVisibility(View.GONE);
}); }
private void initRecyclerView() {
getActivityBuffer().safely(new ActivityBuffer.IRunnable() { getActivityBuffer().safely(new ActivityBuffer.IRunnable() {
@Override @Override
public void run(Activity pActivity) { public void run(Activity pActivity) {
try { try {
feedRecyclerView.setAdapter(feedAdapter); feedRecyclerView.setAdapter(feedAdapter);
//feedRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
} catch (NullPointerException e) { } catch (NullPointerException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
}); });
View view = getActivity().findViewById(R.id.loadingPanel);
if (view != null)
view.setVisibility(View.GONE);
} }
} }
...@@ -87,6 +87,7 @@ import java.util.regex.Pattern; ...@@ -87,6 +87,7 @@ import java.util.regex.Pattern;
import app.insti.Constants; import app.insti.Constants;
import app.insti.R; import app.insti.R;
import app.insti.Utils;
import app.insti.activity.MainActivity; import app.insti.activity.MainActivity;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.model.Venue; import app.insti.api.model.Venue;
...@@ -94,6 +95,7 @@ import retrofit2.Call; ...@@ -94,6 +95,7 @@ import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
import static android.widget.Toast.LENGTH_SHORT;
import static app.insti.Constants.MY_PERMISSIONS_REQUEST_LOCATION; import static app.insti.Constants.MY_PERMISSIONS_REQUEST_LOCATION;
public class MapFragment extends Fragment implements TextWatcher, public class MapFragment extends Fragment implements TextWatcher,
...@@ -226,7 +228,7 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -226,7 +228,7 @@ public class MapFragment extends Fragment implements TextWatcher,
} }
private void getAPILocations() { private void getAPILocations() {
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getAllVenues().enqueue(new Callback<List<Venue>>() { retrofitInterface.getAllVenues().enqueue(new Callback<List<Venue>>() {
@Override @Override
public void onResponse(Call<List<Venue>> call, Response<List<Venue>> response) { public void onResponse(Call<List<Venue>> call, Response<List<Venue>> response) {
...@@ -490,7 +492,7 @@ public class MapFragment extends Fragment implements TextWatcher, ...@@ -490,7 +492,7 @@ public class MapFragment extends Fragment implements TextWatcher,
@Override @Override
public void onItemClick(AdapterView<?> arg0, View arg1, int id, long arg3) { public void onItemClick(AdapterView<?> arg0, View arg1, int id, long arg3) {
if (adapter.getResultSize() == 0) { if (adapter.getResultSize() == 0) {
toast.setText(message); toast = Toast.makeText(getContext(), message, LENGTH_SHORT);
toast.show(); toast.show();
} else { } else {
String selection = editText.getText().toString(); String selection = editText.getText().toString();
......
...@@ -23,7 +23,7 @@ import java.util.Locale; ...@@ -23,7 +23,7 @@ import java.util.Locale;
import app.insti.ActivityBuffer; import app.insti.ActivityBuffer;
import app.insti.Constants; import app.insti.Constants;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity; import app.insti.Utils;
import app.insti.adapter.MessMenuAdapter; import app.insti.adapter.MessMenuAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.model.HostelMessMenu; import app.insti.api.model.HostelMessMenu;
...@@ -107,8 +107,8 @@ public class MessMenuFragment extends BaseFragment { ...@@ -107,8 +107,8 @@ public class MessMenuFragment extends BaseFragment {
} }
private void updateMessMenu(final String hostel) { private void updateMessMenu(final String hostel) {
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getInstituteMessMenu("sessionid=" + getArguments().getString(Constants.SESSION_ID)).enqueue(new Callback<List<HostelMessMenu>>() { retrofitInterface.getInstituteMessMenu(Utils.getSessionIDHeader()).enqueue(new Callback<List<HostelMessMenu>>() {
@Override @Override
public void onResponse(Call<List<HostelMessMenu>> call, Response<List<HostelMessMenu>> response) { public void onResponse(Call<List<HostelMessMenu>> call, Response<List<HostelMessMenu>> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
......
...@@ -11,7 +11,6 @@ import android.view.ViewGroup; ...@@ -11,7 +11,6 @@ import android.view.ViewGroup;
import java.util.List; import java.util.List;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.adapter.NewsAdapter; import app.insti.adapter.NewsAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.model.NewsArticle; import app.insti.api.model.NewsArticle;
...@@ -56,7 +55,7 @@ public class NewsFragment extends RecyclerViewFragment<NewsArticle, NewsAdapter> ...@@ -56,7 +55,7 @@ public class NewsFragment extends RecyclerViewFragment<NewsArticle, NewsAdapter>
} }
@Override @Override
Call<List<NewsArticle>> getCall(RetrofitInterface retrofitInterface, String sessionIDHeader) { Call<List<NewsArticle>> getCall(RetrofitInterface retrofitInterface, String sessionIDHeader, int postCount) {
return retrofitInterface.getNews(sessionIDHeader, getPostCount(), 20, searchQuery); return retrofitInterface.getNews(sessionIDHeader, postCount, 20, searchQuery);
} }
} }
...@@ -3,8 +3,6 @@ package app.insti.fragment; ...@@ -3,8 +3,6 @@ package app.insti.fragment;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
...@@ -16,15 +14,15 @@ import com.google.gson.Gson; ...@@ -16,15 +14,15 @@ import com.google.gson.Gson;
import java.util.List; import java.util.List;
import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity; import app.insti.Utils;
import app.insti.adapter.NotificationsAdapter; import app.insti.adapter.NotificationsAdapter;
import app.insti.api.EmptyCallback; import app.insti.api.EmptyCallback;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.model.Event;
import app.insti.api.model.Notification; import app.insti.api.model.Notification;
import app.insti.api.model.PlacementBlogPost; import app.insti.api.model.PlacementBlogPost;
import app.insti.interfaces.ItemClickListener;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
...@@ -57,8 +55,8 @@ public class NotificationsFragment extends BaseFragment { ...@@ -57,8 +55,8 @@ public class NotificationsFragment extends BaseFragment {
Toolbar toolbar = getActivity().findViewById(R.id.toolbar); Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Notifications"); toolbar.setTitle("Notifications");
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getNotifications(((MainActivity) getActivity()).getSessionIDHeader()).enqueue(new Callback<List<Notification>>() { retrofitInterface.getNotifications(Utils.getSessionIDHeader()).enqueue(new Callback<List<Notification>>() {
@Override @Override
public void onResponse(Call<List<Notification>> call, Response<List<Notification>> response) { public void onResponse(Call<List<Notification>> call, Response<List<Notification>> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -87,51 +85,27 @@ public class NotificationsFragment extends BaseFragment { ...@@ -87,51 +85,27 @@ public class NotificationsFragment extends BaseFragment {
Notification notification = notifications.get(position); Notification notification = notifications.get(position);
/* Mark notification read */ /* Mark notification read */
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
String sessId = ((MainActivity) getActivity()).getSessionIDHeader(); String sessId = Utils.getSessionIDHeader();
retrofitInterface.markNotificationRead(sessId, notification.getNotificationId().toString()).enqueue(new EmptyCallback<Void>()); retrofitInterface.markNotificationRead(sessId, notification.getNotificationId().toString()).enqueue(new EmptyCallback<Void>());
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
String tag = "";
Bundle bundle = getArguments();
if (bundle == null) {
bundle = new Bundle();
}
bundle.putString(Constants.SESSION_ID, ((MainActivity) getActivity()).getSessionIDHeader());
/* Open event */ /* Open event */
if (notification.getNotificationActorType().contains("event")) { if (notification.getNotificationActorType().contains("event")) {
String eventJson = new Gson().toJson(notification.getNotificationActor()); Gson gson = new Gson();
bundle.putString(Constants.EVENT_JSON, eventJson); Event event = gson.fromJson(gson.toJson(notification.getNotificationActor()), Event.class) ;
EventFragment eventFragment = new EventFragment(); Utils.openEventFragment(event, getActivity());
eventFragment.setArguments(bundle);
tag = eventFragment.getTag();
transaction.replace(R.id.framelayout_for_fragment, eventFragment, tag);
} else if (notification.getNotificationActorType().contains("newsentry")) { } else if (notification.getNotificationActorType().contains("newsentry")) {
NewsFragment newsFragment = new NewsFragment(); NewsFragment newsFragment = new NewsFragment();
tag = newsFragment.getTag(); Utils.updateFragment(newsFragment, getActivity());
transaction.replace(R.id.framelayout_for_fragment, newsFragment, tag);
newsFragment.setArguments(bundle);
} else if (notification.getNotificationActorType().contains("blogentry")) { } else if (notification.getNotificationActorType().contains("blogentry")) {
Gson gson = new Gson(); Gson gson = new Gson();
PlacementBlogPost post = gson.fromJson(gson.toJson(notification.getNotificationActor()), PlacementBlogPost.class); PlacementBlogPost post = gson.fromJson(gson.toJson(notification.getNotificationActor()), PlacementBlogPost.class);
if (post.getLink().contains("training")) { if (post.getLink().contains("training")) {
TrainingBlogFragment trainingBlogFragment = new TrainingBlogFragment(); Utils.updateFragment(new TrainingBlogFragment(), getActivity());
trainingBlogFragment.setArguments(bundle);
tag = trainingBlogFragment.getTag();
transaction.replace(R.id.framelayout_for_fragment, trainingBlogFragment, tag);
} else { } else {
PlacementBlogFragment placementBlogFragment = new PlacementBlogFragment(); Utils.updateFragment(new PlacementBlogFragment(), getActivity());
placementBlogFragment.setArguments(bundle);
tag = placementBlogFragment.getTag();
transaction.replace(R.id.framelayout_for_fragment, placementBlogFragment, tag);
} }
} }
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
transaction.addToBackStack(tag).commit();
} }
}); });
notificationsRecyclerView = (RecyclerView) getActivity().findViewById(R.id.notifications_recycler_view); notificationsRecyclerView = (RecyclerView) getActivity().findViewById(R.id.notifications_recycler_view);
......
package app.insti.fragment; package app.insti.fragment;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import app.insti.ActivityBuffer;
import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.adapter.PlacementBlogAdapter; import app.insti.adapter.PlacementBlogAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.model.PlacementBlogPost; import app.insti.api.model.PlacementBlogPost;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
...@@ -73,7 +56,7 @@ public class PlacementBlogFragment extends RecyclerViewFragment<PlacementBlogPos ...@@ -73,7 +56,7 @@ public class PlacementBlogFragment extends RecyclerViewFragment<PlacementBlogPos
} }
@Override @Override
Call<List<PlacementBlogPost>> getCall(RetrofitInterface retrofitInterface, String sessionIDHeader) { Call<List<PlacementBlogPost>> getCall(RetrofitInterface retrofitInterface, String sessionIDHeader, int postCount) {
return retrofitInterface.getPlacementBlogFeed(sessionIDHeader, getPostCount(), 20, searchQuery); return retrofitInterface.getPlacementBlogFeed(sessionIDHeader, postCount, 20, searchQuery);
} }
} }
...@@ -15,15 +15,17 @@ import android.view.View; ...@@ -15,15 +15,17 @@ import android.view.View;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.List; import java.util.List;
import java.util.Objects;
import app.insti.ActivityBuffer; import app.insti.ActivityBuffer;
import app.insti.R;
import app.insti.Utils;
import app.insti.activity.MainActivity;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.interfaces.Browsable; import app.insti.interfaces.Browsable;
import app.insti.interfaces.ItemClickListener; import app.insti.interfaces.ItemClickListener;
import app.insti.R;
import app.insti.interfaces.Readable; import app.insti.interfaces.Readable;
import app.insti.interfaces.Writable; import app.insti.interfaces.Writable;
import app.insti.activity.MainActivity;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
...@@ -38,14 +40,33 @@ public abstract class RecyclerViewFragment<T extends Browsable, S extends Recycl ...@@ -38,14 +40,33 @@ public abstract class RecyclerViewFragment<T extends Browsable, S extends Recycl
protected SwipeRefreshLayout swipeRefreshLayout; protected SwipeRefreshLayout swipeRefreshLayout;
protected String searchQuery; protected String searchQuery;
private S adapter = null; private S adapter = null;
boolean loading = false;
private boolean allLoaded = false;
/** Update the data clearing existing */
protected void updateData() { protected void updateData() {
String sessionIDHeader = ((MainActivity) getActivity()).getSessionIDHeader(); // Skip if we're already destroyed
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); if (getActivity() == null || getView() == null) return;
Call<List<T>> call = getCall(retrofitInterface, sessionIDHeader);
// Clear variables
allLoaded = false;
// Keep current search query
final String requestSearchQuery = searchQuery;
// Make the request
String sessionIDHeader = Utils.getSessionIDHeader();
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
Call<List<T>> call = getCall(retrofitInterface, sessionIDHeader, 0);
call.enqueue(new Callback<List<T>>() { call.enqueue(new Callback<List<T>>() {
@Override @Override
public void onResponse(Call<List<T>> call, Response<List<T>> response) { public void onResponse(Call<List<T>> call, Response<List<T>> response) {
// Check if search query was changed in the meanwhile
if (!Objects.equals(requestSearchQuery, searchQuery)) {
return;
}
// Update display
if (response.isSuccessful()) { if (response.isSuccessful()) {
List<T> posts = response.body(); List<T> posts = response.body();
displayData(posts); displayData(posts);
...@@ -60,12 +81,24 @@ public abstract class RecyclerViewFragment<T extends Browsable, S extends Recycl ...@@ -60,12 +81,24 @@ public abstract class RecyclerViewFragment<T extends Browsable, S extends Recycl
}); });
} }
abstract Call<List<T>> getCall(RetrofitInterface retrofitInterface, String sessionIDHeader); abstract Call<List<T>> getCall(RetrofitInterface retrofitInterface, String sessionIDHeader, int postCount);
private void displayData(final List<T> result) { private void displayData(final List<T> result) {
/* Skip if we're already destroyed */ /* Skip if we're already destroyed */
if (getActivity() == null || getView() == null) return; if (getActivity() == null || getView() == null) return;
if (adapter == null) {
initAdapter(result);
} else {
adapter.setPosts(result);
adapter.notifyDataSetChanged();
}
getActivity().findViewById(R.id.loadingPanel).setVisibility(GONE);
}
/** Initialize the adapter */
private void initAdapter(final List<T> result) {
try { try {
adapter = adapterType.getDeclaredConstructor(List.class, ItemClickListener.class).newInstance(result, new ItemClickListener() { adapter = adapterType.getDeclaredConstructor(List.class, ItemClickListener.class).newInstance(result, new ItemClickListener() {
@Override @Override
...@@ -75,53 +108,58 @@ public abstract class RecyclerViewFragment<T extends Browsable, S extends Recycl ...@@ -75,53 +108,58 @@ public abstract class RecyclerViewFragment<T extends Browsable, S extends Recycl
openWebURL(link); openWebURL(link);
} }
}); });
getActivityBuffer().safely(new ActivityBuffer.IRunnable() { initRecyclerView();
@Override
public void run(Activity pActivity) { } catch (java.lang.InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
recyclerView.setAdapter(adapter); e.printStackTrace();
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); }
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { }
boolean loading = false;
/** Initialize scrolling on the adapter */
@Override private void initRecyclerView() {
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { getActivityBuffer().safely(new ActivityBuffer.IRunnable() {
if (dy > 0) { @Override
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager(); public void run(Activity pActivity) {
if (((layoutManager.getChildCount() + layoutManager.findFirstVisibleItemPosition()) > (layoutManager.getItemCount() - 5)) && (!loading)) { recyclerView.setAdapter(adapter);
loading = true; recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
String sessionIDHeader = ((MainActivity) getActivity()).getSessionIDHeader(); recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); @Override
Call<List<T>> call = getCall(retrofitInterface, sessionIDHeader); public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
call.enqueue(new Callback<List<T>>() { if (dy > 0) {
@Override LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
public void onResponse(Call<List<T>> call, Response<List<T>> response) { if (((layoutManager.getChildCount() + layoutManager.findFirstVisibleItemPosition()) > (layoutManager.getItemCount() - 5)) && (!loading) && (!allLoaded)) {
if (response.isSuccessful()) { loading = true;
loading = false; String sessionIDHeader = Utils.getSessionIDHeader();
List<T> posts = adapter.getPosts(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
posts.addAll(response.body()); Call<List<T>> call = getCall(retrofitInterface, sessionIDHeader, getPostCount());
if (response.body().size() == 0) { call.enqueue(new Callback<List<T>>() {
showLoader = false; @Override
} public void onResponse(Call<List<T>> call, Response<List<T>> response) {
adapter.setPosts(posts); if (getActivity() == null || getView() == null) return;
adapter.notifyDataSetChanged(); loading = false;
if (response.isSuccessful()) {
List<T> posts = adapter.getPosts();
posts.addAll(response.body());
if (response.body().size() == 0) {
showLoader = false;
allLoaded = true;
} }
adapter.setPosts(posts);
adapter.notifyDataSetChanged();
} }
}
@Override @Override
public void onFailure(Call<List<T>> call, Throwable t) { public void onFailure(Call<List<T>> call, Throwable t) {
loading = false; loading = false;
} }
}); });
}
} }
} }
}); }
} });
}); }
getActivity().findViewById(R.id.loadingPanel).setVisibility(GONE); });
} catch (java.lang.InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace();
}
} }
protected int getPostCount() { protected int getPostCount() {
......
...@@ -5,8 +5,6 @@ import android.content.Intent; ...@@ -5,8 +5,6 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
...@@ -20,6 +18,7 @@ import com.squareup.picasso.Picasso; ...@@ -20,6 +18,7 @@ import com.squareup.picasso.Picasso;
import app.insti.Constants; import app.insti.Constants;
import app.insti.R; import app.insti.R;
import app.insti.SessionManager; import app.insti.SessionManager;
import app.insti.Utils;
import app.insti.activity.LoginActivity; import app.insti.activity.LoginActivity;
import app.insti.activity.MainActivity; import app.insti.activity.MainActivity;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
...@@ -57,8 +56,8 @@ public class SettingsFragment extends Fragment { ...@@ -57,8 +56,8 @@ public class SettingsFragment extends Fragment {
populateViews(); populateViews();
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getUser("sessionid=" + getArguments().getString(Constants.SESSION_ID), userID).enqueue(new Callback<User>() { retrofitInterface.getUser(Utils.getSessionIDHeader(), userID).enqueue(new Callback<User>() {
@Override @Override
public void onResponse(Call<User> call, Response<User> response) { public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -123,12 +122,7 @@ public class SettingsFragment extends Fragment { ...@@ -123,12 +122,7 @@ public class SettingsFragment extends Fragment {
aboutButton.setOnClickListener(new View.OnClickListener() { aboutButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
AboutFragment aboutFragment = new AboutFragment(); Utils.updateFragment(new AboutFragment(), getActivity());
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.setCustomAnimations(R.anim.slide_in_left, R.anim.slide_out_left, R.anim.slide_in_right, R.anim.slide_out_right);
transaction.replace(R.id.framelayout_for_fragment, aboutFragment, aboutFragment.getTag());
transaction.addToBackStack(aboutFragment.getTag()).commit();
} }
}); });
...@@ -138,8 +132,8 @@ public class SettingsFragment extends Fragment { ...@@ -138,8 +132,8 @@ public class SettingsFragment extends Fragment {
logoutButton.setOnClickListener(new View.OnClickListener() { logoutButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.logout("sessionid=" + getArguments().getString(Constants.SESSION_ID)).enqueue(new Callback<Void>() { retrofitInterface.logout(Utils.getSessionIDHeader()).enqueue(new Callback<Void>() {
@Override @Override
public void onResponse(Call<Void> call, Response<Void> response) { public void onResponse(Call<Void> call, Response<Void> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
......
package app.insti.fragment; package app.insti.fragment;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import app.insti.ActivityBuffer;
import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.activity.MainActivity;
import app.insti.adapter.TrainingBlogAdapter; import app.insti.adapter.TrainingBlogAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
import app.insti.api.model.TrainingBlogPost; import app.insti.api.model.TrainingBlogPost;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/** /**
* A simple {@link Fragment} subclass. * A simple {@link Fragment} subclass.
...@@ -73,7 +56,7 @@ public class TrainingBlogFragment extends RecyclerViewFragment<TrainingBlogPost, ...@@ -73,7 +56,7 @@ public class TrainingBlogFragment extends RecyclerViewFragment<TrainingBlogPost,
} }
@Override @Override
Call<List<TrainingBlogPost>> getCall(RetrofitInterface retrofitInterface, String sessionIDHeader) { Call<List<TrainingBlogPost>> getCall(RetrofitInterface retrofitInterface, String sessionIDHeader, int postCount) {
return retrofitInterface.getTrainingBlogFeed(sessionIDHeader, getPostCount(), 20, searchQuery); return retrofitInterface.getTrainingBlogFeed(sessionIDHeader, postCount, 20, searchQuery);
} }
} }
...@@ -13,7 +13,6 @@ import android.net.Uri; ...@@ -13,7 +13,6 @@ import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
...@@ -31,10 +30,9 @@ import com.squareup.picasso.Picasso; ...@@ -31,10 +30,9 @@ import com.squareup.picasso.Picasso;
import java.util.List; import java.util.List;
import app.insti.Constants; import app.insti.Constants;
import app.insti.interfaces.ItemClickListener;
import app.insti.R; import app.insti.R;
import app.insti.ShareURLMaker; import app.insti.ShareURLMaker;
import app.insti.activity.MainActivity; import app.insti.Utils;
import app.insti.adapter.RoleAdapter; import app.insti.adapter.RoleAdapter;
import app.insti.adapter.TabAdapter; import app.insti.adapter.TabAdapter;
import app.insti.api.RetrofitInterface; import app.insti.api.RetrofitInterface;
...@@ -42,6 +40,7 @@ import app.insti.api.model.Body; ...@@ -42,6 +40,7 @@ import app.insti.api.model.Body;
import app.insti.api.model.Event; import app.insti.api.model.Event;
import app.insti.api.model.Role; import app.insti.api.model.Role;
import app.insti.api.model.User; import app.insti.api.model.User;
import app.insti.interfaces.ItemClickListener;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
...@@ -107,8 +106,8 @@ public class UserFragment extends BackHandledFragment { ...@@ -107,8 +106,8 @@ public class UserFragment extends BackHandledFragment {
Bundle bundle = getArguments(); Bundle bundle = getArguments();
String userID = bundle.getString(Constants.USER_ID); String userID = bundle.getString(Constants.USER_ID);
RetrofitInterface retrofitInterface = ((MainActivity) getActivity()).getRetrofitInterface(); RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getUser("sessionid=" + getArguments().getString(Constants.SESSION_ID), userID).enqueue(new Callback<User>() { retrofitInterface.getUser(Utils.getSessionIDHeader(), userID).enqueue(new Callback<User>() {
@Override @Override
public void onResponse(Call<User> call, Response<User> response) { public void onResponse(Call<User> call, Response<User> response) {
if (response.isSuccessful()) { if (response.isSuccessful()) {
...@@ -147,12 +146,7 @@ public class UserFragment extends BackHandledFragment { ...@@ -147,12 +146,7 @@ public class UserFragment extends BackHandledFragment {
public void onItemClick(View v, int position) { public void onItemClick(View v, int position) {
Role role = roleList.get(position); Role role = roleList.get(position);
Body roleBody = role.getRoleBodyDetails(); Body roleBody = role.getRoleBodyDetails();
BodyFragment bodyFragment = BodyFragment.newInstance(roleBody); Utils.openBodyFragment(roleBody, getActivity());
FragmentTransaction ft = getActivity().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.replace(R.id.framelayout_for_fragment, bodyFragment, bodyFragment.getTag());
ft.addToBackStack(bodyFragment.getTag());
ft.commit();
} }
}); });
......
...@@ -32,11 +32,11 @@ import android.graphics.Point; ...@@ -32,11 +32,11 @@ import android.graphics.Point;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.RectF; import android.graphics.RectF;
import android.support.media.ExifInterface;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build.VERSION; import android.os.Build.VERSION;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.support.media.ExifInterface;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
......
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Drop Shadow Stack -->
<!-- Background -->
<item>
<shape>
<solid android:color="#e5e5e5" />
</shape>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#30555555" />
<corners android:radius="2dp" />
</shape>
</item>
<item
android:bottom="2dp"
android:left="0dp"
android:right="0dp"
android:top="0dp">
<shape android:shape="rectangle">
<solid android:color="#FFFFFF" />
<corners android:radius="2dp" />
</shape>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#10999999" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#20999999" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#10999999" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" />
</shape>
</item>
<!-- Background -->
<item>
<shape>
<solid android:color="@android:color/transparent" />
</shape>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Drop Shadow Stack -->
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" />
<corners android:radius="5dp" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" />
<corners android:radius="5dp" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" />
<corners android:radius="5dp" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" />
<corners android:radius="5dp" />
</shape>
</item>
<item>
<shape>
<padding
android:bottom="1dp"
android:left="1dp"
android:right="1dp"
android:top="1dp" />
<solid android:color="#00999999" />
<corners android:radius="5dp" />
</shape>
</item>
<!-- Background -->
<item>
<shape>
<gradient
android:angle="90"
android:centerColor="#FFf6f6f6"
android:centerX="6%"
android:endColor="#FFffffff"
android:startColor="#FFe4e4e4"
android:type="linear" />
<corners android:radius="5dp" />
</shape>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="270"
android:centerColor="#19000000"
android:centerX="60%"
android:endColor="#FF000000"
android:startColor="#00000000"
android:type="linear" />
</shape>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0" />
<path
android:fillColor="#FF000000"
android:pathData="M9,2L7.17,4H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2H9zm3,15c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M22,16V4c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zm-11,-4l2.03,2.71L16,11l4,5H8l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2H4V6H2z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M22.7,19l-9.1,-9.1c0.9,-2.3 0.4,-5 -1.5,-6.9 -2,-2 -5,-2.4 -7.4,-1.3L9,6 6,9 1.6,4.7C0.4,7.1 0.9,10.1 2.9,12.1c1.9,1.9 4.6,2.4 6.9,1.5l9.1,9.1c0.4,0.4 1,0.4 1.4,0l2.3,-2.3c0.5,-0.4 0.5,-1.1 0.1,-1.4z" />
</vector>
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M4,6H2v14c0,1.1 0.9,2 2,2h14v-2H4V6zm16,-4H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zm-8,12.5v-9l6,4.5 -6,4.5z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,5c1.66,0 3,1.34 3,3s-1.34,3 -3,3 -3,-1.34 -3,-3 1.34,-3 3,-3zM12,19.2c-2.5,0 -4.71,-1.28 -6,-3.22 0.03,-1.99 4,-3.08 6,-3.08 1.99,0 5.97,1.09 6,3.08 -1.29,1.94 -3.5,3.22 -6,3.22z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="@android:color/white"
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="@android:color/white"
android:pathData="M10.09,15.59L11.5,17l5,-5 -5,-5 -1.41,1.41L12.67,11H3v2h9.67l-2.58,2.59zM19,3H5c-1.11,0 -2,0.9 -2,2v4h2V5h14v14H5v-4H3v4c0,1.1 0.89,2 2,2h14c1.1,0 2,-0.9 2,-2V5c0,-1.1 -0.9,-2 -2,-2z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="@android:color/white"
android:pathData="M20,2L4,2c-1.1,0 -1.99,0.9 -1.99,2L2,22l4,-4h14c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM13,14h-2v-2h2v2zM13,10h-2L11,6h2v4z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-6h2v6zM13,9h-2L11,7h2v2z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M7.58,4.08L6.15,2.65C3.75,4.48 2.17,7.3 2.03,10.5h2c0.15,-2.65 1.51,-4.97 3.55,-6.42zM19.97,10.5h2c-0.15,-3.2 -1.73,-6.02 -4.12,-7.85l-1.42,1.43c2.02,1.45 3.39,3.77 3.54,6.42zM18,11c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2v-5zM12,22c0.14,0 0.27,-0.01 0.4,-0.04 0.65,-0.14 1.18,-0.58 1.44,-1.18 0.1,-0.24 0.15,-0.5 0.15,-0.78h-4c0.01,1.1 0.9,2 2.01,2z"/>
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="@android:color/white"
android:pathData="M6.18,17.82m-2.18,0a2.18,2.18 0,1 1,4.36 0a2.18,2.18 0,1 1,-4.36 0" />
<path
android:fillColor="@android:color/white"
android:pathData="M4,4.44v2.83c7.03,0 12.73,5.7 12.73,12.73h2.83c0,-8.59 -6.97,-15.56 -15.56,-15.56zM4,10.1v2.83c3.9,0 7.07,3.17 7.07,7.07h2.83c0,-5.47 -4.43,-9.9 -9.9,-9.9z" />
</vector>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="@android:color/white"
android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ExpandableListView
android:id="@+id/index_list"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
android:divider="@null"
android:groupIndicator="@null"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:transcriptMode="disabled" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/notification_title"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="colorPrimary">#536dfe</color> <color name="colorPrimary">#536dfe</color>
<color name="primaryLightColor">#8f9bff</color>
<color name="colorPrimaryDark">#0043ca</color> <color name="colorPrimaryDark">#0043ca</color>
<color name="colorAccent">#ffd740</color> <color name="colorAccent">#ffd740</color>
<color name="colorSecondary">#ffd740</color> <color name="colorSecondary">#ffd740</color>
<color name="secondaryLightColor">#ffff74</color>
<color name="secondaryDarkColor">#c8a600</color>
<color name="primaryTextColor">#fafafa</color> <color name="primaryTextColor">#fafafa</color>
<color name="secondaryTextColor">#000000</color> <color name="secondaryTextColor">#000000</color>
<color name="colorCalendarWeek">#000000</color> <color name="colorCalendarWeek">#000000</color>
<color name="colorGray">#757575</color>
<color name="colorWhite">#FFFFFF</color> <color name="colorWhite">#FFFFFF</color>
<!-- Map --> <!-- Map -->
<item name="transparent_black" type="color">#20000000</item> <item name="transparent_black" type="color">#20000000</item>
<item name="list_item_gray_even" type="color">#ffe6e6e6</item> <item name="list_item_gray_even" type="color">#ffe6e6e6</item>
<item name="list_item_gray_odd" type="color">#ffececec</item>
</resources> </resources>
...@@ -4,17 +4,10 @@ ...@@ -4,17 +4,10 @@
<dimen name="activity_vertical_margin">16dp</dimen> <dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="nav_header_vertical_spacing">8dp</dimen> <dimen name="nav_header_vertical_spacing">8dp</dimen>
<dimen name="nav_header_height">176dp</dimen> <dimen name="nav_header_height">176dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="links_margin_start">8dp</dimen>
<!-- Map --> <!-- Map -->
<dimen name="card_height">360dp</dimen>
<dimen name="hidden_card_height">80dp</dimen> <dimen name="hidden_card_height">80dp</dimen>
<dimen name="expanded_card_height">280dp</dimen> <dimen name="expanded_card_height">280dp</dimen>
<dimen name="place_name_text_size">20sp</dimen> <dimen name="place_name_text_size">20sp</dimen>
<dimen name="place_sub_head_text_size">16sp</dimen> <dimen name="place_sub_head_text_size">16sp</dimen>
<dimen name="index_header_text_size">20sp</dimen>
<dimen name="index_item_text_size">16sp</dimen>
<dimen name="list_item_text_size">16sp</dimen>
<dimen name="searchbar_text_size">16sp</dimen>
</resources> </resources>
<resources> <resources>
<item name="ic_menu_camera" type="drawable">@android:drawable/ic_menu_camera</item>
<item name="ic_menu_gallery" type="drawable">@android:drawable/ic_menu_gallery</item>
<item name="ic_menu_slideshow" type="drawable">@android:drawable/ic_menu_slideshow</item>
<item name="ic_menu_manage" type="drawable">@android:drawable/ic_menu_manage</item>
<item name="ic_menu_share" type="drawable">@android:drawable/ic_menu_share</item> <item name="ic_menu_share" type="drawable">@android:drawable/ic_menu_share</item>
<item name="ic_menu_send" type="drawable">@android:drawable/ic_menu_send</item>
</resources> </resources>
...@@ -4,14 +4,8 @@ ...@@ -4,14 +4,8 @@
<string name="navigation_drawer_open">Open navigation drawer</string> <string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string> <string name="navigation_drawer_close">Close navigation drawer</string>
<string name="action_settings">Settings</string>
<!-- TODO: Remove or change this placeholder text --> <!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
<string name="Cancel">Cancel</string>
<string name="gps_network_not_enabled">Location is not enabled. Please turn on your location from the settings.</string>
<string name="open_location_settings">Open Location Settings</string>
<string name="django_api"> <a href="https://github.com/wncc/IITBapp"> Django API</a></string> <string name="django_api"> <a href="https://github.com/wncc/IITBapp"> Django API</a></string>
<string name="android_app"> <a href="https://github.com/wncc/InstiApp"> Android App</a></string> <string name="android_app"> <a href="https://github.com/wncc/InstiApp"> Android App</a></string>
<string name="angular_pwa"> <a href="https://github.com/pulsejet/iitb-app-angular"> Angular PWA </a></string> <string name="angular_pwa"> <a href="https://github.com/pulsejet/iitb-app-angular"> Angular PWA </a></string>
...@@ -37,7 +31,5 @@ ...@@ -37,7 +31,5 @@
<item>QIP</item> <item>QIP</item>
</string-array> </string-array>
<string name="drawer_open">Open the drawer</string>
<string name="drawer_close">Close the drawer</string>
<string name="default_notification_channel_id">INSTIAPP_NOTIFS</string> <string name="default_notification_channel_id">INSTIAPP_NOTIFS</string>
</resources> </resources>
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