0

image

Dear Android community, I have a more architectural questions:

  • I’m building an app which in the end displays detailed movie information
  • Per screen / activity the information of a single movie will be displayed
  • The user should be able to switch between movies by swiping which will then display the next / previous movie
  • Up front I don’t know the number of required screens / activities

Hence my question is:

What is the best architecture to implement this behaviour?

  • Is there a way to define a „template“ activity which then gets filled with new movie data?
  • Is it possible to implement a „swiping“ behaviour in this setup?

Thank you very much for your answer

Kind regards

Anmol
  • 8,110
  • 9
  • 38
  • 63
Geole
  • 356
  • 1
  • 5
  • 17

1 Answers1

0

I think this is a very broad question but what it sounds like:

  • Use a single activity and fragments to display each movie details
  • Add an OnTouchListener to the fragment to detect swipes left and right (Android: How to handle right to left swipe gestures)
  • On a swipe detected, make a new instance of the fragment with the new movie and use a sliding animation when transitioning between the two.

I would recommend you look at Googles Navigation architecture component as well, it will make the navigation part between each fragment easier. I would also recommend using ViewModels, Room and LiveData. (https://developer.android.com/topic/libraries/architecture/) as it will make the whole development faster and hopefully more stable.

Richard Stokes
  • 385
  • 3
  • 11
  • Thanks a lot Richard! That helped a lot. So I will have a closer look on fragments then. – Geole Jan 13 '19 at 22:15