Packagecom.itheima.googleplay_8.utils;ImportAndroid. R.anim;ImportAndroid.content.Context;Importandroid.content.res.Resources;ImportAndroid.os.Handler;ImportCom.itheima.googleplay_8.base. baseapplication;/** * @authorAdministrator * @time 2015-7-15 a.m. 10:59:15 * @des and UI-related tool classes * *@version$Rev: 8 $ * @updateAuthor $Author: ADMIN $ * @updateDate $Date: 2015-07-15 17:06:45 +0800 (Wednesday, 157 months) $ * @upda Tedes TODO*/ Public classUiutils {/**Get Context*/ Public StaticContext GetContext () {returnBaseapplication.getcontext (); } /**Get Resouce Object*/ Public StaticResources getresource () {returnGetContext (). Getresources (); } /**get the string in String.xml*/ Public StaticString getString (intresId) { returngetresource (). getString (ResId); } /**get an array of strings in String.xml*/ Public StaticString[] Getstringarr (intresId) { returngetresource (). Getstringarray (ResId); } /**get the color in Colors.xml*/ Public Static intGetColor (intColorid) { returngetresource (). GetColor (Colorid); } /**get the package name of the application*/ Public StaticString Getpackagename () {returnGetContext (). Getpackagename (); } /**get the main thread ID*/ Public Static LongGetmainthreadid () {returnBaseapplication.getmaintreadid (); } /**get the main thread handler*/ Public StaticHandler Getmainthreadhandler () {returnBaseapplication.gethandler (); } /**secure execution of a task*/ Public Static voidposttasksafely (Runnable Task) {intCurthreadid =Android.os.Process.myTid (); if(Curthreadid = = Getmainthreadid ()) {//if the current thread is the main pathTask.run (); } Else{//if the current thread is not the main pathGetmainthreadhandler (). Post (Task); } }}
Common source of the second: uiutils