@Override public void onVisibilityChanged(boolean visible){
  mVisible=visible;
  if (visible) {
    ArrayList<Class> drawerClasses=new ArrayList<Class>();
    drawerClasses.add(CombinedWifiCellularDrawer.class);
    drawerClasses.add(BatteryDrawer.class);
    if (NotificationService.permissionsGranted) {
      drawerClasses.add(NotificationsDrawer.class);
    }
    mDrawerIndex++;
    if (mDrawerIndex >= drawerClasses.size()) {
      mDrawerIndex=0;
    }
    Class cls=drawerClasses.get(mDrawerIndex);
    if (cls == NotificationsDrawer.class) {
      mDrawer=new NotificationsDrawer(mContext);
    }
 else     if (cls == BatteryDrawer.class) {
      mDrawer=new BatteryDrawer(mContext);
    }
 else {
      mDrawer=new CombinedWifiCellularDrawer(mContext);
    }
    mDrawer.start();
    draw();
  }
 else {
    if (mDrawer != null) {
      mDrawer.destroy();
      mDrawer=null;
    }
    mHandler.removeCallbacks(mUpdateDisplay);
  }
}

@ Override public void onVisibilityChanged ( boolean visible ) { mVisible = visible ; if ( visible ) { ArrayList < Class > drawerClasses = new ArrayList < Class > ( ) ; drawerClasses . add ( CombinedWifiCellularDrawer . class ) ; drawerClasses . add ( BatteryDrawer . class ) ; if ( NotificationService . permissionsGranted ) { drawerClasses . add ( NotificationsDrawer . class ) ; } mDrawerIndex ++ ; if ( mDrawerIndex >= drawerClasses . size ( ) ) { mDrawerIndex = 0 ; } Class cls = drawerClasses . get ( mDrawerIndex ) ; if ( cls == NotificationsDrawer . class ) { mDrawer = new NotificationsDrawer ( mContext ) ; } else if ( cls == BatteryDrawer . class ) { mDrawer = new BatteryDrawer ( mContext ) ; } else { mDrawer = new CombinedWifiCellularDrawer ( mContext ) ; } mDrawer . start ( ) ; draw ( ) ; } else { if ( mDrawer != null ) { mDrawer . destroy ( ) ; mDrawer = null ; } mHandler . removeCallbacks ( mUpdateDisplay ) ; } }
toggle visibility of the wallpaper in this function we create new drawers every time the wallpaper is visible again , cycling through the available ones
