Ejemplo n.º 1
0
    void attach(IWallpaperEngineWrapper wrapper) {
      if (DEBUG) Log.v(TAG, "attach: " + this + " wrapper=" + wrapper);
      if (mDestroyed) {
        return;
      }

      mIWallpaperEngine = wrapper;
      mCaller = wrapper.mCaller;
      mConnection = wrapper.mConnection;
      mWindowToken = wrapper.mWindowToken;
      mSurfaceHolder.setSizeFromLayout();
      mInitializing = true;
      mSession = WindowManagerGlobal.getWindowSession(getMainLooper());

      mWindow.setSession(mSession);

      mScreenOn = ((PowerManager) getSystemService(Context.POWER_SERVICE)).isScreenOn();

      IntentFilter filter = new IntentFilter();
      filter.addAction(Intent.ACTION_SCREEN_ON);
      filter.addAction(Intent.ACTION_SCREEN_OFF);
      registerReceiver(mReceiver, filter);

      if (DEBUG) Log.v(TAG, "onCreate(): " + this);
      onCreate(mSurfaceHolder);

      mInitializing = false;
      mReportedVisible = false;
      updateSurface(false, false, false);
    }
 /*
 ====================CALLBACKS==========================
 */
 @Override
 public void onCreate(SurfaceHolder surfaceHolder) {
   super.onCreate(surfaceHolder);
   Log.d(TAG, ".onCreate()");
   contentResolver = getContentResolver();
   fetchAudio = new FetchAudio(contentResolver);
   mPlayer = MediaPlayer.create(getApplicationContext(), fetchAudio.getRandomTrack().getURI());
   link(mPlayer);
   addBarGraphRenderers();
   mPlayer.start();
   mHandler.removeCallbacks(mUpdateDisplay);
   mHandler.postDelayed(mUpdateDisplay, 200);
 }
 @Override
 public void onCreate(SurfaceHolder surfaceHolder) {
   super.onCreate(surfaceHolder);
   this.replaceRequired = true;
   updateSize();
 }