本文整理汇总了Java中android.support.v4.util.SparseArrayCompat.put方法的典型用法代码示例。如果您正苦于以下问题:Java SparseArrayCompat.put方法的具体用法?Java SparseArrayCompat.put怎么用?Java SparseArrayCompat.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.util.SparseArrayCompat
的用法示例。
在下文中一共展示了SparseArrayCompat.put方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyDataSetChanged
import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
@Override
public void notifyDataSetChanged() {
SparseArrayCompat<Fragment> newFragments =
new SparseArrayCompat<>(fragments.size());
for (int i = 0; i < fragments.size(); i++) {
final int oldPos = fragments.keyAt(i);
final Fragment f = fragments.valueAt(i);
final int newPos = getItemPosition(f);
if (newPos != POSITION_NONE) {
final int pos = (newPos >= 0) ? newPos : oldPos;
newFragments.put(pos, f);
}
}
fragments = newFragments;
super.notifyDataSetChanged();
}
示例2: onCreate
import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.offset_activity_test);
ItemsAdapter adapter = new ItemsAdapter(this);
adapter.setList(new ItemPagedList(this));
manage(adapter);
SparseArrayCompat<Integer> offsetItems = new SparseArrayCompat<>();
offsetItems.put(1, Integer.MAX_VALUE - 1);
offsetItems.put(10, Integer.MAX_VALUE - 2);
OffsetTestAdapter offsetAdapter = new OffsetTestAdapter(this, adapter, offsetItems);
manage(offsetAdapter);
RecyclerView items = (RecyclerView) findViewById(R.id.items);
items.setLayoutManager(new LinearLayoutManager(this));
items.setAdapter(offsetAdapter);
}
示例3: onCreate
import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.offset_activity_test);
ItemsAdapter adapter = new ItemsAdapter(this);
adapter.setList(new ItemPagedList(this));
manage(adapter);
SparseArrayCompat<Integer> offsetItems = new SparseArrayCompat<>();
offsetItems.put(0, Integer.MAX_VALUE - 1);
offsetItems.put(1, Integer.MAX_VALUE - 2);
offsetItems.put(2, Integer.MAX_VALUE - 3);
OffsetTestAdapter offsetAdapter = new OffsetTestAdapter(this, adapter, offsetItems);
manage(offsetAdapter);
RecyclerView items = (RecyclerView) findViewById(R.id.items);
items.setLayoutManager(new LinearLayoutManager(this));
items.setAdapter(offsetAdapter);
}
示例4: getView
import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
protected <T extends View> T getView(View view, int viewId)
{
SparseArrayCompat<View> viewHolder = (SparseArrayCompat<View>) view.getTag();
if (viewHolder == null)
{
viewHolder = new SparseArrayCompat<View>();
view.setTag(viewHolder);
}
View res = viewHolder.get(viewId);
if (res == null)
{
res = view.findViewById(viewId);
viewHolder.put(viewId, res);
}
return (T) res;
}
示例5: switchHeaders
import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
/**
* Method switch view holders in map (map with headers view holders).
*
* @param map header view holder's map
* @param fromIndex index from view holder
* @param toIndex index to view holder
* @param type type of items (column header or row header)
*/
@SuppressWarnings("unused")
private void switchHeaders(SparseArrayCompat<ViewHolder> map, int fromIndex, int toIndex, int type) {
ViewHolder fromVh = map.get(fromIndex);
if (fromVh != null) {
map.remove(fromIndex);
if (type == ViewHolderType.COLUMN_HEADER) {
fromVh.setColumnIndex(toIndex);
} else if (type == ViewHolderType.ROW_HEADER) {
fromVh.setRowIndex(toIndex);
}
}
ViewHolder toVh = map.get(toIndex);
if (toVh != null) {
map.remove(toIndex);
if (type == ViewHolderType.COLUMN_HEADER) {
toVh.setColumnIndex(fromIndex);
} else if (type == ViewHolderType.ROW_HEADER) {
toVh.setRowIndex(fromIndex);
}
}
if (fromVh != null) {
map.put(toIndex, fromVh);
}
if (toVh != null) {
map.put(fromIndex, toVh);
}
}
示例6: put
import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
/**
* Put item to the matrix in row, column position.
*
* @param row item row position
* @param column item column position
* @param item Object
*/
void put(int row, int column, @NonNull TObj item) {
SparseArrayCompat<TObj> array = mData.get(row);
if (array == null) {
array = new SparseArrayCompat<>();
array.put(column, item);
mData.put(row, array);
} else {
array.put(column, item);
}
}
示例7: parseChars
import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
private static void parseChars(
JsonReader reader, LottieComposition composition,
SparseArrayCompat<FontCharacter> characters) throws IOException {
reader.beginArray();
while (reader.hasNext()) {
FontCharacter character = FontCharacterParser.parse(reader, composition);
characters.put(character.hashCode(), character);
}
reader.endArray();
}
示例8: get
import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
/**
* 用于获取ItemView中的控件
*
* @param view ItemView
* @param id 要获取的控件的id
* @param <T> 返回的控件的类型
* @return 返回的控件
*/
public static <T extends View> T get(View view, int id) {
SparseArrayCompat<View> viewHolder = (SparseArrayCompat<View>) view.getTag();
if (viewHolder == null) {
viewHolder = new SparseArrayCompat<>();
view.setTag(viewHolder);
}
View childView = viewHolder.get(id);
if (childView == null) {
childView = view.findViewById(id);
viewHolder.put(id, childView);
}
return (T) childView;
}
示例9: putInto
import android.support.v4.util.SparseArrayCompat; //导入方法依赖的package包/类
@Override
public SparseArrayCompatIterable<V> putInto(final SparseArrayCompat<V> other) {
for (final SparseArrayEntry<V> entry : this) {
other.put(entry.getKey(), entry.getValue());
}
return this;
}