当前位置: 首页>>代码示例>>Java>>正文


Java LongSparseArray.put方法代码示例

本文整理汇总了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;
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:27,代码来源:GridBasedAlgorithm.java

示例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);
  }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:24,代码来源:LottieComposition.java

示例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;
}
 
开发者ID:ximsfei,项目名称:Android-skin-support,代码行数:17,代码来源:SkinCompatDrawableManager.java

示例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);
}
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:23,代码来源:StoreLatestAppsViewHolder.java

示例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);
}
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:23,代码来源:SocialStoreViewHolder.java

示例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);
}
 
开发者ID:Aptoide,项目名称:aptoide-client-v8,代码行数:22,代码来源:AggregatedStoreViewHolder.java

示例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;
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-client-sdk-android,代码行数:23,代码来源:CalendarSensor.java

示例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();
}
 
开发者ID:airbnb,项目名称:lottie-android,代码行数:21,代码来源:LottieCompositionParser.java

示例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;
}
 
开发者ID:MilosKozak,项目名称:AndroidAPS,代码行数:23,代码来源:Profile.java

示例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;
}
 
开发者ID:jp1017,项目名称:TheSceneryAlong,代码行数:27,代码来源:GridBasedAlgorithm.java

示例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();
	}
}
 
开发者ID:WeiChou,项目名称:Wei.IM2A,代码行数:23,代码来源:MsgListHelper.java

示例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();
	}
}
 
开发者ID:WeiChou,项目名称:Wei.IM2A,代码行数:25,代码来源:MsgListHelper.java

示例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;
}
 
开发者ID:10cars,项目名称:Icosphere,代码行数:19,代码来源:Icosphere.java

示例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;
}
 
开发者ID:XinyueZ,项目名称:schautup,代码行数:25,代码来源:BaseActionModeListAdapter.java

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

}
 
开发者ID:kemallette,项目名称:MultiChoiceExpandableList,代码行数:22,代码来源:CheckStateStore.java


注:本文中的android.support.v4.util.LongSparseArray.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。