Android SparseIntArray - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SparseIntArray class.

This code example shows how to use the following methods: indexOfValue, keyAt
    public int getListPosition(int cursorPosition) {
        if (mRemovedCursorPositions.contains(cursorPosition)) {
            return REMOVED;
        } 
 
        int index = mListMapping.indexOfValue(cursorPosition);
        if (index < 0) {
            return cursorPosition;
        } else { 
            return mListMapping.keyAt(index);
        } 
    } 
 
 
} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: indexOfKey, put
        } 
 
        public boolean onKeyUp(KeyEvent event) {
            final int keyCode = event.getKeyCode();
            if (isGameKey(keyCode)) {
                int index = mKeys.indexOfKey(keyCode);
                if (index >= 0) {
                    final String symbolicName = KeyEvent.keyCodeToString(keyCode);
                    mKeys.put(keyCode, 0);
                    Log.i(TAG, mDevice.getName() + " - Key Up: " + symbolicName);
                } 
                return true; 
            } 
            return false; 
        } 
 
        public boolean onJoystickMotion(MotionEvent event) {
            StringBuilder message = new StringBuilder();
            message.append(mDevice.getName()).append(" - Joystick Motion:\n");
 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: indexOfValue, keyAt
    public int getListPosition(int cursorPosition) {
        if (mRemovedCursorPositions.contains(cursorPosition)) {
            return REMOVED;
        } 
 
        int index = mListMapping.indexOfValue(cursorPosition);
        if (index < 0) {
            return cursorPosition;
        } else { 
            return mListMapping.keyAt(index);
        } 
    } 
 
} 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: append
 
    /** 
     */ 
    @Override 
    protected void onPrepareAttributes(SparseIntArray attributes) {
        super.onPrepareAttributes(attributes);
 
        // Add all attributes which should be parsed for view group widget. 
        attributes.append(android.R.attr.padding, android.R.attr.padding);
        attributes.append(android.R.attr.paddingLeft, android.R.attr.paddingLeft);
        attributes.append(android.R.attr.paddingTop, android.R.attr.paddingTop);
        attributes.append(android.R.attr.paddingRight, android.R.attr.paddingRight);
        attributes.append(android.R.attr.paddingBottom, android.R.attr.paddingBottom);
    } 
 
    /** 
     */ 
    @Override 
    protected void onParseStyleElement(int attr, int index, TypedArray typedArray) {
        switch (attr) {
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: get, indexOfKey, indexOfValue, keyAt, valueAt
    } 
 
    @Override 
    public int getPositionForSection(int section){
        LogUtils.d("section: " + section);
        LogUtils.v("mIndexer.get(section): " + mIndexer.get(section));
        LogUtils.v("mIndexer.keyAt(section): " + mIndexer.keyAt(section));
        LogUtils.v("mIndexer.valueAt(section): " + mIndexer.valueAt(section));
        LogUtils.v("mIndexer.indexOfKey(section): " + mIndexer.indexOfKey(section));
        LogUtils.v("mIndexer.indexOfValue(section): " + mIndexer.indexOfValue(section));
        // keyAt は スクロールバーのつまみが一致するがスクロールすると突き抜けていく 
        int position = mIndexer.keyAt(section);
        LogUtils.e("position: " + position);
        return position;
    } 
 
    @Override 
    public int getSectionForPosition(int position){
        LogUtils.i("position: " + position);
        LogUtils.w("mIndexer.get(position): " + mIndexer.get(position));
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: get
            return this.moveToPosition(this.mCount-1);
        } 
         
        @Override 
        public boolean moveToPosition(int position) {
            return super.moveToPosition(mPositions.get(position));
        } 
 
         
    } 
 
    @Override 
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
 
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        Cursor cursor = mGridAdapter.getCursor();
        if (cursor == null)
            return; 
        cursor.moveToPosition(info.position);
        String mediaId = cursor.getString(cursor.getColumnIndex("mediaId"));
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: get, indexOfKey
                ta.getResourceId(R.styleable.AppTheme_appBackgroundColorPrimary, R.color.darkGray));
        ta.recycle();
    } 
 
    public int getThemedResourceId(int stylableId, int defaultResourceId) {
        if (mThemedAssets.indexOfKey(stylableId) < 0)
            return defaultResourceId;
        return mThemedAssets.get(stylableId);
    } 
 
    public Context getContext() {
        return this;
    } 
 
    public synchronized ActionMode getActionMode() {
        return mActionMode;
    } 
 
    public synchronized void setActionMode(ActionMode mode) {
        mActionMode = mode;
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: append
 
    /** 
     */ 
    @Override 
    protected void onPrepareAttributes(SparseIntArray attributes) {
        super.onPrepareAttributes(attributes);
 
        // Add all attributes which should be parsed for list view widget. 
        attributes.append(android.R.attr.dividerHeight, android.R.attr.dividerHeight);
        attributes.append(android.R.attr.divider, android.R.attr.divider);
        attributes.append(android.R.attr.cacheColorHint, android.R.attr.cacheColorHint);
    } 
 
    /** 
     */ 
    @Override 
    protected void onParseStyleElement(int attr, int index, TypedArray typedArray) {
        switch (attr) {
            case android.R.attr.dividerHeight:
                this.mDividerHeight = typedArray.getDimensionPixelSize(index, mDividerHeight);
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: get
				DEFAULT_CODE, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
 
		Notification notification = new NotificationCompat.Builder(mContext)
				.setContentTitle(params.getTitle())
				.setContentText(params.getText())
				.setSmallIcon(ICON_MAP.get(params.getIcon().hashCode()))
				.setContentIntent(pendingIntent).getNotification();
 
		int id = new Random().nextInt();
		mNotificationManager.notify(id, notification);
		callback.succeed(mBridge, new NotificationResult(id + ""));
	} 
 
	@Bridge("system.notification.clear") 
	public void clear(NotificationClearParams params) {
		mNotificationManager.cancel(Integer.parseInt(params.getId()));
	} 
 
	@Override 
	public void onResume() { 
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
     */ 
    public static void initialize(Context context) {
        //Log.e("Orbotix", "initialized"); 
        sInstance.mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
        sInstance.mSoundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
        sInstance.mSoundMap = new SparseIntArray();
    } 
 
    /** 
     * Adds a sound to the sound manager for future playback. 
     * @param soundIdentifier the identifier for this sound to be used for future playback. This will be the id 
     * used to play the sound using {@link #playSound(int)}. 
     * @param resourceId the resource id of the sound file itself. (e.g. R.raw.swoosh_sound) 
     */ 
    public static void addSound(Context context, int soundIdentifier, int resourceId) {
        sInstance.mSoundMap.append(soundIdentifier, sInstance.mSoundPool.load(context, resourceId, 1));
    } 
 
    /** 
     * Adds a sound to the sound manager for future playback. 
Full Snippet Info
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android SparseIntArray Questions & Answers:

See Code Examples for Android SparseIntArray Methods: