Commit 553d3f1e authored by atharvkotwal's avatar atharvkotwal

Number of followers increase/decrease on clicking follow in body

parent ec32a6de
......@@ -232,7 +232,7 @@ public class BodyFragment extends BackHandledFragment {
* Initialize follow button */
followButton.setBackgroundColor(getResources().getColor(body.getBodyUserFollows() ? R.color.colorAccent : R.color.colorWhite));
followButton.setText(EventFragment.getCountBadgeSpannable("FOLLOW", body.getBodyFollowersCount()));
final boolean initial = body.getBodyUserFollows();
followButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
......@@ -241,11 +241,14 @@ public class BodyFragment extends BackHandledFragment {
@Override
public void onResponse(Call<Void> call, Response<Void> response) {
if (response.isSuccessful()) {
body.setBodyUserFollows(!body.getBodyUserFollows());
new updateDbBody().execute(body);
followButton.setBackgroundColor(getResources().getColor(body.getBodyUserFollows() ? R.color.colorAccent : R.color.colorWhite));
if (body.getBodyUserFollows()) followButton.setText( body.getBodyFollowersCount() + 1 );
else {followButton.setText( body.getBodyFollowersCount() + 1 );}
followButton.setText( EventFragment.getCountBadgeSpannable("FOLLOW", body.getBodyFollowersCount()) );
if (! initial ) { if (body.getBodyUserFollows()) {
followButton.setText(EventFragment.getCountBadgeSpannable("FOLLOW", body.getBodyFollowersCount()+1)); }}
else { if (!body.getBodyUserFollows()) {
followButton.setText(EventFragment.getCountBadgeSpannable("FOLLOW", body.getBodyFollowersCount()-1)); }}
}
}
......
......@@ -48,6 +48,8 @@ public class NewsFragment extends BaseFragment {
private AppDatabase appDatabase;
private boolean freshNewsDisplayed = false;
private String searchQuery;
LinearLayoutManager mLayoutManager;
public static int index = -1, top = -1;
public NewsFragment() {
// Required empty public constructor
......@@ -125,6 +127,7 @@ public class NewsFragment extends BaseFragment {
public void run(Activity pActivity) {
try {
newsRecyclerView = getActivity().findViewById(R.id.news_recycler_view);
newsRecyclerView.setAdapter(newsAdapter);
newsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
newsRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
......
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