本文整理汇总了Java中android.support.v4.util.SimpleArrayMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleArrayMap.put方法的具体用法?Java SimpleArrayMap.put怎么用?Java SimpleArrayMap.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.util.SimpleArrayMap
的用法示例。
在下文中一共展示了SimpleArrayMap.put方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setRange
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
/**
* @param start offset relative to its parent
* @param end offset relative to its parent
*/
public void setRange(int start, int end) {
mRange = Range.create(start, end);
if (!mChildren.isEmpty()) {
SimpleArrayMap<Range<Integer>, T> newMap = new SimpleArrayMap<>();
for (int i = 0, size = mChildren.size(); i < size; i++) {
T rangeStyle = mChildren.valueAt(i);
int newStart = rangeStyle.getOriginStartOffset() + start;
int newEnd = rangeStyle.getOriginEndOffset() + start;
Range<Integer> newRange = Range.create(newStart, newEnd);
newMap.put(newRange, rangeStyle);
rangeStyle.setRange(newStart, newEnd);
}
mChildren.clear();
mChildren.putAll(newMap);
}
}
示例2: prepareJob
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
@Nullable
JobInvocation prepareJob(JobCallback callback, Bundle bundle) {
JobInvocation job = prefixedCoder.decodeIntentBundle(bundle);
if (job == null) {
Log.e(TAG, "unable to decode job");
sendResultSafely(callback, JobService.RESULT_FAIL_NORETRY);
return null;
}
synchronized (callbacks) {
SimpleArrayMap<String, JobCallback> map = callbacks.get(job.getService());
if (map == null) {
map = new SimpleArrayMap<>(1);
callbacks.put(job.getService(), map);
}
map.put(job.getTag(), callback);
}
return job;
}
示例3: fromJson
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
public static SimpleArrayMap<String, Task> fromJson(String json)
throws JSONException {
LogUtils.d(TAG, "Parsing " + json);
JSONObject root = new JSONObject(json);
JSONObject jsonTasks = root.getJSONObject(KEY_TASKS);
SimpleArrayMap<String, Task> tasks = new SimpleArrayMap<>();
Iterator<String> iterator = jsonTasks.keys();
while (iterator.hasNext()) {
String cardId = iterator.next();
JSONObject jsonTask = jsonTasks.getJSONObject(cardId);
tasks.put(cardId, fromJson(cardId, jsonTask));
}
return tasks;
}
示例4: readSimpleArrayMap
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
@NonNull
static SimpleArrayMap<String, SparseIntArray> readSimpleArrayMap(Parcel in) {
int size = in.readInt();
if (size <= 0) {
return new SimpleArrayMap<>();
}
SimpleArrayMap<String, SparseIntArray> map = new SimpleArrayMap<>(size);
for (int i = 0; i < size; ++i) {
map.put(in.readString(), readSparseIntArray(in));
}
return map;
}
示例5: loadInBackground
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
@Override
public Boolean loadInBackground() {
SimpleArrayMap<String, Task> tasks = Facade.getTasks(getContext());
if (tasks != null) {
Task task = tasks.get(mCardId);
if (task == null) {
tasks.put(mCardId, new Task(
mCardId,
mIncPomodoros ? 1 : 0,
mTime
));
} else {
int pomodoros = task.getPodomoros();
if (mIncPomodoros) {
++pomodoros;
}
tasks.put(mCardId, new Task(
task.getCardId(),
pomodoros,
task.getTotalTime() + mTime
));
}
TomateApp.get().getTaskCache().setTasks(tasks);
return Facade.saveTasks(getContext(), tasks);
}
return Boolean.FALSE;
}
示例6: doExecuteSelectedTest
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
private void doExecuteSelectedTest() {
QuickTest test = mQuickTests.get(getValue(R.id.home_quick_test));
SimpleArrayMap<Integer, String> params = new SimpleArrayMap<>();
for (Integer paramsId : test.getRequiredParameters()) {
params.put(paramsId, getValue(paramsId));
}
test.execute(mLogger, getActivity(), params);
}
示例7: testEquals
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
public void testEquals() {
final SimpleArrayMap<Integer, String> arrayCompat = new SimpleArrayMap<Integer, String>();
for (int i = 0; i < 5; i++) {
arrayCompat.put(i, String.valueOf(i));
}
assertThat(SparseCollections.iterate(mArray)
.isStrictlyEqualTo(
SparseCollections.iterate(arrayCompat))).isTrue();
assertThat(SparseCollections.iterate(arrayCompat)
.isStrictlyEqualTo(SparseCollections.iterate(mArray))).isTrue();
assertThat(SparseCollections.iterate(arrayCompat)
.only()
.key(2)
.remove()
.isStrictlyEqualTo(
SparseCollections.iterate(mArray))).isFalse();
assertThat(SparseCollections.iterate(mArray)
.isStrictlyEqualTo(
SparseCollections.iterate(arrayCompat))).isFalse();
final SimpleArrayMap<Integer, String> sparseArray =
SparseCollections.iterate(mArray).toSparseArray();
assertThat(SparseCollections.iterate(mArray).isEqualTo(mArray)).isTrue();
assertThat(SparseCollections.iterate(mArray).only().first(2).isEqualTo(mArray)).isFalse();
assertThat(SparseCollections.iterate(mArray).isEqualTo(sparseArray)).isTrue();
assertThat(
SparseCollections.iterate(mArray).only().first(2).isEqualTo(sparseArray)).isFalse();
final ArrayList<ObjectSparseObjectEntry<Integer, String>> list =
SparseCollections.iterate(mArray).toImmutableList();
assertThat(SparseCollections.iterate(mArray).isEqualTo(list)).isTrue();
assertThat(SparseCollections.iterate(mArray).only().first(2).isEqualTo(list)).isFalse();
final ArrayList<ParcelableObjectSparseObjectEntry<Integer, String>> parcelableList =
SparseCollections.iterate(mArray).toParcelableList();
assertThat(SparseCollections.iterate(mArray).isEqualTo(parcelableList)).isTrue();
assertThat(SparseCollections.iterate(mArray)
.only()
.first(2)
.isEqualTo(parcelableList)).isFalse();
final Map<Integer, String> map = SparseCollections.iterate(mArray).toMap();
assertThat(SparseCollections.iterate(mArray).isEqualTo(map)).isTrue();
assertThat(SparseCollections.iterate(mArray).only().first(2).isEqualTo(map)).isFalse();
final SortedMap<Integer, String> sortedMap =
SparseCollections.iterate(mArray).toSortedMap();
assertThat(SparseCollections.iterate(mArray).isEqualTo(sortedMap)).isTrue();
assertThat(
SparseCollections.iterate(mArray).only().first(2).isEqualTo(sortedMap)).isFalse();
mArray.put(7, "7");
assertThat(SparseCollections.iterate(mArray).isEqualTo(sparseArray)).isFalse();
assertThat(SparseCollections.iterate(mArray).but().last(1).isEqualTo(sparseArray)).isTrue();
assertThat(SparseCollections.iterate(mArray).isEqualTo(list)).isFalse();
assertThat(SparseCollections.iterate(mArray).but().last(1).isEqualTo(list)).isTrue();
assertThat(SparseCollections.iterate(mArray).isEqualTo(parcelableList)).isFalse();
assertThat(
SparseCollections.iterate(mArray).but().last(1).isEqualTo(parcelableList)).isTrue();
assertThat(SparseCollections.iterate(mArray).isEqualTo(map)).isFalse();
assertThat(SparseCollections.iterate(mArray).but().last(1).isEqualTo(map)).isTrue();
assertThat(SparseCollections.iterate(mArray).isEqualTo(sortedMap)).isFalse();
assertThat(SparseCollections.iterate(mArray).but().last(1).isEqualTo(sortedMap)).isTrue();
}
示例8: testEquals
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
public void testEquals() {
assertThat(mArray).isEqualTo(mArray);
assertThat(mArray.equals(mArray)).isTrue();
final EnhancedArrayMap<Integer, String> array = new EnhancedArrayMap<Integer, String>();
for (int i = 0; i < 5; i++) {
array.put(i, String.valueOf(i));
}
assertThat(mArray).isEqualTo(array);
assertThat(array).isEqualTo(mArray);
assertThat(mArray.equals(array)).isTrue();
assertThat(array.equals(mArray)).isTrue();
final SimpleArrayMap<Integer, String> simpleArray = new SimpleArrayMap<Integer, String>();
for (int i = 0; i < 5; i++) {
simpleArray.put(i, String.valueOf(i));
}
assertThat(mArray.equals(simpleArray)).isTrue();
assertThat(simpleArray.equals(mArray)).isFalse();
}
示例9: putInto
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
@Override
public SimpleArrayMapIterable<K, V> putInto(final SimpleArrayMap<K, V> other) {
for (final SimpleArrayMapEntry<K, V> entry : this) {
other.put(entry.getKey(), entry.getValue());
}
return this;
}
示例10: replaceValues
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
@Override
public SimpleArrayMapIterable<K, V> replaceValues(final Translator<V, V> translator) {
final SimpleArrayMap<K, V> arrayMap = mArrayMap;
for (final SimpleArrayMapEntry<K, V> entry : this) {
arrayMap.put(entry.getKey(), translator.translate(entry.getValue()));
}
return this;
}
示例11: toSparseArray
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
@Override
public SimpleArrayMap<K, V> toSparseArray() {
final SimpleArrayMap<K, V> array = new SimpleArrayMap<K, V>();
for (final SimpleArrayMapEntry<K, V> entry : this) {
array.put(entry.getKey(), entry.getValue());
}
return array;
}
示例12: setUp
import android.support.v4.util.SimpleArrayMap; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
final SimpleArrayMap<Integer, String> array = new SimpleArrayMap<Integer, String>();
for (int i = 0; i < 5; i++) {
array.put(i, String.valueOf(i));
}
mArray = array;
}