Commit 9075f6b6 authored by Sajal Narang's avatar Sajal Narang Committed by GitHub

Merge branch 'master' into badlogin

parents b639c3cd dbf57e30
......@@ -62,6 +62,7 @@
font-size: 1.05em;
}
</style>
</head>
......
......@@ -30,6 +30,7 @@ import com.squareup.picasso.Picasso;
import in.ac.iitb.gymkhana.iitbapp.api.UnsafeOkHttpClient;
import in.ac.iitb.gymkhana.iitbapp.api.model.NotificationsResponse;
import in.ac.iitb.gymkhana.iitbapp.data.User;
import in.ac.iitb.gymkhana.iitbapp.fragment.AboutFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.CalendarFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.FeedFragment;
import in.ac.iitb.gymkhana.iitbapp.fragment.MapFragment;
......@@ -248,6 +249,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
case R.id.nav_settings:
SettingsFragment settingsFragment = new SettingsFragment();
updateFragment(settingsFragment);
//Checking the about fragment
//AboutFragment aboutFragment = new AboutFragment();
//updateFragment(aboutFragment);
break;
}
......@@ -264,7 +268,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
}
bundle.putString(Constants.SESSION_ID, session.pref.getString(Constants.SESSION_ID, "Error"));
if (fragment instanceof MessMenuFragment)
bundle.putString(Constants.USER_HOSTEL, currentUser.getHostel());
bundle.putString(Constants.USER_HOSTEL, session.isLoggedIn() ? currentUser.getHostel() : "1");
if (fragment instanceof SettingsFragment && session.isLoggedIn())
bundle.putString(Constants.USER_ID, currentUser.getUserID());
fragment.setArguments(bundle);
......
......@@ -3,6 +3,7 @@ package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
......@@ -10,9 +11,8 @@ import java.util.List;
@Entity(tableName = "bodies")
public class Body {
@PrimaryKey(autoGenerate = true)
int db_id;
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
String bodyID;
......
......@@ -3,6 +3,7 @@ package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
......@@ -12,9 +13,8 @@ import java.util.List;
@Entity(tableName = "events")
public class Event {
@PrimaryKey(autoGenerate = true)
int db_id;
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
String eventID;
......
......@@ -3,6 +3,7 @@ package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
......@@ -10,9 +11,8 @@ import java.util.List;
@Entity(tableName = "hostelMessMenus")
public class HostelMessMenu {
@PrimaryKey(autoGenerate = true)
int db_id;
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
private String menuID;
......
package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
public class MessMenu {
@NonNull()
@PrimaryKey()
@SerializedName("id")
private String mealID;
......
......@@ -3,6 +3,7 @@ package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
......@@ -11,10 +12,8 @@ import java.sql.Timestamp;
@Entity(tableName = "news")
public class NewsArticle {
@PrimaryKey(autoGenerate = true)
int db_id;
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
private String articleID;
......
......@@ -3,6 +3,7 @@ package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
......@@ -11,10 +12,8 @@ import java.sql.Timestamp;
@Entity(tableName = "placementBlogPosts")
public class PlacementBlogPost {
@PrimaryKey(autoGenerate = true)
int db_id;
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
private String postID;
......
......@@ -3,6 +3,7 @@ package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
......@@ -12,10 +13,8 @@ import java.util.List;
public class Role {
@PrimaryKey(autoGenerate = true)
int db_id;
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
String roleID;
......
......@@ -3,6 +3,7 @@ package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
......@@ -11,10 +12,8 @@ import java.sql.Timestamp;
@Entity(tableName = "trainingBlogPosts")
public class TrainingBlogPost {
@PrimaryKey(autoGenerate = true)
int db_id;
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
private String postID;
......
......@@ -4,6 +4,7 @@ import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.Ignore;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
......@@ -12,9 +13,8 @@ import java.util.List;
@Entity(tableName = "users")
public class User {
@PrimaryKey(autoGenerate = true)
int db_id;
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
String userID;
......@@ -70,8 +70,7 @@ public class User {
@Ignore
String currentRole;
public User(int db_id, String userID, String userName, String userProfilePictureUrl, List<Event> userInterestedEvents, List<Event> userGoingEvents, String userEmail, String userRollNumber, String userContactNumber, String userAbout, List<Body> userFollowedBodies, List<String> userFollowedBodiesID, List<Role> userRoles, List<Role> userInstituteRoles, String userWebsiteURL, String userLDAPId, String hostel) {
this.db_id = db_id;
public User(@NonNull String userID, String userName, String userProfilePictureUrl, List<Event> userInterestedEvents, List<Event> userGoingEvents, String userEmail, String userRollNumber, String userContactNumber, String userAbout, List<Body> userFollowedBodies, List<String> userFollowedBodiesID, List<Role> userRoles, List<Role> userInstituteRoles, String userWebsiteURL, String userLDAPId, String hostel) {
this.userID = userID;
this.userName = userName;
this.userProfilePictureUrl = userProfilePictureUrl;
......
......@@ -3,13 +3,14 @@ package in.ac.iitb.gymkhana.iitbapp.data;
import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.PrimaryKey;
import android.support.annotation.NonNull;
import com.google.gson.annotations.SerializedName;
@Entity(tableName = "venues")
public class Venue {
@PrimaryKey(autoGenerate = true)
int db_id;
@NonNull()
@PrimaryKey()
@ColumnInfo(name = "id")
@SerializedName("id")
String venueID;
......
......@@ -6,7 +6,11 @@ import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.squareup.picasso.Picasso;
import de.hdodenhof.circleimageview.CircleImageView;
import in.ac.iitb.gymkhana.iitbapp.R;
/**
......@@ -25,6 +29,55 @@ public class AboutFragment extends BaseFragment {
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_about, container, false);
}
@Override
public void onStart() {
super.onStart();
CircleImageView varunimg = getActivity().findViewById(R.id.varunimg);
CircleImageView sajalimg = getActivity().findViewById(R.id.sajalimg);
CircleImageView nihalimg = getActivity().findViewById(R.id.nihalimg);
CircleImageView ydidwaniaimg = getActivity().findViewById(R.id.ydidwaniaimg);
CircleImageView cheekuimg = getActivity().findViewById(R.id.cheekuimg);
CircleImageView sarthakimg = getActivity().findViewById(R.id.sarthakimg);
CircleImageView sohamimg = getActivity().findViewById(R.id.sohamimg);
CircleImageView mrunmayiimg = getActivity().findViewById(R.id.mrunmayiimg);
CircleImageView owaisimg = getActivity().findViewById(R.id.owaisimg);
CircleImageView hrushikeshimg = getActivity().findViewById(R.id.hrushikeshimg);
CircleImageView yashkhemimg = getActivity().findViewById(R.id.yashkhemimg);
CircleImageView bavishimg = getActivity().findViewById(R.id.bavishimg);
CircleImageView mayuimg = getActivity().findViewById(R.id.mayuimg);
CircleImageView tomarimg = getActivity().findViewById(R.id.tomarimg);
CircleImageView bijoyimg = getActivity().findViewById(R.id.bijoyimg);
CircleImageView dheerendraimg = getActivity().findViewById(R.id.dheerendraimg);
CircleImageView ranveerimg = getActivity().findViewById(R.id.ranveerimg);
CircleImageView amangourimg = getActivity().findViewById(R.id.amangourimg);
CircleImageView wnccimg = getActivity().findViewById(R.id.wnccimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/varun.jpg").into(varunimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/sajal.jpg").into(sajalimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/nihal.jpg").into(nihalimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/ydidwania.jpg").into(ydidwaniaimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/cheeku.jpg").into(cheekuimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/sarthak.jpg").into(sarthakimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/soham.jpg").into(sohamimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/mrunmayi.jpg").into(mrunmayiimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/owais.jpg").into(owaisimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/hrushikesh.jpg").into(hrushikeshimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/yashkhem.jpg").into(yashkhemimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/bavish.jpg").into(bavishimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/mayu.jpg").into(mayuimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/tomar.jpg").into(tomarimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/bijoy.jpg").into(bijoyimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/dheerendra.jpg").into(dheerendraimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/ranveer.jpg").into(ranveerimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/amangour.jpg").into(amangourimg);
Picasso.with(getContext()).load("https://insti.app/team-pics/wncc.jpg").into(wnccimg);
}
}
......@@ -113,6 +113,17 @@ public class AddEventFragment extends BaseFragment {
}
}
public static Timestamp makeTimestamp(int year, int month, int day, int hour, int minute) {
Calendar cal = new GregorianCalendar();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DATE, day);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
return new Timestamp(cal.getTimeInMillis());
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
......@@ -247,17 +258,6 @@ public class AddEventFragment extends BaseFragment {
});
}
public static Timestamp makeTimestamp(int year, int month, int day, int hour, int minute) {
Calendar cal = new GregorianCalendar();
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DATE, day);
cal.set(Calendar.HOUR_OF_DAY, hour);
cal.set(Calendar.MINUTE, minute);
return new Timestamp(cal.getTimeInMillis());
}
private void sendImage() {
progressDialog.setMessage("Uploading Image");
ImageUploadRequest imageUploadRequest = new ImageUploadRequest(base64Image);
......
......@@ -115,7 +115,7 @@ public class BodyFragment extends Fragment {
if (response.isSuccessful()) {
Body body = response.body();
new insertDbBody().execute(body);
new updateDbBody().execute(body);
displayBody(body);
bodySwipeRefreshLayout.setRefreshing(false);
......@@ -130,7 +130,18 @@ public class BodyFragment extends Fragment {
});
}
private void setVisibleIfHasElements(int[] viewIds, List list) {
if (list != null && list.size() > 0) {
for (int viewId: viewIds){
getActivity().findViewById(viewId).setVisibility(View.VISIBLE);
}
}
}
private void displayBody(final Body body) {
/* Skip if we're already destroyed */
if (getView() == null) return;
TextView bodyName = (TextView) getView().findViewById(R.id.body_name);
TextView bodyDescription = (TextView) getView().findViewById(R.id.body_description);
ImageView eventPicture = (ImageView) getActivity().findViewById(R.id.body_picture);
......@@ -138,6 +149,12 @@ public class BodyFragment extends Fragment {
ImageButton shareBodyButton = getActivity().findViewById(R.id.share_body_button);
final Button followButton = getActivity().findViewById(R.id.follow_button);
/* Show relevant card titles */
setVisibleIfHasElements(new int[]{R.id.body_events_title, R.id.event_card_recycler_view}, body.getBodyEvents());
setVisibleIfHasElements(new int[]{R.id.body_orgs_title, R.id.org_card_recycler_view}, body.getBodyChildren());
setVisibleIfHasElements(new int[]{R.id.body_parents_title, R.id.parentorg_card_recycler_view}, body.getBodyParents());
setVisibleIfHasElements(new int[]{R.id.body_people_title, R.id.people_card_recycler_view}, body.getBodyRoles());
/* Set body information */
bodyName.setText(body.getBodyName());
Picasso.with(getContext()).load(body.getBodyImageURL()).into(eventPicture);
......@@ -306,15 +323,11 @@ public class BodyFragment extends Fragment {
private class updateDbBody extends AsyncTask<Body, Void, Integer> {
@Override
protected Integer doInBackground(Body... body) {
appDatabase.dbDao().updateBody(body[0]);
return 1;
}
}
private class insertDbBody extends AsyncTask<Body, Void, Integer> {
@Override
protected Integer doInBackground(Body... body) {
appDatabase.dbDao().insertBody(body[0]);
if (appDatabase.dbDao().getBody(body[0].getBodyID()).length > 0) {
appDatabase.dbDao().updateBody(body[0]);
} else {
appDatabase.dbDao().insertBody(body[0]);
}
return 1;
}
}
......
......@@ -11,6 +11,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CalendarView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson;
......@@ -134,6 +135,8 @@ public class CalendarFragment extends BaseFragment {
}
private void showEventsForDate(Date date) {
/* Skip if we're already destroyed */
if (getActivity() == null) return;
final List<Event> filteredEvents = new ArrayList<Event>();
for (Event event : events) {
......@@ -144,6 +147,16 @@ public class CalendarFragment extends BaseFragment {
}
}
/* Show number of events */
TextView noEvents = getActivity().findViewById(R.id.number_of_events);
if (filteredEvents.size() == 0) {
noEvents.setText("No Events");
} else if (filteredEvents.size() == 1) {
noEvents.setText("1 Event");
} else {
noEvents.setText(Integer.toString(filteredEvents.size()) + " Events");
}
RecyclerView eventRecyclerView = (RecyclerView) getActivity().findViewById(R.id.calendar_event_card_recycler_view);
FeedAdapter eventAdapter = new FeedAdapter(filteredEvents, new ItemClickListener() {
@Override
......
......@@ -42,6 +42,7 @@ public class FeedFragment extends BaseFragment {
private SwipeRefreshLayout feedSwipeRefreshLayout;
private AppDatabase appDatabase;
private FloatingActionButton fab;
private boolean freshEventsDisplayed = false;
public FeedFragment() {
// Required empty public constructor
......@@ -98,6 +99,7 @@ public class FeedFragment extends BaseFragment {
if (response.isSuccessful()) {
NewsFeedResponse newsFeedResponse = response.body();
List<Event> events = newsFeedResponse.getEvents();
freshEventsDisplayed = true;
displayEvents(events);
new updateDatabase().execute(events);
......@@ -115,6 +117,9 @@ public class FeedFragment extends BaseFragment {
}
private void displayEvents(final List<Event> events) {
/* Skip if we're already destroyed */
if (getActivity() == null) return;
final FeedAdapter feedAdapter = new FeedAdapter(events, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
......@@ -163,7 +168,9 @@ public class FeedFragment extends BaseFragment {
}
protected void onPostExecute(List<Event> result) {
displayEvents(result);
if (!freshEventsDisplayed) {
displayEvents(result);
}
}
}
}
......@@ -15,7 +15,10 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Locale;
import in.ac.iitb.gymkhana.iitbapp.ActivityBuffer;
import in.ac.iitb.gymkhana.iitbapp.Constants;
......@@ -25,6 +28,7 @@ import in.ac.iitb.gymkhana.iitbapp.api.RetrofitInterface;
import in.ac.iitb.gymkhana.iitbapp.api.ServiceGenerator;
import in.ac.iitb.gymkhana.iitbapp.data.AppDatabase;
import in.ac.iitb.gymkhana.iitbapp.data.HostelMessMenu;
import in.ac.iitb.gymkhana.iitbapp.data.MessMenu;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
......@@ -133,7 +137,29 @@ public class MessMenuFragment extends BaseFragment {
}
private void displayMessMenu(HostelMessMenu hostelMessMenu) {
final MessMenuAdapter messMenuAdapter = new MessMenuAdapter(hostelMessMenu.getMessMenus());
/* Skip if we're already destroyed */
if (getActivity() == null) return;
List<MessMenu> messMenus = hostelMessMenu.getMessMenus();
/* Sort by day starting today
* This could have been done in a much simpler way with Java 8 :(
* Don't try to fix this */
final List<MessMenu> sortedMenus = new ArrayList();
final Calendar calendar = Calendar.getInstance(Locale.UK);
int today = calendar.get(Calendar.DAY_OF_WEEK) - 2;
if (today == -1) { today = 6; }
for (int i = 0; i < 7; i++) {
final int day = (today + i) % 7 + 1;
for(MessMenu menu : messMenus) {
if(menu.getDay() == day) {
sortedMenus.add(menu);
}
}
}
final MessMenuAdapter messMenuAdapter = new MessMenuAdapter(sortedMenus);
getActivityBuffer().safely(new ActivityBuffer.IRunnable() {
@Override
public void run(Activity pActivity) {
......
package in.ac.iitb.gymkhana.iitbapp.fragment;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
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.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.gson.Gson;
import java.util.List;
import in.ac.iitb.gymkhana.iitbapp.ActivityBuffer;
import in.ac.iitb.gymkhana.iitbapp.Constants;
import in.ac.iitb.gymkhana.iitbapp.ItemClickListener;
import in.ac.iitb.gymkhana.iitbapp.R;
import in.ac.iitb.gymkhana.iitbapp.adapter.FeedAdapter;
import in.ac.iitb.gymkhana.iitbapp.data.AppDatabase;
import in.ac.iitb.gymkhana.iitbapp.data.Event;
/**
* A simple {@link Fragment} subclass.
*/
public class MyEventsFragment extends BaseFragment {
FloatingActionButton fab;
private RecyclerView myEventsFeedRecyclerView;
private SwipeRefreshLayout myEventsFeedSwipeRefreshLayout;
private AppDatabase appDatabase;
private FloatingActionButton fab;
public MyEventsFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_my_events, container, false);
fab = (FloatingActionButton) view.findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
......@@ -44,7 +60,79 @@ public class MyEventsFragment extends BaseFragment {
}
});
return view;
}
@Override
public void onStart() {
super.onStart();
appDatabase = AppDatabase.getAppDatabase(getContext());
new showEvents().execute();
myEventsFeedSwipeRefreshLayout = getActivity().findViewById(R.id.my_events_feed_swipe_refresh_layout);
myEventsFeedSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
updateOnRefresh();
myEventsFeedSwipeRefreshLayout.setRefreshing(false);
}
});
}
private void updateOnRefresh() {
new showEvents().execute();
}
private void displayEvents(final List<Event> events) {
final FeedAdapter feedAdapter = new FeedAdapter(events, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
String eventJson = new Gson().toJson(events.get(position));
Bundle bundle = getArguments();
if (bundle == null)
bundle = new Bundle();
bundle.putString(Constants.EVENT_JSON, eventJson);
EventFragment eventFragment = new EventFragment();
eventFragment.setArguments(bundle);
FragmentManager manager = getActivity().getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.framelayout_for_fragment, eventFragment, eventFragment.getTag());
transaction.addToBackStack(eventFragment.getTag()).commit();
}
});
getActivityBuffer().safely(new ActivityBuffer.IRunnable() {
@Override
public void run(Activity pActivity) {
try {
myEventsFeedRecyclerView = getActivity().findViewById(R.id.my_events_feed_recycler_view);
myEventsFeedRecyclerView.setAdapter(feedAdapter);
myEventsFeedRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
} catch (NullPointerException e) {
e.printStackTrace();
}
}
});
}
}
private class showEvents extends AsyncTask<String, Void, List<Event>> {
@Override
protected List<Event> doInBackground(String... events) {
List<Event> temp = appDatabase.dbDao().getAllEvents();
List<Event> eventsfollowing = appDatabase.dbDao().getAllEvents();
eventsfollowing.clear();
int k = temp.size();
for (int i = 0; i < k; i++) {
if (temp.get(i).getEventUserUes() != 0) eventsfollowing.add(temp.get(i));
}
return eventsfollowing;
}
protected void onPostExecute(List<Event> result) {
displayEvents(result);
}
}
}
\ No newline at end of file
......@@ -37,6 +37,7 @@ public class NewsFragment extends BaseFragment {
private RecyclerView newsRecyclerView;
private SwipeRefreshLayout newsSwipeRefreshLayout;
private AppDatabase appDatabase;
private boolean freshNewsDisplayed = false;
public NewsFragment() {
// Required empty public constructor
......@@ -75,6 +76,7 @@ public class NewsFragment extends BaseFragment {
public void onResponse(Call<List<NewsArticle>> call, Response<List<NewsArticle>> response) {
if (response.isSuccessful()) {
List<NewsArticle> articles = response.body();
freshNewsDisplayed = true;
displayNews(articles);
new updateDatabase().execute(articles);
......@@ -92,6 +94,9 @@ public class NewsFragment extends BaseFragment {
}
private void displayNews(final List<NewsArticle> result) {
/* Skip if we're already destroyed */
if (getActivity() == null) return;
final NewsAdapter newsAdapter = new NewsAdapter(result, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
......@@ -134,7 +139,9 @@ public class NewsFragment extends BaseFragment {
}
protected void onPostExecute(List<NewsArticle> result) {
displayNews(result);
if (!freshNewsDisplayed) {
displayNews(result);
}
}
}
}
......@@ -37,6 +37,7 @@ public class PlacementBlogFragment extends BaseFragment {
private RecyclerView placementFeedRecyclerView;
private SwipeRefreshLayout feedSwipeRefreshLayout;
private AppDatabase appDatabase;
private boolean freshBlogDisplayed = false;
public PlacementBlogFragment() {
......@@ -76,6 +77,7 @@ public class PlacementBlogFragment extends BaseFragment {
public void onResponse(Call<List<PlacementBlogPost>> call, Response<List<PlacementBlogPost>> response) {
if (response.isSuccessful()) {
List<PlacementBlogPost> posts = response.body();
freshBlogDisplayed = true;
displayPlacementFeed(posts);
new updateDatabase().execute(posts);
......@@ -93,6 +95,9 @@ public class PlacementBlogFragment extends BaseFragment {
}
private void displayPlacementFeed(final List<PlacementBlogPost> result) {
/* Skip if we're already destroyed */
if (getActivity() == null) return;
final PlacementBlogAdapter placementBlogAdapter = new PlacementBlogAdapter(result, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
......@@ -135,7 +140,9 @@ public class PlacementBlogFragment extends BaseFragment {
}
protected void onPostExecute(List<PlacementBlogPost> result) {
displayPlacementFeed(result);
if (!freshBlogDisplayed) {
displayPlacementFeed(result);
}
}
}
}
......@@ -72,7 +72,11 @@ public class SettingsFragment extends Fragment {
ImageView userProfilePictureImageView = getActivity().findViewById(R.id.user_card_avatar);
TextView userNameTextView = getActivity().findViewById(R.id.user_card_name);
Picasso.with(getContext()).load(user.getUserProfilePictureUrl()).into(userProfilePictureImageView);
Picasso.with(getContext())
.load(user.getUserProfilePictureUrl())
.resize(800, 0)
.placeholder(R.drawable.user_placeholder)
.into(userProfilePictureImageView);
userNameTextView.setText(user.getUserName());
Button updateProfileButton = getActivity().findViewById(R.id.settings_update_profile);
......
......@@ -37,6 +37,7 @@ public class TrainingBlogFragment extends BaseFragment {
private RecyclerView trainingFeedRecyclerView;
private SwipeRefreshLayout feedSwipeRefreshLayout;
private AppDatabase appDatabase;
private boolean freshBlogDisplayed = false;
public TrainingBlogFragment() {
......@@ -76,6 +77,7 @@ public class TrainingBlogFragment extends BaseFragment {
public void onResponse(Call<List<TrainingBlogPost>> call, Response<List<TrainingBlogPost>> response) {
if (response.isSuccessful()) {
List<TrainingBlogPost> posts = response.body();
freshBlogDisplayed = true;
displayTrainingFeed(posts);
new updateDatabase().execute(posts);
......@@ -93,6 +95,9 @@ public class TrainingBlogFragment extends BaseFragment {
}
private void displayTrainingFeed(final List<TrainingBlogPost> result) {
/* Skip if we're already destroyed */
if (getActivity() == null) return;
final TrainingBlogAdapter trainingBlogAdapter = new TrainingBlogAdapter(result, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
......@@ -135,7 +140,9 @@ public class TrainingBlogFragment extends BaseFragment {
}
protected void onPostExecute(List<TrainingBlogPost> result) {
displayTrainingFeed(result);
if (!freshBlogDisplayed) {
displayTrainingFeed(result);
}
}
}
}
<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:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M3.9,12c0,-1.71 1.39,-3.1 3.1,-3.1h4L11,7L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h4v-1.9L7,15.1c-1.71,0 -3.1,-1.39 -3.1,-3.1zM8,13h8v-2L8,11v2zM17,7h-4v1.9h4c1.71,0 3.1,1.39 3.1,3.1s-1.39,3.1 -3.1,3.1h-4L13,17h4c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5z"/>
android:pathData="M3.9,12c0,-1.71 1.39,-3.1 3.1,-3.1h4L11,7L7,7c-2.76,0 -5,2.24 -5,5s2.24,5 5,5h4v-1.9L7,15.1c-1.71,0 -3.1,-1.39 -3.1,-3.1zM8,13h8v-2L8,11v2zM17,7h-4v1.9h4c1.71,0 3.1,1.39 3.1,3.1s-1.39,3.1 -3.1,3.1h-4L13,17h4c2.76,0 5,-2.24 5,-5s-2.24,-5 -5,-5z" />
</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:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z" />
</vector>
<vector android:height="24dp" android:viewportHeight="2250"
android:viewportWidth="2250" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#c5c5c5"
android:pathData="M0,1125l0,-1125 1125,0 1125,0 0,1125 0,1125 -140,0c-77,0 -140,-3 -140,-6 0,-48 -51,-287 -69,-322 -5,-9 -19,-42 -32,-72 -82,-193 -257,-378 -431,-455 -37,-17 -68,-33 -68,-36 0,-3 17,-15 38,-27 20,-11 56,-40 78,-64 222,-231 179,-606 -89,-771 -102,-63 -154,-79 -267,-79 -154,-1 -248,38 -355,146 -82,83 -119,153 -141,264 -37,187 49,393 209,502 20,14 37,28 37,31 0,4 -20,14 -45,23 -73,28 -195,114 -264,184 -112,117 -177,228 -231,391 -25,76 -34,115 -56,259l-5,32 -139,0 -140,0 0,-1125z" android:strokeColor="#00000000"/>
<path android:fillColor="#fefefe"
android:pathData="M286,2208c32,-228 86,-375 194,-533 77,-111 244,-248 355,-291 25,-9 45,-19 45,-23 0,-3 -17,-17 -37,-31 -160,-109 -246,-315 -209,-502 22,-111 59,-181 141,-264 107,-108 201,-147 355,-146 113,0 165,16 267,79 195,120 281,365 205,584 -36,103 -117,207 -194,251 -21,12 -38,24 -38,27 0,3 31,19 68,36 174,77 349,262 431,455 13,30 27,63 32,72 18,35 69,274 69,322 0,3 -380,6 -845,6l-845,0 6,-42z" android:strokeColor="#00000000"/>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="2250"
android:viewportWidth="2250">
<path
android:fillColor="#c5c5c5"
android:pathData="M0,1125l0,-1125 1125,0 1125,0 0,1125 0,1125 -140,0c-77,0 -140,-3 -140,-6 0,-48 -51,-287 -69,-322 -5,-9 -19,-42 -32,-72 -82,-193 -257,-378 -431,-455 -37,-17 -68,-33 -68,-36 0,-3 17,-15 38,-27 20,-11 56,-40 78,-64 222,-231 179,-606 -89,-771 -102,-63 -154,-79 -267,-79 -154,-1 -248,38 -355,146 -82,83 -119,153 -141,264 -37,187 49,393 209,502 20,14 37,28 37,31 0,4 -20,14 -45,23 -73,28 -195,114 -264,184 -112,117 -177,228 -231,391 -25,76 -34,115 -56,259l-5,32 -139,0 -140,0 0,-1125z"
android:strokeColor="#00000000" />
<path
android:fillColor="#fefefe"
android:pathData="M286,2208c32,-228 86,-375 194,-533 77,-111 244,-248 355,-291 25,-9 45,-19 45,-23 0,-3 -17,-17 -37,-31 -160,-109 -246,-315 -209,-502 22,-111 59,-181 141,-264 107,-108 201,-147 355,-146 113,0 165,16 267,79 195,120 281,365 205,584 -36,103 -117,207 -194,251 -21,12 -38,24 -38,27 0,3 31,19 68,36 174,77 349,262 431,455 13,30 27,63 32,72 18,35 69,274 69,322 0,3 -380,6 -845,6l-845,0 6,-42z"
android:strokeColor="#00000000" />
</vector>
......@@ -44,7 +44,10 @@
android:id="@+id/body_card_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Description" />
android:text="Description"
android:scrollHorizontally="true"
android:ellipsize="end"
android:maxLines="1" />
</LinearLayout>
</LinearLayout>
......
......@@ -78,7 +78,9 @@
android:layout_width="100dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:text="LH 101" />
android:text="LH 101"
android:scrollHorizontally="true"
android:maxLines="1"/>
</LinearLayout>
</LinearLayout>
......
This diff is collapsed.
......@@ -77,11 +77,11 @@
<TextView
android:id="@+id/tv_end"
android:enabled="false"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/editTextBackground"
android:enabled="false"
android:gravity="bottom"
android:hint="To "
android:paddingRight="6dp"
......
......@@ -127,6 +127,8 @@
android:textSize="16sp" />
<TextView
android:id="@+id/body_events_title"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
......@@ -136,12 +138,15 @@
<android.support.v7.widget.RecyclerView
android:id="@+id/event_card_recycler_view"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:nestedScrollingEnabled="false" />
<TextView
android:id="@+id/body_orgs_title"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
......@@ -151,12 +156,15 @@
<android.support.v7.widget.RecyclerView
android:id="@+id/org_card_recycler_view"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:nestedScrollingEnabled="false" />
<TextView
android:id="@+id/body_people_title"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
......@@ -166,12 +174,15 @@
<android.support.v7.widget.RecyclerView
android:id="@+id/people_card_recycler_view"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:nestedScrollingEnabled="false" />
<TextView
android:id="@+id/body_parents_title"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
......@@ -181,9 +192,10 @@
<android.support.v7.widget.RecyclerView
android:id="@+id/parentorg_card_recycler_view"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:nestedScrollingEnabled="false" />
</LinearLayout>
......@@ -194,7 +206,7 @@
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
......
......@@ -41,13 +41,14 @@
android:background="@android:color/darker_gray" />
<TextView
android:id="@+id/number_of_events"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_below="@id/simpleCalendarView"
android:layout_centerHorizontal="true"
android:background="@drawable/round_text_box"
android:gravity="center"
android:text="# Events Today"
android:text="No Events"
android:textColor="@color/secondaryTextColor" />
</RelativeLayout>
......@@ -77,7 +78,7 @@
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
......
......@@ -31,7 +31,7 @@
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
......
......@@ -2,8 +2,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
......@@ -36,7 +35,7 @@
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
......
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relative_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/my_events_feed_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="in.ac.iitb.gymkhana.iitbapp.fragment.MyEventsFragment">
<android.support.v7.widget.RecyclerView
android:id="@+id/my_events_feed_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="8dp" />
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
......
......@@ -21,7 +21,7 @@
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
......
......@@ -21,7 +21,7 @@
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
......
......@@ -2,8 +2,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
xmlns:tools="http://schemas.android.com/tools"
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
......@@ -92,11 +91,12 @@
android:layout_height="wrap_content" />
</LinearLayout>
<RelativeLayout
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
......
......@@ -21,7 +21,7 @@
android:id="@+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
android:gravity="center">
<ProgressBar
android:layout_width="wrap_content"
......
......@@ -17,20 +17,20 @@
android:layout_width="64dp"
android:layout_height="64dp"
android:paddingTop="@dimen/nav_header_vertical_spacing"
app:srcCompat="@mipmap/ic_launcher_round" />
android:src="@drawable/user_placeholder" />
<TextView
android:id="@+id/user_name_nav_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/nav_header_vertical_spacing"
android:text="Android Studio"
android:text="Guest"
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="@+id/user_rollno_nav_header"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android.studio@android.com" />
android:text="IITB User" />
</LinearLayout>
......@@ -44,7 +44,10 @@
android:id="@+id/role_card_role"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Role" />
android:text="Role"
android:scrollHorizontally="true"
android:ellipsize="end"
android:maxLines="1" />
</LinearLayout>
</LinearLayout>
......
<?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"/>
<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"?>
<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"/>
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@mipmap/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
......@@ -12,6 +12,9 @@
<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="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-array name="hostels_array">
<item>Hostel 1</item>
......
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