本文整理汇总了Java中android.support.v4.util.LongSparseArray.put方法的典型用法代码示例。如果您正苦于以下问题:Java LongSparseArray.put方法的具体用法?Java LongSparseArray.put怎么用?Java LongSparseArray.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.util.LongSparseArray
的用法示例。
在下文中一共展示了LongSparseArray.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: parsePrecomps
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
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);
}
}
示例3: addDrawableToCache
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
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;
}
示例4: showStoreLatestApps
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
private void showStoreLatestApps(StoreLatestApps card, int position) {
Map<View, Long> apps = new HashMap<>();
LongSparseArray<String> appsPackages = new LongSparseArray<>();
appsContainer.removeAllViews();
View latestAppView;
ImageView latestAppIcon;
TextView latestAppName;
for (App latestApp : card.getApps()) {
latestAppView = inflater.inflate(R.layout.social_timeline_latest_app, appsContainer, false);
latestAppIcon = (ImageView) latestAppView.findViewById(R.id.social_timeline_latest_app_icon);
latestAppName = (TextView) latestAppView.findViewById(R.id.social_timeline_latest_app_name);
ImageLoader.with(itemView.getContext())
.load(latestApp.getIcon(), latestAppIcon);
latestAppName.setText(latestApp.getName());
appsContainer.addView(latestAppView);
apps.put(latestAppView, latestApp.getId());
appsPackages.put(latestApp.getId(), latestApp.getPackageName());
}
setStoreLatestAppsListeners(card, apps, appsPackages, position);
}
示例5: showStoreLatestApps
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
private void showStoreLatestApps(SocialStore card, int position) {
Map<View, Long> apps = new HashMap<>();
LongSparseArray<String> appsPackages = new LongSparseArray<>();
appsContainer.removeAllViews();
View latestAppView;
ImageView latestAppIcon;
TextView latestAppName;
for (App latestApp : card.getApps()) {
latestAppView = inflater.inflate(R.layout.social_timeline_latest_app, appsContainer, false);
latestAppIcon = (ImageView) latestAppView.findViewById(R.id.social_timeline_latest_app_icon);
latestAppName = (TextView) latestAppView.findViewById(R.id.social_timeline_latest_app_name);
ImageLoader.with(itemView.getContext())
.load(latestApp.getIcon(), latestAppIcon);
latestAppName.setText(latestApp.getName());
appsContainer.addView(latestAppView);
apps.put(latestAppView, latestApp.getId());
appsPackages.put(latestApp.getId(), latestApp.getPackageName());
}
setStoreLatestAppsListeners(card, apps, appsPackages, position);
}
示例6: showStoreLatestApps
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
private void showStoreLatestApps(AggregatedStore card) {
Map<View, Long> apps = new HashMap<>();
LongSparseArray<String> appsPackages = new LongSparseArray<>();
appsContainer.removeAllViews();
View latestAppView;
ImageView latestAppIcon;
TextView latestAppName;
for (App latestApp : card.getApps()) {
latestAppView = inflater.inflate(R.layout.social_timeline_latest_app, appsContainer, false);
latestAppIcon = (ImageView) latestAppView.findViewById(R.id.social_timeline_latest_app_icon);
latestAppName = (TextView) latestAppView.findViewById(R.id.social_timeline_latest_app_name);
ImageLoader.with(itemView.getContext())
.load(latestApp.getIcon(), latestAppIcon);
latestAppName.setText(latestApp.getName());
appsContainer.addView(latestAppView);
apps.put(latestAppView, latestApp.getId());
appsPackages.put(latestApp.getId(), latestApp.getPackageName());
}
setStoreLatestAppsListeners(card, apps, appsPackages);
}
示例7: getExistingReminders
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
/**
* Returns map of <reminder_id, reminder_object>
*
* @param eventId
* @return
*/
private LongSparseArray<DbCalendarReminderSensor> getExistingReminders(long eventId) {
long deviceId = PreferenceProvider.getInstance(context).getCurrentDeviceId();
List<DbCalendarReminderSensor> list = daoProvider
.getCalendarReminderSensorDao()
.getAllByEventId(eventId, deviceId);
LongSparseArray<DbCalendarReminderSensor> map = new LongSparseArray<>(list.size());
for (DbCalendarReminderSensor reminder : list) {
map.put(reminder.getReminderId(), reminder);
}
return map;
}
示例8: parseLayers
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
private static void parseLayers(JsonReader reader, LottieComposition composition,
List<Layer> layers, LongSparseArray<Layer> layerMap) throws IOException {
int imageCount = 0;
reader.beginArray();
while (reader.hasNext()) {
Layer layer = LayerParser.parse(reader, composition);
if (layer.getLayerType() == Layer.LayerType.Image) {
imageCount++;
}
layers.add(layer);
layerMap.put(layer.getId(), layer);
if (imageCount > 4) {
L.warn("You have " + imageCount + " images. Lottie should primarily be " +
"used with shapes. If you are using Adobe Illustrator, convert the Illustrator layers" +
" to shape layers.");
}
}
reader.endArray();
}
示例9: convertToSparseArray
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
private LongSparseArray<Double> convertToSparseArray(JSONArray array) {
double multiplier = getMultiplier(array);
LongSparseArray<Double> sparse = new LongSparseArray<>();
for (Integer index = 0; index < array.length(); index++) {
try {
JSONObject o = array.getJSONObject(index);
long tas = getShitfTimeSecs((int) o.getLong("timeAsSeconds"));
Double value = o.getDouble("value") * multiplier;
sparse.put(tas, value);
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
}
// check if start is at 0 (midnight)
// and add last value before midnight if not
if (sparse.keyAt(0) != 0) {
sparse.put(0, sparse.valueAt(sparse.size() - 1));
}
return sparse;
}
示例10: 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;
}
示例11: loadSendMsgBeansToMap
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
public static synchronized void loadSendMsgBeansToMap(ContentResolver resolver, long mid, long uid, LongSparseArray<MsgBean> mapSend, long targetOrderNum, int count) {
checkUIDs(mid, uid);
if (targetOrderNum < 0) targetOrderNum = ContentHelper.getMaxOrderNumSendOrReceived(resolver, mid, uid) - count;
Cursor cursorSend = ContentHelper.MSG_SEND.getCursorOrderNumDesc(resolver, mid, uid);
if (cursorSend != null) {
while (cursorSend.moveToNext()) {
long orderNum = cursorSend.getLong(cursorSend.getColumnIndex(MSG.DbColumns.MsgSend._ORDER_NUM));
if (orderNum <= targetOrderNum) {
break;
}
long id = cursorSend.getLong(cursorSend.getColumnIndex(MSG.DbColumns.MsgSend._ID));
int ctype = cursorSend.getInt(cursorSend.getColumnIndex(MSG.DbColumns.MsgSend._TYPE_CONTENT));
String content = cursorSend.getString(cursorSend.getColumnIndex(MSG.DbColumns.MsgSend._CONTENT));
int arriveState = cursorSend.getInt(cursorSend.getColumnIndex(MSG.DbColumns.MsgSend._ARRIVE_STATE));
MsgBean bean = new MsgBean(id, MsgBean.TYPE_ME, ctype, content, orderNum, 0, arriveState);
bean.timeSend = cursorSend.getLong(cursorSend.getColumnIndex(MSG.DbColumns.MsgSend._TIME_LOCAL));
mapSend.put(bean.id, bean);
}
cursorSend.close();
}
}
示例12: loadReceivedMsgBeansToMap
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
public static synchronized void loadReceivedMsgBeansToMap(ContentResolver resolver, long mid, long uid, LongSparseArray<MsgBean> mapReceived, long targetOrderNum, int count) {
checkUIDs(mid, uid);
if (targetOrderNum < 0) targetOrderNum = ContentHelper.getMaxOrderNumSendOrReceived(resolver, mid, uid) - count;
Cursor cursorReceived = ContentHelper.MSG_RECEIVED.getCursorOrderNumDesc(resolver, mid, uid);
if (cursorReceived != null) {
while (cursorReceived.moveToNext()) {
long orderNum = cursorReceived.getLong(cursorReceived.getColumnIndex(MSG.DbColumns.MsgReceived._ORDER_NUM));
if (orderNum <= targetOrderNum) {
break;
}
long id = cursorReceived.getLong(cursorReceived.getColumnIndex(MSG.DbColumns.MsgReceived._ID));
int ctype = cursorReceived.getInt(cursorReceived.getColumnIndex(MSG.DbColumns.MsgReceived._TYPE_CONTENT));
String content = cursorReceived.getString(cursorReceived.getColumnIndex(MSG.DbColumns.MsgReceived._CONTENT));
int timeLength = cursorReceived.getInt(cursorReceived.getColumnIndex(MSG.DbColumns.MsgReceived._TIME_LENGTH));
int readTimes = cursorReceived.getInt(cursorReceived.getColumnIndex(MSG.DbColumns.MsgReceived._READ_TIMES));
MsgBean bean = new MsgBean(id, MsgBean.TYPE_OTHER, ctype, content, orderNum, timeLength);
bean.timeSend = cursorReceived.getLong(cursorReceived.getColumnIndex(MSG.DbColumns.MsgReceived._TIME_SEND));
bean.readTimes = readTimes;
mapReceived.put(bean.id, bean);
}
cursorReceived.close();
}
}
示例13: 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;
}
示例14: 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;
}
示例15: putCheckedChild
import android.support.v4.util.LongSparseArray; //导入方法依赖的package包/类
/*********************************************************************
* Data store helpers (internal use)
**********************************************************************/
private void putCheckedChild(final long groupId,
final int childPosition,
final long childId){
if (mCheckedChildren.get(groupId) != null)
mCheckedChildren.get(groupId)
.put( childId,
childPosition);
else{
final LongSparseArray<Integer> mChildStates = new LongSparseArray<Integer>();
mChildStates.put( childId,
childPosition);
mCheckedChildren.put( groupId,
mChildStates);
}
}