mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-27 15:59:29 +00:00
Dynamically update selected navigation tab.
This commit is contained in:
parent
3923e2b704
commit
52a9c15290
@ -280,7 +280,20 @@ public class MainActivity extends AppCompatActivity implements
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify what is the selected
|
||||||
|
*
|
||||||
|
* @param activity An instance of {@link MainActivity}
|
||||||
|
* @param id The identifier of the menu to choose
|
||||||
|
*/
|
||||||
|
public static void SetNavbarSelectedOption(@NonNull Activity activity, int id){
|
||||||
|
|
||||||
|
if(!(activity instanceof MainActivity))
|
||||||
|
throw new RuntimeException("Specified activity is not an instance of activity!");
|
||||||
|
|
||||||
|
((MainActivity)activity).mNavBar.setIdentifierSelected(id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ import org.communiquons.android.comunic.client.data.models.ConversationsInfo;
|
|||||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||||
import org.communiquons.android.comunic.client.data.runnables.ConversationRefreshRunnable;
|
import org.communiquons.android.comunic.client.data.runnables.ConversationRefreshRunnable;
|
||||||
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
import org.communiquons.android.comunic.client.data.utils.AccountUtils;
|
||||||
|
import org.communiquons.android.comunic.client.ui.activities.MainActivity;
|
||||||
import org.communiquons.android.comunic.client.ui.adapters.ConversationMessageAdapter;
|
import org.communiquons.android.comunic.client.ui.adapters.ConversationMessageAdapter;
|
||||||
import org.communiquons.android.comunic.client.ui.listeners.OnScrollChangeDetectListener;
|
import org.communiquons.android.comunic.client.ui.listeners.OnScrollChangeDetectListener;
|
||||||
import org.communiquons.android.comunic.client.ui.utils.BitmapUtils;
|
import org.communiquons.android.comunic.client.ui.utils.BitmapUtils;
|
||||||
@ -307,6 +308,7 @@ public class ConversationFragment extends Fragment
|
|||||||
|
|
||||||
//Update conversation title
|
//Update conversation title
|
||||||
getActivity().setTitle(R.string.fragment_conversation_title);
|
getActivity().setTitle(R.string.fragment_conversation_title);
|
||||||
|
MainActivity.SetNavbarSelectedOption(getActivity(), R.id.action_conversations);
|
||||||
|
|
||||||
|
|
||||||
//Check for conversation information
|
//Check for conversation information
|
||||||
|
@ -153,6 +153,7 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O
|
|||||||
|
|
||||||
//Update activity title
|
//Update activity title
|
||||||
getActivity().setTitle(R.string.fragment_conversationslist_title);
|
getActivity().setTitle(R.string.fragment_conversationslist_title);
|
||||||
|
MainActivity.SetNavbarSelectedOption(getActivity(), R.id.action_conversations);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,6 +166,7 @@ public class FriendsListFragment extends Fragment
|
|||||||
|
|
||||||
//Update the title of the application
|
//Update the title of the application
|
||||||
getActivity().setTitle(R.string.fragment_friendslist_title);
|
getActivity().setTitle(R.string.fragment_friendslist_title);
|
||||||
|
MainActivity.SetNavbarSelectedOption(getActivity(), R.id.action_friendslist);
|
||||||
|
|
||||||
//Refresh the friends list
|
//Refresh the friends list
|
||||||
refresh_friend_list();
|
refresh_friend_list();
|
||||||
|
@ -109,6 +109,7 @@ public class LatestPostsFragment extends Fragment
|
|||||||
|
|
||||||
//Update dock and activity title
|
//Update dock and activity title
|
||||||
getActivity().setTitle(R.string.fragment_latestposts_title);
|
getActivity().setTitle(R.string.fragment_latestposts_title);
|
||||||
|
MainActivity.SetNavbarSelectedOption(getActivity(), R.id.action_latest_posts);
|
||||||
|
|
||||||
//Refresh the list of posts of the user
|
//Refresh the list of posts of the user
|
||||||
refresh_posts_list();
|
refresh_posts_list();
|
||||||
|
@ -142,6 +142,7 @@ public class NotificationsFragment extends Fragment implements View.OnCreateCont
|
|||||||
|
|
||||||
//Update the title of the application
|
//Update the title of the application
|
||||||
getActivity().setTitle(R.string.fragment_notifications_title);
|
getActivity().setTitle(R.string.fragment_notifications_title);
|
||||||
|
MainActivity.SetNavbarSelectedOption(getActivity(), R.id.action_notifications);
|
||||||
|
|
||||||
//Get user page opener
|
//Get user page opener
|
||||||
mUserPageOpener = (onOpenUsersPageListener) getActivity();
|
mUserPageOpener = (onOpenUsersPageListener) getActivity();
|
||||||
|
@ -235,6 +235,7 @@ public class UpdateConversationFragment extends Fragment {
|
|||||||
getActivity().setTitle(R.string.fragment_update_conversation_title_create);
|
getActivity().setTitle(R.string.fragment_update_conversation_title_create);
|
||||||
else
|
else
|
||||||
getActivity().setTitle(R.string.fragment_update_conversation_title_update);
|
getActivity().setTitle(R.string.fragment_update_conversation_title_update);
|
||||||
|
MainActivity.SetNavbarSelectedOption(getActivity(), R.id.action_conversations);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,6 +115,8 @@ public class UserPageFragment extends Fragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
MainActivity.SetNavbarSelectedOption(getActivity(), R.id.action_personal_page);
|
||||||
|
|
||||||
//Check if we got information about the user
|
//Check if we got information about the user
|
||||||
if(userInfo == null || mTabLayout.getTabCount() < 2){
|
if(userInfo == null || mTabLayout.getTabCount() < 2){
|
||||||
|
|
||||||
|
@ -107,6 +107,15 @@ public class NavigationBar extends BaseFrameLayoutView implements NavigationBarI
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the currently selected item by its identifier in the list
|
||||||
|
*
|
||||||
|
* @param id The index of the item to mark as selected
|
||||||
|
*/
|
||||||
|
public void setIdentifierSelected(int id){
|
||||||
|
setIndexSelected(MenuUtils.MenuIdentifierToIndex(mMenu, id));
|
||||||
|
}
|
||||||
|
|
||||||
public void setOnNavigationItemSelectedListener(OnNavigationItemSelectedListener onNavigationItemSelectedListener) {
|
public void setOnNavigationItemSelectedListener(OnNavigationItemSelectedListener onNavigationItemSelectedListener) {
|
||||||
this.mOnNavigationItemSelectedListener = onNavigationItemSelectedListener;
|
this.mOnNavigationItemSelectedListener = onNavigationItemSelectedListener;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
<string name="fragment_friendslist_title">Friends</string>
|
<string name="fragment_friendslist_title">Friends</string>
|
||||||
<string name="fragment_conversationslist_title">Conversations</string>
|
<string name="fragment_conversationslist_title">Conversations</string>
|
||||||
<string name="fragment_userinfos_title">About me</string>
|
<string name="fragment_userinfos_title">About me</string>
|
||||||
<string name="fragment_conversation_title">Title</string>
|
<string name="fragment_conversation_title">Conversation</string>
|
||||||
<string name="fragment_conversation_err_getconvinfos">Could not get information about the conversation !</string>
|
<string name="fragment_conversation_err_getconvinfos">Could not get information about the conversation !</string>
|
||||||
<string name="action_conversation_delete">Delete</string>
|
<string name="action_conversation_delete">Delete</string>
|
||||||
<string name="action_conversation_update">Update</string>
|
<string name="action_conversation_update">Update</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user