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


Java SparseArrayCompat.put方法代码示例

本文整理汇总了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();
}
 
开发者ID:Laaidback,项目名称:A.scribe,代码行数:17,代码来源:FragmentStatePagerAdapter2.java

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

示例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);
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:22,代码来源:OffsetTestActivity2.java

示例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;
}
 
开发者ID:dmfs,项目名称:opentasks,代码行数:17,代码来源:BaseTaskViewDescriptor.java

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

示例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);
    }
}
 
开发者ID:Cleveroad,项目名称:AdaptiveTableLayout,代码行数:18,代码来源:SparseMatrix.java

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

示例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;
}
 
开发者ID:ownwell,项目名称:zztinews,代码行数:22,代码来源:CommonViewHolder.java

示例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;
}
 
开发者ID:davide-maestroni,项目名称:robo-fashion,代码行数:11,代码来源:SparseArrayCompatIterableImpl.java


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