本文整理汇总了Java中android.support.v4.util.LongSparseArray类的典型用法代码示例。如果您正苦于以下问题:Java LongSparseArray类的具体用法?Java LongSparseArray怎么用?Java LongSparseArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LongSparseArray类属于android.support.v4.util包,在下文中一共展示了LongSparseArray类的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;
}
}
示例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();
}
示例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;
}
示例4: onCreate
import android.support.v4.util.LongSparseArray; //导入依赖的package包/类
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = this.getArguments();
if (bundle != null) {
selecting = bundle.getBoolean("select", false);
selectedLabelId = bundle.getLong("selected_label_id", -1L);
} else {
selecting = false;
}
if(savedInstanceState != null) {
selectedLabelId = savedInstanceState.getLong("selected_label_id", -1L);
selectedIds = savedInstanceState.getParcelable("myLongSparseBooleanArray");
}
if (selectedIds == null){
selectedIds = new LongSparseArray<>();
}
setHasOptionsMenu(true);
}
示例5: 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);
}
}
示例6: setChoiceMode
import android.support.v4.util.LongSparseArray; //导入依赖的package包/类
@TargetApi(11)
public void setChoiceMode(int choiceMode) {
this.mChoiceMode = choiceMode;
if (VERSION.SDK_INT >= 11 && this.mChoiceActionMode != null) {
if (VERSION.SDK_INT >= 11) {
((ActionMode) this.mChoiceActionMode).finish();
}
this.mChoiceActionMode = null;
}
if (this.mChoiceMode != 0) {
if (this.mCheckStates == null) {
this.mCheckStates = new SparseArrayCompat();
}
if (this.mCheckedIdStates == null && this.mAdapter != null && this.mAdapter.hasStableIds()) {
this.mCheckedIdStates = new LongSparseArray();
}
if (VERSION.SDK_INT >= 11 && this.mChoiceMode == 3) {
clearChoices();
setLongClickable(true);
}
}
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: BasicDownloader
import android.support.v4.util.LongSparseArray; //导入依赖的package包/类
/**
* Create a new instance.
*
* @param aContext
* the context to use for accessing the content provider etc
* @param aPolicyProvider
* the download policy provider to use
* @param aStatusUpdater
* the download status updater to use
*/
public BasicDownloader(final Context aContext,
final DownloadPolicyProvider aPolicyProvider,
final DownloadStatusUpdater aStatusUpdater) {
Log.d(LOG_TAG, "BasicDownloader()");
downloader = Executors.newFixedThreadPool(MAX_DOWNLOAD_THREADS,
new MinPriorityThreadFactory(this.getClass()
.getSimpleName()));
context = aContext;
statusUpdater = aStatusUpdater;
policyProvider = aPolicyProvider;
runningDownloads = new LongSparseArray<>();
wifiLocks = new LongSparseArray<>();
final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
int wifiMode = WifiManager.WIFI_MODE_FULL;
if (android.os.Build.VERSION.SDK_INT >= ANDROID_SDK_VERSION_12) {
wifiMode = WifiManager.WIFI_MODE_FULL_HIGH_PERF;
}
wifiLock = wifiManager.createWifiLock(wifiMode, this.getClass().getSimpleName());
startReadingQueueFromContentProvider();
}
示例11: 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);
}
示例12: 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);
}
示例13: 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);
}
示例14: 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;
}
示例15: 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();
}