I have an if statement in when i the position 3 is selected that checks a condition of if a particular key has been stored in tinyDB(a form of shared preferences) to open a particular fragment this condition is true(i checked this with the System.out.println(tiny.getString("userSignedIn"); but the fragment does not open. The condition on position 3 in the code. Than you very much
bottomNavigation.setOnTabSelectedListener(new AHBottomNavigation.OnTabSelectedListener() {
@Override
public boolean onTabSelected(int position, boolean wasSelected) {
if (position == 0){
Home home = new Home();
android.support.v4.app.FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
fragmentTransaction.replace(R.id.parentLayout, home);
moreOptions.setImageResource(R.drawable.ic_more);
moreOptions.setVisibility(View.VISIBLE);
text_changer.setText(R.string.app_name);
fragmentTransaction.commit();
}else if (position ==1){
Categories categories = new Categories();
android.support.v4.app.FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
fragmentTransaction.replace(R.id.parentLayout, categories);
moreOptions.setVisibility(View.INVISIBLE);
text_changer.setText(R.string.tab_2);
fragmentTransaction.commit();
}else if (position ==2){
MyDownloads myDownloads = new MyDownloads();
android.support.v4.app.FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
fragmentTransaction.replace(R.id.parentLayout, myDownloads);
moreOptions.setVisibility(View.INVISIBLE);
text_changer.setText(R.string.tab_3);
fragmentTransaction.commit();
}else if (position == 3){
System.out.println(tinyDB.getString("userSignedIn"));
//Check if user has already signed in
if (getUserSignedIn.equals("Sign in Successful")){
UserSignedInProfile userSignedInProfile = new UserSignedInProfile();
android.support.v4.app.FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
fragmentTransaction.replace(R.id.parentLayout, userSignedInProfile);
moreOptions.setVisibility(View.INVISIBLE);
text_changer.setText(R.string.tab_4);
fragmentTransaction.commit();
}else if (getUserSignedIn.equals("Email address or password not correct")){
Profile recentVideos = new Profile();
android.support.v4.app.FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
fragmentTransaction.replace(R.id.parentLayout, recentVideos);
moreOptions.setVisibility(View.INVISIBLE);
text_changer.setText(R.string.tab_4);
fragmentTransaction.commit();
}
Aucun commentaire:
Enregistrer un commentaire