Android development of the Search Ya Project description (3)

Source: Internet
Author: User



Project
Mobile Client Search
A brief description of the----seller,app,base three packages
Author
Zeng Jinlong
tel:18664312687 QQ: [Email protected]
Time
2014-10-14
Description
Code description






The first part seller package
1, start Page Startupactivity.java
Start the page and search for the first page of the bud. In Android development, you need to set the entry of the program in manifest.
As follows:
<activity
Android:name= "Com.souya.seller.StartUpActivity"
Android:label= "@string/app_name"
Android:theme= "@style/notitle" >
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Logic to start the page:
Display the search photos, deliberately stay 2 seconds (2000 milliseconds), and then jump to the login page, using new Handler (). Postdelayed Method Implementation
。 See the code and don't repeat it.


2, log in page
Loginactivity.java


The logic to log in to the page:
Accept user input, save locally, send a login request to the server, and receive a reply if successful, jump to the main page.


The logical block diagram is as follows:
The user triggers the button's onclick to log in. Opens an asynchronous task implementation. The asynchronous task calls Dataproxy to build and send the login package. Dataproxy will be the agent of our entire program and server. Can look inside the code, it is the HTTP request and the corresponding one encapsulation.
After the login is returned, we will open a thread dedicated to heartbeat processing. The heartbeat packet is sent regularly.
See details: Sellerapplication.getinstance (). Mheartbeatthread = new Thread (new Runnable () {
This line of code.
Not implemented: registration.











3, program main Page surface Mainactivity.java
The main interface of the program
1) inherited from Selleractivity is mainly to listen to some events. Specifically, you can see the code.
2) Viewpager Tabpageindicator Tabsadapter implements the tab page, and this indicator is a viewpagerindicator project (as described in the Project import documentation).
What you need to know is how to add a tab page and put it in.
Mtabsadapter.addtab can be.


3) ActionBar. Know how to add one of your own directory options in Actionbar. See Oncreateoptionsmenu


4) Tabsadapter inner class. You can look at it without changing it.


Part II App Pack
1 active page Management Activitymanager
The management of activity, why this class, can go online search, mainly in order to solve the return time of the activity management issues.


2 Crash log capture Crashhandler
When the app exits abnormally, log the logs to the file so that we could analyze where to crash. See code for details.


3 IP Monitoring Ipmonitor
Not used for the time being.
4 Sellerapplication Application Class
The application class is typically used to hold global data for initialization at the very beginning. This type of function and design can be learned online.
Here we initialize the log of the log4j, save the user login account information.




Part Three base Package
This package is mainly a few base classes. For better abstraction and listener events, we abstracted the sellerfragment, which inherits the fragment.
1 sellerfragment
About Android recommends using fragment instead of activity articles, online learning, here do not introduce.
Sellerfragment mainly integrates some common functions.
1) Picture Cache object Imagefetcher Mimagefetcher (the internal mechanism of the image cache object does not need to know, is the third-party code, can be used later).
2) Encapsulation of common fagment operations.


2 refreshablefragment
Inherits the Sellerfragment, mainly adds the processing to the refresh action.


3 basefragment
Inherited the Refreshablefragment.
The main addition, to take to the image of the event of monitoring, network change monitoring, refresh operation monitoring.


4 selleractivity
The base class for various activities in the seller program. The main is to enrich the processing of the menu.
Note: Clothsearch Mclothsearch; domains are for adding searches in Actionbar. In the Actionbar search is a common industry design is also a difficult point, follow-up time to study carefully.






Q&a:
1 Why are fragment, not activity?
A: As far as I can see, outsourcing with more is activity, and we use more fragment here, our principle is to use fragment place to try not to use activity.
2 Some code can not understand, the statement and there is no place to use, why?
A: Some code I did not remove clean, not lazy, because may not be used now, but I think the follow-up will definitely use, so left a primer in there. If you see this code, you don't have to pay much attention.
3 Why is this version and design requirement in the first place?
A: Because of limited energy, and design sometimes not necessarily the best. For example, the search, see the general practice of the market, everyone is right, we do not have to doubt the design capabilities of so many internet companies. Of course, more ugly because there is no time to adjust.



































































Android development of the Search Ya Project description (3)

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.