android.support.v4.util.LongSparseArray Java Examples

The following examples show how to use android.support.v4.util.LongSparseArray. 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 Project: android-map-sdk   Author: navermaps   File: TileCoverHelperActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_map_fragment);

    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setDisplayShowHomeEnabled(true);
    }

    MapFragment mapFragment = (MapFragment)getSupportFragmentManager().findFragmentById(R.id.map_fragment);
    if (mapFragment == null) {
        mapFragment = MapFragment.newInstance();
        getSupportFragmentManager().beginTransaction().add(R.id.map_fragment, mapFragment).commit();
    }
    mapFragment.getMapAsync(this);

    overlays = new LongSparseArray<>();
}
 
Example #2
Source Project: atlas   Author: alibaba   File: LottieComposition.java    License: Apache License 2.0 6 votes vote down vote up
private static void parsePrecomps(
    @Nullable JSONArray assetsJson, LottieComposition composition) {
  if (assetsJson == null) {
    return;
  }
  int length = assetsJson.length();
  for (int i = 0; i < length; i++) {
    JSONObject assetJson = assetsJson.optJSONObject(i);
    JSONArray layersJson = assetJson.optJSONArray("layers");
    if (layersJson == null) {
      continue;
    }
    List<Layer> layers = new ArrayList<>(layersJson.length());
    LongSparseArray<Layer> layerMap = new LongSparseArray<>();
    for (int j = 0; j < layersJson.length(); j++) {
      Layer layer = Layer.Factory.newInstance(layersJson.optJSONObject(j), composition);
      layerMap.put(layer.getId(), layer);
      layers.add(layer);
    }
    String id = assetJson.optString("id");
    composition.precomps.put(id, layers);
  }
}
 
Example #3
Source Project: Android-skin-support   Author: ximsfei   File: SkinCompatDrawableManager.java    License: MIT License 6 votes vote down vote up
private Drawable getCachedDrawable(@NonNull final Context context, final long key) {
    synchronized (mDrawableCacheLock) {
        final LongSparseArray<WeakReference<ConstantState>> cache
                = mDrawableCaches.get(context);
        if (cache == null) {
            return null;
        }

        final WeakReference<ConstantState> wr = cache.get(key);
        if (wr != null) {
            // We have the key, and the secret
            ConstantState entry = wr.get();
            if (entry != null) {
                return entry.newDrawable(context.getResources());
            } else {
                // Our entry has been purged
                cache.delete(key);
            }
        }
    }
    return null;
}
 
Example #4
Source Project: Android-skin-support   Author: ximsfei   File: SkinCompatDrawableManager.java    License: MIT License 6 votes vote down vote up
private boolean addDrawableToCache(@NonNull final Context context, final long key,
                                   @NonNull final Drawable drawable) {
    final ConstantState cs = drawable.getConstantState();
    if (cs != null) {
        synchronized (mDrawableCacheLock) {
            LongSparseArray<WeakReference<ConstantState>> cache = mDrawableCaches.get(context);
            if (cache == null) {
                cache = new LongSparseArray<>();
                mDrawableCaches.put(context, cache);
            }
            cache.put(key, new WeakReference<ConstantState>(cs));
        }
        return true;
    }
    return false;
}
 
Example #5
Source Project: orWall   Author: EthACKdotOrg   File: AppFragment.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * List all disabled application. Meaning: installed app requiring Internet, but NOT in NatRules.
 * It also filters out special apps like orbot and i2p.
 *
 * @return List of AppRule
 */
private List<AppRule> listDisabledApps(LongSparseArray<AppRule> index) {
    PackageManager packageManager = this.getActivity().getPackageManager();
    List<AppRule> pkgList = new ArrayList<>();

    List<PackageInfo> pkgInstalled = packageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS);

    for (PackageInfo pkgInfo : pkgInstalled) {
        if (needInternet(pkgInfo) && !isReservedApp(pkgInfo)) {
            if (index.indexOfKey((long) pkgInfo.applicationInfo.uid) < 0) {
                AppRule app = new AppRule(false, pkgInfo.packageName, (long) pkgInfo.applicationInfo.uid, Constants.DB_ONION_TYPE_NONE, false, false);
                app.setAppName(packageManager.getApplicationLabel(pkgInfo.applicationInfo).toString());
                pkgList.add(app);
            }
        }
    }
    return pkgList;
}
 
