use of app.insti.adapter.ComplaintsAdapter in project IITB-App by wncc.
the class ComplaintsHomeFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_complaints_home, container, false);
RecyclerView recyclerViewHome = view.findViewById(R.id.recyclerViewHome);
homeListAdapter = new ComplaintsAdapter(getActivity(), uID, uProfileUrl);
swipeContainer = view.findViewById(R.id.swipeContainer);
error_message_home = view.findViewById(R.id.error_message_home);
LinearLayoutManager llm = new LinearLayoutManager(getActivity());
recyclerViewHome.setLayoutManager(llm);
recyclerViewHome.setHasFixedSize(true);
recyclerViewHome.setAdapter(homeListAdapter);
recyclerViewHome.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
if (networkBusy || currentIndex == -1)
return;
if (!recyclerView.canScrollVertically(1)) {
networkBusy = true;
swipeContainer.setRefreshing(true);
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getAllComplaints(Utils.getSessionIDHeader(), currentIndex, 5).enqueue(new Callback<List<Venter.Complaint>>() {
@Override
public void onResponse(Call<List<Venter.Complaint>> call, Response<List<Venter.Complaint>> response) {
if (response.isSuccessful()) {
if (response.body() != null && !response.body().isEmpty()) {
complaints.addAll(response.body());
initialiseRecyclerView(complaints);
currentIndex += 5;
} else {
currentIndex = -1;
}
}
networkBusy = false;
swipeContainer.setRefreshing(false);
}
@Override
public void onFailure(Call<List<Venter.Complaint>> call, Throwable t) {
networkBusy = false;
swipeContainer.setRefreshing(false);
}
});
}
}
});
swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
callServerToGetNearbyComplaints();
}
});
swipeContainer.setColorSchemeResources(R.color.colorPrimary);
if (!isCalled) {
swipeContainer.post(new Runnable() {
@Override
public void run() {
swipeContainer.setRefreshing(true);
callServerToGetNearbyComplaints();
}
});
isCalled = true;
}
return view;
}
use of app.insti.adapter.ComplaintsAdapter in project IITB-App by wncc.
the class ComplaintsMeFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_complaints_me, container, false);
RecyclerView recyclerViewMe = view.findViewById(R.id.recyclerViewMe);
meListAdapter = new ComplaintsAdapter(getActivity(), uID, uProfileUrl);
swipeContainer = view.findViewById(R.id.swipeContainer);
error_message_me = view.findViewById(R.id.error_message_me);
LinearLayoutManager llm = new LinearLayoutManager(getActivity());
recyclerViewMe.setLayoutManager(llm);
recyclerViewMe.setHasFixedSize(true);
recyclerViewMe.setAdapter(meListAdapter);
swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
getMeItems();
}
});
swipeContainer.setColorSchemeColors(getResources().getColor(R.color.colorPrimary));
if (!isCalled) {
swipeContainer.post(new Runnable() {
@Override
public void run() {
swipeContainer.setRefreshing(true);
getMeItems();
}
});
isCalled = true;
}
return view;
}
Aggregations