use of br.ufrj.caronae.acts.MainAct in project caronae-android by caronae.
the class AllRidesFrag method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_all_rides, container, false);
ButterKnife.bind(this, view);
context = getContext();
setHasOptionsMenu(true);
coordinatorLayout = (CoordinatorLayout) view.findViewById(R.id.all_rides_coordinator);
listAllRides(1);
if (((MainAct) getActivity()).filterText.getText().equals("")) {
((MainAct) getActivity()).hideFilterCard(context);
}
return view;
}
use of br.ufrj.caronae.acts.MainAct in project caronae-android by caronae.
the class MyRidesListFrag method getActiveRides.
private void getActiveRides() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
CaronaeAPI.service(getContext()).getMyActiveRides().enqueue(new Callback<List<RideForJson>>() {
@Override
public void onResponse(Call<List<RideForJson>> call, Response<List<RideForJson>> response) {
if (response.isSuccessful()) {
List<RideForJson> rideWithUsersList = response.body();
if (rideWithUsersList == null || rideWithUsersList.isEmpty()) {
MyRidesFrag.hideProgressBar();
myRidesList.setAdapter(new MyActiveRidesAdapter(new ArrayList<RideForJson>(), (MainAct) getActivity()));
myRidesList.setHasFixedSize(true);
myRidesList.setLayoutManager(new LinearLayoutManager(getActivity()));
new LoadRides().execute();
return;
}
ActiveRide.deleteAll(ActiveRide.class);
// subscribe to ride id topic
for (RideForJson rideWithUsers : rideWithUsersList) {
int rideId = rideWithUsers.getId().intValue();
rideWithUsers.setDbId(rideId);
FirebaseTopicsHandler.subscribeFirebaseTopic(rideId + "");
new ActiveRide(rideWithUsers.getDbId(), rideWithUsers.isGoing(), rideWithUsers.getDate()).save();
}
Collections.sort(rideWithUsersList, new RideOfferComparatorByDateAndTime());
addAllActiveRidesToList(rideWithUsersList);
MyRidesFrag.hideProgressBar();
} else {
Util.treatResponseFromServer(response);
MyRidesFrag.hideProgressBar();
norides_tv.setVisibility(View.VISIBLE);
Util.toast(R.string.frag_myactiverides_errorGetActiveRides);
Log.e("getMyActiveRides", response.message());
}
new LoadRides().execute();
}
@Override
public void onFailure(Call<List<RideForJson>> call, Throwable t) {
MyRidesFrag.hideProgressBar();
norides_tv.setVisibility(View.VISIBLE);
Util.toast(R.string.frag_myactiverides_errorGetActiveRides);
new LoadRides().execute();
Log.e("getMyActiveRides", t.getMessage());
}
});
}
});
}
use of br.ufrj.caronae.acts.MainAct in project caronae-android by caronae.
the class MyRidesListFrag method updateAdapter.
private void updateAdapter() {
adapter = new MyRidesAdapter(allRides, (MainAct) getActivity());
myRidesList.setAdapter(adapter);
myRidesList.setLayoutManager(new LinearLayoutManager(getActivity()));
}
Aggregations