Search in sources :

Example 11 with LongSparseArray

use of android.util.LongSparseArray in project android_frameworks_base by ResurrectionRemix.

the class KeySetUtils method getPubKey.

public static PublicKey getPubKey(KeySetManagerService ksms, long pkId) throws NoSuchFieldException, IllegalAccessException {
    Field pkField = ksms.getClass().getDeclaredField("mPublicKeys");
    pkField.setAccessible(true);
    LongSparseArray<KeySetManagerService.PublicKeyHandle> mPublicKeys = (LongSparseArray<KeySetManagerService.PublicKeyHandle>) pkField.get(ksms);
    KeySetManagerService.PublicKeyHandle pkh = mPublicKeys.get(pkId);
    if (pkh == null) {
        return null;
    } else {
        return pkh.getKey();
    }
}
Also used : Field(java.lang.reflect.Field) LongSparseArray(android.util.LongSparseArray)

Example 12 with LongSparseArray

use of android.util.LongSparseArray in project android_frameworks_base by ResurrectionRemix.

the class KeySetUtils method getPubKeyRefCount.

public static int getPubKeyRefCount(KeySetManagerService ksms, long pkId) throws NoSuchFieldException, IllegalAccessException {
    Field pkField = ksms.getClass().getDeclaredField("mPublicKeys");
    pkField.setAccessible(true);
    LongSparseArray<KeySetManagerService.PublicKeyHandle> mPublicKeys = (LongSparseArray<KeySetManagerService.PublicKeyHandle>) pkField.get(ksms);
    KeySetManagerService.PublicKeyHandle pkh = mPublicKeys.get(pkId);
    if (pkh == null) {
        return 0;
    } else {
        return pkh.getRefCountLPr();
    }
}
Also used : Field(java.lang.reflect.Field) LongSparseArray(android.util.LongSparseArray)

Example 13 with LongSparseArray

use of android.util.LongSparseArray in project react-native-android-video-editor by RZulfikri.

the class VideoTimeline method getBitmap.

private void getBitmap(final int width) {
    layoutWidth = width;
    BackgroundExecutor.execute(new BackgroundExecutor.Task("", 0L, "") {

        @Override
        public void execute() {
            try {
                LongSparseArray<Bitmap> thumbnailList = new LongSparseArray<>();
                MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
                mediaMetadataRetriever.setDataSource(mVideoUri);
                int videoWidth = Integer.parseInt(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH));
                int videoHeight = Integer.parseInt(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT));
                int rotation = Integer.parseInt(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION));
                Boolean isHorizontal = false;
                if (rotation == 90 || rotation == 360) {
                    isHorizontal = false;
                }
                if (rotation == 0 || rotation == 180) {
                    if (videoHeight > videoWidth) {
                        isHorizontal = false;
                    } else {
                        isHorizontal = true;
                    }
                }
                // Retrieve media data
                long videoLengthInMs = Integer.parseInt(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)) * 1000;
                mVideoLength = videoLengthInMs / 1000;
                // Set thumbnail properties (Thumbs are squares)
                final int thumbWidth = getThumbWidth(videoLengthInMs, width);
                final int thumbHeight = layoutHeight - 40;
                final long interval = getInterval(videoLengthInMs);
                final int count = getCount(videoLengthInMs);
                for (int i = 0; i < count; i++) {
                    Bitmap bitmap = mediaMetadataRetriever.getFrameAtTime(((i * interval) + (mStartVideo * 1000L)), MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
                    try {
                        if (isHorizontal) {
                            if (count > 10 && 1 == count - 1) {
                                int minuteDurationI = (int) mVideoLength / 60000;
                                float minuteDurationF = (float) mVideoLength / 60000.0f;
                                float imageWidthLeft = minuteDurationF - minuteDurationI;
                                int xOffset = (bitmap.getWidth() - bitmap.getHeight()) / 2;
                                bitmap = Bitmap.createBitmap(bitmap, xOffset, 0, bitmap.getHeight(), bitmap.getHeight());
                                bitmap = Bitmap.createScaledBitmap(bitmap, (int) (thumbWidth * imageWidthLeft), thumbHeight, false);
                            } else {
                                int xOffset = (bitmap.getWidth() - bitmap.getHeight()) / 2;
                                bitmap = Bitmap.createBitmap(bitmap, xOffset, 0, bitmap.getHeight(), bitmap.getHeight());
                                bitmap = Bitmap.createScaledBitmap(bitmap, thumbWidth, thumbHeight, false);
                            }
                        } else {
                            if (count > 10 && 1 == count - 1) {
                                int minuteDurationI = (int) mVideoLength / 60000;
                                float minuteDurationF = (float) mVideoLength / 60000.0f;
                                float imageWidthLeft = minuteDurationF - minuteDurationI;
                                int yOffset = (bitmap.getHeight() - bitmap.getWidth()) / 2;
                                bitmap = Bitmap.createBitmap(bitmap, 0, yOffset, bitmap.getWidth(), bitmap.getWidth());
                                bitmap = Bitmap.createScaledBitmap(bitmap, (int) (thumbWidth * imageWidthLeft), thumbHeight, false);
                            } else {
                                int yOffset = (bitmap.getHeight() - bitmap.getWidth()) / 2;
                                bitmap = Bitmap.createBitmap(bitmap, 0, yOffset, bitmap.getWidth(), bitmap.getWidth());
                                bitmap = Bitmap.createScaledBitmap(bitmap, thumbWidth, thumbHeight, false);
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    thumbnailList.put(i, bitmap);
                }
                mediaMetadataRetriever.release();
                returnBitmaps(thumbnailList);
            } catch (final Throwable e) {
                Thread.getDefaultUncaughtExceptionHandler().uncaughtException(Thread.currentThread(), e);
            }
        }
    });
}
Also used : LongSparseArray(android.util.LongSparseArray) Bitmap(android.graphics.Bitmap) MediaMetadataRetriever(android.media.MediaMetadataRetriever)

