本文整理汇总了Java中android.support.v4.util.LongSparseArray.get方法的典型用法代码示例。如果您正苦于以下问题:Java LongSparseArray.get方法的具体用法?Java LongSparseArray.get怎么用?Java LongSparseArray.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.util.LongSparseArray
的用法示例。
在下文中一共展示了LongSparseArray.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sameNameFilterExists
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
/**
* Checks if filter with the same name (ignoring case) already exists.
*/
private boolean sameNameFilterExists(String name) {
LongSparseArray<Filter> filters = FiltersClient.INSTANCE.getByNameIgnoreCase(getContext(), name);
if (isEditingExistingFilter()) {
long id = getArguments().getLong(ARG_ID);
for (int i = 0; i < filters.size(); i++) {
long filterId = filters.keyAt(i);
Filter filter = filters.get(filterId);
// Ignore currently edited filter
if (name.equalsIgnoreCase(filter.getName()) && id != filterId) {
return true;
}
}
return false;
} else { // New filter
return filters.size() > 0;
}
}
示例2: addContacts
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
@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();
}
示例3: getClusters
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
@Override
public Set<? extends Cluster<T>> getClusters(double zoom) {
long numCells = (long) Math.ceil(256 * Math.pow(2, zoom) / GRID_SIZE);
SphericalMercatorProjection proj = new SphericalMercatorProjection(numCells);
HashSet<Cluster<T>> clusters = new HashSet<>();
LongSparseArray<StaticCluster<T>> sparseArray = new LongSparseArray<StaticCluster<T>>();
synchronized (mItems) {
for (T item : mItems) {
Point p = proj.toPoint(item.getPosition());
long coord = getCoord(numCells, p.x, p.y);
StaticCluster<T> cluster = sparseArray.get(coord);
if (cluster == null) {
cluster = new StaticCluster<T>(proj.toLatLng(new Point(Math.floor(p.x) + .5, Math.floor(p.y) + .5)));
sparseArray.put(coord, cluster);
clusters.add(cluster);
}
cluster.add(item);
}
}
return clusters;
}
示例4: getCachedDelegateDrawable
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
private Drawable getCachedDelegateDrawable(@NonNull Context context, long key) {
Drawable drawable = null;
synchronized (this.mDelegateDrawableCacheLock) {
LongSparseArray<WeakReference<ConstantState>> cache = (LongSparseArray) this.mDelegateDrawableCaches.get(context);
if (cache == null) {
} else {
WeakReference<ConstantState> wr = (WeakReference) cache.get(key);
if (wr != null) {
ConstantState entry = (ConstantState) wr.get();
if (entry != null) {
drawable = entry.newDrawable(context.getResources());
} else {
cache.delete(key);
}
}
}
}
return drawable;
}
示例5: getCachedDrawable
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
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;
}
示例6: getClusters
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
@Override
public Set<? extends Cluster<T>> getClusters(double zoom) {
long numCells = (long) Math.ceil(256 * Math.pow(2, zoom) / GRID_SIZE);
SphericalMercatorProjection proj = new SphericalMercatorProjection(numCells);
HashSet<Cluster<T>> clusters = new HashSet<Cluster<T>>();
LongSparseArray<StaticCluster<T>> sparseArray = new LongSparseArray<StaticCluster<T>>();
synchronized (mItems) {
for (T item : mItems) {
Point p = proj.toPoint(item.getPosition());
long coord = getCoord(numCells, p.x, p.y);
StaticCluster<T> cluster = sparseArray.get(coord);
if (cluster == null) {
cluster = new StaticCluster<T>(proj.toLatLng(new Point(Math.floor(p.x) + .5, Math.floor(p.y) + .5)));
sparseArray.put(coord, cluster);
clusters.add(cluster);
}
cluster.add(item);
}
}
return clusters;
}
示例7: Conversation
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
/**
* This constructor is for working with cache.
*
* If contact was in cache we won't resolve contact
* but will get directly from cache.
*
* @param context Context in order to use resolve some contact parts. (Like contact)
* @param cursor cursor to get data from.
* @param contactCache so save or retrieve contact without querying...
*/
public Conversation(Context context,Cursor cursor,LongSparseArray<ArrayList<Contact>> contactCache){
this.recipientIds = cursor.getString(cursor.getColumnIndex(RECIPIENT_IDS));
this.lastMessage = cursor.getString(cursor.getColumnIndex(LAST_MESSAGE));
this.date = new Date(cursor.getLong(cursor.getColumnIndex(DATE)));
this.messageRead = cursor.getInt(cursor.getColumnIndex(IS_READ)) == 1;
this.id = cursor.getLong(cursor.getColumnIndex(THREAD_ID));
ArrayList<Contact> cached= contactCache.get(id,null);
if(cached == null){
this.contacts = resolveContacts(context,recipientIds);
// save in cache
contactCache.append(id,contacts);
}else{
this.contacts = cached;
}
}
示例8: findMidPoint
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
private short findMidPoint(short v1, short v2, short vCount, LongSparseArray<Short> vertexCache) {
float x = (vertices[v1 * 3] + vertices[v2 * 3]) / 2f;
float y = (vertices[v1 * 3 + 1] + vertices[v2 * 3 + 1]) / 2f;
float z = (vertices[v1 * 3 + 2] + vertices[v2 * 3 + 2]) / 2f;
short tmp;
if (v1 > v2) {
tmp = v1;
v1 = v2;
v2 = tmp;
}
Short index = vertexCache.get((long) v1 << 32 | (long) v2);
if (index == null) {
addVertex(x, y, z, vCount);
vertexCache.put((long) v1 << 32 | (long) v2, vCount);
index = vCount;
}
return index;
}
示例9: removeItems
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
/**
* Removed all selected items from cached {@link java.util.List}.
*
* @return Data items that have been removed from cache. Return {@code null} when no removal happened.
*/
public LongSparseArray<T> removeItems() {
LongSparseArray<T> itemsToRmv = new LongSparseArray<T>();
List<T> ds = getDataSource();
for (T t : ds) {
if (t.isChecked()) {
itemsToRmv.put(getItemKey(t), t);
}
}
long key;
T item; ;
for (int i = 0; i < itemsToRmv.size(); i++) {
key = itemsToRmv.keyAt(i);
item = itemsToRmv.get(key);
ds.remove(item);
}
return itemsToRmv;
}
示例10: matchItemIds
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
/**
* 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(ArrayMap<View, TransitionValues> unmatchedStart,
ArrayMap<View, TransitionValues> unmatchedEnd,
LongSparseArray<View> startItemIds, 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);
}
}
}
}
}
示例11: CompositionLayer
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
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);
}
}
}
示例12: checkForContactChange
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
private boolean checkForContactChange(LongSparseArray<DbContactSensor> map, DbContactSensor newItem) {
long id = newItem.getContactId();
DbContactSensor existingReminder = map.get(id);
boolean result = false;
DbContactSensor existingItem = map.get(id);
map.delete(id);
if (existingItem == null) {
newItem.setIsNew(Boolean.TRUE);
newItem.setIsUpdated(Boolean.TRUE);
newItem.setIsDeleted(Boolean.FALSE);
result = true;
} else {
if (hasContactDifference(existingItem, newItem)) {
newItem.setIsNew(Boolean.FALSE);
newItem.setIsUpdated(Boolean.TRUE);
newItem.setIsDeleted(Boolean.FALSE);
newItem.setId(existingItem.getId());
result = true;
}
}
if (!result) {
newItem.setId(existingReminder.getId());
}
return result;
}
示例13: checkForChange
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
private boolean checkForChange(LongSparseArray<DbCalendarSensor> map, DbCalendarSensor newItem) {
Long eventId = newItem.getEventId();
if (eventId == null) {
return false;
}
DbCalendarSensor existingItem = map.get(eventId);
map.delete(eventId);
if (existingItem == null) {
newItem.setIsNew(Boolean.TRUE);
newItem.setIsUpdated(Boolean.TRUE);
newItem.setIsDeleted(Boolean.FALSE);
return true;
}
if (hasEventDifference(existingItem, newItem)) {
newItem.setIsNew(Boolean.FALSE);
newItem.setIsUpdated(Boolean.TRUE);
newItem.setIsDeleted(Boolean.FALSE);
newItem.setId(existingItem.getId());
return true;
}
return false;
}
示例14: checkForReminderChange
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
private boolean checkForReminderChange(LongSparseArray<DbCalendarReminderSensor> map, DbCalendarReminderSensor newItem) {
if (newItem == null) {
throw new IllegalArgumentException();
}
Long eventId = newItem.getEventId();
if (eventId == null) {
return false;
}
DbCalendarReminderSensor existingItem = map.get(eventId);
map.delete(eventId);
if (existingItem == null) {
newItem.setIsNew(Boolean.TRUE);
newItem.setIsUpdated(Boolean.TRUE);
newItem.setIsDeleted(Boolean.FALSE);
return true;
}
if (hasReminderDifference(existingItem, newItem)) {
newItem.setIsNew(Boolean.FALSE);
newItem.setIsUpdated(Boolean.TRUE);
newItem.setIsDeleted(Boolean.FALSE);
newItem.setId(existingItem.getId());
return true;
}
return false;
}
示例15: getCachedDrawable
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
private Drawable getCachedDrawable(LongSparseArray<WeakReference<Drawable.ConstantState>> cache, long key) {
synchronized (mAccessLock) {
WeakReference<Drawable.ConstantState> wr = cache.get(key);
if (wr != null) {
Drawable.ConstantState entry = wr.get();
if (entry != null) {
return entry.newDrawable(this);
} else {
cache.delete(key);
}
}
}
return null;
}