use of br.ufrj.caronae.adapters.RideOfferAdapter in project caronae-android by caronae.
the class AllRidesListFrag method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_all_rides_list, container, false);
ButterKnife.bind(this, view);
Bundle bundle = getArguments();
ArrayList<RideForJson> rideOffers = bundle.getParcelableArrayList("rides");
pageIdentifier = bundle.getInt("ID");
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
pageCounter = FIRST_PAGE_TO_LOAD;
for (int counter = FIRST_PAGE_TO_LOAD; counter <= pageCounter; counter++) {
refreshRideList(counter);
}
}
});
adapter = new RideOfferAdapter(new ArrayList<RideForJson>(), getContext(), getActivity().getFragmentManager());
mLayoutManager = new LinearLayoutManager(getContext());
rvRides.setLayoutManager(mLayoutManager);
scrollListener = new EndlessRecyclerViewScrollListener(mLayoutManager) {
@Override
public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
loadOneMorePage();
}
};
rvRides.addOnScrollListener(scrollListener);
rvRides.setAdapter(adapter);
if (!(rideOffers == null || rideOffers.isEmpty())) {
adapter.makeList(rideOffers);
}
App.getBus().register(this);
// After setting layout manager, adapter, etc...
float offsetBottonPx = getResources().getDimension(R.dimen.recycler_view_botton_offset);
float offsetTopPx = getResources().getDimension(R.dimen.recycler_view_top_offset);
Util.OffsetDecoration OffsetDecoration = new Util.OffsetDecoration((int) offsetBottonPx, (int) offsetTopPx);
rvRides.addItemDecoration(OffsetDecoration);
animateListFadeIn();
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(App.getInst());
sharedPreferences.registerOnSharedPreferenceChangeListener(new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals(SharedPref.RIDE_FILTER_PREF_KEY)) {
pageCounter = FIRST_PAGE_TO_LOAD;
refreshRideList(pageCounter);
}
}
});
return view;
}
use of br.ufrj.caronae.adapters.RideOfferAdapter in project caronae-android by caronae.
the class RideSearchFrag method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_ride_search, container, false);
ButterKnife.bind(this, view);
adapter = new RideOfferAdapter(new ArrayList<RideForJson>(), getActivity(), getActivity().getFragmentManager());
rvRides.setAdapter(adapter);
rvRides.setHasFixedSize(true);
rvRides.setLayoutManager(new LinearLayoutManager(getActivity()));
String lastRideSearchFilters = SharedPref.getLastRideSearchFiltersPref();
if (!lastRideSearchFilters.equals(SharedPref.MISSING_PREF)) {
loadLastFilters(lastRideSearchFilters);
}
App.getBus().register(this);
return view;
}
Aggregations