final View J(int paramInt) {
   View localView = (View) nx.get(paramInt);
   if (localView != null) {
     nx.delete(paramInt);
   }
   return localView;
 }
  /**
   * Start activity for result.
   *
   * @param intent Intent to start activity.
   * @param callback Result call-back.
   * @return Handle to this operation.
   */
  public Handle startActivityForResult(Intent intent, ActivityResultCallback callback) {
    // check parameter
    if (intent == null) {
      Log.e(TAG, "startActivityForResult() - No intent");
      return null;
    }

    // check state
    this.verifyAccess();

    // generate request code
    int requestCode = 64;
    for (; requestCode > 0; --requestCode) {
      if (m_ActivityResultHandles.get(requestCode) == null) break;
    }
    if (requestCode <= 0) {
      Log.e(TAG, "startActivityForResult() - No available request code");
      return null;
    }

    // create handle
    ActivityResultHandle handle = new ActivityResultHandle(callback);
    m_ActivityResultHandles.put(requestCode, handle);

    // start activity for result
    try {
      this.startActivityForResult(intent, requestCode);
      return handle;
    } catch (Throwable ex) {
      Log.e(TAG, "startActivityForResult() - Fail to start activity", ex);
      m_ActivityResultHandles.delete(requestCode);
      return null;
    }
  }
 private void removeCameraUserLocked(IBinder token, int cameraId) {
   CameraUserRecord record = mCamerasInUse.get(cameraId);
   if (record != null && record.token == token) {
     if (DEBUG) Log.d(TAG, "Removing camera user " + token);
     mCamerasInUse.delete(cameraId);
   }
 }
 // Called after getting result from activity.
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   ActivityResultHandle handle = m_ActivityResultHandles.get(requestCode);
   if (handle != null) {
     m_ActivityResultHandles.delete(requestCode);
     if (Handle.isValid(handle) && handle.callback != null)
       handle.callback.onActivityResult(handle, resultCode, data);
     return;
   }
   super.onActivityResult(requestCode, resultCode, data);
 }
Пример #5
0
 View get(int position) {
   // System.out.print("Looking for " + position);
   View result = mScrapHeap.get(position);
   if (result != null) {
     // System.out.println(" HIT");
     mScrapHeap.delete(position);
   } else {
     // System.out.println(" MISS");
   }
   return result;
 }
Пример #6
0
  public void deleteSong(int id) {
    SongDb.deleteSongById(mContext, id);
    SongInfo info = mSongInfos.get(id);
    if (info != null) {
      SongInfo currentSong = getCurrentSong();
      if (currentSong != null && currentSong.getId() == info.getId()) {
        mContext.sendBroadcast(new Intent("stop"));
      }
      File file = new File(info.getPath());
      if (file.exists()) file.delete();
    }

    mSongInfos.delete(id);
    sort();
  }
Пример #7
0
  private static void makeInstanceWeak(int javaObjectID, boolean keepAsWeak) {
    if (IsLogEnabled)
      Log.d(
          DEFAULT_LOG_TAG,
          "makeInstanceWeak instance " + javaObjectID + " keepAsWeak=" + keepAsWeak);
    Object instance = strongInstances.get(javaObjectID);

    if (keepAsWeak) {
      weakJavaObjectToID.put(instance, Integer.valueOf(javaObjectID));
      weakInstances.put(javaObjectID, new WeakReference<Object>(instance));
    }

    strongInstances.delete(javaObjectID);
    strongJavaObjectToID.remove(instance);
  }
Пример #8
0
  /**
   * Responds to the intent result if the intent was created by the native window.
   *
   * @param requestCode Request code of the requested intent.
   * @param resultCode Result code of the requested intent.
   * @param data The data returned by the intent.
   * @return Boolean value of whether the intent was started by the native window.
   */
  public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
    IntentCallback callback = mOutstandingIntents.get(requestCode);
    mOutstandingIntents.delete(requestCode);
    String errorMessage = mIntentErrors.remove(requestCode);

    if (callback != null) {
      callback.onIntentCompleted(this, resultCode, mActivity.getContentResolver(), data);
      return true;
    } else {
      if (errorMessage != null) {
        showCallbackNonExistentError(errorMessage);
        return true;
      }
    }
    return false;
  }
Пример #9
0
 @Override
 public void onRequestPermissionsResult(
     int requestCode, String permissions[], int[] grantResults) {
   // Verify that we can now grant all the requested permissions. Note that although grant()
   // takes a list of permissions, grant() is actually all-or-nothing. If there are any
   // requested permissions not included in the granted permissions, all will be denied.
   PermissionRequest request = mPendingRequests.get(requestCode);
   for (String webkitPermission : request.getResources()) {
     if (!canGrant(webkitPermission)) {
       request.deny();
       return;
     }
   }
   request.grant(request.getResources());
   mPendingRequests.delete(requestCode);
 }
