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


Java SparseArray.get方法代码示例

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


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

示例1: retrieveFromScrap

import android.util.SparseArray; //导入方法依赖的package包/类
static View retrieveFromScrap(SparseArray<View> scrapViews, int position) {
    int size = scrapViews.size();
    if (size <= 0) {
        return null;
    }
    for (int i = 0; i < size; i++) {
        int fromPosition = scrapViews.keyAt(i);
        View view = (View) scrapViews.get(fromPosition);
        if (fromPosition == position) {
            scrapViews.remove(fromPosition);
            return view;
        }
    }
    int index = size - 1;
    View r = (View) scrapViews.valueAt(index);
    scrapViews.remove(scrapViews.keyAt(index));
    return r;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:RecycleBin.java

示例2: retrieveFromScrap

import android.util.SparseArray; //导入方法依赖的package包/类
static View retrieveFromScrap(SparseArray<View> scrapViews, int position) {
  int size = scrapViews.size();
  if (size > 0) {
    // See if we still have a view for this position.
    for (int i = 0; i < size; i++) {
      int fromPosition = scrapViews.keyAt(i);
      View view = scrapViews.get(fromPosition);
      if (fromPosition == position) {
        scrapViews.remove(fromPosition);
        return view;
      }
    }
    int index = size - 1;
    View r = scrapViews.valueAt(index);
    scrapViews.remove(scrapViews.keyAt(index));
    return r;
  } else {
    return null;
  }
}
 
开发者ID:AndroidBoySC,项目名称:Mybilibili,代码行数:21,代码来源:RecycleBin.java

示例3: loadToCacheAndInsert

import android.util.SparseArray; //导入方法依赖的package包/类
@Test
public void loadToCacheAndInsert() {
    final SparseArray<BreakpointInfo> infoSparseArray = helper.loadToCache();
    assertThat(infoSparseArray.size()).isEqualTo(2);

    final BreakpointInfo info1 = infoSparseArray.get(insertedInfo1.id);
    assertThat(info1.getBlockCount()).isEqualTo(1);
    assertThat(info1.getUrl()).isEqualTo("url1");
    assertThat(info1.parentPath).isEqualTo("p-path1");
    assertThat(info1.getFilename()).isNull();

    final BreakpointInfo info2 = infoSparseArray.get(insertedInfo2.id);
    assertThat(info2.getBlockCount()).isEqualTo(2);
    assertThat(info2.getUrl()).isEqualTo("url2");
    assertThat(info2.parentPath).isEqualTo("p-path2");
    assertThat(info2.getFilename()).isEqualTo("filename2");
}
 
开发者ID:lingochamp,项目名称:okdownload,代码行数:18,代码来源:BreakpointSQLiteHelperTest.java

示例4: getTMXTileProperties

import android.util.SparseArray; //导入方法依赖的package包/类
public TMXProperties<TMXTileProperty> getTMXTileProperties(final int pGlobalTileID) {
	final SparseArray<TMXProperties<TMXTileProperty>> globalTileIDToTMXTilePropertiesCache = this.mGlobalTileIDToTMXTilePropertiesCache;

	final TMXProperties<TMXTileProperty> cachedTMXTileProperties = globalTileIDToTMXTilePropertiesCache
			.get(pGlobalTileID);
	if (cachedTMXTileProperties != null) {
		return cachedTMXTileProperties;
	} else {
		final ArrayList<TMXTileSet> tmxTileSets = this.mTMXTileSets;

		for (int i = tmxTileSets.size() - 1; i >= 0; i--) {
			final TMXTileSet tmxTileSet = tmxTileSets.get(i);
			if (pGlobalTileID >= tmxTileSet.getFirstGlobalTileID()) {
				return tmxTileSet.getTMXTilePropertiesFromGlobalTileID(pGlobalTileID);
			}
		}
		throw new IllegalArgumentException("No TMXTileProperties found for pGlobalTileID=" + pGlobalTileID);
	}
}
 
开发者ID:Linguaculturalists,项目名称:Phoenicia,代码行数:20,代码来源:TMXTiledMap.java

示例5: 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:wp521,项目名称:MyFire,代码行数:15,代码来源:ViewHolderUtil.java

示例6: 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:Gericop,项目名称:DateTimePicker,代码行数:23,代码来源:NumberPicker.java

示例7: getView

import android.util.SparseArray; //导入方法依赖的package包/类
/**
 * 用法: ImageView bananaView = ViewHolder.get(convertView, R.id.banana);
 * 
 * @param convertView
 * @param id
 * @return
 */
@SuppressWarnings("unchecked")
public static <T extends View> T getView(View convertView, int id) {
	SparseArray<View> viewHolder = (SparseArray<View>) convertView.getTag();
	if (viewHolder == null) {
		viewHolder = new SparseArray<View>();
		convertView.setTag(viewHolder);
	}
	View childView = viewHolder.get(id);
	if (childView == null) {
		childView = convertView.findViewById(id);
		viewHolder.put(id, childView);
	}
	return (T) childView;
}
 
开发者ID:kevinbobby,项目名称:NavigatorBar,代码行数:22,代码来源:ViewHolderUtil.java

示例8: addViewsInSection

import android.util.SparseArray; //导入方法依赖的package包/类
private void addViewsInSection(SparseArray<View> items, LinearLayout parent, int itemWidth) {

            for (int i = 0; i < items.size(); i++) {
                View itemView = items.get(i);
                setItemWidth(itemView, itemWidth);
                parent.addView(itemView);
            }
        }
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:9,代码来源:QMUIBottomSheet.java

示例9: getMainAvatorPath

import android.util.SparseArray; //导入方法依赖的package包/类
@Override
public String getMainAvatorPath() {
    SparseArray<String> sparseArray=dragSquare.getImageUrls();
    String mainPath;
    mainPath=sparseArray.get(0);
    return mainPath;
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:8,代码来源:DraggablePresenterImpl.java

示例10: getCurrentSavedState

import android.util.SparseArray; //导入方法依赖的package包/类
private Fragment.SavedState getCurrentSavedState(int position) {
    SparseArray<Fragment.SavedState> states = mSavedState.get(position);
    if (states != null) {
        return states.get(getCurrentViewMode(position));
    } else {
        return null;
    }
}
 
开发者ID:mocircle,项目名称:devsuite-android,代码行数:9,代码来源:MultiFragmentStatePagerAdapter.java

示例11: getCurrentFragment

import android.util.SparseArray; //导入方法依赖的package包/类
private Fragment getCurrentFragment(int position) {
    SparseArray<Fragment> fragments = mFragments.get(position);
    if (fragments != null) {
        return fragments.get(getCurrentViewMode(position));
    } else {
        return null;
    }
}
 
开发者ID:mocircle,项目名称:devsuite-android,代码行数:9,代码来源:MultiFragmentStatePagerAdapter.java

示例12: setLastIn

import android.util.SparseArray; //导入方法依赖的package包/类
private void setLastIn(SparseArray<Fragment> firstOutFragments, SparseArray<Fragment> lastInFragments, Fragment fragment) {
    if (fragment != null) {
        int containerId = fragment.mContainerId;
        if (containerId != 0) {
            if (!fragment.isAdded()) {
                lastInFragments.put(containerId, fragment);
            }
            if (firstOutFragments.get(containerId) == fragment) {
                firstOutFragments.remove(containerId);
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:BackStackRecord.java

示例13: getIsolatedUid

import android.util.SparseArray; //导入方法依赖的package包/类
private int getIsolatedUid(int uid) {
	if (PrivacyManager.isIsolated(uid))
		try {
			Field fmIsolatedProcesses = null;
			Class<?> cam = mAm.getClass();
			while (cam != null && fmIsolatedProcesses == null)
				try {
					fmIsolatedProcesses = cam.getDeclaredField("mIsolatedProcesses");
				} catch (NoSuchFieldException ignored) {
					cam = cam.getSuperclass();
				}

			if (fmIsolatedProcesses == null)
				throw new Exception(mAm.getClass().getName() + ".mIsolatedProcesses not found");

			fmIsolatedProcesses.setAccessible(true);
			SparseArray<?> mIsolatedProcesses = (SparseArray<?>) fmIsolatedProcesses.get(mAm);
			Object processRecord = mIsolatedProcesses.get(uid);
			Field fInfo = processRecord.getClass().getDeclaredField("info");
			fInfo.setAccessible(true);
			ApplicationInfo info = (ApplicationInfo) fInfo.get(processRecord);

			Util.log(null, Log.WARN, "Translated isolated uid=" + uid + " into application uid=" + info.uid
					+ " pkg=" + info.packageName);
			return info.uid;
		} catch (Throwable ex) {
			Util.bug(null, ex);
		}
	return uid;
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:31,代码来源:PrivacyService.java

示例14: getRow

import android.util.SparseArray; //导入方法依赖的package包/类
List<String> getRow(int rowIndex) {
        List<String> result = new ArrayList<>();

        // cache logic. Show field after not saved changes
        List<String> cachedRow = mItemsCache.get(rowIndex);
        if (cachedRow != null && !cachedRow.isEmpty()) {
            SparseArray<String> changedRow = mChangedItems.get(rowIndex);
            if (changedRow != null && changedRow.size() > 0) {
                for (int count = cachedRow.size(), i = 0; i < count; i++) {
                    String cachedItem = cachedRow.get(i);
                    String changedItem = changedRow.get(i);
                    result.add(TextUtils.isEmpty(changedItem) ? cachedItem : changedItem);
                }
            } else {
                result.addAll(cachedRow);
            }
        }


        if (!result.isEmpty()) {
            return result;
        }

        //read from file
        InputStreamReader fileReader = null;

        try {
            fileReader = getInputStreamReader();
            int cacheRowIndex = rowIndex < READ_FILE_LINES_LIMIT ? 0 : rowIndex - READ_FILE_LINES_LIMIT;
            //skip upper lines
            Scanner scanner = new Scanner(fileReader).skip("(?:.*\\r?\\n|\\r){" + cacheRowIndex + "}");

//            for (int i = 0; i < cacheRowIndex; i++) {
//                scanner.nextLine();
//            }

            int cacheRowLimitIndex = cacheRowIndex + READ_FILE_LINES_LIMIT + READ_FILE_LINES_LIMIT;
            //on scroll to bottom
            for (int i = cacheRowIndex; i < getRowsCount() && i < cacheRowLimitIndex && scanner.hasNextLine(); i++) {
                List<String> line = new ArrayList<>(CsvUtils.parseLine(scanner.nextLine()));
                mItemsCache.put(i, line);
                if (i == rowIndex) {
                    result.addAll(line);
                }
            }

            // clear cache
            Iterator<Map.Entry<Integer, List<String>>> iterator = mItemsCache.entrySet().iterator();
            while (iterator.hasNext()) {
                Map.Entry<Integer, List<String>> entry = iterator.next();
                if (entry.getKey() < cacheRowIndex || entry.getKey() > cacheRowLimitIndex) {
                    iterator.remove();
                }
            }

        } catch (Exception e) {
            Log.e(TAG, "getRow method error ", e);
        } finally {
            ClosableUtil.closeWithoutException(fileReader);
        }

        return result;
    }
 
开发者ID:Cleveroad,项目名称:AdaptiveTableLayout,代码行数:64,代码来源:CsvFileDataSourceImpl.java

示例15: readTrackPointFormDataBase

import android.util.SparseArray; //导入方法依赖的package包/类
/**
 * 按日期检索位置信息,以升序形式返回
 * @param dayTime
 * @return
 */
public SparseArray<List<TrackPoint>> readTrackPointFormDataBase(String dayTime) {
    SparseArray<List<TrackPoint>> groupResult = new SparseArray<>();

    SQLiteDatabase db = mLocationDataBase.getReadableDatabase();

    int recordCount = queryRecordCountToday(dayTime);
    for(int i=0;i <= recordCount;i++) {
        String query_sql = "select * from " + LocationDataBase.TABLE_LOCATION
                + " where " + LocationDataBase.FILED_TIME_DAY + " = " + dayTime
            + " and "+ LocationDataBase.FILED_RECORD_COUNT + " = " + i
                + " order by " + LocationDataBase.FILED_TIME_STAMP + " asc ";
        Cursor cursor = db.rawQuery(query_sql, null);
        try {
            while (cursor.moveToNext()) {
                int latitudeIndex = cursor.getColumnIndex(LocationDataBase.FILED_LATITUDE);
                int longitudeIndex = cursor.getColumnIndex(LocationDataBase.FILED_LONGITUDE);
                int timeStampIndex = cursor.getColumnIndex(LocationDataBase.FILED_TIME_STAMP);
                int buildingIndex = cursor.getColumnIndex(LocationDataBase.FILED_BUILD_NAME);
                int countIndex = cursor.getColumnIndex(LocationDataBase.FILED_RECORD_COUNT);
                double latitude = cursor.getDouble(latitudeIndex);
                double longitude = cursor.getDouble(longitudeIndex);
                long timeStamp = Long.valueOf(cursor.getString(timeStampIndex));
                String building = cursor.getString(buildingIndex);
                int count = cursor.getInt(countIndex);
                List<TrackPoint> pointList = groupResult.get(count);
                if (pointList == null) {
                    pointList = new ArrayList<>();
                    groupResult.put(count, pointList);
                }
                TrackPoint point = new TrackPoint(new LatLng(latitude, longitude), building, timeStamp);
                pointList.add(point);
            }
        } finally {
            if (cursor != null) {
                cursor.close();
            }
        }
    }
    return groupResult;
}
 
开发者ID:stdnull,项目名称:RunMap,代码行数:46,代码来源:DataManager.java


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