Example #6
Source Project: Klyph   Author: jonathangerbaud   File: AbsHListView.java    License: MIT License 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void setAdapter( ListAdapter adapter ) {
	if ( adapter != null ) {
		mAdapterHasStableIds = mAdapter.hasStableIds();
		if ( mChoiceMode != ListView.CHOICE_MODE_NONE && mAdapterHasStableIds &&
				mCheckedIdStates == null ) {
			mCheckedIdStates = new LongSparseArray<Integer>();
		}
	}

	if ( mCheckStates != null ) {
		mCheckStates.clear();
	}

	if ( mCheckedIdStates != null ) {
		mCheckedIdStates.clear();
	}
}
 
Example #7
Source Project: Klyph   Author: jonathangerbaud   File: AbsHListView.java    License: MIT License 6 votes vote down vote up
/**
 * Returns the set of checked items ids. The result is only valid if the choice mode has not been set to
 * {@link #CHOICE_MODE_NONE} and the adapter has stable IDs. ({@link ListAdapter#hasStableIds()} == {@code true})
 * 
 * @return A new array which contains the id of each checked item in the list.
 */
public long[] getCheckedItemIds() {
	if ( mChoiceMode == ListView.CHOICE_MODE_NONE || mCheckedIdStates == null || mAdapter == null ) {
		return new long[0];
	}

	final LongSparseArray<Integer> idStates = mCheckedIdStates;
	final int count = idStates.size();
	final long[] ids = new long[count];

	for ( int i = 0; i < count; i++ ) {
		ids[i] = idStates.keyAt( i );
	}

	return ids;
}
 
Example #8
Source Project: Klyph   Author: jonathangerbaud   File: AbsHListView.java    License: MIT License 6 votes vote down vote up
/**
 * Constructor called from {@link #CREATOR}
 */
private SavedState( Parcel in ) {
	super( in );
	selectedId = in.readLong();
	firstId = in.readLong();
	viewLeft = in.readInt();
	position = in.readInt();
	width = in.readInt();
	filter = in.readString();
	inActionMode = in.readByte() != 0;
	checkedItemCount = in.readInt();
	checkState = in.readSparseBooleanArray();
	final int N = in.readInt();
	if ( N > 0 ) {
		checkIdState = new LongSparseArray<Integer>();
		for ( int i = 0; i < N; i++ ) {
			final long key = in.readLong();
			final int value = in.readInt();
			checkIdState.put( key, value );
		}
	}
}
 
Example #9
Source Project: Transitions-Everywhere   Author: andkulikov   File: Transition.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Match start/end values by Adapter item ID. Adds matched values to mStartValuesList
 * and mEndValuesList and removes them from unmatchedStart and unmatchedEnd, using
 * startItemIds and endItemIds as a guide for which Views have unique item IDs.
 */
private void matchItemIds(@NonNull ArrayMap<View, TransitionValues> unmatchedStart,
                          @NonNull ArrayMap<View, TransitionValues> unmatchedEnd,
                          @NonNull LongSparseArray<View> startItemIds,
                          @NonNull LongSparseArray<View> endItemIds) {
    int numStartIds = startItemIds.size();
    for (int i = 0; i < numStartIds; i++) {
        View startView = startItemIds.valueAt(i);
        if (startView != null && isValidTarget(startView)) {
            View endView = endItemIds.get(startItemIds.keyAt(i));
            if (endView != null && isValidTarget(endView)) {
                TransitionValues startValues = unmatchedStart.get(startView);
                TransitionValues endValues = unmatchedEnd.get(endView);
                if (startValues != null && endValues != null) {
                    mStartValuesList.add(startValues);
                    mEndValuesList.add(endValues);
                    unmatchedStart.remove(startView);
                    unmatchedEnd.remove(endView);
                }
            }
        }
    }
}
 
Example #10
public ReactNativeDownloadManagerModule(ReactApplicationContext reactContext) {
    super(reactContext);
    downloader = new Downloader(reactContext);
    appDownloads = new LongSparseArray<>();
    IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE);
    reactContext.registerReceiver(downloadReceiver, filter);
}
 
