Many programs many programs apes may be the same as me, when the company developed the project, the completion of the function is the first, so always appear, here should be able to write better, next version. The recent project is nearing the end and feels like a new look at the project, which should be one of the best ways to improve yourself and optimize your project.
End of nonsense ....
First, share
Programme I: Share directly with friends of the league
Http://dev.umeng.com/social/android/quick-integration
Scenario Two: Each platform's SDK is called separately
1. Share the circle of friends and
private void Regtowx () {API = Wxapifactory.createwxapi (this, app_id, true);//Get Iwxapi instance Api.registerapp (app_id);} Share private void Sendreq (Boolean Ryan) {regtowx (); Bitmap BMP = Capturewebview (WB); Wximageobject imgobj = new Wximageobject (BMP); Wxmediamessage msg = new Wxmediamessage (); msg.mediaobject = Imgobj; Bitmap thumbbmp = bitmap.createscaledbitmap (BMP, N, Thumb_size, True); Bmp.recycle (); msg.thumbdata = Util.bmptobytearray (Thumbbmp, true); Sendmessagetowx.req Req = new Sendmessagetowx.req (); req.transaction = Gettransaction (); req.message = Msg;req.scene = Sendmessagetowx.req.wxscenesession;api.sendreq (REQ);} Share friend Circle private void Sendreqa () {regtowx (); Bitmap BMP = Capturewebview (WB); Wximageobject imgobj = new Wximageobject (BMP); Wxmediamessage msg = new Wxmediamessage (); msg.mediaobject = Imgobj; Bitmap thumbbmp = bitmap.createscaledbitmap (BMP, N, Thumb_size, True); Bmp.recycle (); msg.thumbdata = Util.bmptobytearray (Thumbbmp, true); Sendmessagetowx.req Req = new Sendmessagetowx.req (); Req.transAction = Gettransaction (); req.message = Msg;req.scene = Sendmessagetowx.req.wxscenetimeline;api.sendreq (req);}
/** * Screenshot--current screen * @param context * @return * /private Bitmap Capturescreen (Activity context) { View CV = Context.getwindow (). Getdecorview (); Bitmap bmp = Bitmap.createbitmap (Cv.getwidth (), Cv.getheight (), config.argb_8888); Canvas canvas = new canvas (BMP); Cv.draw (canvas); return BMP;
/** * Intercept WebView Snapshot (the size of the entire content loaded by WebView) * * @param webView * @return */public static Bitmap Capturewebview (WebView Webvie W) {Picture snapShot = Webview.capturepicture (); Bitmap bmp = Bitmap.createbitmap (Snapshot.getwidth (), Snapshot.getheight (), Bitmap.Config.ARGB_8888); Canvas canvas = new canvas (BMP); Snapshot.draw (canvas); return bmp;}
2. Sina Share
First step: Download the Sina SDK
Step two: Apply for the developer account on the Sina public account platform to get AppID
private void Sendmultimessage () {//1. Initializing Weibo sharing message weibomultimessage weibomessage = new Weibomultimessage (); Weibomessage.mediaobject = Getimageobj (); weibomessage.textobject = Gettextobj ();//2. Initialize message requests from third parties to Weibo sendmultimessagetoweiborequest request = new Sendmultimessagetoweiborequest ();// Uniquely identifies a request with transaction Request.transaction = String.valueof (System.currenttimemillis ()); request.multimessage = weibomessage;//3. Send a request message to Weibo to evoke the microblog sharing interface Weiboapi.sendrequest (request);} /** * Create a text message object. * * @return text Message object. */private textobject gettextobj () {Textobject textobject = new Textobject (); textobject.text = "Share picture"; return textobject;} /** * Create a picture Message object. * * @return Picture Message object. */private imageobject getimageobj () {imageobject imageobject = new Imageobject (); Bitmap BMP = Capturewebview (WB); Imageobject.setimageobject (BMP); return imageobject;}
Private String Gettransaction () {final Getmessagefromwx.req Req = new Getmessagefromwx.req (bundle); return Req.transaction;}
Ii. use of dialog and Popupwindow
1, the use of dialog
private void Updateversiondialog (string title, string text, String Yes,string No, final Integer Isupdatenewestversion,fin Al Integer nowsystemnum) {Customdialog.builder Ibuilder = new Customdialog.builder (getactivity ()); Ibuilder.settitle ( title); Ibuilder.setmessage (text); Ibuilder.setpositivebutton (yes, new Dialoginterface.onclicklistener () {@ overridepublic void OnClick (dialoginterface dialog, int which) {//ok operation Dialog.dismiss ();}); Ibuilder.setnegativebutton (No, new Dialoginterface.onclicklistener () {@Overridepublic void OnClick (dialoginterface dialog, int which) {//randomly bound dialog.dismiss (); <pre name= "code" class= "plain" >//ok canceled operation
}}); Customdialog dialog = Ibuilder.create ();d ialog.show ();d ialog.setcanceledontouchoutside (false);//Shield background trigger
Dialog.setcancelable (false);//Shield return button trigger}
2, the use of Popupwindow
1. For Popupwindow view layout, get layout view through Layoutinflator. e.g. Layoutinflater Inflater = (layoutinflater) This.anchor.getContext (). Getsystemservice (Context.layout_inflater_service); View Textentryview = inflater.inflate (r.layout.paopao_alert_dialog, null); 2, display location, there are many ways to set the display mode Pop.showatlocation (Findviewbyid (R.ID.LL2), Gravity.left, 0,-90), or Pop.showasdropdown (View Anchor, int xoff, int yoff) 3, into the animation Pop.setanimationstyle (r.style.popupanimation); 4, click outside the Popupwindow area, Popupwindow disappear This.window = new Popupwindow (Anchor.getcontext ()); This.window.setTouchInterceptor (New Ontouchlistener () {@Overridepublic Boolean onTouch (View V, motionevent event) {if ( Event.getaction () ==motionevent.action_outside) { BetterPopupWindow.this.window.dismiss (); return true;} return false;}});
The difference between the two:
Popupwindow differs from dialog in that the background activity can still get focus (except Popupwindow setfocusable (False) when the Popupwindow pops up), set setfocusable (True) is similar to dialog and cannot receive key events. The simplest way to close a pop-up dialog if you want to enable Popupwindow to respond to key events or click on the background activity is to use setbackgrounddrawable (), or to use a constructor that can create background This is because when background is set, Contentview is placed in a Popupviewcontainer class container to Windowmanager,popupviewcontainer is the inner class of Popupview, Implements the handling of keystrokes and touch events. Of course not set background itself through set to the outermost Contentview call Setonkeylistener (), Setontouchlistener () can also be implemented. When the keyboard comes out here, the original layout is not compressed.
To be continued ....... .............
To be continued ....... .............
To be continued ....... .............
Third, the use of Slidingmenu
Iv. combination of fragment and Radiogroup for Tabhost
V. Picture of the ListView cache processing. Optimized image caching, picture loading optimization, picture loading queue priority loading based on current sliding position
Six, the Start page processing Viewpager
Seven, Andorid through the webview through the JS call Highcharts display all kinds of charts
Eight, viewpager+ slider to implement the two-page head button to switch back and forth, Viewpager slide when the sliding line animation slide, you can try to use Actionbar+viewpager to achieve
Nine, dropdown refresh, using the ListView drop-down refresh, open Source Library Pulltorefreshlistview, the new dropdown refresh API is available on the ANDROID19 version
Ten, small icons to adapt to various compatibility, consider using the Icomoon icon through the string processing
XI. head round processing. You can overlay a fillet with XML, or re-ondraw the picture by integrating the view
12, the height, the date, the age choice card the better display plan
13, share the current page. Principle: Save the current view settings to the cache caches and measure get the bitmap of the current view cache
14, sound, vibration of the reminder
XV, the notification receives, temporarily uses is polling, considers oneself uses the long connection realizes the notification, through the heartbeat packet to maintain the connection to consider the network and so on the situation
16. Switch the progress bar in my target
17. Call album to set your avatar
18. Loading of GIF images
19, activity up and down slide out of the animation
20. Data storage: Application save global variables, shareperefence store data to file, SQLite save database, intent blind object pass values (special objects can be considered to base64 storage), content Provider seems to be useless in this project.
21, service broadcast notification use
Android Project "Brush the Bracelet" code review