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