bishopmatthew / HackerNews

An open source Hacker News client for Android.
230 stars 61 forks source link

Back button doesn't return you to search results #27

Open bishopmatthew opened 11 years ago

bishopmatthew commented 11 years ago

This is related to #17 because this app doesn't use the Android activity back stack normally. By the way this was a bad architecture decision that will need to be fixed eventually -- the app show probably become single activity and only use Fragments. I didn't do this originally because animations don't work properly with Fragments on Android 2.3.

Basically there are lots of ways to end up on the MainActivity, which shows the Story list and Comments page on both phones and tablets. This leads to the possibility of moving in a loop which grows the Activity back stack (and crashes somewhere around 8 activities). For example Story -> Comments -> Search -> Comments -> User -> Comments -> Search -> Comments... etc.

To combat this, the app currently has the MainActivity set to singleTask="true", and most other activities finish themselves before moving to another activity. Whenever the user goes "back" we're actually faking it by creating a new activity but playing the "back" animation.

There are two possible fixes: 1) Pass additional information between activities to fake the back stack better (i.e. search terms, list scroll position) 2) Switch to a single Activity, and just use Fragments everywhere. The Fragment back stack doesn't seem to have the same size limitations of the Activity back stack