Example #11
Source Project: BlackList   Author: kaliturin   File: AddContactsFragment.java    License: Apache License 2.0 5 votes vote down vote up
protected void addContacts(List<Contact> contacts, LongSparseArray<ContactNumber> singleContactNumbers) {
    // if permission is granted
    if (!Permissions.notifyIfNotGranted(getContext(), Permissions.WRITE_EXTERNAL_STORAGE)) {
        ContactsWriter writer = new ContactsWriter(contactType, contacts, singleContactNumbers.clone());
        writer.execute();
    }
}
 
Example #12
Source Project: BlackList   Author: kaliturin   File: GetContactsFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void addContacts(List<Contact> contacts, LongSparseArray<ContactNumber> singleContactNumbers) {
    // prepare returning arguments - data of the chosen contacts
    ArrayList<String> names = new ArrayList<>();
    ArrayList<String> numbers = new ArrayList<>();
    ArrayList<Integer> types = new ArrayList<>();
    for (Contact contact : contacts) {
        ContactNumber contactNumber = singleContactNumbers.get(contact.id);
        if (contactNumber != null) {
            // add single number of the contact
            names.add(contact.name);
            numbers.add(contactNumber.number);
            types.add(contactNumber.type);
        } else {
            // all numbers of the contact
            for (ContactNumber _contactNumber : contact.numbers) {
                names.add(contact.name);
                numbers.add(_contactNumber.number);
                types.add(_contactNumber.type);
            }
        }
    }

    // return arguments
    Intent intent = new Intent();
    intent.putStringArrayListExtra(CONTACT_NAMES, names);
    intent.putStringArrayListExtra(CONTACT_NUMBERS, numbers);
    intent.putIntegerArrayListExtra(CONTACT_NUMBER_TYPES, types);
    getActivity().setResult(Activity.RESULT_OK, intent);
    getActivity().finish();
}
 
Example #13
Source Project: atlas   Author: alibaba   File: CompositionLayer.java    License: Apache License 2.0 5 votes vote down vote up
CompositionLayer(LottieDrawable lottieDrawable, Layer layerModel, List<Layer> layerModels,
    LottieComposition composition) {
  super(lottieDrawable, layerModel);

  LongSparseArray<BaseLayer> layerMap =
      new LongSparseArray<>(composition.getLayers().size());

  BaseLayer mattedLayer = null;
  for (int i = layerModels.size() - 1; i >= 0; i--) {
    Layer lm = layerModels.get(i);
    BaseLayer layer = BaseLayer.forModel(lm, lottieDrawable, composition);
    layerMap.put(layer.getLayerModel().getId(), layer);
    if (mattedLayer != null) {
      mattedLayer.setMatteLayer(layer);
      mattedLayer = null;
    } else {
      layers.add(0, layer);
      switch (lm.getMatteType()) {
        case Add:
        case Invert:
          mattedLayer = layer;
          break;
      }
    }
  }

  for (int i = 0; i < layerMap.size(); i++) {
    long key = layerMap.keyAt(i);
    BaseLayer layerView = layerMap.get(key);
    BaseLayer parentLayer = layerMap.get(layerView.getLayerModel().getParentId());
    if (parentLayer != null) {
      layerView.setParentLayer(parentLayer);
    }
  }
}
 
Example #14
Source Project: letv   Author: JackChan1999   File: AbsHListView.java    License: Apache License 2.0 5 votes vote down vote up
public void setAdapter(ListAdapter adapter) {
    if (adapter != null) {
        this.mAdapterHasStableIds = this.mAdapter.hasStableIds();
        if (this.mChoiceMode != 0 && this.mAdapterHasStableIds && this.mCheckedIdStates == null) {
            this.mCheckedIdStates = new LongSparseArray();
        }
    }
    if (this.mCheckStates != null) {
        this.mCheckStates.clear();
    }
    if (this.mCheckedIdStates != null) {
        this.mCheckedIdStates.clear();
    }
}
 
Example #15
Source Project: letv   Author: JackChan1999   File: AbsHListView.java    License: Apache License 2.0 5 votes vote down vote up
public long[] getCheckedItemIds() {
    if (this.mChoiceMode == 0 || this.mCheckedIdStates == null || this.mAdapter == null) {
        return new long[0];
    }
    LongSparseArray<Integer> idStates = this.mCheckedIdStates;
    int count = idStates.size();
    long[] ids = new long[count];
    for (int i = 0; i < count; i++) {
        ids[i] = idStates.keyAt(i);
    }
    return ids;
}
 
