I tried to make an Android application with MVC now (Java)

Introduction

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

environment

macOS High Sierra version 10.13.2

Android Studio 3.2.1

What to make

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.

App requirements

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.

function

Lists 47 prefectures and displays the weather for the selected prefectures today, tomorrow, and the day after tomorrow.

screen structure

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)

Prefecture list screen

default

default

Details screen

default

Glossary

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 ...)

What is business logic?

In the explanation of here, it is "the part of the system that performs system-specific processing".

The following applies to this app

What is a layout?

The following applies to this app

What is a user action?

The following applies to this app

Each design

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.

Almost Activity

For the time being, I made it with Activity without thinking about anything this

number of files

Number of lines of Activity (including comments)

Impressions made

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

recognition

A_MVC

Model (Applicable: Object)

View (Applicable: Fragment, View, xml)

Controller (Applicable: Activity)

number of files

Number of lines of Activity (including comments)

Impressions made

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

Other points that deviate from the main point but were worrisome

at the end

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

I tried to make an Android application with MVC now (Java)
I tried to make Basic authentication with Java
I tried to interact with Java
I tried to summarize Java 8 now
I tried to make an application in 3 months from inexperienced
I tried to make an introduction to PHP + MySQL with Docker
I tried to modernize a Java EE application with OpenShift.
I tried to develop an application in 2 languages
I tried to break a block with java (1)
I tried to summarize the stumbling points when developing an Android application
I tried to make an automatic backup with pleasanter + PostgreSQL + SSL + docker
[iOS] I tried to make a processing application like Instagram with Swift
I tried to make a talk application in Java using AI "A3RT"
I tried to implement file upload with Spring MVC
I tried to make a machine learning application with Dash (+ Docker) part3 ~ Practice ~
I tried to implement TCP / IP + BIO with JAVA
[Java 11] I tried to execute Java without compiling with javac
I tried to make a login function in Java
I tried to implement Stalin sort with Java Collector
App development beginners tried to make an Android calculator app
Rails6 I tried to introduce Docker to an existing application
[Android] I tried to make a material list screen with ListView + Bottom Sheet
I made an Android application that GETs with HTTP
~ I tried to learn functional programming in Java now ~
I used to make nc (netcat) with JAVA normally
[Azure] I tried to create a Java application for free ~ Connect with FTP ~ [Beginner]
I tried to create a java8 development environment with Chocolatey
I tried to make Venn diagram an easy-to-understand GIF animation
I want to make a list with kotlin and java!
I want to make a function with kotlin and java!
I tried to make Java Optional and guard clause coexist
How to make an app using Tensorflow with Android Studio
I tried to make a client of RESAS-API in Java
I tried using the CameraX library with Android Java Fragment
I tried UDP communication with Java
I tried to summarize Java learning (1)
Run an application made with Java8 with Java6
Easy to make LINE BOT with Java Servlet Part 2: I tried image messages and templates
I was addicted to WSl when trying to build an android application development environment with Vue.js
I tried connecting to MySQL using JDBC Template with Spring MVC
I tried to build an http2 development environment with Eclipse + Tomcat
I tried to make it an arbitrary URL using routing nesting
[Java] I tried to make a maze by the digging method ♪
I tried to make a group function (bulletin board) with Rails
I want to make an ios.android app
I tried to summarize Java lambda expressions
I tried to get started with WebAssembly
I tried using OpenCV with Java + Tomcat
After learning Progate, I tried to make an SNS application using Rails in the local environment
I tried to implement ModanShogi with Kinx
I tried to make a Web API that connects to DB with Quarkus
Java beginner tried to make a simple web application using Spring Boot
I tried to build a Firebase application development environment with Docker in 2020
01. I tried to build an environment with SpringBoot + IntelliJ + MySQL (MyBatis) (Windows10)
I want to ForEach an array with a Lambda expression in Java
How to make an app with a plugin mechanism [C # and Java]
I tried to make a machine learning application with Dash (+ Docker) part1 ~ Environment construction and operation check ~
I tried to verify AdoptOpenJDK 11 (11.0.2) with Docker image
I tried to manage login information with JMX
java I tried to break a simple block
I did Java to make (a == 1 && a == 2 && a == 3) always true