TEAMtalk Android Code Analysis (Business process chapter)

Source: Internet
Author: User

TEAMtalk Android Code Analysis (Business process chapter)

1.1 General structure

1. The overall structure is somewhat similar to the MVC sense, and the module structure from top to bottom is roughly:

UI layer: Activity and fragment composition, including some commonly used open source controls such as: Imageloader,speedx,gifview, and the underlying data change notification via bus event completion (Eventbus)

Management: Service (ie: Imservice, which is used below) and some manager (Loginmanager,contactmanager,sessionmanager,socketmanager, etc.) that are divided by business This layer is responsible for the flow of business and the provision of data interfaces,

Data and Cache layer: Greendao implementation, including a series of business-related caches, cached objects are processed in each manager entity.

Network layer: specifically implemented by Netty, get or send data through the PB Protocol (PROTOBUF)

2.1 Login Process

1> Request Login Server (HTTP), assign message server and other related configuration

2> Link Request message Server

3> If the network connection fails, the local login process is used, i.e., in the case of login status, there is no network to view local historical information.

4> the log on message server succeeds, send the bus event notification Imservice

5>imservice initializes each manager to enable local and network data requests, local caches, and other configured data fills.

3.1 Contactmanager initialization operation

3.1.1 Business operations on local data

1> Database Load Department list and populate departmental map (DEPARTMENTMAP)

2> Database load user list and populate user map (UserMap)

3> sends bus events, notifies the relevant interface (chat/contacts/my), and sets the manager data status ready

The relevant page actions are as follows:

1> Chat page Action: Only the Session,user,group data is all ready, this page will be updated, and later detailed analysis

2> Address Book page actions:

(1) Set user tab data, update UI

(2) Set Up Department tab data, update UI

(3) User and department data is ready, search status can be manipulated

3> Get login information through Loginmanager, update UI (the trigger of this location, can be placed in a timely event notification after successful login)

3.1.2 Business operations for network data

1> requests the Department list according to the last point in time for local storage

2> requests a list of users according to the last point in time stored locally

3> Get Department data:

1) Cache Map

2) Storage db

3) Send bus event (Userinfoevent event, user_info_update), notification page update UI

The pages involved are: Contacts page: User list ui/Department list ui/User details (userinfofragment), if the page receives notifications, gets cached data, updates the UI

4> Get User data:

1) Cache UserMap

2) Storage db

3) Send bus Event Update UI, page response with department data.

Note: Notify the page to update the bus events, consider the use of Poststicky form.

3.2 Groupmanager Initialization operation

TEAMtalk Android Code Analysis (Business process chapter)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.