Exemplo n.º 1
0
  @Override
  public void selfDestruct() {
    mTextFontInterfaceRef.clear();
    mTextFontInterfaceRef = null;

    GoSettingControler controler = GOLauncherApp.getSettingControler();
    controler.unRegisterObserver(this);
    controler = null;
  }
Exemplo n.º 2
0
 @Override
 public void selfConstruct() {
   GoSettingControler controler = GOLauncherApp.getSettingControler();
   if (null != controler) {
     controler.registerObserver(this);
     initTypeface(
         controler.getUsedFontBean().mFontTypeface, controler.getUsedFontBean().mFontStyle);
   }
 }
  /**
   * 调整壁纸尺寸的方法,只要是针对壁纸放大的问题(用户当前是可滚,但是选择壁纸时却是单屏,这时候设回为单屏)
   *
   * @param wallpaperManager
   * @return
   */
  public static boolean adjustWallpaperDimension(WallpaperManager wallpaperManager) {
    // 是否进行调整的结果
    boolean result = false;
    if (wallpaperManager == null) {
      wallpaperManager = WallpaperManager.getInstance(GOLauncherApp.getContext());
    }
    try {
      Method method = wallpaperManager.getClass().getMethod("getIWallpaperManager");
      Object iWallpaperManager = method.invoke(wallpaperManager);
      // Class IWallpaperManager = iWallpaperManager.getClass();
      Class iWallpaperManagerClass = Class.forName("android.app.IWallpaperManager");

      Field field = wallpaperManager.getClass().getDeclaredField("sGlobals");
      field.setAccessible(true);
      Object globals = field.get(wallpaperManager);

      Class[] arrayOfClass =
          new Class[] {Class.forName("android.app.IWallpaperManagerCallback"), Bundle.class};
      method = iWallpaperManagerClass.getDeclaredMethod("getWallpaper", arrayOfClass);
      method.setAccessible(true);

      Bundle params = new Bundle();
      ParcelFileDescriptor fd =
          (ParcelFileDescriptor) method.invoke(iWallpaperManager, new Object[] {globals, params});

      if (fd != null) {
        final int width = params.getInt("width", 0);
        final int height = params.getInt("height", 0);
        try {
          BitmapFactory.Options options = new BitmapFactory.Options();
          Bitmap bm = BitmapFactory.decodeFileDescriptor(fd.getFileDescriptor(), null, options);
          final int bitWidth = bm.getWidth();
          final int bitHeight = bm.getHeight();
          GoSettingControler settingControler = GOLauncherApp.getSettingControler();
          ScreenSettingInfo screenSettingInfo =
              GOLauncherApp.getSettingControler().getScreenSettingInfo();

          if (bitWidth == width / 2 && screenSettingInfo.mWallpaperScroll) {
            screenSettingInfo.mWallpaperScroll = false;
            result = true;
          }
          // else if(bitWidth == width * 2 &&
          // !screenSettingInfo.mWallpaperScroll){
          // screenSettingInfo.mWallpaperScroll = true;
          // result = true;
          // }
          if (result) {
            // 把屏幕是否可滚写进数据库
            settingControler.updateScreenSettingInfo(screenSettingInfo, false);
            WallpaperDensityUtil.setWallpaperDimension(GoLauncher.getContext());
          }
        } catch (OutOfMemoryError e) {
          result = false;
        } finally {
          try {
            fd.close();
          } catch (IOException e) {
            result = false;
          }
        }
      }
    } catch (Throwable e) {
      Log.v("System.out.print", e.toString());
      result = false;
    }
    return result;
  } // end adjustWallpaperDimension