use of in.ac.iitb.gymkhana.iitbapp.ItemClickListener in project IITB-App by wncc.
the class FeedFragment method updateFeed.
private void updateFeed() {
RetrofitInterface retrofitInterface = ServiceGenerator.createService(RetrofitInterface.class);
retrofitInterface.getNewsFeed("sessionid=" + getArguments().getString(SESSION_ID)).enqueue(new Callback<NewsFeedResponse>() {
@Override
public void onResponse(Call<NewsFeedResponse> call, Response<NewsFeedResponse> response) {
if (response.isSuccessful()) {
NewsFeedResponse newsFeedResponse = response.body();
final List<Event> events = newsFeedResponse.getEvents();
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 = 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.commit();
}
});
feedRecyclerView = (RecyclerView) getActivity().findViewById(R.id.feed_recycler_view);
feedRecyclerView.setAdapter(feedAdapter);
feedRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
appDatabase.dbDao().deleteEvents();
appDatabase.dbDao().insertEvents(events);
// Server Error
feedSwipeRefreshLayout.setRefreshing(false);
}
}
@Override
public void onFailure(Call<NewsFeedResponse> call, Throwable t) {
// Network Error
feedSwipeRefreshLayout.setRefreshing(false);
}
});
}
use of in.ac.iitb.gymkhana.iitbapp.ItemClickListener in project IITB-App by wncc.
the class FeedFragment method onStart.
@Override
public void onStart() {
super.onStart();
appDatabase = AppDatabase.getAppDatabase(getContext());
final List<Event> events = appDatabase.dbDao().getAllEvents();
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 = 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.commit();
}
});
feedRecyclerView = (RecyclerView) getActivity().findViewById(R.id.feed_recycler_view);
feedRecyclerView.setAdapter(feedAdapter);
feedRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
// }
updateFeed();
feedSwipeRefreshLayout = (SwipeRefreshLayout) getActivity().findViewById(R.id.feed_swipe_refresh_layout);
feedSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
updateFeed();
}
});
}
use of in.ac.iitb.gymkhana.iitbapp.ItemClickListener in project IITB-App by wncc.
the class NotificationsFragment method showNotifications.
private void showNotifications(NotificationsResponse notificationsResponse) {
List<AppNotification> notifications = notificationsResponse.getNotifications();
NotificationsAdapter notificationsAdapter = new NotificationsAdapter(notifications, new ItemClickListener() {
@Override
public void onItemClick(View v, int position) {
// TODO: What to do?
}
});
notificationsRecyclerView = (RecyclerView) getActivity().findViewById(R.id.notifications_recycler_view);
notificationsRecyclerView.setAdapter(notificationsAdapter);
notificationsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
}
Aggregations