Example 14 with LongSparseArray

use of android.util.LongSparseArray in project android_frameworks_base by DirtyUnicorns.

the class AbsListView method onSaveInstanceState.

@Override
public Parcelable onSaveInstanceState() {
    /*
         * This doesn't really make sense as the place to dismiss the
         * popups, but there don't seem to be any other useful hooks
         * that happen early enough to keep from getting complaints
         * about having leaked the window.
         */
    dismissPopup();
    Parcelable superState = super.onSaveInstanceState();
    SavedState ss = new SavedState(superState);
    if (mPendingSync != null) {
        // Just keep what we last restored.
        ss.selectedId = mPendingSync.selectedId;
        ss.firstId = mPendingSync.firstId;
        ss.viewTop = mPendingSync.viewTop;
        ss.position = mPendingSync.position;
        ss.height = mPendingSync.height;
        ss.filter = mPendingSync.filter;
        ss.inActionMode = mPendingSync.inActionMode;
        ss.checkedItemCount = mPendingSync.checkedItemCount;
        ss.checkState = mPendingSync.checkState;
        ss.checkIdState = mPendingSync.checkIdState;
        return ss;
    }
    boolean haveChildren = getChildCount() > 0 && mItemCount > 0;
    long selectedId = getSelectedItemId();
    ss.selectedId = selectedId;
    ss.height = getHeight();
    if (selectedId >= 0) {
        // Remember the selection
        ss.viewTop = mSelectedTop;
        ss.position = getSelectedItemPosition();
        ss.firstId = INVALID_POSITION;
    } else {
        if (haveChildren && mFirstPosition > 0) {
            // Remember the position of the first child.
            // We only do this if we are not currently at the top of
            // the list, for two reasons:
            // (1) The list may be in the process of becoming empty, in
            // which case mItemCount may not be 0, but if we try to
            // ask for any information about position 0 we will crash.
            // (2) Being "at the top" seems like a special case, anyway,
            // and the user wouldn't expect to end up somewhere else when
            // they revisit the list even if its content has changed.
            View v = getChildAt(0);
            ss.viewTop = v.getTop();
            int firstPos = mFirstPosition;
            if (firstPos >= mItemCount) {
                firstPos = mItemCount - 1;
            }
            ss.position = firstPos;
            ss.firstId = mAdapter.getItemId(firstPos);
        } else {
            ss.viewTop = 0;
            ss.firstId = INVALID_POSITION;
            ss.position = 0;
        }
    }
    ss.filter = null;
    if (mFiltered) {
        final EditText textFilter = mTextFilter;
        if (textFilter != null) {
            Editable filterText = textFilter.getText();
            if (filterText != null) {
                ss.filter = filterText.toString();
            }
        }
    }
    ss.inActionMode = mChoiceMode == CHOICE_MODE_MULTIPLE_MODAL && mChoiceActionMode != null;
    if (mCheckStates != null) {
        ss.checkState = mCheckStates.clone();
    }
    if (mCheckedIdStates != null) {
        final LongSparseArray<Integer> idState = new LongSparseArray<Integer>();
        final int count = mCheckedIdStates.size();
        for (int i = 0; i < count; i++) {
            idState.put(mCheckedIdStates.keyAt(i), mCheckedIdStates.valueAt(i));
        }
        ss.checkIdState = idState;
    }
    ss.checkedItemCount = mCheckedItemCount;
    if (mRemoteAdapter != null) {
        mRemoteAdapter.saveRemoteViewsCache();
    }
    return ss;
}
Also used : LongSparseArray(android.util.LongSparseArray) Editable(android.text.Editable) Parcelable(android.os.Parcelable) View(android.view.View)

Example 15 with LongSparseArray

use of android.util.LongSparseArray in project android_frameworks_base by DirtyUnicorns.

the class KeySetUtils method getPubKey.

public static PublicKey getPubKey(KeySetManagerService ksms, long pkId) throws NoSuchFieldException, IllegalAccessException {
    Field pkField = ksms.getClass().getDeclaredField("mPublicKeys");
    pkField.setAccessible(true);
    LongSparseArray<KeySetManagerService.PublicKeyHandle> mPublicKeys = (LongSparseArray<KeySetManagerService.PublicKeyHandle>) pkField.get(ksms);
    KeySetManagerService.PublicKeyHandle pkh = mPublicKeys.get(pkId);
    if (pkh == null) {
        return null;
    } else {
        return pkh.getKey();
    }
}
Also used : Field(java.lang.reflect.Field) LongSparseArray(android.util.LongSparseArray)

Aggregations

LongSparseArray (android.util.LongSparseArray)33 Field (java.lang.reflect.Field)19 Parcelable (android.os.Parcelable)7 Editable (android.text.Editable)7 View (android.view.View)7 ArrayList (java.util.ArrayList)7 PendingHostUpdate (android.appwidget.PendingHostUpdate)5 ParceledListSlice (android.content.pm.ParceledListSlice)5 Point (android.graphics.Point)5 IAppWidgetHost (com.android.internal.appwidget.IAppWidgetHost)5 Resources (android.content.res.Resources)1 Bitmap (android.graphics.Bitmap)1 MediaMetadataRetriever (android.media.MediaMetadataRetriever)1 SparseArray (android.util.SparseArray)1 Method (java.lang.reflect.Method)1 TermModel (org.wordpress.android.fluxc.model.TermModel)1