Android app market Source Code released [Day 2]

Source: Internet
Author: User

Today's content is mostly on the home page. Here we will first release some of the content because this class has more than 1000 lines of code and will be released twice.
[Day 1]: Click to open the link
Product download trial: http://download.csdn.net/detail/zxciop110/4625423

I forgot to mention one thing on the first day, that is, sharedpreferences is not going to be a guide page when it is opened for the second time, but rather a loading. This is not an exception in many projects, today, by the way, let's look at the picture first.

/*** Animation_index.java * COM. yzz. twan ** function: Todo ** ver Date Author * ── ─ ** HP ** copyright (c) 2012, TNT All Rights Reserved. */package COM. yzz. twan; import Java. util. arraylist; import Java. util. list; import android. app. activity; import android. app. alertdialog; import android. app. alertdialog. builder; import android. content. componentname; import android Oid. content. context; import android. content. dialoginterface; import android. content. intent; import android.net. connectivitymanager; import android.net. networkinfo; import android. OS. bundle; import android. OS. handler; import android. OS. message; import android. provider. settings; import android. util. displaymetrics; import android. util. log; import android. view. gravity; import android. view. view; import android. view. Viewgroup. layoutparams; import android. view. window; import android. view. windowmanager; import android. view. animation. animation; import android. view. animation. animationutils; import android. widget. button; import android. widget. imageview; import android. widget. linearlayout;/*** classname: after the first start page, * function: Todo add function * reason: todo add reason ** @ author HP * @ version * @ since ver 1.1 * @ date 201 2-8-9 am 09:54:25 ** <a href = "\" http://www.eoeandroid.com/home.php? MoD = Space & uid = 133757 \ "" target = "\" _ blank \ ""> @ See </a> */public class animation_index extends activity {public animation ANM, ANMs; Public int marginstop; public list <imageview> images; Public imageview IV; Public button BTN; private context cont = This; Public linearlayout ll; Boolean flag = true; @ override protected void oncreate (bundle savedinstancestate) {// todo auto-generated method Stub this. R Equestwindowfeature (window. feature_no_title); super. oncreate (savedinstancestate); getwindow (). setflags (windowmanager. layoutparams. flag_fullscreen, windowmanager. layoutparams. flag_fullscreen); // setcontentview (R. layout. animation_index); networkstatus (cont); displaymetrics dm = This. getresources (). getdisplaymetrics (); int Height = DM. heightpixels; // absolute height marginstop = height-100; ANM = animationutils. Loadanimation (this, R. anim. myanim); ANMs = animationutils. loadanimation (this, R. anim. push_right_in); animation anim = animationutils. loadanimation (this, R. anim. round_loading); // BTN = (button) findviewbyid (R. id. loadingbtn); // BTN = new button (this); // BTN. startanimation (anim); LL = new linearlayout (this); // lls = new linearlayout (this); LL. setbackgroundresource (R. drawable. animations); // ll. setbac Kgroundresource (R. drawable. ainmation); images = new arraylist <imageview> (); initimage (LL); playanimation (); setcontentview (LL); // linearlayout. layoutparams paramd = new linearlayout. layoutparams (40, 40); paramd. gravity = gravity. center; // paramd. setmargins (0, 0,100, 0); // BTN = new button (this); // BTN. startanimation (anim); BTN. setlayoutparams (paramd); BTN. setbackgrounddrawable (getresources (). ge Tdrawable (R. drawable. refresh_normal); BTN. startanimation (anim); LL. addview (BTN); // IV = new imageview (this); // ll. setgravity (gravity. clip_horizontal); // IV. setimagedrawable (animation_index.this.getresources (). getdrawable (R. drawable. ainmation); // IV. setpressed (pressed) // IV. setlayoutparams (paramd); // ll. addview (IV); // ll. setgravity (gravity. center_horizontal); // linearlayout. layoutparams par AMSS = new linearlayout. layoutparams (40, 40); // paramss. setmargins (180,180,180,180); // IV. setlayoutparams (paramss); // ll. addview (IV); // images. add (IV); // images. get (4 ). setimagedrawable (animation_index.this.getresources (). getdrawable (R. drawable. ainmation); // images. add (30dip ", R. drawable. a); // images. get (7 ). setanimation (ANMs);} // The Private void playanimation () {New thread () {@ ove Rride public void run () {// todo auto-generated method stub // super. run (); try {thread. sleep (1000);} catch (interruptedexception e) {e. printstacktrace ();} int runcount = 0; while (FLAG) {If (runcount <2) {for (INT I = 0; I <= 6; I ++) {handler. sendemptymessage (I); try {thread. sleep (400);} catch (interruptedexception e) {e. printstacktrace () ;}} runcount ++;} else {handler. sendemptymessage (99); runcoun T = 0 ;}}}}. start (); // todo auto-generated method stub} // determine the private Boolean networkstatus (context con) {// Boolean netsataus = false; connectivitymanager cwjmanager = (connectivitymanager) getsystemservice (context. connectivity_service); // log. V ("WJP", "cwjmanager" + cwjmanager); If (cwjmanager = NULL) return false; networkinfo netinfo = cwjmanager. getactivenetworkinfo (); If (netinfo! = NULL) {// return netinfo. isavailable (); // whether return netinfo is available. isconnected (); // check the connection} If (netinfo = NULL) {builder B = new alertdialog. builder (this ). settitle ("no available network "). setmessage ("do you want to set the network? "); B. setpositivebutton ("yes", new dialoginterface. onclicklistener () {public void onclick (dialoginterface Diener, int whichbutton) {intent mintent = new intent ("/"); componentname comp = new componentname ("com. android. settings "," com. android. settings. wireless. settings "); mintent. setcomponent (COMP); mintent. setaction ("android. intent. action. view "); // startactivityforresult (mintent, 0); startactivity (new intent (settings. action_settings ));}}). setneutralbutton ("no", new dialoginterface. onclicklistener () {public void onclick (dialoginterface dialog, int whichbutton) {dialog. cancel ();}}). show (); Return true;} return true;} @ override protected void ondestroy () {flag = false; // todo auto-generated method stub super. ondestroy ();} handler = new handler () {@ override public void handlemessage (Message MSG) {Switch (MSG. what) {Case 0: images. get (0 ). setimagedrawable (animation_index.this.getresources (). getdrawable (R. drawable. loading_a); images. get (0 ). startanimation (ANM); break; Case 1: images. get (1 ). setimagedrawable (animation_index.this.getresources (). getdrawable (R. drawable. loading_ B); images. get (1 ). startanimation (ANM); break; Case 2: images. get (2 ). setimagedrawable (animation_index.this.getresources (). getdrawable (R. drawable. loading_c); images. get (2 ). startanimation (ANM); break; Case 3: images. get (3 ). setimagedrawable (animation_index.this.getresources (). getdrawable (R. drawable. loading_d); images. get (3 ). startanimation (ANM); break; Case 4: images. get (4 ). setimagedrawable (animation_index.this.getresources (). getdrawable (R. drawable. loading_e); images. get (4 ). startanimation (ANM); break; Case 5: images. get (5 ). setimagedrawable (animation_index.this.getresources (). getdrawable (R. drawable. loading_f); images. get (5 ). setanimation (ANM); break; Case 6: images. get (6 ). setimagedrawable (animation_index.this.getresources (). getdrawable (R. drawable. loading_g); images. get (6 ). setanimation (ANM); break; // case 7: // images. get (7 ). setimagedrawable (animation_index.this.getresources (). getdrawable (R. drawable. GAM); // images. get (7 ). setanimation (ANM); // break; // case 8: // images. get (8 ). setimagedrawable (animation_index.this.getresources (). getdrawable (R. drawable. GAM); // images. get (8 ). setanimation (ANM); // break; // case 9: // images. get (9 ). setimagedrawable (animation_index.this.getresources (). getdrawable (R. drawable. GAM); // images. get (9 ). setanimation (ANM); // break; Case 99: // clearimage (); intent = new intent (); intent. setclass (animation_index.this, mytab. class); startactivity (intent); finish (); // * // handler. removecallbacks (handler); break ;}}; // Private void clearimage () // {// For (imageview image: Images) // {// image. setimagedrawable (null); // image. destroydrawingcache (); //} // layout private void initimage (linearlayout layout) {layout. setgravity (gravity. center_horizontal); linearlayout. layoutparams Param = new linearlayout. layoutparams (40, 40); Param. setmargins (130, marginstop, 0, 0); linearlayout. layoutparams param2 = new linearlayout. layoutparams (40, 40); param2.setmargins (-5, marginstop, 0, 0); // layout. setgravity (gravity. center_horizontal); // linearlayout. layoutparams Params = new linearlayout. layoutparams (140,140); // Params. setmargins (30, marginstop, 0, 0); // linearlayout. layoutparams paramsd = new linearlayout. layoutparams (40, 40); // paramsd. setmargins (-5, marginstop, 0, 0); imageview L = new imageview (this); L. setlayoutparams (PARAM); layout. addview (l); images. add (l); imageview o = new imageview (this); O. setlayoutparams (param2); layout. addview (o); images. add (o); imageview A = new imageview (this);. setlayoutparams (param2); layout. addview (a); images. add (a); imageview d = new imageview (this); D. setlayoutparams (param2); layout. addview (d); images. add (d); imageview I = new imageview (this); I. setlayoutparams (param2); layout. addview (I); images. add (I); imageview n = new imageview (this); N. setlayoutparams (param2); layout. addview (n); images. add (n); imageview G = new imageview (this); G. setlayoutparams (param2); layout. addview (g); images. add (g); imageview H = new imageview (this); H. setlayoutparams (param2); layout. addview (h); images. add (h); imageview y = new imageview (this); Y. setlayoutparams (param2); layout. addview (y); images. add (y); imageview K = new imageview (this); K. setlayoutparams (param2); layout. addview (k); images. add (k); // finish (); // todo auto-generated method stub }}

In fact, there is not much to mention here. In fact, it is very simple. Let's take a look at the loading implementation of the custom layout, and the circle is always in the circle.
Method: playanimation

// The Private void playanimation () {New thread () {@ override public void run () {// todo auto-generated method stub // super. run (); try {thread. sleep (1000);} catch (interruptedexception e) {e. printstacktrace ();} int runcount = 0; while (FLAG) {If (runcount <2) {for (INT I = 0; I <= 6; I ++) {handler. sendemptymessage (I); try {thread. sleep (400);} catch (interruptedexception e) {e. printstacktrace () ;}} runcount ++;} else {handler. sendemptymessage (99); runcount = 0 ;}}}}. start (); // todo auto-generated method stub}

Handler handler=new Handler(){         @Override        public void handleMessage(Message msg) {                         switch(msg.what){                case 0:                    images.get(0).setImageDrawable(Animation_index.this.getResources().getDrawable(R.drawable.loading_a));                    images.get(0).startAnimation(anm);                    break;                case 1:                    images.get(1).setImageDrawable(Animation_index.this.getResources().getDrawable(R.drawable.loading_b));                    images.get(1).startAnimation(anm);                    break;                case 2:                    images.get(2).setImageDrawable(Animation_index.this.getResources().getDrawable(R.drawable.loading_c));                    images.get(2).startAnimation(anm);                    break;                case 3:                    images.get(3).setImageDrawable(Animation_index.this.getResources().getDrawable(R.drawable.loading_d));                    images.get(3).startAnimation(anm);                    break;                case 4:                    images.get(4).setImageDrawable(Animation_index.this.getResources().getDrawable(R.drawable.loading_e));                    images.get(4).startAnimation(anm);                    break;                case 5:                    images.get(5).setImageDrawable(Animation_index.this.getResources().getDrawable(R.drawable.loading_f));                    images.get(5).setAnimation(anm);                    break;                case 6:                    images.get(6).setImageDrawable(Animation_index.this.getResources().getDrawable(R.drawable.loading_g));                    images.get(6).setAnimation(anm);                    break;               //                case 7://                    images.get(7).setImageDrawable(Animation_index.this.getResources().getDrawable(R.drawable.gam));//                    images.get(7).setAnimation(anm);//                    break;//                case 8://                    images.get(8).setImageDrawable(Animation_index.this.getResources().getDrawable(R.drawable.gam));//                    images.get(8).setAnimation(anm);//                    break;//                case 9://                    images.get(9).setImageDrawable(Animation_index.this.getResources().getDrawable(R.drawable.gam));//                    images.get(9).setAnimation(anm);//                    break;                                     case 99:                    //clearImage();                                         Intent intent=new Intent();                    intent.setClass(Animation_index.this, MyTab.class);                    startActivity(intent);                    finish();//*/                    //handler.removeCallbacks(handler);                    break;             }                     }     };

This page is very simple. I am not talking about it. I will talk more about it on the homepage. There are more code.

Related Article

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.