Пример #10
0
 @Override
 public void destroyItem(ViewGroup container, int position, Object object) {
   getLoaderManager().destroyLoader(position);
   ((ViewPager) container).removeView((View) object);
   mEntryViews.delete(position);
 }
Пример #11
0
  /**
   * Decode the Icon Directory for this ICO and store the result in iconDirectory.
   *
   * @return true if ICO decoding was considered to probably be a success, false if it certainly was
   *     a failure.
   */
  private boolean decodeIconDirectoryAndPossiblyPrune() {
    hasDecoded = true;

    // Fail if the end of the described range is out of bounds.
    if (offset + len > decodand.length) {
      return false;
    }

    // Fail if we don't have enough space for the header.
    if (len < ICO_HEADER_LENGTH_BYTES) {
      return false;
    }

    // Check that the reserved fields in the header are indeed zero, and that the type field
    // specifies ICO. If not, we've probably been given something that isn't really an ICO.
    if (decodand[offset] != 0
        || decodand[offset + 1] != 0
        || decodand[offset + 2] != 1
        || decodand[offset + 3] != 0) {
      return false;
    }

    // Here, and in many other places, byte values are ANDed with 0xFF. This is because Java
    // bytes are signed - to obtain a numerical value of a longer type which holds the unsigned
    // interpretation of the byte of interest, we do this.
    int numEncodedImages = (decodand[offset + 4] & 0xFF) | (decodand[offset + 5] & 0xFF) << 8;

    // Fail if there are no images or the field is corrupt.
    if (numEncodedImages <= 0) {
      return false;
    }

    final int headerAndDirectorySize =
        ICO_HEADER_LENGTH_BYTES + (numEncodedImages * ICO_ICONDIRENTRY_LENGTH_BYTES);

    // Fail if there is not enough space in the buffer for the stated number of icondir entries,
    // let alone the data.
    if (len < headerAndDirectorySize) {
      return false;
    }

    // Put the pointer on the first byte of the first Icon Directory Entry.
    int bufferIndex = offset + ICO_HEADER_LENGTH_BYTES;

    // We now iterate over the Icon Directory, decoding each entry as we go. We also need to
    // discard all entries except one >= the maximum interesting size.

    // Size of the smallest image larger than the limit encountered.
    int minimumMaximum = Integer.MAX_VALUE;

    // Used to track the best entry for each size. The entries we want to keep.
    SparseArray<IconDirectoryEntry> preferenceArray = new SparseArray<IconDirectoryEntry>();

    for (int i = 0; i < numEncodedImages; i++, bufferIndex += ICO_ICONDIRENTRY_LENGTH_BYTES) {
      // Decode the Icon Directory Entry at this offset.
      IconDirectoryEntry newEntry =
          IconDirectoryEntry.createFromBuffer(decodand, offset, len, bufferIndex);
      newEntry.index = i;

      if (newEntry.isErroneous) {
        continue;
      }

      if (newEntry.width > Favicons.largestFaviconSize) {
        // If we already have a smaller image larger than the maximum size of interest, we
        // don't care about the new one which is larger than the smallest image larger than
        // the maximum size.
        if (newEntry.width >= minimumMaximum) {
          continue;
        }

        // Remove the previous minimum-maximum.
        preferenceArray.delete(minimumMaximum);

        minimumMaximum = newEntry.width;
      }

      IconDirectoryEntry oldEntry = preferenceArray.get(newEntry.width);
      if (oldEntry == null) {
        preferenceArray.put(newEntry.width, newEntry);
        continue;
      }

      if (oldEntry.compareTo(newEntry) < 0) {
        preferenceArray.put(newEntry.width, newEntry);
      }
    }

    final int count = preferenceArray.size();

    // Abort if no entries are desired (Perhaps all are corrupt?)
    if (count == 0) {
      return false;
    }

    // Allocate space for the icon directory entries in the decoded directory.
    iconDirectory = new IconDirectoryEntry[count];

    // The size of the data in the buffer that we find useful.
    int retainedSpace = ICO_HEADER_LENGTH_BYTES;

    for (int i = 0; i < count; i++) {
      IconDirectoryEntry e = preferenceArray.valueAt(i);
      retainedSpace += ICO_ICONDIRENTRY_LENGTH_BYTES + e.payloadSize;
      iconDirectory[i] = e;
    }

    isValid = true;

    // Set the number of images field in the buffer to reflect the number of retained entries.
    decodand[offset + 4] = (byte) iconDirectory.length;
    decodand[offset + 5] = (byte) (iconDirectory.length >>> 8);

    if ((len - retainedSpace) > COMPACT_THRESHOLD) {
      compactingCopy(retainedSpace);
    }

    return true;
  }