Skip to content

Commit

Permalink
add funkcionality: show mutual followers
Browse files Browse the repository at this point in the history
  • Loading branch information
josefjebavy committed Feb 28, 2021
1 parent e507c4f commit 7331f11
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package me.grishka.houseclub.api.methods;

import java.util.HashMap;
import java.util.List;

import me.grishka.houseclub.api.ClubhouseAPIRequest;
import me.grishka.houseclub.api.model.FullUser;

public class GetMutualFollowers extends ClubhouseAPIRequest<GetMutualFollowers.Response>{
public GetMutualFollowers(int userID, int pageSize, int page){
super("GET", "get_mutual_follows", Response.class);
queryParams=new HashMap<>();
queryParams.put("user_id", userID+"");
queryParams.put("page_size", pageSize+"");
queryParams.put("page", page+"");
}

public static class Response{
public List<FullUser> users;
public int count;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package me.grishka.houseclub.fragments;

import android.app.Activity;

import me.grishka.appkit.api.SimpleCallback;
import me.grishka.houseclub.R;
import me.grishka.houseclub.api.methods.GetMutualFollowers;

public class MutualFollowersFragment extends UserListFragment{

@Override
public void onAttach(Activity activity){
super.onAttach(activity);
setTitle(R.string.mutual_followers_title);
}

@Override
protected void doLoadData(int offset, int count){
currentRequest=new GetMutualFollowers(getArguments().getInt("id"), 50, offset/50+1)
.setCallback(new SimpleCallback<GetMutualFollowers.Response>(this){
@Override
public void onSuccess(GetMutualFollowers.Response result){
currentRequest=null;
onDataLoaded(result.users, data.size()+preloadedData.size()+result.users.size()<result.count);
}
})
.exec();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class ProfileFragment extends LoaderFragment{
private FullUser user;

private TextView name, username, followers, following, followsYou, bio, inviteInfo, twitter, instagram,
invites;
invites, mutualfollowers;
private ImageView photo, inviterPhoto;
private Button followBtn, inviteButton;
private EditText invitePhoneNum;
Expand All @@ -76,6 +76,7 @@ public View onCreateContentView(LayoutInflater inflater, ViewGroup container, Bu
name=v.findViewById(R.id.name);
username=v.findViewById(R.id.username);
followers=v.findViewById(R.id.followers);
mutualfollowers=v.findViewById(R.id.mutualfollowers);
following=v.findViewById(R.id.following);
followsYou=v.findViewById(R.id.follows_you);
bio=v.findViewById(R.id.bio);
Expand All @@ -95,6 +96,7 @@ public View onCreateContentView(LayoutInflater inflater, ViewGroup container, Bu
instagram.setOnClickListener(this::onInstagramClick);
twitter.setOnClickListener(this::onTwitterClick);
followers.setOnClickListener(this::onFollowersClick);
mutualfollowers.setOnClickListener(this::onMutualFollowersClick);
following.setOnClickListener(this::onFollowingClick);
v.findViewById(R.id.inviter_btn).setOnClickListener(this::onInviterClick);
if(self){
Expand Down Expand Up @@ -127,6 +129,7 @@ public void onSuccess(GetProfile.Response result){

followsYou.setVisibility(user.followsMe ? View.VISIBLE : View.GONE);
followers.setText(getResources().getQuantityString(R.plurals.followers, user.numFollowers, user.numFollowers));
mutualfollowers.setText(R.string.mutual_followers_title);
following.setText(getResources().getQuantityString(R.plurals.following, user.numFollowing, user.numFollowing));
bio.setText(user.bio);
if(TextUtils.isEmpty(user.bio) && self)
Expand Down Expand Up @@ -300,6 +303,11 @@ private void onFollowersClick(View v){
args.putInt("id", user.userId);
Nav.go(getActivity(), FollowersFragment.class, args);
}
private void onMutualFollowersClick(View v){
Bundle args=new Bundle();
args.putInt("id", user.userId);
Nav.go(getActivity(), MutualFollowersFragment.class, args);
}

private void onFollowingClick(View v){
Bundle args=new Bundle();
Expand Down
10 changes: 8 additions & 2 deletions Houseclub/src/main/res/layout/profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@
android:layout_marginLeft="16dp"
android:textSize="13dp"
tools:text="25 following"/>

<TextView
android:id="@+id/mutualfollowers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:textSize="13dp"
tools:text="25 mutual followers"/>
</LinearLayout>

<TextView
Expand Down Expand Up @@ -190,4 +196,4 @@

</LinearLayout>

</ScrollView>
</ScrollView>
1 change: 1 addition & 0 deletions Houseclub/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,5 @@
<string name="event_expired">This event has already ended</string>
<string name="log_in_to_activate">Please log in again to activate your account.</string>
<string name="ok">OK</string>
<string name="mutual_followers_title">Mutual Followers</string>
</resources>

0 comments on commit 7331f11

Please sign in to comment.