Search for Ya project for Android Development (3)

Source: Internet
Author: User

Search for Ya project for Android Development (3)


Project
Search bud mobile client
---- Seller, app, and base
Author
Zeng Jinlong
Tel: 18664312687 QQ: 470910357@qq.com
Time
2014-10-14
Description
Code Description






Part 1 Seller package
1. StartUpActivity. java
Start page: the first page of the search. In Android development, you need to set the entry of the program in Manifest.
As follows:
Android: name = "com. souya. seller. StartUpActivity"
Android: label = "@ string/app_name"
Android: theme = "@ style/notitle">





Startup page logic:
Show the search bud image, deliberately stay for 2 seconds (2000 ms), then jump to the login page, using the new Handler (). postDelayed method to achieve
. For more information, see the code.


2. logon page
LoginActivity. java


Login page logic:
Accept user input, save it locally, and send a login request to the server. If the response is received successfully, it will jump to the homepage.


The logical diagram is as follows:
Log on to the trigger button Onclick. Enable an asynchronous task implementation. Call DataProxy in an asynchronous task to build and send the login package. DataProxy will act as a proxy for our entire program and server. Let's take a look at the code in it. It is an encapsulation of the http request and the corresponding one.
After the login returns, we will enable a thread for dedicated heartbeat processing. Send heartbeat packets periodically.
For details, see SellerApplication. getInstance (). mHeartbeatThread = new Thread (new Runnable (){
This line of code.
Not implemented: registration.











3. MainActivity. java on the program Homepage
Main Interface of the program
1) inherited from SellerActivity is mainly used to listen to some events. For more information, see the code.
2) ViewPager TabPageIndicator TabsAdapter implements the Tab page, and this Indicator is for the ViewPagerIndicator project (which is described in the project import documentation ).
You need to know how to add a Tab page.
MTabsAdapter. addTab.


3) ActionBar. You know how to add a directory option in the ActionBar. See onCreateOptionsMenu


4) Internal TabsAdapter class. You can see that there is no need to change.


Part 2 app package
1. ActivityManager on the activity page
Why is this class required for Activity management? You can search online to solve the issue of Activity management during rollback.


2 crash log capture CrashHandler
When the APP exits unexpectedly, it records the log to the file, so that we can analyze where the crash occurred. For details, see the code.


3. IP Monitor
Not used for the moment.
4 SellerApplication application class
The Application class is generally used to save global data for initial initialization. These features and designs can be learned online.
Here we initialize the log4j log and save the user login account information.




Part 3 base package
This package mainly contains several base classes. To better abstract and listen to events, we abstracted SellerFragment, which inherits Fragment.
1 SellerFragment
This article describes how to use Fragment instead of Activity for Android.
SellerFragment mainly integrates some common functions.
1) image cache object ImageFetcher mImageFetcher (the internal mechanism of the image cache object is a third-party code and will be used later ).
2) encapsulate common Fagment operations.


2 RefreshableFragment
It inherits SellerFragment and mainly adds processing for refreshing actions.


3 BaseFragment
Inherits RefreshableFragment
Mainly added: monitors image events, network changes, and refresh operations.


4 SellerActivity
Base classes of various activities in the Seller program. It mainly enriches the processing of menus.
Note: The ClothSearch mClothSearch domain is generated to add a search in the ActionBar. Searching in Actionbar is a general design in the industry and also a difficult point. You will have time to study it carefully later.






Q &:
1. Why are they all Fragment instead of Activity?
A: As far as I can see, most of the outsourcing is Activity, and we use more Fragment here. Our principle is that we should try not to use Activity where Fragment can be used.
2. Why?
A: Some codes are not clean and not lazy, because they may not be used now, but I think they will be used in the future, so I leave an introduction there. If you see such code, you do not need to pay too much attention.
3. Why is there a new version and design requirement?
A: Because of limited energy and sometimes the best design. For example, for the search, please refer to the common practices on the market. Everyone's approach is right. We don't need to doubt the design capabilities of so many Internet companies. Of course, it is more ugly because there is no time to adjust it.



































































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.