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


Java SparseArray.put方法代码示例

本文整理汇总了Java中android.util.SparseArray.put方法的典型用法代码示例。如果您正苦于以下问题:Java SparseArray.put方法的具体用法?Java SparseArray.put怎么用?Java SparseArray.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.util.SparseArray的用法示例。


在下文中一共展示了SparseArray.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getView

import android.util.SparseArray; //导入方法依赖的package包/类
/**
 * findViewById
 * @param rootView
 * @param viewId
 * @param <T>
 * @return
 */
public static <T extends View> T getView(View rootView, int viewId) {
    SparseArray<View> views = null;

    Object tag = rootView.getTag();
    if (tag != null && tag instanceof SparseArray) {
        views = (SparseArray<View>)tag;
    }

    if(views == null){
        views = new SparseArray<>();
        rootView.setTag(views);
    }

    View view = views.get(viewId);
    if (view == null) {
        view = rootView.findViewById(viewId);
        views.put(viewId, view);
    }
    return (T) view;
}
 
开发者ID:A-Miracle,项目名称:QiangHongBao,代码行数:28,代码来源:ViewUtils.java

示例2: ensureCachedScrollSelectorValue

import android.util.SparseArray; //导入方法依赖的package包/类
/**
 * Ensures we have a cached string representation of the given <code>
 * selectorIndex</code> to avoid multiple instantiations of the same string.
 */
private void ensureCachedScrollSelectorValue(int selectorIndex) {
    SparseArray<String> cache = mSelectorIndexToStringCache;
    String scrollSelectorValue = cache.get(selectorIndex);
    if (scrollSelectorValue != null) {
        return;
    }
    if (selectorIndex < mMinValue || selectorIndex > mMaxValue) {
        scrollSelectorValue = "";
    } else {
        if (mDisplayedValues != null) {
            int displayedValueIndex = selectorIndex - mMinValue;
            scrollSelectorValue = mDisplayedValues[displayedValueIndex];
        } else {
            scrollSelectorValue = formatNumber(selectorIndex);
        }
    }
    cache.put(selectorIndex, scrollSelectorValue);
}
 
开发者ID:h6ah4i,项目名称:android-numberpickercompat,代码行数:23,代码来源:NumberPicker.java

示例3: hold

import android.util.SparseArray; //导入方法依赖的package包/类
/**
 * ViewHolder简洁写法,避免适配器中重复定义ViewHolder,减少代码量 用法:
 * 
 * <pre>
 * if (convertView == null)
 * {
 * 	convertView = View.inflate(context, R.layout.ad_demo, null);
 * }
 * TextView tv_demo = ViewHolderUtils.get(convertView, R.id.tv_demo);
 * ImageView iv_demo = ViewHolderUtils.get(convertView, R.id.iv_demo);
 * </pre>
 */
