Anroid-Engineering Structure

Source: Internet
Author: User

Anroid-Engineering Structure
During development, I like to think about the basic functional modules. Anroid is generally used to figure out which functions are available, which open-source libraries are needed, and which basic functional classes are needed; such as file operations, Bitmap operations, Sqlite operations, UI customization, and basic screen information. So I usually divide it into the following parts (this is also something that has been slowly accumulated in a few small projects): Likewise, experts can give pointers, or drift through ~~~ After the project is completed, we will release the project to github. Although it is poorly written, it should be useful for beginners.

By the way, message push uses AndroidPN, refer to http://www.cnblogs.com/hanyonglu/archive/2012/03/16/2399655.html
Download http://sourceforge.net/projects/androidpn/files/
It is easy to use. Just take a look at the reference. The key is that you can modify the source code. Here, you have changed the click message event so that you can directly process the message when you click it; instead of jumping to a detailed page, click OK to trigger the operation. I will modify another problem, how to push messages in the Application Center on the main interface-I plan to add a function to push messages on the server, in the form of App: content. For messages like this received by the front-end, instead of sending notifications, You can notify the started program to update the message in the Application Center, and distinguish between links, announcements, and others (although this is not started, but it should be achievable );
Speaking of this, I think I still need to verify a question about AndroidPN performance. I will test the number of clients supported by the server-I would like to open n threads for testing;
Com. errorvenus. fxunlei
The following figure shows the main interface and boot screen. The Boot screen is encapsulated here, mainly because a thread is opened in the boot screen and Initialization is mainly done: for example, creating folders, obtaining screen information, sqlite. copy db (download from assert or from the server and copy it to the data of the application-this can synchronize user data), and start message push and other related operations.
The boot screen is encapsulated as an abstract class that provides an abstract method (jump after 5s ):

 
 
  1. Public abstract class MDSplashActivity extends Activity
  2. {

  3. @ Override
  4. Protected void onCreate (Bundle savedInstanceState)
  5. {
  6. // TODO Auto-generated method stub
  7. Super. onCreate (savedInstanceState );

  8. /// <Boot Animation
  9. View view = LayoutInflater. from (this). inflate (setLayoutId (), null );
  10. SetContentView (view );
  11. AlphaAnimation alphaAnimation = new AlphaAnimation (1.0f, 0.0f );
  12. AlphaAnimation. setDuration (5000 );
  13. View. startAnimation (alphaAnimation );

  14. /// <Asynchronous Initialization
  15. New Thread (new Runnable ()
  16. {
  17. @ Override
  18. Public void run ()
  19. {
  20. Handler ();
  21. }
  22. }). Start ();

  23. New Handler (). postDelayed (new Runnable ()
  24. {
  25. Public void run ()
  26. {
  27. Intent mainIntent = new Intent (MDSplashActivity. this, setToActivity ());
  28. MDSplashActivity. this. startActivity (mainIntent );
  29. MDSplashActivity. this. finish ();
  30. }

  31. },5000 );
  32. };

  33. /**
  34. * Additional operations except display and redirection
  35. */
  36. Public abstract void handler ();

  37. /**
  38. * Provides a view to fade away
  39. * @ Return
  40. */
  41. Public abstract int setLayoutId ();

  42. /**
  43. * Set the Activity. class to jump
  44. * @ Return
  45. */
  46. Public abstract Class <?> SetToActivity ();
I believe it should be practical.
Com. errorvenus. log
The custom log class is mainly used to facilitate the output of custom logs. At the same time, a crash capture function is added and uploaded to the backend server for easy access. I know someone who prefers to use System. out output, but when there are too many logs, it is very difficult to delete them one by one. It will also be missed, So if you define a custom interface, you can comment out the custom interface, so that you can easily find the places where logs are written; if there are more logs, it will actually affect the performance. Some log libraries may be useful, or platforms like umeng may be used.

Com. errovenus. listen
Although this project only has one main interface, there are three or four functional areas: menu functional areas on the left, custom title bar functional areas, intermediate content functional areas, and Application Center functional areas, we cannot get all the listening events into a class, so the code is too large and very difficult to maintain, so we need to submit the event separately, and each function listens for processing a functional area. The current image content functional area is not processed by a single listener, but is stored in the Adapter for processing: The reason is that the structure of the listener processed on the left menu bar is displayed through the content functional area, it is implemented through the adapter, so the content click processing is done in the adapter.

Com. errovenus. adapter
This is mainly for implementing the menu bar function. It mainly includes the content being downloaded, the downloaded content, and privacy. Therefore, there will be two or three adapters. The "entry" of the corresponding adapter is mainly in com. errovenus. data, that is, the basic information of the "entry" displayed in the listview;

Com. errovenus. core
In this case, I am tired of creating the program folder, and then the operation class of the specific data in the database will be removed from com. errovenus. data is moved here. Because core is mainly related to the core business and involves specific business operations, it will be put here, personal habits or regulations.

Like others, optimization, expansion, and good structure may take a long time to come up with ideas.
The basic content structure is roughly as follows-it will certainly be optimized in the future (some of which are tool-class MD headers accumulated by previous projects ):





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.