當前位置: 首頁>>代碼示例>>Java>>正文


Java LongSparseArray.get方法代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:26,代碼來源:FilterFragment.java

示例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();
}
 
開發者ID:kaliturin,項目名稱:BlackList,代碼行數:32,代碼來源:GetContactsFragment.java

示例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;
}
 
開發者ID:mapbox,項目名稱:mapbox-plugins-android,代碼行數:27,代碼來源:GridBasedAlgorithm.java

示例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;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:20,代碼來源:AppCompatDrawableManager.java

示例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;
}
 
開發者ID:ximsfei,項目名稱:Android-skin-support,代碼行數:23,代碼來源:SkinCompatDrawableManager.java

示例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;
}
 
開發者ID:jp1017,項目名稱:TheSceneryAlong,代碼行數:27,代碼來源:GridBasedAlgorithm.java

示例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;
    }

}
 
開發者ID:Ioane5,項目名稱:GeoSMS-Release,代碼行數:29,代碼來源:Conversation.java

示例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;
}
 
開發者ID:10cars,項目名稱:Icosphere,代碼行數:19,代碼來源:Icosphere.java

示例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;
}
 
開發者ID:XinyueZ,項目名稱:schautup,代碼行數:25,代碼來源:BaseActionModeListAdapter.java

示例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);
                }
            }
        }
    }
}
 
開發者ID:andkulikov,項目名稱:Transitions-Everywhere,代碼行數:27,代碼來源:Transition.java

示例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);
    }
  }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:36,代碼來源:CompositionLayer.java

示例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;
    }
 
開發者ID:Telecooperation,項目名稱:assistance-platform-client-sdk-android,代碼行數:37,代碼來源:ContactsSensor.java

示例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;
    }
 
開發者ID:Telecooperation,項目名稱:assistance-platform-client-sdk-android,代碼行數:33,代碼來源:CalendarSensor.java

示例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;
    }
 
開發者ID:Telecooperation,項目名稱:assistance-platform-client-sdk-android,代碼行數:37,代碼來源:CalendarSensor.java

示例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;
}
 
開發者ID:ZieIony,項目名稱:Carbon,代碼行數:15,代碼來源:CarbonResources.java


注:本文中的android.support.v4.util.LongSparseArray.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。