Coder Social home page Coder Social logo

Comments (7)

st235 avatar st235 commented on May 30, 2024 1

Good morning, @rajam1215 👋

Thank you for provided information, I really appreciate it. However, as I wrote below - it's not a default behavior for alternative native android widget. Moreover, it looks like as an application layer responsibility to cache fragments. I can recommend you to look at fragmentFactory - probably, it will cover you case.

Best wishes,
Alex

from expandablebottombar.

st235 avatar st235 commented on May 30, 2024

Hi @rajam1215,

sorry for a bit late replay. Did you check the default BottomBarNavigation view? Does it behave in an expected way? Also, did I understand you correctly - double-clicking on the same item causes Fragment recreation? If you don't mind, it would be really cool, if you can record a small video, which reflects wrong behaviour.

Looking forward to hearing from you

from expandablebottombar.

rajam1215 avatar rajam1215 commented on May 30, 2024

Hi @rajam1215,

sorry for a bit late replay. Did you check the default BottomBarNavigation view? Does it behave in an expected way? Also, did I understand you correctly - double-clicking on the same item causes Fragment recreation? If you don't mind, it would be really cool, if you can record a small video, which reflects wrong behaviour.

Looking forward to hearing from you

Hello @st235

I am very glade to see you again, i know the default behavior of bottom navigation, this is used only for show activities or fragments, but in this library we move forward already, it have MVVM support, but default doesn't, we need to avoid the recreation of fragment, now please check what is happen right now.

your qus - double-clicking on the same item causes Fragment recreation?
no it's not, it recreate fragment again when click on other menu item,
it will recreate again and again, i want when all fragments create once, then no need to create again, just visible and gone.

i make one little video,it will clear your query

ezgif com-video-to-gif

Please check once.

from expandablebottombar.

st235 avatar st235 commented on May 30, 2024

Hi @rajam1215,
sorry, it was a really crazy week. I'll be able to take a look at the problem only at the end of this week.

PS: However, it's always welcomed any kind of contribution here. So, if you have any ideas on how to solve this problem, do not hesitate, please, to create a pull request.

Kind regards,
Alexander Dadukin

from expandablebottombar.

rajam1215 avatar rajam1215 commented on May 30, 2024

Hello @st235

not an issue, please see on the issue end of the week, but i have one solution for that.

public class MainActivity extends AppCompatActivity {

final Fragment fragment1 = new HomeFragment();
final Fragment fragment2 = new DashboardFragment();
final Fragment fragment3 = new NotificationsFragment();
final FragmentManager fm = getSupportFragmentManager();
Fragment active = fragment1;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);


BottomNavigationView navigation = (BottomNavigationView) findViewById(R.id.navigation);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);

fm.beginTransaction().add(R.id.main_container, fragment3, "3").hide(fragment3).commit();
fm.beginTransaction().add(R.id.main_container, fragment2, "2").hide(fragment2).commit();
fm.beginTransaction().add(R.id.main_container,fragment1, "1").commit();

}


private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
   = new BottomNavigationView.OnNavigationItemSelectedListener() {

@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
    switch (item.getItemId()) {
        case R.id.navigation_home:
            fm.beginTransaction().hide(active).show(fragment1).commit();
            active = fragment1;
            return true;

        case R.id.navigation_dashboard:
            fm.beginTransaction().hide(active).show(fragment2).commit();
            active = fragment2;
            return true;

        case R.id.navigation_notifications:
            fm.beginTransaction().hide(active).show(fragment3).commit();
            active = fragment3;
            return true;
    }
    return false;
 }
 };`
}

But this solution work with onItemselectedLinstner of bottom navigation.

but not with MVVM Technique

Refer to this for the official solution.
https://github.com/android/architecture-components-samples/tree/master/NavigationAdvancedSample

Please check the official solution for MVVM support, the solution code work with kotlin, and expandable bottom bar project work with kotlin, so you can handle this

Please look in to it.

Regards
Bishal Malick

from expandablebottombar.

st235 avatar st235 commented on May 30, 2024

@rajam1215, hi 👋

Hopefully, you are well. I took a look at the problem. I tried to reproduce similar behaviour with default android components, so I've changed ExpandableBottomBar to

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigation"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:backgroundTint="#fff"
        app:menu="@menu/navigation_menu"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent" />

and also used NavigationUI (an alternative for native android view).

 NavigationUI.setupWithNavController(bottomNavigation, navigationController)

Unfortunately, the behaviour you mentioned below is not followed by material design components. As it's not a native behaviour, I cannot implement it in this library. The users will not expect such behaviour at this component.

I've made a small video of BottomNavigationView. This video contains the default behaviour for default android widget:

device-2020-07-19-223556

PS: also, I looked at the provided sample. The main highlight here: they don't use NavigationUI, but do use a custom extension (BottomNavigationView#setupWithNavController) to provide required behaviour.

Kind regards,
Alexander Dadukin

from expandablebottombar.

rajam1215 avatar rajam1215 commented on May 30, 2024

@st235 hello

I understand what you want to say, it is not necessary to add this functionality in the library, but in my suggestion this feature you can see in maximum apps, you can check from your side also, those who use bottom navigation in the app. coz some time user don't want to see the app screen again and again from start, user always want to use it from where he/she left (App User), i hope you can understand,

you can add this functionality in your lib, if user want to use this functionality in app they can use, if not they can not use (Coder)

Thanks and Regards
Bishal Malick

from expandablebottombar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.