Example #16
Source Project: letv   Author: JackChan1999   File: AbsHListView.java    License: Apache License 2.0 5 votes vote down vote up
@TargetApi(11)
public void setChoiceMode(int choiceMode) {
    this.mChoiceMode = choiceMode;
    if (VERSION.SDK_INT >= 11 && this.mChoiceActionMode != null) {
        if (VERSION.SDK_INT >= 11) {
            ((ActionMode) this.mChoiceActionMode).finish();
        }
        this.mChoiceActionMode = null;
    }
    if (this.mChoiceMode != 0) {
        if (this.mCheckStates == null) {
            this.mCheckStates = new SparseArrayCompat();
        }
        if (this.mCheckedIdStates == null && this.mAdapter != null && this.mAdapter.hasStableIds()) {
            this.mCheckedIdStates = new LongSparseArray();
        }
        if (VERSION.SDK_INT >= 11 && this.mChoiceMode == 3) {
            clearChoices();
            setLongClickable(true);
        }
    }
}
 
Example #17
Source Project: Android-skin-support   Author: ximsfei   File: SkinCompatDrawableManager.java    License: MIT License 5 votes vote down vote up
public void onConfigurationChanged(@NonNull Context context) {
    synchronized (mDrawableCacheLock) {
        LongSparseArray<WeakReference<ConstantState>> cache = mDrawableCaches.get(context);
        if (cache != null) {
            // Crude, but we'll just clear the cache when the configuration changes
            cache.clear();
        }
    }
}
 
Example #18
Source Project: BrainPhaser   Author: Kamshak   File: CategoryAdapter.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adapter for Listing Categories in a recycler view
 * @param categories list of categories to show
 * @param dueChallengeCounts an SparseArray that maps category ids to their due challenge count.
 * @param listener listener that is notified when a category is clicked.
 */
public CategoryAdapter(List<Category> categories, LongSparseArray<Integer> dueChallengeCounts, SelectionListener listener) {
    mListener = listener;
    mCategories = categories;
    mDueChallengeCounts = dueChallengeCounts;

    setHasStableIds(true);
}
 
Example #19
Source Project: BrainPhaser   Author: Kamshak   File: DueChallengeLogic.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the amount of due challenges for each category id.
 *
 * @param categories the list of categories
 * @return array that maps category counts to category ids. (Key = CategoryId, Value = Count)
 */
public LongSparseArray<Integer> getDueChallengeCounts(List<Category> categories) {
    LongSparseArray<Integer> dueChallengeCounts = new LongSparseArray<>();
    for (Category category : categories) {
        int challengesDueCount = getDueChallenges(category.getId()).size();
        dueChallengeCounts.put(category.getId(), challengesDueCount);
    }
    return dueChallengeCounts;
}
 
Example #20
Source Project: BrainPhaser   Author: Kamshak   File: CategorySelectionTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets up fake returns for the data sources
 */
public void setUp() {
    mTestAppComponent.inject(this);

    // Fake categories
    mFakeCategories = Arrays.asList(
        new Category(1L, "Englisch", "Verbessere deine Englischkenntnisse und dein Wissen über Englischsprachige Länder. Lerne nützliche Phrasen und Umgangsformen.", "@drawable/englisch"),
        new Category(2L, "Architektur", "Verbessere dein Wissen über berühmte Gebäude, Bauarten und Architekturepochen..", "@drawable/architektur"),
        new Category(3L, "Computer", "Lerne neue, coole Fakten über Computer und Informationstechnologie. Du wirst mit Fragen zu Netzwerken, Hardware, Software, Programmiersprachen und Softwareprojekten getestet.", "@drawable/computer"),
        new Category(4L, "Geographie", "Länder, Kulturen und Traditionen.", "@drawable/englisch")
    );
    Mockito.when(mockCategoryDataSource.getAll()).thenReturn(
        mFakeCategories
    );

    // How many due challenges in above categories
    LongSparseArray<Integer> fakeCounts = new LongSparseArray<>();
    fakeCounts.put(1, 10);
    fakeCounts.put(2, 0);
    fakeCounts.put(3, 11);
    fakeCounts.put(4, 3);
    mockDueChallengeLogic = Mockito.mock(DueChallengeLogic.class);
    Mockito.when(mockDueChallengeLogic.getDueChallengeCounts(Mockito.anyListOf(Category.class))).thenReturn(
        fakeCounts
    );

    Mockito.when(mockLogicFactory.createDueChallengeLogic(org.mockito.Matchers.any(User.class)))
        .thenReturn(mockDueChallengeLogic);

    // Which category should be at which position (pos -> categoryId)
    mPositions.put(4, mFakeCategories.get(1));
    mPositions.put(3, mFakeCategories.get(3));
    mPositions.put(2, mFakeCategories.get(0));
    mPositions.put(1, mFakeCategories.get(2));
}
 
