This is the Android version (Java) of this.
My Android experience is at a level where I can make something that works. I made iOS, so why not Android !!
I don't know much about Android, so I made it with MVC for the time being. I did a quick search for MVC on Android, but I wasn't sure, so I've put it on iOS quite a bit.
I made it with the feeling that it is probably like this, so I would appreciate it if you could point out if it was wrong.
The iOS guy I made earlier
macOS High Sierra version 10.13.2
Android Studio 3.2.1
If there are too few functions, it will be difficult to understand the difference even if you make it with various designs, so this time I will make the following application.
An application that displays the weather of each prefecture using livedoor weather Web API (not available for commercial use).
The target is Android 5.0 or later.
Lists 47 prefectures and displays the weather for the selected prefectures today, tomorrow, and the day after tomorrow.
Two screens, a prefecture list screen and a detail screen. (3 screens including splash)
Ignore the splash screen. (Because it is not separated by MVC)
I think that one of the reasons why there are differences in recognition among individuals such as MVC is that the meaning of katakana is ambiguous.
I'm researching MVC and I'm not sure about business logic after all, so I'll write about the meaning of Katakana in this article. (It may be different from the actual meaning ...)
In the explanation of here, it is "the part of the system that performs system-specific processing".
The following applies to this app
The following applies to this app
The following applies to this app
I gave what I made to here.
What I made this time is Okhttp3 for communication and JSONExport for creating a class that handles JSON data. I used.
I will write my perception of each design, the number of files, the number of lines of Activity, and the impression I made.
For the time being, I made it with Activity without thinking about anything this
The number of files is small and the development speed is fast. Each class has about 300 lines, so I think this is also possible for this scale. Since the process is written in the Adapter, I feel that the number of lines of Activity has decreased.
MVC
The project is this
For the time being, I made Fragment as View. Getting the button event and passing the List to the Adapter is a bit annoying, but it's slimmer. Creating a Model makes it easier to save with onSaveInstanceState
. The display process of PopupWindow has increased the number of lines of Activity considerably, so if you can divide it a little more, you may be able to make it a little slimmer. For screens with many parts, `` `findViewById``` can be grouped into Fragment, so Activity is quite refreshing, so I think it's quite easy to use.
Other points that deviate from the main point but were worrisome
There were quite a lot of parts that I wasn't used to when I made it like iOS. When I used Activity with the same feeling as ViewController, it was a bug. Activity and Fragment die so often. It feels unpleasant to have a List in the Adapter as well, but I feel that this can't be helped.
I wrote this article because I wanted someone to give me an opinion, so I would appreciate it if you could give me an opinion. If you think "this is the strongest design!", Please try to make an app with the above specifications.
If you feel like it, I'll try making it in Kotlin. I feel that Kotlin is the mainstream these days ...
Recommended Posts