當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。