@Override
public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) {
if (buttonView == loopCheckBox) {
ultraviewPager.setInfiniteLoop(isChecked);
}
if (buttonView == autoScrollCheckBox) {
if (isChecked) {
SparseIntArray special = new SparseIntArray();
special.put(0,5000);
special.put(1,1500);
ultraviewPager.setAutoScroll(2000,special);
}
else
ultraviewPager.disableAutoScroll();
}
}
项目:GitHub
文件:FastAdapter.java
/**
* returns the expanded items this contains position and the count of items
* which are expanded by this position
*
* @return the expanded items
*/
public SparseIntArray getExpanded() {
if (mPositionBasedStateManagement) {
return mExpanded;
} else {
SparseIntArray expandedItems = new SparseIntArray();
Item item;
for (int i = 0,size = getItemCount(); i < size; i++) {
item = getItem(i);
if (item instanceof IExpandable && ((IExpandable) item).isExpanded()) {
expandedItems.put(i,((IExpandable) item).getSubItems().size());
}
}
return expandedItems;
}
}
项目:SubwayTooter
文件:ExifInterface.java
protected int getTagDeFinitionForTag( short tagId,short type,int count,int ifd ) {
int[] defs = getTagDeFinitionsForTagId( tagId );
if( defs == null ) {
return TAG_NULL;
}
SparseIntArray infos = getTagInfo();
int ret = TAG_NULL;
for( int i : defs ) {
int info = infos.get( i );
short def_type = getTypeFromInfo( info );
int def_count = getComponentCountFromInfo( info );
int[] def_ifds = getAllowedIfdsFromInfo( info );
boolean valid_ifd = false;
for( int j : def_ifds ) {
if( j == ifd ) {
valid_ifd = true;
break;
}
}
if( valid_ifd && type == def_type && ( count == def_count || def_count == ExifTag.SIZE_UNDEFINED ) ) {
ret = i;
break;
}
}
return ret;
}
项目:xbot_head
文件:SignInFragment.java
@Override
public void onStart() {
super.onStart();
initView();
mFaces = new FaceResult[MAX_FACE_COUNT];
mPrevIoUsFaces = new FaceResult[MAX_FACE_COUNT];
mDetectedFaces = new FaceDetector.Face[MAX_FACE_COUNT];
for (int i = 0; i < MAX_FACE_COUNT; i++) {
mFaces[i] = new FaceResult();
mPrevIoUsFaces[i] = new FaceResult();
}
mFacesCountMap = new SparseIntArray();
presenter = new SignInPresenter(this,getContext());
presenter.start();
}
/**
* Set up pool params
* @param maxSizeSoftCap soft cap on max size of the pool
* @param maxSizeHardCap hard cap on max size of the pool
* @param bucketSizes (optional) bucket sizes and lengths for the pool
* @param minBucketSize min bucket size for the pool
* @param maxBucketSize max bucket size for the pool
* @param maxnumThreads the maximum number of threads in th epool,or -1 if the pool doesn't care
*/
public PoolParams(
int maxSizeSoftCap,int maxSizeHardCap,@Nullable SparseIntArray bucketSizes,int minBucketSize,int maxBucketSize,int maxnumThreads) {
Preconditions.checkState(maxSizeSoftCap >= 0 && maxSizeHardCap >= maxSizeSoftCap);
this.maxSizeSoftCap = maxSizeSoftCap;
this.maxSizeHardCap = maxSizeHardCap;
this.bucketSizes = bucketSizes;
this.minBucketSize = minBucketSize;
this.maxBucketSize = maxBucketSize;
this.maxnumThreads = maxnumThreads;
}
public static PoolParams get() {
SparseIntArray DEFAULT_BUCKETS = new SparseIntArray();
DEFAULT_BUCKETS.put(1 * ByteConstants.KB,SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(2 * ByteConstants.KB,SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(4 * ByteConstants.KB,SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(8 * ByteConstants.KB,SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(16 * ByteConstants.KB,SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(32 * ByteConstants.KB,SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(64 * ByteConstants.KB,SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(128 * ByteConstants.KB,SMALL_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(256 * ByteConstants.KB,LARGE_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(512 * ByteConstants.KB,LARGE_BUCKET_LENGTH);
DEFAULT_BUCKETS.put(1024 * ByteConstants.KB,LARGE_BUCKET_LENGTH);
return new PoolParams(
getMaxSizeSoftCap(),getMaxSizeHardCap(),DEFAULT_BUCKETS);
}
项目:GitHub
文件:BasePool.java
/**
* Creates a new instance of the pool.
* @param poolParams pool parameters
* @param poolStatsTracker
*/
public BasePool(
MemoryTrimmableRegistry memoryTrimmableRegistry,PoolParams poolParams,PoolStatsTracker poolStatsTracker) {
mMemoryTrimmableRegistry = Preconditions.checkNotNull(memoryTrimmableRegistry);
mPoolParams = Preconditions.checkNotNull(poolParams);
mPoolStatsTracker = Preconditions.checkNotNull(poolStatsTracker);
// initialize the buckets
mBuckets = new SparseArray<Bucket<V>>();
initBuckets(new SparseIntArray(0));
mInUseValues = Sets.newIdentityHashSet();
mFree = new Counter();
mUsed = new Counter();
}
项目:GitHub
文件:BasePool.java
/**
* Initialize the list of buckets. Get the bucket sizes (and bucket lengths) from the bucket
* sizes provider
* @param inUseCounts map of current buckets and their in use counts
*/
private synchronized void initBuckets(SparseIntArray inUseCounts) {
Preconditions.checkNotNull(inUseCounts);
// clear out all the buckets
mBuckets.clear();
// create the new buckets
final SparseIntArray bucketSizes = mPoolParams.bucketSizes;
if (bucketSizes != null) {
for (int i = 0; i < bucketSizes.size(); ++i) {
final int bucketSize = bucketSizes.keyAt(i);
final int maxLength = bucketSizes.valueAt(i);
int bucketInUseCount = inUseCounts.get(bucketSize,0);
mBuckets.put(
bucketSize,new Bucket<V>(
getSizeInBytes(bucketSize),maxLength,bucketInUseCount));
}
mAllowNewBuckets = false;
} else {
mAllowNewBuckets = true;
}
}
public void setSpecialInterval(JSONObject jsonObject) {
if (jsonObject != null) {
this.mSpecialInterval = new SparseIntArray();
Iterator<String> itr = jsonObject.keys();
while (itr.hasNext()) {
String key = itr.next();
try {
int index = Integer.parseInt(key);
int value = jsonObject.optInt(key);
if (value > 0) {
this.mSpecialInterval.put(index,value);
}
} catch (NumberFormatException e) {
}
}
}
}
项目:GitHub
文件:FlexByteArrayPoolTest.java
@Before
public void setup() {
SparseIntArray buckets = new SparseIntArray();
for (int i = MIN_BUFFER_SIZE; i <= MAX_BUFFER_SIZE; i*=2) {
buckets.put(i,3);
}
mPool = new FlexByteArrayPool(
mock(MemoryTrimmableRegistry.class),new PoolParams(
Integer.MAX_VALUE,Integer.MAX_VALUE,buckets,MIN_BUFFER_SIZE,MAX_BUFFER_SIZE,1));
mDelegatePool = mPool.mDelegatePool;
}
项目:RNLearn_Project1
文件:FlatUIViewOperationQueue.java
private UpdateClippingMountState(
int reactTag,@Nullable DrawCommand[] drawCommands,SparseIntArray drawViewIndexMap,float[] commandMaxBot,float[] commandMinTop,@Nullable AttachDetachListener[] listeners,@Nullable NodeRegion[] nodeRegions,float[] regionMaxBot,float[] regionMinTop,boolean willMountViews) {
mReactTag = reactTag;
mDrawCommands = drawCommands;
mDrawViewIndexMap = drawViewIndexMap;
mCommandMaxBot = commandMaxBot;
mCommandMinTop = commandMinTop;
mAttachDetachListeners = listeners;
mNodeRegions = nodeRegions;
mRegionMaxBot = regionMaxBot;
mRegionMinTop = regionMinTop;
mWillMountViews = willMountViews;
}
项目:SkinFramework
文件:SkinResource.java
/**
* Build inflate rules.
*
* @param v
* @param array ID map of which Key as skin id and value as mapped id.
*/
protected void buildInflateRules(View v,SparseIntArray array) {
ViewGroup.LayoutParams lp = v.getLayoutParams();
if (lp == null) {
return;
}
if (lp instanceof RelativeLayout.LayoutParams) {
int[] rules = ((RelativeLayout.LayoutParams) lp).getRules();
if (rules == null) {
return;
}
int size = rules.length;
int mapRule = -1;
for (int i = 0; i < size; i++) {
//Key as skin id and value as mapped id.
if (rules[i] > 0 && (mapRule = array.get(rules[i])) > 0) {
// Log.i(TAG,"Rules[" + i + "]: Mapped from: " + rules[i] + " to " +mapRule);
rules[i] = mapRule;
}
}
}
}
项目:SocEltech
文件:TestViewActivity.java
private int getMaxAnswersId() {
int max = 0;
int id = 0;
SparseIntArray answers = new SparseIntArray();
for (QA qa : socTest.getQa()) {
int answer = qa.getAnswer();
answers.put(answer,answers.get(answer,0) + 1);
}
for (int i = 0; i < answers.size(); i++) {
if (max < answers.valueAt(i)) {
max = answers.valueAt(i);
id = answers.keyAt(i);
}
}
return id;
}
/**
* @param mode Mode for the extractor. One of {@link #MODE_MULTI_PMT},{@link #MODE_SINGLE_PMT}
* and {@link #MODE_HLS}.
* @param timestampAdjuster A timestamp adjuster for offsetting and scaling sample timestamps.
* @param payloadReaderFactory Factory for injecting a custom set of payload readers.
*/
public TsExtractor(@Mode int mode,TimestampAdjuster timestampAdjuster,TsPayloadReader.Factory payloadReaderFactory) {
this.payloadReaderFactory = Assertions.checkNotNull(payloadReaderFactory);
this.mode = mode;
if (mode == MODE_SINGLE_PMT || mode == MODE_HLS) {
timestampAdjusters = Collections.singletonList(timestampAdjuster);
} else {
timestampAdjusters = new ArrayList<>();
timestampAdjusters.add(timestampAdjuster);
}
tsPacketBuffer = new ParsableByteArray(BUFFER_SIZE);
tsScratch = new ParsableBitArray(new byte[3]);
trackIds = new SparseBooleanArray();
tsPayloadReaders = new SparseArray<>();
continuityCounters = new SparseIntArray();
resetPayloadReaders();
}
项目:FanChat
文件:EaseContactAdapter.java
@Override
public Object[] getSections() {
positionOfSection = new SparseIntArray();
sectionOfPosition = new SparseIntArray();
int count = getCount();
list = new ArrayList<String>();
list.add(getContext().getString(R.string.search_header));
positionOfSection.put(0,0);
sectionOfPosition.put(0,0);
for (int i = 1; i < count; i++) {
String letter = getItem(i).getinitialLetter();
int section = list.size() - 1;
if (list.get(section) != null && !list.get(section).equals(letter)) {
list.add(letter);
section++;
positionOfSection.put(section,i);
}
sectionOfPosition.put(i,section);
}
return list.toArray(new String[list.size()]);
}
项目:KTalk
文件:EaseContactAdapter.java
@Override
public Object[] getSections() {
positionOfSection = new SparseIntArray();
sectionOfPosition = new SparseIntArray();
int count = getCount();
list = new ArrayList<String>();
list.add(getContext().getString(R.string.search_header));
positionOfSection.put(0,section);
}
return list.toArray(new String[list.size()]);
}
项目:Tribe
文件:EaseContactAdapter.java
@Override
public Object[] getSections() {
positionOfSection = new SparseIntArray();
sectionOfPosition = new SparseIntArray();
int count = getCount();
list = new ArrayList<String>();
list.add(getContext().getString(R.string.search_header));
positionOfSection.put(0,section);
}
return list.toArray(new String[list.size()]);
}
项目:ChatExchange-old
文件:ChatDataBundle.java
public void resetArrays(boolean shouldEmptyIDs,SharedPreferences.Editor mEditor)
{
if (shouldEmptyIDs)
{
mSEChatIDs = new HashSet<>(0);
mSOChatIDs = new HashSet<>(0);
setSOStringSet(mEditor);
setSEStringSet(mEditor);
}
mSEChatUrls = new SparseArray<>();
mSOChatUrls = new SparseArray<>();
mSEChats = new SparseArray<>();
mSOChats = new SparseArray<>();
mSEChatNames = new SparseArray<>();
mSOChatNames = new SparseArray<>();
mSEChatIcons = new SparseArray<>();
mSOChatIcons = new SparseArray<>();
mSEChatColors = new SparseIntArray();
mSOChatColors = new SparseIntArray();
}
项目:MyAnimeViewer
文件:ParseAnimeService.java
@Override
public void onCreate() {
// Start up the thread running the service. Note that we create a
// separate thread because the service normally runs in the process's
// main thread,which we don't want to block. We also make it
// background priority so cpu-intensive work will not disrupt our UI.
//HandlerThread thread = new HandlerThread("ServiceStartArguments",Process.THREAD_PRIORITY_BACKGROUND);
//thread.start();
mnotificationmanager = (notificationmanager) getSystemService(NOTIFICATION_SERVICE);
mNotificationMap = new SparseIntArray();
// Get the HandlerThread's Looper and use it for our Handler
//mServiceLooper = thread.getLooper();
mServiceLooper = Looper.getMainLooper();
//mServiceHandler = new ServiceHandler(mServiceLooper);
mServiceHandler = new ServiceHandler(mServiceLooper,this);
}
项目:SubwayTooter
文件:ExifInterface.java
protected int[] getTagDeFinitionsForTagId( short tagId ) {
int[] ifds = IfdData.getIfds();
int[] defs = new int[ifds.length];
int counter = 0;
SparseIntArray infos = getTagInfo();
for( int i : ifds ) {
int def = defineTag( i,tagId );
if( infos.get( def ) != DEFinitioN_NULL ) {
defs[counter++] = def;
}
}
if( counter == 0 ) {
return null;
}
return Arrays.copyOfRange( defs,counter );
}
项目:GCSApp
文件:EaseContactAdapter.java
@Override
public Object[] getSections() {
positionOfSection = new SparseIntArray();
sectionOfPosition = new SparseIntArray();
int count = getCount();
list = new ArrayList<String>();
list.add(getContext().getString(R.string.search_header));
positionOfSection.put(0,section);
}
return list.toArray(new String[list.size()]);
}
项目:RNLearn_Project1
文件:FlatUIViewOperationQueue.java
/**
* Enqueues a new UIOperation that will update DrawCommands for a View defined by reactTag.
*/
public void enqueueUpdateClippingMountState(
int reactTag,boolean willMountViews) {
enqueueUIOperation(new UpdateClippingMountState(
reactTag,drawCommands,drawViewIndexMap,commandMaxBot,commandMinTop,listeners,nodeRegions,regionMaxBot,regionMinTop,willMountViews));
}
项目:GitHub
文件:AdapterUtil.java
/**
* internal method to handle the selections if items are added / removed
*
* @param positions the positions map which should be adjusted
* @param startPosition the global index of the first element modified
* @param endPosition the global index up to which the modification changed the indices (should be MAX_INT if we check til the end)
* @param adjustBy the value by which the data was shifted
* @return the adjusted map
*/
public static SparseIntArray adjustPosition(SparseIntArray positions,int startPosition,int endPosition,int adjustBy) {
SparseIntArray newPositions = new SparseIntArray();
for (int i = 0,size = positions.size(); i < size; i++) {
int position = positions.keyAt(i);
//if our current position is not within the bounds to check for we can add it
if (position < startPosition || position > endPosition) {
newPositions.put(position,positions.valueAt(i));
} else if (adjustBy > 0) {
//if we added items and we are within the bounds we can simply add the adjustBy to our entry
newPositions.put(position + adjustBy,positions.valueAt(i));
} else if (adjustBy < 0) {
//if we removed items and we are within the bounds we have to check if the item was removed
//adjustBy is negative in this case
if (position > startPosition + adjustBy && position <= startPosition) {
;//we are within the removed items range we don't add this item anymore
} else {
//otherwise we adjust our position
newPositions.put(position + adjustBy,positions.valueAt(i));
}
}
}
return newPositions;
}
/**
* Get default {@link PoolParams}.
*/
public static PoolParams get() {
// This pool supports only one bucket size: DEFAULT_IO_BUFFER_SIZE
SparseIntArray defaultBuckets = new SparseIntArray();
defaultBuckets.put(DEFAULT_IO_BUFFER_SIZE,DEFAULT_BUCKET_SIZE);
return new PoolParams(
MAX_SIZE_SOFT_CAP,MAX_SIZE_HARD_CAP,defaultBuckets);
}
项目:TrendChartView
文件:TrendChartView.java
public void fillData(List<ITrendData> dataList,List<String> dayListInfo,int dayCount) {
mListSize = dataList.size();
mControlPoints = new ArrayList<>(mListSize);
mChartTrendWidthAbs = mListSize * getItemWidthWithSpace();
mDataList = dataList;
mDayCount = dayCount;
mDayRecord = new SparseIntArray(mDayCount);
mDayListInfo = dayListInfo;
mCurrentTimePosition = getCurrentTimePosition(mDayListInfo);
for (ITrendData data : dataList) {
if (data.value() >= 300) {
mBigModeChart = true;
break;
}
}
if (mBigModeChart) {
mMaxAqiValue = 500f;
} else {
mMaxAqiValue = 300f;
}
mAverageDayWidth = mChartTrendWidthAbs / mDayCount;
//初始化当前 item
mCurrentIndex = 0;
mCurrentData = mDataList.get(mCurrentIndex);
//计算柱状图的点集合
calculateCurveDot();
//计算背景虚线的 path
calculatedLinePath();
//计算日期的位置坐标集合
calculateBottomTextPoint();
//发起重绘请求
requestLayout();
}
项目:RNLearn_Project1
文件:FlatNativeViewHierarchyManager.java
/**
* Updates DrawCommands and AttachDetachListeners of a clipping FlatViewGroup specified by a
* reactTag.
*
* @param reactTag The react tag to lookup FlatViewGroup by.
* @param drawCommands If non-null,new draw commands to execute during the drawing.
* @param drawViewIndexMap Mapping of react tags to the index of the corresponding DrawView
* command in the draw command array.
* @param commandMaxBot At each index i,the maximum bottom value (or right value in the case of
* horizontal clipping) value of all draw commands at or below i.
* @param commandMinTop At each index i,the minimum top value (or left value in the case of
* horizontal clipping) value of all draw commands at or below i.
* @param listeners If non-null,new attach-detach listeners.
* @param nodeRegions Node regions to mount.
* @param regionMaxBot At each index i,the maximum bottom value (or right value in the case of
* horizontal clipping) value of all node regions at or below i.
* @param regionMinTop At each index i,the minimum top value (or left value in the case of
* horizontal clipping) value of all draw commands at or below i.
* @param willMountViews Whether we are going to also send a mountViews command in this state
* cycle.
*/
/* package */ void updateClippingMountState(
int reactTag,boolean willMountViews) {
FlatViewGroup view = (FlatViewGroup) resolveView(reactTag);
if (drawCommands != null) {
view.mountClippingDrawCommands(
drawCommands,willMountViews);
}
if (listeners != null) {
view.mountAttachDetachListeners(listeners);
}
if (nodeRegions != null) {
view.mountClippingNodeRegions(nodeRegions,regionMinTop);
}
}
项目:GitHub
文件:NativeMemoryChunkPool.java
/**
* Creates a new instance of the NativeMemoryChunkPool class
* @param memoryTrimmableRegistry the memory manager to register with
* @param poolParams provider for pool parameters
* @param nativeMemoryChunkPoolStatsTracker
*/
public NativeMemoryChunkPool(
MemoryTrimmableRegistry memoryTrimmableRegistry,PoolStatsTracker nativeMemoryChunkPoolStatsTracker) {
super(memoryTrimmableRegistry,poolParams,nativeMemoryChunkPoolStatsTracker);
SparseIntArray bucketSizes = poolParams.bucketSizes;
mBucketSizes = new int[bucketSizes.size()];
for (int i = 0; i < mBucketSizes.length; ++i) {
mBucketSizes[i] = bucketSizes.keyAt(i);
}
initialize();
}
public static SparseIntArray generateBuckets(int min,int max,int numThreads) {
SparseIntArray buckets = new SparseIntArray();
for (int i = min; i <= max; i*=2) {
buckets.put(i,numThreads);
}
return buckets;
}
项目:GitHub
文件:BasePoolTest.java
项目:GitHub
文件:NativeMemoryChunkPoolTest.java
@Before
public void setup() {
final SparseIntArray bucketSizes = new SparseIntArray();
bucketSizes.put(32,2);
bucketSizes.put(64,1);
bucketSizes.put(128,1);
mPool = new FakeNativeMemoryChunkPool(
new PoolParams(128,bucketSizes));
}
项目:GitHub
文件:FakeNativeMemoryChunkPool.java
private static SparseIntArray getBucketSizes() {
final SparseIntArray bucketSizes = new SparseIntArray();
bucketSizes.put(4,10);
bucketSizes.put(8,10);
bucketSizes.put(16,10);
bucketSizes.put(32,10);
return bucketSizes;
}
项目:weex-uikit
文件:BorderUtil.java
static void updateSparseArray(@NonNull SparseIntArray array,int position,int value) {
if (position == Spacing.ALL) {
array.put(Spacing.ALL,value);
array.put(Spacing.TOP,value);
array.put(Spacing.LEFT,value);
array.put(Spacing.RIGHT,value);
array.put(Spacing.BottOM,value);
} else {
array.put(position,value);
}
}
项目:SkinFramework
文件:SkinResource.java
/**
* Handle view to support used by app.
*
* @param v View resource from skin package.
*/
public void handleView(Context context,View v) {
resetID();
//Id map: Key as skin id and Value as local id.
SparseIntArray array = new SparseIntArray();
buildIdRules(context,v,array);
int size = array.size();
// Map ids to which app can recognize locally.
for (int i = 0; i < size; i++) {
//Map id defined in skin package into real id in app.
v.findViewById(array.keyAt(i)).setId(array.valueAt(i));
}
}
项目:SampleAppArch
文件:RepoDao.java
public LiveData<List<Repo>> loadOrdered(List<Integer> repoIds) {
SparseIntArray order = new SparseIntArray();
int index = 0;
for (Integer repoId : repoIds) {
order.put(repoId,index++);
}
return Transformations.map(loadById(repoIds),repositories -> {
Collections.sort(repositories,(r1,r2) -> {
int pos1 = order.get(r1.id);
int pos2 = order.get(r2.id);
return pos1 - pos2;
});
return repositories;
});
}
项目:Android-UtilCode
文件:EmptyUtils.java
/**
* 判断对象是否为空
*
* @param obj 对象
* @return {@code true}: 为空<br>{@code false}: 不为空
*/
public static boolean isEmpty(Object obj) {
if (obj == null) {
return true;
}
if (obj instanceof String && obj.toString().length() == 0) {
return true;
}
if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
return true;
}
if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
return true;
}
if (obj instanceof Map && ((Map) obj).isEmpty()) {
return true;
}
if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
return true;
}
if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
return true;
}
if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
return true;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
return true;
}
}
return false;
}
项目:Android-UtilCode
文件:EmptyUtilsTest.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
@Test
public void isEmpty() throws Exception {
String string = "";
String string1 = " ";
int[][] arr = new int[][]{};
int[] arr1 = null;
LinkedList<Integer> list = new LinkedList<>();
HashMap<String,Integer> map = new HashMap<>();
SparseArray<String> sa = new SparseArray<>();
SparseBooleanArray sba = new SparseBooleanArray();
SparseIntArray sia = new SparseIntArray();
SparseLongArray sla = new SparseLongArray();
assertthat(EmptyUtils.isEmpty(string)).isTrue();
assertthat(EmptyUtils.isEmpty(string1)).isFalse();
assertthat(EmptyUtils.isEmpty(arr)).isTrue();
assertthat(EmptyUtils.isEmpty(arr1)).isTrue();
assertthat(EmptyUtils.isEmpty(list)).isTrue();
assertthat(EmptyUtils.isEmpty(map)).isTrue();
assertthat(EmptyUtils.isEmpty(sa)).isTrue();
assertthat(EmptyUtils.isEmpty(sba)).isTrue();
assertthat(EmptyUtils.isEmpty(sia)).isTrue();
assertthat(EmptyUtils.isEmpty(sla)).isTrue();
assertthat(!EmptyUtils.isNotEmpty(string)).isTrue();
assertthat(!EmptyUtils.isNotEmpty(string1)).isFalse();
assertthat(!EmptyUtils.isNotEmpty(arr)).isTrue();
assertthat(!EmptyUtils.isNotEmpty(arr1)).isTrue();
assertthat(!EmptyUtils.isNotEmpty(list)).isTrue();
assertthat(!EmptyUtils.isNotEmpty(map)).isTrue();
assertthat(!EmptyUtils.isNotEmpty(sa)).isTrue();
assertthat(!EmptyUtils.isNotEmpty(sba)).isTrue();
assertthat(!EmptyUtils.isNotEmpty(sia)).isTrue();
assertthat(!EmptyUtils.isNotEmpty(sla)).isTrue();
}
项目:RLibrary
文件:EmptyUtils.java
/**
* 判断对象是否为空
*
* @param obj 对象
* @return {@code true}: 为空<br>{@code false}: 不为空
*/
public static boolean isEmpty(Object obj) {
if (obj == null) {
return true;
}
if (obj instanceof String && obj.toString().length() == 0) {
return true;
}
if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
return true;
}
if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
return true;
}
if (obj instanceof Map && ((Map) obj).isEmpty()) {
return true;
}
if (obj instanceof SparseArray && ((SparseArray) obj).size() == 0) {
return true;
}
if (obj instanceof SparseBooleanArray && ((SparseBooleanArray) obj).size() == 0) {
return true;
}
if (obj instanceof SparseIntArray && ((SparseIntArray) obj).size() == 0) {
return true;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
if (obj instanceof SparseLongArray && ((SparseLongArray) obj).size() == 0) {
return true;
}
}
return false;
}
项目:RNLearn_Project1
文件:HorizontalDrawCommandManager.java
/**
* Populates the max and min arrays for a given set of draw commands. Also populates a mapping of
* react tags to their index position in the command array.
*
* This should never be called from the UI thread,as the reason it exists is to do work off the
* UI thread.
*
* @param commands The draw commands that will eventually be mounted.
* @param maxRight At each index i,the maximum right value of all draw commands at or below i.
* @param minLeft At each index i,the minimum left value of all draw commands at or below i.
* @param drawViewIndexMap Mapping of ids to index position within the draw command array.
*/
public static void fillMaxMinArrays(
DrawCommand[] commands,float[] maxRight,float[] minLeft,SparseIntArray drawViewIndexMap) {
float last = 0;
// Loop through the DrawCommands,keeping track of the maximum we've seen if we only iterated
// through items up to this position.
for (int i = 0; i < commands.length; i++) {
if (commands[i] instanceof DrawView) {
DrawView drawView = (DrawView) commands[i];
// These will generally be roughly sorted by id,so try to insert at the end if possible.
drawViewIndexMap.append(drawView.reactTag,i);
last = Math.max(last,drawView.mLogicalRight);
} else {
last = Math.max(last,commands[i].getRight());
}
maxRight[i] = last;
}
// Intentionally leave last as it was,since it's at the maximum bottom position we've seen so
// far,we can use it again.
// Loop through backwards,keeping track of the minimum we've seen at this position.
for (int i = commands.length - 1; i >= 0; i--) {
if (commands[i] instanceof DrawView) {
last = Math.min(last,((DrawView) commands[i]).mLogicalLeft);
} else {
last = Math.min(last,commands[i].getLeft());
}
minLeft[i] = last;
}
}
项目:RNLearn_Project1
文件:VerticalDrawCommandManager.java
/**
* Populates the max and min arrays for a given set of draw commands. Also populates a mapping of
* react tags to their index position in the command array.
*
* This should never be called from the UI thread,as the reason it exists is to do work off the
* UI thread.
*
* @param commands The draw commands that will eventually be mounted.
* @param maxBottom At each index i,the maximum bottom value of all draw commands at or below i.
* @param minTop At each index i,the minimum top value of all draw commands at or below i.
* @param drawViewIndexMap Mapping of ids to index position within the draw command array.
*/
public static void fillMaxMinArrays(
DrawCommand[] commands,float[] maxBottom,float[] minTop,drawView.mLogicalBottom);
} else {
last = Math.max(last,commands[i].getBottom());
}
maxBottom[i] = last;
}
// Intentionally leave last as it was,((DrawView) commands[i]).mLogicalTop);
} else {
last = Math.min(last,commands[i].getTop());
}
minTop[i] = last;
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。