Piwigo / Piwigo-Android

Piwigo Native Android App
GNU General Public License v3.0
140 stars 43 forks source link

Create About Activity #43

Closed ramack closed 6 years ago

ramack commented 6 years ago

show properties like

Edit:

ramack commented 6 years ago

@Philio in the meantime I got a little used to databindings and see some benefits. Nevertheless I failed to adjust the NavigationViewBindingAdapter to also support "single click actions without state". E. g. for an "about activity" I think it is best to set android:checkable="false" for the menu item in the drawer_menu, as I'd start a new activity to show the about stuff and when this is closed via back (in the action bar or the back button) I'd like to come back to the MainActivity, showing the Albums, but the navigation drawer still has the "About" entry selected.

Can you give me some advice to extend the NavigationViewBindingAdapter to support a lambda attribute to call a method in the viewModel? Or do you think selecting the entry programmatically in MainActivity.onResume() is the best way to do that? Or how would do recommend to solve this?

Philio commented 6 years ago

~If you remove this if statement it will stop automatic selection:~

~https://github.com/Piwigo/Piwigo-Android/blame/master/app/src/main/java/org/piwigo/internal/binding/adapter/NavigationViewBindingAdapter.java#L47~

Edit: Actually not sure the above is right... Let me checkout the code and check it properly.

Then you should be able to change the selection by setting navigationItemId in MainViewModel as I think it's a 2-way bind?

ramack commented 6 years ago

To make some of the entries not selectable I tried to change the menu xml (android:checkable="false"), but with this for sure the binding adapter doesn't find the selected item anymore. And I did not manage to make the adapter fire a method call / notify observer or whatever just for the "click" action... I would like to have a "onSelect" attribute in the xml, configured for a lambda on the viewModel like app:onClickListener="@{() -> viewModel.menuEntryClick()}" and if possible with some form of a parameter passing the id (for example the resource id of the menu entry)...

ramack commented 6 years ago

@Philio even though I closed the issue because I implemented a workaround, you feedback would still be welcome. I'd like to understand that...