I have a rather peculiar issue. My page has a list view with bunch of view cells containing appointment information. Now when user taps the list view entry they are redirected to appointment detail page using Shell.Current.GoToAsync(). On that page user can go back either through button press or through shell's back arrow.
Case 1.) When they press the Button "OK" - all works as intended, they go back to the page with listview, they can tap on any entry and it will open once.
Case 2.) When using back arrow, the page renders additional method run inside listview.itemtapped method, which I called OnListViewApptFinishedTapped. So every time the user goes back using the arrow, next time they press on any item from the list view, multiple appointment detail pages will open.
I hope I explained it well enough to get the gist of it. I have a temporary workaround with counter inside the ontap method, but it's definitely suboptimal.
Any pointers welcome!
Related
Let say the favorite button is pressed on detail page then on back press when I come back on listing page I wanted the state of the button to be shown as the view of pressed, using RxJava
I'm trying to redesign my android app, but I'm not sure what the best programming method is for what I'm trying to do.
Currently, I have a page in my navigation drawer called "My Workout". In this page I have an expandable list view, and each item is a workout and contains 4 child items (Week 1 to week 4). When they click on a child item, a new activity is opened with 3 fragment tabs (Mon, Wed, Fri). Each tab contains a recycler view that is populated depending on the exp list view item clicked.
Id like to change it so the expandable list view activity is called "Choose a Workout", and the expandable list view is turned into a normal listview. When an item is clicked it goes to a new page(My Workout) in the navigation drawer and starts a new.. "activity" in the app. So instead of having the user have to go to each item, then the week, then the day, it'll simply load the first day(with the recycler view) on a new page. There will then be a button on that page saying "Completed", and when clicked, it will bring up the next day (Week 1 Wed), and it will continue that until the month is complete.
I'm pretty sure I can get this to work with simple intents and intent extras. The problem I am worried about is how will the app react when it is closed and re-opened to My Workout from the navigation drawer? As far as I know the intent will be lost because it is no longer coming from the listview page (Choose a Workout).
Does anyone know what the best way to save what workout they are on in the "My Workout" page, so if they start a specific workout, then close the app, then re-open it and go directly to the "My Workout" page, it is the same place they left off?
Thanks!
Best possible ways are using SharedPreference or SQLite. Saving the result in SharedPreference is always preferred. Save result into preference, once the user comes back to the app, check the result of the previously saved data/stage(whatever according to your app) and perform the action.
There are two things which I like on the Instagram for Android app and I'd like to implement them in my app.
1. Infinite go back in history of fragments
If you tap on a user, you can see his details, taping on followers will return a list of followers, pressing on another user will show his details... and so on. Basically you can do this thing for many times BUT when you go back everything is instant without loading. How can this be implemented? My initial thought was to have only one activity with a top actionbar and for the rest use fragments (one fragment for user details, one fragment for users list) and so on. The problem is I can't think of a good way to allow going back in history. The only way I can see is by caching all the data (user data / list adapters) is an ArrayList so when the user presses back, take the last item from the list and instantiate the fragment. Is there a better way of doing it ? I'm thinking I could start a new activity for each user interaction and them when the user presses back, simply finish the current one. My only worry in this case would be running out of memory. Is there a way to cache fragments with their state ?
2.GridView inside ScrollView
On user details there are two main layouts: a layout with user details and a gridview of images. When the user scrolls, at the scroll's end, the gridview gets new set of items (load as you scroll). While I know how to implement load as I scroll for the gridview, I don't know how to add the gridview inside a scrollview and keep listening for scroll events
Haven't got a quick answer for number 2 but for the first question why not just add the fragments to the backstack with FragmentTransaction.addToBackStack ?
That way you get the natural back-action with fragments without having to start new activities for every action.
Could someone please point me to the right direction in terms of managing complex navigation flow in Android application.
The use case is as follows: User may click on a thumbnail in a grid of thumbnails, this takes user to "detailed" view of an image. This detailed view in addition to details of particular image has list/carousel of "related" images to the image. User clicks on one of related and taken to "detailed" view of that image. And so on and so on.
This basically creates a stack of unlimited/unknown length.
By hitting "back" button user is taken to previous view.
The task: I want to be able to set some limit to the views stack. So for example if user has navigated to 10-th "detailed" view - they will have to hit "back" only 3 times to get to grid of thumbnails where they have started the whole flow.
I am using fragments in my application.
Would really appreciate any help.
I'd use 2 activities. One activity shows the grid, the other the detailed view. The detailed view maintains a stack of previous images, with max length 3. When a related image is pressed, you push the current image onto the stack , dropping the oldest if needed. Then redisplay for the new image. Override onBackPressed to pop the image from the stack. If the stack is empty, call finish() and you'll return to the grid.
One suggestion i would say is not Open a new Activity for "detailed" view .Instead just refresh the activity with the new supporting data.This way there would be only 2 activities in your activity stack.In case you would want atleast the last 3 detail pages then override back button and maintain a stack of 3 images to show the details page.
CONTEXT:
I have a simple ListActivity (call it "Activity1") that contains a ListView and a number of menu items.
Clicking an item in the ListView shows a popup dialog.
Clicking a menu item button (let's call it "Button") in the ActionBar starts an Activity (let's call it "Activity2") using startActivityForResult()
PROBLEM: If the user touches a ListView item, generating an onListItemClick() event in the ListActivity and then really quickly touches Button, a onOptionsItemSelected() event is posted to the message queue and processed in due course. This results in the following odd behaviour:
User touches ListView item
User touches Button
User sees dialog generated by onListItemClick() for a split second
Activity2 started by onOptionsItemSelected() starts over top of the dialog
When user finishes with the Activity2, he returns back to the dialog, not right back to Activity1
This is very odd and unsettling. In my experience doing UIs in older GUI frameworks, the GUI framework never allowed the second event to post to the queue so you never had to worry about these things.
QUESTION: Is there a "preferred" design pattern to prevent the user from being able to press Button and have it start Activity2 when my app is already in the process of showing a dialog in response to the ListView item select?
Disable the entire Activity1 view hierarchy until the dialog ends??
Write in your ToS that users with 2 thumbs per hand should use the app with caution.
More seriously, maybe you can check if your dialog is open before starting your activity with either a boolean or Dialog.isShowing()