public static <T extends View> T hold(View view, int id)
{
	SparseArray<View> viewHolder = (SparseArray<View>) view.getTag();

	if (viewHolder == null)
	{
		viewHolder = new SparseArray<View>();
		view.setTag(viewHolder);
	}

	View childView = viewHolder.get(id);

	if (childView == null)
	{
		childView = view.findViewById(id);
		viewHolder.put(id, childView);
	}

	return (T) childView;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:ViewFindUtils.java

示例4: addAndGetModel

import android.util.SparseArray; //导入方法依赖的package包/类
private synchronized Listener4Model addAndGetModel(BreakpointInfo info) {
    SparseArray<Long> blockCurrentOffsetMap = new SparseArray<>();
    final int blockCount = info.getBlockCount();
    for (int i = 0; i < blockCount; i++) {
        final BlockInfo blockInfo = info.getBlock(i);
        blockCurrentOffsetMap.put(i, blockInfo.getCurrentOffset());
    }

    Listener4Model model = new Listener4Model(info, info.getTotalOffset(),
            blockCurrentOffsetMap);

    if (assistExtend != null) model = assistExtend.inspectAddModel(model);

    if (singleTaskModel == null || singleTaskModel.info.getId() == info.getId()) {
        singleTaskModel = model;
    } else {
        modelList.put(info.getId(), model);
    }

    return model;
}
 
开发者ID:lingochamp,项目名称:okdownload,代码行数:22,代码来源:Listener4Assist.java

示例5: getIMAddressesMap

import android.util.SparseArray; //导入方法依赖的package包/类
private SparseArray<List<IMAddress>> getIMAddressesMap() {
    SparseArray<List<IMAddress>> idImAddressMap = new SparseArray<>();
    Cursor cur = getCursorFromContentType(new String[]{ID_KEY, MAIN_DATA_KEY, Im.PROTOCOL, Im.CUSTOM_PROTOCOL}, Im.CONTENT_ITEM_TYPE);
    if (cur != null) {
        while (cur.moveToNext()) {
            int id = cur.getInt(cur.getColumnIndex(ID_KEY));
            String data = cur.getString(cur.getColumnIndex(MAIN_DATA_KEY));
            int labelId = cur.getInt(cur.getColumnIndex(Im.PROTOCOL));
            String customLabel = cur.getString(cur.getColumnIndex(Im.CUSTOM_PROTOCOL));
            IMAddress current;
            if (customLabel == null)
                current = new IMAddress(mCtx, data, labelId);
            else
                current = new IMAddress(data, customLabel);
            List<IMAddress> currentWebsiteList = idImAddressMap.get(id);
            if (currentWebsiteList == null) {
                currentWebsiteList = new ArrayList<>();
                currentWebsiteList.add(current);
                idImAddressMap.put(id, currentWebsiteList);
            } else currentWebsiteList.add(current);
        }
        cur.close();
    }
    return idImAddressMap;
}
 
开发者ID:blainepwnz,项目名称:AndroidContacts,代码行数:26,代码来源:ContactsGetter.java

示例6: showFab

import android.util.SparseArray; //导入方法依赖的package包/类
private void showFab(int tabPosition) {
    SparseArray<FloatingActionButton> positionToFab = new SparseArray<>();
    positionToFab.put(1, addArtistFab);
    positionToFab.put(2, addLocationFab);

    ScreenUtils.remainRightFab(positionToFab.get(tabPosition, null), allFabs);
}
 
开发者ID:andreybgm,项目名称:gigreminder,代码行数:8,代码来源:MainActivity.java

示例7: cleanFiles

import android.util.SparseArray; //导入方法依赖的package包/类
/**
 * 将所选文件添加到清理列表中
 */
private void cleanFiles() {
    ArrayList<String> _cleanPathList = new ArrayList<>(_adapter.get_checkList().size());
    SparseArray<SDFile> _cleanFiles = new SparseArray<>(_adapter.get_checkList().size());
    for (int _position : _adapter.get_checkList()) {
        _cleanPathList.add(_adapter.get_data().get_children().get(_position).get_path());
        _cleanFiles.put(_position, _adapter.get_data().get_children().get(_position));
    }
    Global.add_cleanList(_cleanPathList);
    showProgress(ACTION_CLEAN, _cleanFiles.size());
    new UpdateRubbishThread(_cleanFiles).start();
}
 
开发者ID:bonepeople,项目名称:SDCardCleaner,代码行数:15,代码来源:FileListActivity.java

示例8: get

import android.util.SparseArray; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static <T extends View> T get(View view, int id) {
	SparseArray<View> viewHolder = (SparseArray<View>) view.getTag();
	if (viewHolder == null) {
		viewHolder = new SparseArray<View>();
		view.setTag(viewHolder);
	}
	View childView = viewHolder.get(id);
	if (childView == null) {
		childView = view.findViewById(id);
		viewHolder.put(id, childView);
	}
	return (T) childView;
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:15,代码来源:ViewHolder.java

示例9: scrapActiveViews

import android.util.SparseArray; //导入方法依赖的package包/类
/**
 * Move all views remaining in activeViews to scrapViews.
 */
void scrapActiveViews() {
    final View[] activeViews = this.activeViews;
    final int[] activeViewTypes = this.activeViewTypes;
    final boolean multipleScraps = viewTypeCount > 1;

    SparseArray<View> scrapViews = currentScrapViews;
    final int count = activeViews.length;
    for (int i = count - 1; i >= 0; i--) {
        final View victim = activeViews[i];
        if (victim != null) {
            int whichScrap = activeViewTypes[i];

            activeViews[i] = null;
            activeViewTypes[i] = -1;

            if (!shouldRecycleViewType(whichScrap)) {
                continue;
            }

            if (multipleScraps) {
                scrapViews = this.scrapViews[whichScrap];
            }
            scrapViews.put(i, victim);

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                victim.setAccessibilityDelegate(null);
            }
        }
    }

    pruneScrapViews();
}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:36,代码来源:RecyclingPagerAdapter.java

示例10: filterOutNoExist

import android.util.SparseArray; //导入方法依赖的package包/类
private synchronized void filterOutNoExist() {
    SparseArray<DownloadLaunchRunnable> correctedRunnablePool = new SparseArray<>();
    final int size = runnablePool.size();
    for (int i = 0; i < size; i++) {
        final int key = runnablePool.keyAt(i);
        final DownloadLaunchRunnable runnable = runnablePool.get(key);
        if (runnable.isAlive()) {
            correctedRunnablePool.put(key, runnable);
        }
    }
    runnablePool = correctedRunnablePool;
}
 
开发者ID:yannanzheng,项目名称:FileDownloader-master,代码行数:13,代码来源:FileDownloadThreadPool.java

示例11: getLayoutIdMap

import android.util.SparseArray; //导入方法依赖的package包/类
@Override
protected SparseArray<Integer> getLayoutIdMap() {
        SparseArray<Integer> result = new SparseArray<>();
        result.put(Demo.TYPE_NORMAL, R.layout.demo_normal_layout);
        result.put(Demo.TYPE_SPECIAL, R.layout.demo_special_layout);
        return result;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:8,代码来源:DemoAdapter.java

示例12: initSkin

import android.util.SparseArray; //导入方法依赖的package包/类
/**
 * Copy skin from assets.
 */
void initSkin(Context context) {
    SparseArray<String> array = new SparseArray<>();
    array.put(R.raw.skin_vivid, "生动皮肤");
    array.put(R.raw.skin_plain, "普通皮肤");
    File root = new File(SKIN_ROOT);
    if (!root.exists()) {
        root.mkdirs();
    }
    for (int i = 0; i < array.size(); i++) {
        copySkinArchive(context, array.keyAt(i), SKIN_ROOT + File.separator + array.valueAt(i) + SKIN_SUFFIX);
    }
}
 
开发者ID:Zeal27,项目名称:SkinFramework,代码行数:16,代码来源:SkinHelper.java

示例13: getIncomingMessages

import android.util.SparseArray; //导入方法依赖的package包/类
SparseArray<ConversationItem> getIncomingMessages() {
	SparseArray<ConversationItem> messages = new SparseArray<>();

	for (int i = 0; i < items.size(); i++) {
		ConversationItem item = items.get(i);
		if (item.isIncoming()) {
			messages.put(i, item);
		}
	}
	return messages;
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:12,代码来源:ConversationAdapter.java

示例14: loadTravelersSuccess

import android.util.SparseArray; //导入方法依赖的package包/类
protected Response.Listener<JSONArray> loadTravelersSuccess() {
    return new Response.Listener<JSONArray>() {
        @Override
        public void onResponse(JSONArray response) {
            try {
                SparseArray<Traveler> sparseArray = new SparseArray<Traveler>();

                for (int i = 0; i < response.length(); i++) {
                    Traveler traveler = new Traveler(
                            response.getJSONObject(i).getInt("id"),
                            response.getJSONObject(i).getString("firstName"),
                            response.getJSONObject(i).getString("lastName"),
                            response.getJSONObject(i).getString("email"),
                            response.getJSONObject(i).getString("uid")
                    );

                    if (traveler.getId() != currentUser.getId()) {
                        // Only add traveler if it's not me.
                        sparseArray.put(traveler.getId(), traveler);
                    }
                }

                TravelerAdapter adapter = new TravelerAdapter(sparseArray);
                mListView.setAdapter(adapter);
            } catch (JSONException e) {
                Toast.makeText(ListPublicChatMembersActivity.this, TAG + ": " + e.getMessage(), Toast.LENGTH_SHORT).show();
            }
        }
    };
}
 
开发者ID:trvlrch,项目名称:trvlr-android,代码行数:31,代码来源:ListPublicChatMembersActivity.java

示例15: scrapActiveViews

import android.util.SparseArray; //导入方法依赖的package包/类
/** Move all views remaining in activeViews to scrapViews. */
void scrapActiveViews() {
  final View[] activeViews = this.activeViews;
  final int[] activeViewTypes = this.activeViewTypes;
  final boolean multipleScraps = viewTypeCount > 1;

  SparseArray<View> scrapViews = currentScrapViews;
  final int count = activeViews.length;
  for (int i = count - 1; i >= 0; i--) {
    final View victim = activeViews[i];
    if (victim != null) {
      int whichScrap = activeViewTypes[i];

      activeViews[i] = null;
      activeViewTypes[i] = -1;

      if (!shouldRecycleViewType(whichScrap)) {
        continue;
      }

      if (multipleScraps) {
        scrapViews = this.scrapViews[whichScrap];
      }
      scrapViews.put(i, victim);

      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        victim.setAccessibilityDelegate(null);
      }
    }
  }

  pruneScrapViews();
}
 
开发者ID:LineChen,项目名称:Month_Calendar,代码行数:34,代码来源:RecycleBin.java


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