private void replayUpdates(PackageInstallInfo newInfo) {
    if (DEBUG) Log.d(TAG, "updates resumed");
    if (!mResumed || !mBound) {
      // Not yet ready
      return;
    }
    if ((mPendingReplays.size() == 0) && (newInfo == null)) {
      // Nothing to update
      return;
    }

    LauncherAppState app = LauncherAppState.getInstanceNoCreate();
    if (app == null) {
      // Try again later
      if (DEBUG) Log.d(TAG, "app is null, delaying send");
      return;
    }

    ArrayList<PackageInstallInfo> updates = new ArrayList<PackageInstallInfo>();
    if ((newInfo != null) && (newInfo.state != STATUS_INSTALLED)) {
      updates.add(newInfo);
    }
    for (int i = mPendingReplays.size() - 1; i >= 0; i--) {
      SessionInfo session = mPendingReplays.valueAt(i);
      if (session.getAppPackageName() != null) {
        updates.add(
            new PackageInstallInfo(
                session.getAppPackageName(),
                STATUS_INSTALLING,
                (int) (session.getProgress() * 100)));
      }
    }
    mPendingReplays.clear();
    if (!updates.isEmpty()) {
      app.setPackageState(updates);
    }

    if (!mPendingBadgeUpdates.isEmpty()) {
      for (String pkg : mPendingBadgeUpdates) {
        app.updatePackageBadge(pkg);
      }
      mPendingBadgeUpdates.clear();
    }
  }
  PackageInstallerCompatVL(Context context) {
    mInstaller = context.getPackageManager().getPackageInstaller();
    LauncherAppState.setApplicationContext(context.getApplicationContext());
    mCache = LauncherAppState.getInstance().getIconCache();
    mWorker = new Handler();

    mResumed = false;
    mBound = false;

    mInstaller.registerSessionCallback(mCallback, mWorker);

    // On start, send updates for all active sessions
    mWorker.post(
        new Runnable() {

          @Override
          public void run() {
            for (SessionInfo info : mInstaller.getAllSessions()) {
              mPendingReplays.append(info.getSessionId(), info);
            }
          }
        });
  }
Beispiel #3
0
  @SuppressWarnings("deprecation")
  @Override
  protected void onFinishInflate() {
    super.onFinishInflate();

    mOriginalTextColor = getTextColors();

    // Get the hover color
    Resources r = getResources();
    mHoverColor = r.getColor(R.color.info_target_hover_tint);
    mDrawable = (TransitionDrawable) getCurrentDrawable();
    if (null != mDrawable) {
      mDrawable.setCrossFadeEnabled(true);
    }

    // Remove the text in the Phone UI in landscape
    int orientation = getResources().getConfiguration().orientation;
    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
      if (!LauncherAppState.getInstance().isScreenLarge()) {
        setText("");
      }
    }
  }