本文整理匯總了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);
}
}