Like many apps my app has a button bar in the bottom of most screens for easy navigation. There are four buttons, one for each of the most used screens. The current screen is highlighted in the button bar.
This setup involves a few issues:
[I want the app it to be crossplatform as much as possible so whatever I do regarding the issues below it should be compatible with B4i if at all possible.]
1. Duplication
Now I simply copy & paste the panel in the designer and also the few lines in the designer scripts that place the buttons nicely. I also copy and paste the events from the buttons.
Are there better ways of doing this? Can I somehow share a panel including events between several activities?
2. Transitions between screens
When the main activity starts I like the default animation. It looks good. However, when I navigate to the Home screen via the button bar, it looks bad. Is it possible to set Animation Duration in code? I can set it to zero in the designer, but then it also disables the initial animation which I do want to keep.
If I instead of using the home button presses the back button the previous activity is shown instantly as it was before without animations etc. Can I somehow start the activity in the same way and state as pressing the back button?
3. Activity stack
Let's say I right after start press the second button to go to activity #2. If I press Back twice it first goes back to the Home activity, then exits the application. But if I press Home from activity #2 and then press Back I go back to #2. I have solved the problem with
but it actually seems to make the transition more noticeable. Is there a better way to bypass the activity stack?
4. Single activity?
I think all the issues above could be solved by using a single activity and then load the respective layouts. It would also solve the problem with pre-loading a webview.
However, it seems contra intuitive to me with just a single activity. Are there any problems with this approach? (Apart from making the code less readable/maintainable). Is it widely used?
This setup involves a few issues:
[I want the app it to be crossplatform as much as possible so whatever I do regarding the issues below it should be compatible with B4i if at all possible.]
1. Duplication
Now I simply copy & paste the panel in the designer and also the few lines in the designer scripts that place the buttons nicely. I also copy and paste the events from the buttons.
Are there better ways of doing this? Can I somehow share a panel including events between several activities?
2. Transitions between screens
a. Disable animations in code
When the main activity starts I like the default animation. It looks good. However, when I navigate to the Home screen via the button bar, it looks bad. Is it possible to set Animation Duration in code? I can set it to zero in the designer, but then it also disables the initial animation which I do want to keep.
b. Seamless transitions
Even with animations disabled there is a noticeable "flash" when moving between activities. The new activity slides in from the right. In other apps the transition is seamless. How is that done? With seamless I mean that there is sometimes a delay of the content itself in the activity, but the button bar is completely steady. It doesn't "flash".If I instead of using the home button presses the back button the previous activity is shown instantly as it was before without animations etc. Can I somehow start the activity in the same way and state as pressing the back button?
3. Activity stack
Let's say I right after start press the second button to go to activity #2. If I press Back twice it first goes back to the Home activity, then exits the application. But if I press Home from activity #2 and then press Back I go back to #2. I have solved the problem with
B4X:
Dim jo As JavaObject
jo.InitializeContext
jo.RunMethod("finishAffinity", Null)
StartActivity(Main)
but it actually seems to make the transition more noticeable. Is there a better way to bypass the activity stack?
4. Single activity?
I think all the issues above could be solved by using a single activity and then load the respective layouts. It would also solve the problem with pre-loading a webview.
However, it seems contra intuitive to me with just a single activity. Are there any problems with this approach? (Apart from making the code less readable/maintainable). Is it widely used?