mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 13:59:29 +00:00
Linked friends list with users page
This commit is contained in:
parent
71e9cb163f
commit
c5a162ecfb
@ -19,6 +19,7 @@ import org.communiquons.android.comunic.client.api.APIRequest;
|
||||
import org.communiquons.android.comunic.client.data.Account.Account;
|
||||
import org.communiquons.android.comunic.client.data.Account.AccountUtils;
|
||||
import org.communiquons.android.comunic.client.data.DatabaseHelper;
|
||||
import org.communiquons.android.comunic.client.data.UsersInfo.GetUsersHelper;
|
||||
import org.communiquons.android.comunic.client.data.conversations.ConversationsListHelper;
|
||||
import org.communiquons.android.comunic.client.data.friendsList.FriendRefreshLoopRunnable;
|
||||
import org.communiquons.android.comunic.client.data.utils.UiUtils;
|
||||
@ -37,7 +38,8 @@ import org.communiquons.android.comunic.client.fragments.UserPageFragment;
|
||||
*/
|
||||
public class MainActivity extends AppCompatActivity
|
||||
implements ConversationsListHelper.openConversationListener,
|
||||
ConversationsListHelper.updateConversationListener {
|
||||
ConversationsListHelper.updateConversationListener,
|
||||
GetUsersHelper.onOpenUsersPageListener {
|
||||
|
||||
/**
|
||||
* Debug tag
|
||||
@ -272,7 +274,8 @@ public class MainActivity extends AppCompatActivity
|
||||
*
|
||||
* @param userID The ID of the user to open
|
||||
*/
|
||||
void openUserPage(int userID){
|
||||
@Override
|
||||
public void openUserPage(int userID){
|
||||
|
||||
//Prepare arguments
|
||||
Bundle args = new Bundle();
|
||||
|
@ -66,4 +66,14 @@ public class FriendUser {
|
||||
public void setFriend(Friend friend) {
|
||||
this.friend = friend;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* Get the ID of the user
|
||||
*
|
||||
* @return The id of the user
|
||||
*/
|
||||
public int get_user_id(){
|
||||
return userInfo.getId();
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,8 @@ import java.util.ArrayList;
|
||||
* Created by pierre on 11/11/17.
|
||||
*/
|
||||
|
||||
public class FriendsListFragment extends Fragment {
|
||||
public class FriendsListFragment extends Fragment
|
||||
implements AdapterView.OnItemClickListener{
|
||||
|
||||
/**
|
||||
* Debug tag
|
||||
@ -81,6 +82,11 @@ public class FriendsListFragment extends Fragment {
|
||||
*/
|
||||
private ConversationsListHelper.openConversationListener convOpener;
|
||||
|
||||
/**
|
||||
* Users page opener
|
||||
*/
|
||||
private GetUsersHelper.onOpenUsersPageListener usersPageOpener;
|
||||
|
||||
/**
|
||||
* Friend adapter
|
||||
*/
|
||||
@ -105,11 +111,13 @@ public class FriendsListFragment extends Fragment {
|
||||
//Cast activity to convOpener
|
||||
try {
|
||||
convOpener = (ConversationsListHelper.openConversationListener) getActivity();
|
||||
usersPageOpener = (GetUsersHelper.onOpenUsersPageListener) getActivity();
|
||||
} catch (ClassCastException e){
|
||||
e.printStackTrace();
|
||||
|
||||
throw new RuntimeException(getActivity().getClass().getName() + " must implement" +
|
||||
"ConversationsListHelper.openConversationListener !");
|
||||
"ConversationsListHelper.openConversationListener " +
|
||||
"and GetUsersHelper.onOpenUsersPageListener !");
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,6 +222,8 @@ public class FriendsListFragment extends Fragment {
|
||||
|
||||
//Register the view for the context menu
|
||||
registerForContextMenu(listView);
|
||||
|
||||
listView.setOnItemClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -366,4 +376,14 @@ public class FriendsListFragment extends Fragment {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
|
||||
//Get clicked user ID
|
||||
int userID = friendsList.get(position).get_user_id();
|
||||
|
||||
//Open user page
|
||||
usersPageOpener.openUserPage(userID);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,9 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.communiquons.android.comunic.client.MainActivity;
|
||||
import org.communiquons.android.comunic.client.R;
|
||||
import org.communiquons.android.comunic.client.data.Account.AccountUtils;
|
||||
import org.communiquons.android.comunic.client.data.DatabaseHelper;
|
||||
import org.communiquons.android.comunic.client.data.ImageLoad.ImageLoadManager;
|
||||
import org.communiquons.android.comunic.client.data.UsersInfo.AdvancedUserInfo;
|
||||
@ -152,9 +154,21 @@ public class UserPageFragment extends Fragment {
|
||||
//Save user informations
|
||||
userInfo = info;
|
||||
|
||||
//Set activity title
|
||||
getActivity().setTitle(userInfo.getDisplayFullName());
|
||||
|
||||
//Update activity menu dock
|
||||
if(AccountUtils.getID(getActivity()) == userID)
|
||||
((MainActivity) getActivity()).setSelectedNavigationItem(
|
||||
R.id.main_bottom_navigation_me_view);
|
||||
else
|
||||
((MainActivity) getActivity()).setSelectedNavigationItem(
|
||||
R.id.main_bottom_navigation_users_view);
|
||||
|
||||
//Update user name and account image
|
||||
user_name.setText(userInfo.getDisplayFullName());
|
||||
ImageLoadManager.remove(user_image);
|
||||
ImageLoadManager.load(getActivity(), userInfo.getAcountImageURL(), user_image);
|
||||
|
||||
}
|
||||
}
|
||||
|
BIN
app/src/main/res/drawable/perm_group_personal_info.png
Normal file
BIN
app/src/main/res/drawable/perm_group_personal_info.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -6,6 +6,12 @@
|
||||
android:icon="@drawable/ic_menu_allfriends"
|
||||
/>
|
||||
|
||||
<item
|
||||
android:id="@+id/main_bottom_navigation_users_view"
|
||||
android:title="@string/navigation_bottom_user_item"
|
||||
android:icon="@drawable/perm_group_personal_info"
|
||||
android:visible="false" />
|
||||
|
||||
<item
|
||||
android:id="@+id/main_bottom_navigation_me_view"
|
||||
android:title="@string/navigation_bottom_me_item"
|
||||
|
@ -95,4 +95,5 @@
|
||||
<string name="action_friends_start_private_conversation">Private conversation</string>
|
||||
<string name="err_get_private_conversation">Could not get a private conversation !</string>
|
||||
<string name="dialog_loading_msg">Loading…</string>
|
||||
<string name="navigation_bottom_user_item">User</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user