Exemplo n.º 1
0
 public ThemeInfo getCurrentThemeInfo() {
   ContentResolver contentResolver = getContext().getContentResolver();
   if (mCurrentThemeInfo == null) {
     String where = ThemeColumns.IS_APPLY + "=" + 1;
     Cursor cursor = contentResolver.query(ThemeColumns.CONTENT_URI, null, where, null, null);
     if (cursor != null) {
       if (cursor.moveToFirst()) {
         mCurrentThemeInfo = ThemeInfo.CreateFromDB(cursor);
       }
       cursor.close();
     }
     if (mCurrentThemeInfo == null) {
       HomeUtils.markThemeAsApply(
           getContext(), HomeDataBaseHelper.getInstance(getContext()).getDefaultThemeID());
       cursor = contentResolver.query(ThemeColumns.CONTENT_URI, null, where, null, null);
       if (cursor != null) {
         if (cursor.moveToFirst()) {
           mCurrentThemeInfo = ThemeInfo.CreateFromDB(cursor);
         }
         cursor.close();
       }
     }
     if (mCurrentThemeInfo == null) {
       // 数据库错误,删除数据库
       HomeUtils.deleteFile(getContext().getDatabasePath(ProviderUtils.DATABASE_NAME).getParent());
       Process.killProcess(Process.myPid());
     }
   }
   mCurrentThemeInfo.initFromXML(getContext());
   return mCurrentThemeInfo;
 }
Exemplo n.º 2
0
 public void changeTheme(ThemeInfo themeInfo) {
   if (mCurrentThemeInfo != null && mModelObjectsManager != null) {
     mCurrentThemeInfo = themeInfo;
     mCurrentThemeInfo.initFromXML(getContext());
     HomeUtils.staticUsingTheme(getContext(), themeInfo.mThemeName);
     SESceneManager.getInstance().removeMessage(HomeScene.MSG_TYPE_UPDATE_SCENE);
     SESceneManager.getInstance().handleMessage(HomeScene.MSG_TYPE_UPDATE_SCENE, themeInfo);
     checkSceneRotation(themeInfo);
   }
 }
Exemplo n.º 3
0
 public static void updateTexture(
     Messenger messenger,
     Context context,
     String s,
     String s1,
     String s2,
     boolean flag,
     boolean flag1) {
   if (s == null) {
     updateTexture(messenger, s1, s2, flag, flag1);
   } else {
     Bitmap bitmap = ThemeInfo.getBitmap(context, s, s2);
     if (bitmap != null) {
       updateTexture(messenger, s1, bitmap, flag, flag1);
       return;
     }
   }
 }
Exemplo n.º 4
0
  /**
   * The following theme parameters are required by the scroll pane:
   *
   * <table>
   * <tr>
   * <th>Parameter name</th>
   * <th>Type</th>
   * <th>Description</th>
   * </tr>
   * <tr>
   * <td>autoScrollArea</td>
   * <td>integer</td>
   * <td>The size of the auto scroll area</td>
   * </tr>
   * <tr>
   * <td>autoScrollSpeed</td>
   * <td>integer</td>
   * <td>The speed in pixels to scroll every 50 ms</td>
   * </tr>
   * <tr>
   * <td>hasDragButton</td>
   * <td>boolean</td>
   * <td>If the dragButton should be shown or not</td>
   * </tr>
   * <tr>
   * <td>scrollbarsAlwaysVisible</td>
   * <td>boolean</td>
   * <td>Show scrollbars always (true) or only when needed (false)</td>
   * </tr>
   * </table>
   *
   * <br>
   * The following optional parameters can be used to change the appearance of the scroll pane:
   *
   * <table>
   * <tr>
   * <th>Parameter name</th>
   * <th>Type</th>
   * <th>Description</th>
   * </tr>
   * <tr>
   * <td>hscrollbarOffset</td>
   * <td>Dimension</td>
   * <td>Moves the horizontal scrollbar but does not change the available area
   * for the scroll content.</td>
   * </tr>
   * <tr>
   * <td>vscrollbarOffset</td>
   * <td>Dimension</td>
   * <td>Moves the vertical scrollbar but does not change the available area
   * for the scroll content.</td>
   * </tr>
   * <tr>
   * <td>contentScrollbarSpacing</td>
   * <td>Dimension</td>
   * <td>An optional spacing between the scrollbar and the content area. This
   * is only applied when the corresponding scrollbar is visible. It should be
   * &gt;= 0.</td>
   * </tr>
   * </table>
   *
   * @param themeInfo the theme info
   */
  protected void applyThemeScrollPane(ThemeInfo themeInfo) {
    autoScrollArea = themeInfo.getParameter("autoScrollArea", 5);
    autoScrollSpeed = themeInfo.getParameter("autoScrollSpeed", autoScrollArea * 2);
    hscrollbarOffset =
        themeInfo.getParameterValue("hscrollbarOffset", false, Dimension.class, Dimension.ZERO);
    vscrollbarOffset =
        themeInfo.getParameterValue("vscrollbarOffset", false, Dimension.class, Dimension.ZERO);
    contentScrollbarSpacing =
        themeInfo.getParameterValue(
            "contentScrollbarSpacing", false, Dimension.class, Dimension.ZERO);
    scrollbarsAlwaysVisible = themeInfo.getParameter("scrollbarsAlwaysVisible", false);

    boolean hasDragButton = themeInfo.getParameter("hasDragButton", false);
    if (hasDragButton && dragButton == null) {
      dragButton = new DraggableButton();
      dragButton.setTheme("dragButton");
      dragButton.setListener(
          new DraggableButton.DragListener() {
            public void dragStarted() {
              scrollbarH.externalDragStart();
              scrollbarV.externalDragStart();
            }

            public void dragged(int deltaX, int deltaY) {
              scrollbarH.externalDragged(deltaX, deltaY);
              scrollbarV.externalDragged(deltaX, deltaY);
            }

            public void dragStopped() {
              scrollbarH.externalDragStopped();
              scrollbarV.externalDragStopped();
            }
          });
      super.insertChild(dragButton, 3);
    } else if (!hasDragButton && dragButton != null) {
      assert super.getChild(3) == dragButton;
      super.removeChild(3);
      dragButton = null;
    }
  }