Lean Mobile App Development by Mike van Drongelen
Author:Mike van Drongelen
Language: eng
Format: epub, mobi
Tags: COM051460 - COMPUTERS / Programming / Mobile Devices, COM051230 - COMPUTERS / Software Development and Engineering / General, COM051440 - COMPUTERS / Software Development and Engineering / Tools
Publisher: Packt Publishing
Published: 2017-11-27T09:06:22+00:00
Everybody likes stories, so the first action probably will be that the user clicks on a story of which the summary looks appealing. (Again this is a hypothesis that needs to be proven.) If the user clicks on the floating action button (the one with the plus sign on it), he will create a new story:
class StoriesFragment : Fragment(), OnCardViewClicked, OnRepositoryResult { private var recyclerView: RecyclerView? = null private var adapter: StoryAdapter? = null private var viewModel = mutableListOf<Story>() ...
If you take a look inside StoriesFragment, you will see that a RecyclerView widget and a StoryAdapter will be used to display the data shown here. In the onCreateView method, the loadData method will be called, which in turn calls the getStories method of the Repository class, passing the fragment itself as the handler of the results:
override fun onResult(result: List<Story>) { viewModel = result.toMutableList() adapter = StoryAdapter(viewModel) adapter?.setOnCardViewClicked(this) recyclerView?.adapter = adapter }
When the results come in, an instance of the StoryAdapter class will be created and attached to the RecyclerView instance. The StoryAdapter binds the data for each story to a row in the list:
override fun onCardClicked(view: View, position: Int) { (activity as MainActivity).onReadStory(viewModel[position]) }
If the user clicks on any of the rows the OnCardViewClick event will be triggered, which will call the onReadStory method from MainActivity, passing the selected story as the parameter. This will bring us to the StoryDetailFragment implementation.
This fragment displays the full story to the user, including the name of the contributors. Here, the user can contribute to the story by clicking on the CONTRIBUTE (as shown in the example image):
class StoryDetailFragment : Fragment() { private var mStory: Story? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) mStory = getArguments().getParcelable(ARG_STORY) }
In the onCreate method, the selected story will receive through the bundle. It is here where the Parcelable implementation comes in handy. In the onCreateView method, the content of the story will be set as text for textView using the getFullStory method of the story object:
Download
Lean Mobile App Development by Mike van Drongelen.mobi
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12607)
Hello! Python by Anthony Briggs(9929)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9805)
The Mikado Method by Ola Ellnestam Daniel Brolund(9794)
Dependency Injection in .NET by Mark Seemann(9351)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8315)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7774)
Grails in Action by Glen Smith Peter Ledbrook(7706)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7571)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7226)
Microservices with Go by Alexander Shuiskov(6991)
Practical Design Patterns for Java Developers by Miroslav Wengner(6899)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6854)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6429)
Angular Projects - Third Edition by Aristeidis Bampakos(6269)
The Art of Crafting User Stories by The Art of Crafting User Stories(5787)
NetSuite for Consultants - Second Edition by Peter Ries(5715)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5531)
Kotlin in Action by Dmitry Jemerov(5077)
