I made an RSS aggregator on Android. Although it is very simple, I still have to say that it is still somewhat designed.
1. simplest implementation
Write several required activities and jump between these interfaces to complete all functions.
Disadvantages: 1. Single thread, the UI will be blocked by network access
2. The implementation logic is a straight line, making it very clumsy to jump back to the complicated logic.
2. Implementation of the C/S Mode
The main service mainservice is the main thread. It abstracts various tasks into task tasks and submits them to the handler of mainservice for processing. It cyclically detects tasks and starts a thread for each task to execute them.
Define an interface irssactivity:
//All activities implement this interface.Public InterfaceIrssactivity {//Create a task in init and hand it over to mainservice for it to doPublic VoidInit ();//Refresh activity and mainservice callback. This method refreshes the UI at the end of the task.Public VoidRefresh (object... Param );}
Advantages: 1. If you want to do anything anywhere, you only need to hand over a task to mainservice, just like it will go back and do it. If you need to refresh the UI.
There is still a problem: how to handle the memory and manage the memory.