Example #21
Source Project: standardlib   Author: stablekernel   File: SparseArrayUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static <T> List<T> asList(LongSparseArray<T> sparseArray) {
    if (sparseArray == null) {
        return null;
    }

    ArrayList<T> list = new ArrayList<>(sparseArray.size());
    for (int i = 0; i < sparseArray.size(); i++) {
        list.add(sparseArray.valueAt(i));
    }
    return list;
}
 
Example #22
Source Project: orWall   Author: EthACKdotOrg   File: AppFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
private List<AppRule> listSpecialApps(LongSparseArray<AppRule> index) {
    List<AppRule> pkgList = new ArrayList<>();
    Map<String,PackageInfoData> specialApps = PackageInfoData.specialApps();

    for (PackageInfoData pkgInfo: specialApps.values()) {
        if (index.indexOfKey(pkgInfo.getUid()) < 0) {
            AppRule app = new AppRule(false, pkgInfo.getPkgName(), pkgInfo.getUid(), Constants.DB_ONION_TYPE_NONE, false, false);
            app.setAppName(pkgInfo.getName());
            pkgList.add(app);
        }
    }

    return pkgList;
}
 
Example #23
Source Project: QuickLyric   Author: QuickLyric   File: LocalLyricsFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
public LongSparseArray<Integer> collectTopPositions() {
    final LongSparseArray<Integer> itemIdTopMap = new LongSparseArray<>();
    int firstVisiblePosition = megaListView.getFirstVisiblePosition();
    for (int i = 0; i < megaListView.getChildCount(); ++i) {
        View child = megaListView.getChildAt(i);
        int position = firstVisiblePosition + i;
        long itemId = megaListView.getAdapter().getItemId(position);
        itemIdTopMap.put(itemId, child.getTop());
    }
    return itemIdTopMap;
}
 
Example #24
Source Project: RippleDrawable   Author: ozodrukh   File: LollipopDrawablesCompat.java    License: MIT License 5 votes vote down vote up
private static Drawable getCachedDrawable(LongSparseArray<WeakReference<Drawable.ConstantState>> cache,
                                          long key, Resources res) {
    synchronized (mAccessLock) {
        WeakReference<Drawable.ConstantState> wr = cache.get(key);
        if (wr != null) {
            Drawable.ConstantState entry = wr.get();
            if (entry != null) {
                return entry.newDrawable(res);
            } else {
                cache.delete(key);
            }
        }
    }
    return null;
}
 
Example #25
Source Project: RippleDrawable   Author: ozodrukh   File: LollipopDrawablesCompat.java    License: MIT License 5 votes vote down vote up
private static void cacheDrawable(TypedValue value, Resources resources, Resources.Theme theme, boolean isColorDrawable, long key, Drawable drawable, LongSparseArray<WeakReference<Drawable.ConstantState>> caches) {

        Drawable.ConstantState cs = drawable.getConstantState();
        if (cs == null) {
            return;
        }

        synchronized (mAccessLock) {
            caches.put(key, new WeakReference<>(cs));
        }
    }
 
