gdx 源码分析摘录

来源:互联网 发布:支持大数据的技术 编辑:程序博客网 时间:2024/05/21 06:30

一, HandlerCaller的使用

        封装handler;

        1,实现类

              HandlerCaller   mCaller = new HandlerCaller(context, context.getMainLooper(), this, true);

        2,实现回调;

               class XX implements HandlerCaller.Callback

               public void executeMessage(Message message) { }

        3,创建发送message

           Message msg = mCaller.obtainMessageI(MSG_VISIBILITY_CHANGED,
                    visible ? 1 : 0);
            mCaller.sendMessage(msg);


二, Engine

        The actual implementation of a wallpaper. You must implement {@link WallpaperService#onCreateEngine()}

         to return your concrete Engine implementation.

              1,监听屏幕

             

 final BroadcastReceiver mReceiver = new BroadcastReceiver() {            @Override            public void onReceive(Context context, Intent intent) {                if (Intent.ACTION_SCREEN_ON.equals(intent.getAction())) {                    mScreenOn = true;                    reportVisibility();                } else if (Intent.ACTION_SCREEN_OFF.equals(intent.getAction())) {                    mScreenOn = false;                    reportVisibility();                }            }        };        
    

三, class WallpaperService extends Service

         实现了IWallpaperService


四,IWallpaperService.stub

       attach(); 在attach中创建engine


五,IWallpaperEngine

oneway interface IWallpaperEngine {    void setDesiredSize(int width, int height);    void setVisibility(boolean visible);    void dispatchPointer(in MotionEvent event);    void dispatchWallpaperCommand(String action, int x, int y,            int z, in Bundle extras);        void destroy();}控制wallpaper的生命周期,ibinder对象

六: 创建AndroidWallpaperEngine(libgdx封装)

         public class AndroidWallpaperEngine extends Engine


七:  Application

       It sets up a window and rendering surface and manages the * different aspects of your application


0 0