mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 22:09:30 +00:00
Bottom navigation item selected auto-update
This commit is contained in:
parent
f3a49693a2
commit
7e451d73a9
@ -52,6 +52,11 @@ public class MainActivity extends AppCompatActivity
|
|||||||
*/
|
*/
|
||||||
private DatabaseHelper dbHelper;
|
private DatabaseHelper dbHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bottom navigation view
|
||||||
|
*/
|
||||||
|
private BottomNavigationView navigationView;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -141,9 +146,8 @@ public class MainActivity extends AppCompatActivity
|
|||||||
* Bottom menu creation
|
* Bottom menu creation
|
||||||
*/
|
*/
|
||||||
void init_bottom_menu(){
|
void init_bottom_menu(){
|
||||||
BottomNavigationView navigation =
|
navigationView = (BottomNavigationView) findViewById(R.id.main_bottom_navigation);
|
||||||
(BottomNavigationView) findViewById(R.id.main_bottom_navigation);
|
navigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
||||||
navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
|
||||||
|
|
||||||
@ -173,6 +177,15 @@ public class MainActivity extends AppCompatActivity
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the currently selected item in the bottom navigation view
|
||||||
|
*
|
||||||
|
* @param item The ID of the item
|
||||||
|
*/
|
||||||
|
public void setSelectedNavigationItem(int item){
|
||||||
|
navigationView.getMenu().findItem(item).setChecked(true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ask user to confirm if he really what to sign out or not
|
* Ask user to confirm if he really what to sign out or not
|
||||||
*/
|
*/
|
||||||
|
@ -21,6 +21,7 @@ import android.widget.ListView;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.communiquons.android.comunic.client.MainActivity;
|
||||||
import org.communiquons.android.comunic.client.R;
|
import org.communiquons.android.comunic.client.R;
|
||||||
import org.communiquons.android.comunic.client.data.Account.AccountUtils;
|
import org.communiquons.android.comunic.client.data.Account.AccountUtils;
|
||||||
import org.communiquons.android.comunic.client.data.DatabaseHelper;
|
import org.communiquons.android.comunic.client.data.DatabaseHelper;
|
||||||
@ -236,6 +237,10 @@ public class ConversationFragment extends Fragment
|
|||||||
|
|
||||||
//Create and start the thread
|
//Create and start the thread
|
||||||
new Thread(refreshRunnable).start();
|
new Thread(refreshRunnable).start();
|
||||||
|
|
||||||
|
//Update the bottom navigation menu
|
||||||
|
((MainActivity) getActivity())
|
||||||
|
.setSelectedNavigationItem(R.id.main_bottom_navigation_conversations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,6 +15,7 @@ import android.widget.AdapterView;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.communiquons.android.comunic.client.MainActivity;
|
||||||
import org.communiquons.android.comunic.client.R;
|
import org.communiquons.android.comunic.client.R;
|
||||||
import org.communiquons.android.comunic.client.data.DatabaseHelper;
|
import org.communiquons.android.comunic.client.data.DatabaseHelper;
|
||||||
import org.communiquons.android.comunic.client.data.UsersInfo.GetUsersHelper;
|
import org.communiquons.android.comunic.client.data.UsersInfo.GetUsersHelper;
|
||||||
@ -126,7 +127,12 @@ public class ConversationsListFragment extends Fragment implements AdapterView.O
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
//Update activity title
|
||||||
getActivity().setTitle(R.string.fragment_conversationslist_title);
|
getActivity().setTitle(R.string.fragment_conversationslist_title);
|
||||||
|
|
||||||
|
//Update the bottom navigation menu
|
||||||
|
((MainActivity) getActivity())
|
||||||
|
.setSelectedNavigationItem(R.id.main_bottom_navigation_conversations);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,7 @@ import android.widget.AdapterView;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.communiquons.android.comunic.client.MainActivity;
|
||||||
import org.communiquons.android.comunic.client.R;
|
import org.communiquons.android.comunic.client.R;
|
||||||
import org.communiquons.android.comunic.client.data.DatabaseHelper;
|
import org.communiquons.android.comunic.client.data.DatabaseHelper;
|
||||||
import org.communiquons.android.comunic.client.data.UsersInfo.GetUsersInfos;
|
import org.communiquons.android.comunic.client.data.UsersInfo.GetUsersInfos;
|
||||||
@ -109,6 +110,10 @@ 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);
|
||||||
|
|
||||||
|
//Update the bottom navigation menu
|
||||||
|
((MainActivity) getActivity())
|
||||||
|
.setSelectedNavigationItem(R.id.main_bottom_navigation_friends_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -141,7 +146,7 @@ public class FriendsListFragment extends Fragment {
|
|||||||
Toast.LENGTH_LONG).show();
|
Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
new GetUsersInfos(mContext, mDbHelper).
|
new GetUsersInfos(mContext, mDbHelper).
|
||||||
getMultiple(FriendsUtils.getFriendsIDs(friendsList), new GetUsersInfos.getMultipleUserInfosCallback() {
|
getMultiple(FriendsUtils.getFriendsIDs(friendsList), new GetUsersInfos.getMultipleUserInfosCallback() {
|
||||||
@Override
|
@Override
|
||||||
@ -163,7 +168,7 @@ public class FriendsListFragment extends Fragment {
|
|||||||
apply_friends_list(friendsUserList);
|
apply_friends_list(friendsUserList);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}.execute();
|
}.execute();
|
||||||
|
@ -12,6 +12,7 @@ import android.widget.ImageView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.communiquons.android.comunic.client.MainActivity;
|
||||||
import org.communiquons.android.comunic.client.R;
|
import org.communiquons.android.comunic.client.R;
|
||||||
import org.communiquons.android.comunic.client.data.Account.AccountUtils;
|
import org.communiquons.android.comunic.client.data.Account.AccountUtils;
|
||||||
import org.communiquons.android.comunic.client.data.DatabaseHelper;
|
import org.communiquons.android.comunic.client.data.DatabaseHelper;
|
||||||
@ -59,8 +60,8 @@ public class UserInfosFragment extends Fragment {
|
|||||||
dbHelper = new DatabaseHelper(mContext);
|
dbHelper = new DatabaseHelper(mContext);
|
||||||
|
|
||||||
//Get required views
|
//Get required views
|
||||||
final ImageView imageView = (ImageView) view.findViewById(R.id.fragments_userinfos_account_image);
|
final ImageView imageView = view.findViewById(R.id.fragments_userinfos_account_image);
|
||||||
final TextView userNameView = (TextView) view.findViewById(R.id.fragments_userinfos_user_name);
|
final TextView userNameView = view.findViewById(R.id.fragments_userinfos_user_name);
|
||||||
|
|
||||||
//Retrieve user informations in order to display them
|
//Retrieve user informations in order to display them
|
||||||
int user_id = new AccountUtils(mContext).get_current_user_id();
|
int user_id = new AccountUtils(mContext).get_current_user_id();
|
||||||
@ -90,5 +91,9 @@ public class UserInfosFragment extends Fragment {
|
|||||||
|
|
||||||
//Update the title
|
//Update the title
|
||||||
getActivity().setTitle(R.string.fragment_userinfos_title);
|
getActivity().setTitle(R.string.fragment_userinfos_title);
|
||||||
|
|
||||||
|
//Update the bottom navigation menu
|
||||||
|
((MainActivity) getActivity())
|
||||||
|
.setSelectedNavigationItem(R.id.main_bottom_navigation_me_view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user