Example #26
Source Project: fingen   Author: YoshiOne   File: TransactionsDAO.java    License: Apache License 2.0 4 votes vote down vote up
public synchronized LongSparseArray<LongSparseArray<IAbstractModel>> getEntityReport(int modelType, FilterListHelper filterListHelper, Context context) throws Exception {
    LongSparseArray<LongSparseArray<IAbstractModel>> map = new LongSparseArray<>();
    AbstractDAO abstractDAO = BaseDAO.getDAO(modelType, context);
    if (abstractDAO == null) return map;
    List<AbstractFilter> filterList = filterListHelper.getFilters();
    long cabbageID;
    long modelID;
    IAbstractModel model;
    LongSparseArray<IAbstractModel> models;
    String entityField = getEntityField(modelType);
    String excludeTransfers = modelType == IAbstractModel.MODEL_TYPE_ACCOUNT ? "" : "WHERE  ExcludeTransfer != 1 ";

    createTempTransactionsTable(filterList, context);

    String sql = "SELECT\n" +
            "Currency, " + entityField + ",\n" +
            "TOTAL(CASE WHEN Income = 1 THEN Amount ELSE 0 END) AS InAmountSum,\n" +
            "TOTAL(CASE WHEN Income = 0 THEN Amount ELSE 0 END) AS OutAmountSum\n" +
            "FROM temp_all_Transactions\n" +
            excludeTransfers +
            "GROUP BY Currency, " + entityField + ";";
    if (BuildConfig.DEBUG) {
        Log.d(SQLTAG, sql);
    }

    Cursor cursor = mDatabase.rawQuery(sql, null);
    if (cursor != null) {
        try {
            if (cursor.moveToFirst()) {
                while (!cursor.isAfterLast()) {
                    cabbageID = cursor.getLong(0);
                    modelID = cursor.getLong(1);
                    if (modelID > 0) {
                        model = abstractDAO.getModelById(modelID);
                    } else {
                        model = abstractDAO.createEmptyModel();
                    }
                    model.setIncome(new BigDecimal(cursor.getDouble(2)).abs());
                    model.setExpense(new BigDecimal(cursor.getDouble(3)).abs());
                    if (map.indexOfKey(cabbageID) < 0) {
                        map.put(cabbageID, new LongSparseArray<>());
                    }
                    models = map.get(cabbageID);
                    models.put(model.getID(), model);
                    cursor.moveToNext();
                }
            }
        } finally {
            cursor.close();
        }
    }
    return map;
}
 
Example #27
Source Project: timecat   Author: triline3   File: EmptyUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 判断对象是否为空
 *
 * @param obj 对象
 * @return {@code true}: 为空<br>{@code false}: 不为空
 */
public static boolean isEmpty(final 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 SimpleArrayMap && ((SimpleArrayMap) 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;
        }
    }
    if (obj instanceof LongSparseArray && ((LongSparseArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        if (obj instanceof android.util.LongSparseArray && ((android.util.LongSparseArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}
 
Example #28
Source Project: BlackList   Author: kaliturin   File: AddContactsFragment.java    License: Apache License 2.0 4 votes vote down vote up
ContactsWriter(int contactType, List<Contact> contacts,
               LongSparseArray<ContactNumber> singleContactNumbers) {
    this.contactType = contactType;
    this.contacts = contacts;
    this.singleContactNumbers = singleContactNumbers;
}
 
Example #29
Source Project: atlas   Author: alibaba   File: LottieComposition.java    License: Apache License 2.0 4 votes vote down vote up
private static void addLayer(List<Layer> layers, LongSparseArray<Layer> layerMap, Layer layer) {
  layers.add(layer);
  layerMap.put(layer.getId(), layer);
}
 
Example #30
Source Project: AndroidUtilCode   Author: Blankj   File: ObjectUtils.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Return whether object is empty.
 *
 * @param obj The object.
 * @return {@code true}: yes<br>{@code false}: no
 */
public static boolean isEmpty(final Object obj) {
    if (obj == null) {
        return true;
    }
    if (obj.getClass().isArray() && Array.getLength(obj) == 0) {
        return true;
    }
    if (obj instanceof CharSequence && obj.toString().length() == 0) {
        return true;
    }
    if (obj instanceof Collection && ((Collection) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof Map && ((Map) obj).isEmpty()) {
        return true;
    }
    if (obj instanceof SimpleArrayMap && ((SimpleArrayMap) 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;
        }
    }
    if (obj instanceof LongSparseArray && ((LongSparseArray) obj).size() == 0) {
        return true;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        if (obj instanceof android.util.LongSparseArray
                && ((android.util.LongSparseArray) obj).size() == 0) {
            return true;
        }
    }
    return false;
}