Java Code Examples for android.util.SparseArray#clone()
The following examples show how to use
android.util.SparseArray#clone() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProtectedPackages.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Sets the device/profile owner information. */ public synchronized void setDeviceAndProfileOwnerPackages( int deviceOwnerUserId, String deviceOwnerPackage, SparseArray<String> profileOwnerPackages) { mDeviceOwnerUserId = deviceOwnerUserId; mDeviceOwnerPackage = (deviceOwnerUserId == UserHandle.USER_NULL) ? null : deviceOwnerPackage; mProfileOwnerPackages = (profileOwnerPackages == null) ? null : profileOwnerPackages.clone(); }
Example 2
Source File: Manager.java From BlueSTSDK_Android with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * register a new device id or add feature to an already defined device * <p>the change will affect only the node discover after this call</p> * @param deviceId device type that will use the feature, it can be a new device id * @param features array of feature that we will add, the index of the feature will be used * as feature mask. the feature mask must have only one bit to 1 * @throws InvalidFeatureBitMaskException throw when a feature is a position that is not a * power of 2 */ public static void addFeatureToNode(byte deviceId,SparseArray<Class<? extends Feature>> features) throws InvalidFeatureBitMaskException { SparseArray<Class<? extends Feature>> updateMe; if(!sFeatureMapDecoder.containsKey(deviceId)){ updateMe = BLENodeDefines.FeatureCharacteristics.DEFAULT_MASK_TO_FEATURE.clone(); sFeatureMapDecoder.put(deviceId,updateMe); }else{ updateMe = sFeatureMapDecoder.get(deviceId); }//if-else SparseArray<Class<? extends Feature>> addMe = features.clone(); long mask=1; //we test all the 32bit of the feature mask for(int i=0; i<32; i++ ){ Class<? extends Feature> featureClass = addMe.get((int)mask); if (featureClass != null) { updateMe.append((int) mask, featureClass); addMe.remove((int)mask); } mask=mask<<1; }//for if(addMe.size()!=0) throw new InvalidFeatureBitMaskException("Not all elements have a single bit in " + "as key"); }
Example 3
Source File: DrawableContainerCompat.java From MaterialProgressBar with Apache License 2.0 | 4 votes |
DrawableContainerState(DrawableContainerState orig, DrawableContainerCompat owner, Resources res) { mOwner = owner; mSourceRes = res != null ? res : (orig != null ? orig.mSourceRes : null); mDensity = resolveDensity(res, orig != null ? orig.mDensity : 0); if (orig != null) { mChangingConfigurations = orig.mChangingConfigurations; mChildrenChangingConfigurations = orig.mChildrenChangingConfigurations; mCheckedConstantState = true; mCanConstantState = true; mVariablePadding = orig.mVariablePadding; mConstantSize = orig.mConstantSize; mDither = orig.mDither; mMutated = orig.mMutated; mLayoutDirection = orig.mLayoutDirection; mEnterFadeDuration = orig.mEnterFadeDuration; mExitFadeDuration = orig.mExitFadeDuration; mAutoMirrored = orig.mAutoMirrored; mColorFilter = orig.mColorFilter; mHasColorFilter = orig.mHasColorFilter; mTintList = orig.mTintList; mTintMode = orig.mTintMode; mHasTintList = orig.mHasTintList; mHasTintMode = orig.mHasTintMode; if (orig.mDensity == mDensity) { if (orig.mCheckedPadding) { mConstantPadding = new Rect(orig.mConstantPadding); mCheckedPadding = true; } if (orig.mCheckedConstantSize) { mConstantWidth = orig.mConstantWidth; mConstantHeight = orig.mConstantHeight; mConstantMinimumWidth = orig.mConstantMinimumWidth; mConstantMinimumHeight = orig.mConstantMinimumHeight; mCheckedConstantSize = true; } } if (orig.mCheckedOpacity) { mOpacity = orig.mOpacity; mCheckedOpacity = true; } if (orig.mCheckedStateful) { mStateful = orig.mStateful; mCheckedStateful = true; } // Postpone cloning children and futures until we're absolutely // sure that we're done computing values for the original state. final Drawable[] origDr = orig.mDrawables; mDrawables = new Drawable[origDr.length]; mNumChildren = orig.mNumChildren; final SparseArray<ConstantState> origDf = orig.mDrawableFutures; if (origDf != null) { mDrawableFutures = origDf.clone(); } else { mDrawableFutures = new SparseArray<>(mNumChildren); } // Create futures for drawables with constant states. If a // drawable doesn't have a constant state, then we can't clone // it and we'll have to reference the original. final int count = mNumChildren; for (int i = 0; i < count; i++) { if (origDr[i] != null) { final ConstantState cs = origDr[i].getConstantState(); if (cs != null) { mDrawableFutures.put(i, cs); } else { mDrawables[i] = origDr[i]; } } } } else { mDrawables = new Drawable[10]; mNumChildren = 0; } }