Answer the question
In order to leave comments, you need to log in
App architecture irk client for android?
Good day.
I decided to write for the first time in my life applications for android - irc client.
I have no experience writing for this platform, and in general I have never developed anything major. In this regard, I had problems with the architecture of the application.
After reading the article, I realized that the mvvm pattern is used in android applications. Layouts are used as views, the Activity class descendants are used as the ViewModel, and the ContentProvider and Service class descendants are used as the models.
After some thought, I came to the conclusion that the application will have the following layouts: main window, settings window (there will be specific settings items, for example, main settings, text settings, etc.), channels window (probably all channels and private conversations will be implemented in one window using tab).
As I understand it, for each of these layouts, you need to create a ViewModel and a model?
On the other hand, after thinking, I realized that I need at least the following classes for the full operation of the application:
1) The Irc class, which will implement the basic operations: connecting to the server, sending a message, receiving a message, authorization, etc. By the way, it seems that all operations with the network need to be moved to a separate thread?
2) The StringParser class, which is responsible for parsing strings received from the server or client. The class defines what needs to be done. For example, if a command came from server 450 to show a list to a person, or, for example, if a person wrote /msg NICKNAME msg to the chat, then you need to open the NICKNAME private conversation window and send msg. The input of the main method in this class is a string, and the output is expected to be an action that needs to be performed somewhere, and some array of information.
It is not very clear how to present this information (action and information). You can, of course, just create some kind of array, but this does not seem to be the best option.
3) Commands class, which, probably, should start a new thread (Irc class) that will work with the network. Further, this class will probably receive data from the client and server, send them to the StringParser class and call the commands that are needed.
4) It seems that classes are needed that will implement such actions as editing settings, displaying a list of nicknames, etc. However, I think that all these classes are typical representatives of the Model in the MVVM pattern.
So that was the preface. What do you not like about what I said? How to fix what to do?
Questions:
1) How to attach the Irc, StringParser, Commands classes to the MVVP pattern?
2) If the classes Irc, StringParser, Commands are helpers, then what is the application life cycle? A person enters the program, the main window is loaded, and, I think, an object of the Commands class is created. It, in turn, creates an object of the Irc class, which should run on a new thread. What's next? Are all user actions in models redirected to an object of the Commands class?
Answer the question
In order to leave comments, you need to log in
In your case, everything fits into MVVM quite simply. Irc, StringParser and Commands are classes that lie in the model, while StringParser and Commands are essentially singletons. And yes, it turns out the main VM class - Commands, which handles user interaction.
And how many models to create in general? As much as layout? Or create two models (inheritors of the ContentProvider class) for the Irc and StringParser classes? Or even one model (an inheritor of the ContentProvider class), in which to nest the Irc and StringParser classes?
And the Commands class is what? It seems to be a ViewModel, that is, an Activity?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question