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


Java LongSparseArray类代码示例

本文整理汇总了Java中android.util.LongSparseArray的典型用法代码示例。如果您正苦于以下问题:Java LongSparseArray类的具体用法?Java LongSparseArray怎么用?Java LongSparseArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getKeyPairs

import android.util.LongSparseArray; //导入依赖的package包/类
private Single<LongSparseArray<AesKeyPair>> getKeyPairs(final int accountId, final List<Pair<Integer, Long>> tokens) {
    return Single.create(emitter -> {
        LongSparseArray<AesKeyPair> keys = new LongSparseArray<>(tokens.size());

        for (Pair<Integer, Long> token : tokens) {
            if (emitter.isDisposed()) {
                break;
            }

            final long sessionId = token.getSecond();
            final int keyPolicy = token.getFirst();

            AesKeyPair keyPair = store.keys(keyPolicy).findKeyPairFor(accountId, sessionId).blockingGet();

            if (nonNull(keyPair)) {
                keys.append(sessionId, keyPair);
            }
        }

        emitter.onSuccess(keys);
    });
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:23,代码来源:MessagesDecryptor.java

示例2: walkroundActionMenuTextColor

import android.util.LongSparseArray; //导入依赖的package包/类
public static void walkroundActionMenuTextColor(Resources res){
    try {
        if (Build.VERSION.SDK_INT>=16 && Build.VERSION.SDK_INT <= 19) {
            final long key = (((long) -1) << 32) | 0x7f010082;
            if(walkroundStateList==null) {
                walkroundStateList = ColorStateList.valueOf(Color.rgb(0, 0, 0));
            }
            Field mColorStateListCacheField = AndroidHack.findField(res, "mColorStateListCache");
            mColorStateListCacheField.setAccessible(true);
            LongSparseArray mColorStateListCache = (LongSparseArray) mColorStateListCacheField.get(res);
            mColorStateListCache.put(key,new WeakReference<>(walkroundStateList));
        }
    }catch(Throwable e){
        e.printStackTrace();
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:17,代码来源:DelegateResources.java

示例3: buildChannelMap

import android.util.LongSparseArray; //导入依赖的package包/类
public static LongSparseArray<XmlTvParser.XmlTvChannel> buildChannelMap(
        ContentResolver resolver, String inputId, List<XmlTvParser.XmlTvChannel> channels) {
    Uri uri = TvContract.buildChannelsUriForInput(inputId);
    String[] projection = {
            TvContract.Channels._ID,
            TvContract.Channels.COLUMN_DISPLAY_NUMBER
    };

    LongSparseArray<XmlTvParser.XmlTvChannel> channelMap = new LongSparseArray<>();
    try (Cursor cursor = resolver.query(uri, projection, null, null, null)) {
        if (cursor == null || cursor.getCount() == 0) {
            return null;
        }

        while (cursor.moveToNext()) {
            long channelId = cursor.getLong(0);
            String channelNumber = cursor.getString(1);
            channelMap.put(channelId, getChannelByNumber(channelNumber, channels));
        }
    } catch (Exception e) {
        Log.d(TAG, "Content provider query: " + Arrays.toString(e.getStackTrace()));
        return null;
    }
    return channelMap;
}
 
开发者ID:nejtv,项目名称:androidtv-sample,代码行数:26,代码来源:TvContractUtils.java

示例4: setAdapter

import android.util.LongSparseArray; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void setAdapter(ListAdapter adapter) {
	if (adapter != null) {
		mAdapterHasStableIds = mAdapter.hasStableIds();
		if (mChoiceMode != AbsListView.CHOICE_MODE_NONE
				&& mAdapterHasStableIds && mCheckedIdStates == null) {
			mCheckedIdStates = new LongSparseArray<Integer>();
		}
	}

	if (mCheckStates != null) {
		mCheckStates.clear();
	}

	if (mCheckedIdStates != null) {
		mCheckedIdStates.clear();
	}
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:22,代码来源:AbsHListView.java

示例5: getCheckedItemIds

import android.util.LongSparseArray; //导入依赖的package包/类
/**
 * Returns the set of checked items ids. The result is only valid if the
 * choice mode has not been set to {@link #CHOICE_MODE_NONE} and the adapter
 * has stable IDs. ({@link ListAdapter#hasStableIds()} == {@code true})
 * 
 * @return A new array which contains the id of each checked item in the
 *         list.
 */
public long[] getCheckedItemIds() {
	if (mChoiceMode == AbsListView.CHOICE_MODE_NONE
			|| mCheckedIdStates == null || mAdapter == null) {
		return new long[0];
	}

	final LongSparseArray<Integer> idStates = mCheckedIdStates;
	final int count = idStates.size();
	final long[] ids = new long[count];

	for (int i = 0; i < count; i++) {
		ids[i] = idStates.keyAt(i);
	}

	return ids;
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:25,代码来源:AbsHListView.java

示例6: read

import android.util.LongSparseArray; //导入依赖的package包/类
@Override
public LongSparseArray<T> read(JsonReader jsonReader) throws IOException {
    if (jsonReader.peek() == JsonToken.NULL) {
        jsonReader.nextNull();
        return null;
    }
    LongSparseArray<Object> temp = gson.fromJson(jsonReader, typeOfLongSparseArrayOfObject);
    LongSparseArray<T> result = new LongSparseArray<>(temp.size());
    long key;
    JsonElement tElement;
    for (int i = 0, size = temp.size(); i < size; ++i) {
        key = temp.keyAt(i);
        tElement = gson.toJsonTree(temp.get(key));
        result.put(key, (T) JSONUtils.jsonToSimpleObject(tElement.toString(), typeOfT));
    }
    return result;
}
 
开发者ID:MessageOnTap,项目名称:MessageOnTap_API,代码行数:18,代码来源:LongSparseArrayTypeAdapter.java

示例7: testPickOneProgramPerEpisode_manyPerEpisode

import android.util.LongSparseArray; //导入依赖的package包/类
public void testPickOneProgramPerEpisode_manyPerEpisode() {
    SeriesRecording seriesRecording = SeriesRecording.buildFrom(mBaseSeriesRecording)
            .setId(SERIES_RECORDING_ID1).build();
    mDataManager.addSeriesRecording(seriesRecording);
    List<Program> programs = new ArrayList<>();
    Program program1 = new Program.Builder(mBaseProgram).setSeasonNumber(SEASON_NUMBER1)
            .setEpisodeNumber(EPISODE_NUMBER1).setStartTimeUtcMillis(0).build();
    programs.add(program1);
    Program program2 = new Program.Builder(program1).setStartTimeUtcMillis(1).build();
    programs.add(program2);
    Program program3 = new Program.Builder(mBaseProgram).setSeasonNumber(SEASON_NUMBER2)
            .setEpisodeNumber(EPISODE_NUMBER2).build();
    programs.add(program3);
    Program program4 = new Program.Builder(program1).setStartTimeUtcMillis(1).build();
    programs.add(program4);
    LongSparseArray<List<Program>> result = SeriesRecordingScheduler.pickOneProgramPerEpisode(
            mDataManager, Collections.singletonList(seriesRecording), programs);
    MoreAsserts.assertContentsInAnyOrder(result.get(SERIES_RECORDING_ID1), program1, program3);
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:20,代码来源:SeriesRecordingSchedulerTest.java

示例8: setChoiceMode

import android.util.LongSparseArray; //导入依赖的package包/类
/**
 * Defines the choice behavior for the List. By default, Lists do not have any choice behavior
 * ({@link AbsListView#CHOICE_MODE_NONE}). By setting the choiceMode to {@link AbsListView#CHOICE_MODE_SINGLE}, the
 * List allows up to one item to  be in a chosen state. By setting the choiceMode to
 * {@link AbsListView#CHOICE_MODE_MULTIPLE}, the list allows any number of items to be chosen.
 *
 * @param choiceMode One of {@link AbsListView#CHOICE_MODE_NONE}, {@link AbsListView#CHOICE_MODE_SINGLE}, or
 * {@link AbsListView#CHOICE_MODE_MULTIPLE}
 */
public void setChoiceMode(int choiceMode) {
    mChoiceMode = choiceMode;
    if (mChoiceActionMode != null) {
        mChoiceActionMode.finish();
        mChoiceActionMode = null;
    }
    if (mChoiceMode != AbsListView.CHOICE_MODE_NONE) {
        if (mCheckStates == null) {
            mCheckStates = new SparseBooleanArray(0);
        }
        if (mCheckedIdStates == null && hasStableIds()) {
            mCheckedIdStates = new LongSparseArray<Integer>(0);
        }
        // Modal multi-choice mode only has choices when the mode is active. Clear them.
        if (mChoiceMode == AbsListView.CHOICE_MODE_MULTIPLE_MODAL) {
            clearChoices();
            if (mAttachedRecyclerView != null) {
                mAttachedRecyclerView.setLongClickable(true);
            }
        }
    }
}
 
开发者ID:mobvoi,项目名称:ticdesign,代码行数:32,代码来源:TrackSelectionAdapterWrapper.java

示例9: getCheckedItemIds

import android.util.LongSparseArray; //导入依赖的package包/类
/**
 * Returns the set of checked items ids. The result is only valid if the
 * choice mode has not been set to {@link AbsListView#CHOICE_MODE_NONE} and the adapter
 * has stable IDs. ({@link ListAdapter#hasStableIds()} == {@code true})
 *
 * @return A new array which contains the id of each checked item in the
 *         list.
 */
public long[] getCheckedItemIds() {
    if (mChoiceMode == AbsListView.CHOICE_MODE_NONE || mCheckedIdStates == null) {
        return new long[0];
    }

    final LongSparseArray<Integer> idStates = mCheckedIdStates;
    final int count = idStates.size();
    final long[] ids = new long[count];

    for (int i = 0; i < count; i++) {
        ids[i] = idStates.keyAt(i);
    }

    return ids;
}
 
开发者ID:mobvoi,项目名称:ticdesign,代码行数:24,代码来源:TrackSelectionAdapterWrapper.java

示例10: parseOne

import android.util.LongSparseArray; //导入依赖的package包/类
private Element parseOne(String xml, LongSparseArray<List<LatLon>> expectedGeometry)
{
	SingleElementHandler handler = new SingleElementHandler();
	OverpassMapDataParser parser = new OverpassMapDataParser(
			new TestElementGeometryCreator(expectedGeometry), new OsmMapDataFactory());
	parser.setHandler(handler);
	try
	{
		parser.parse(asInputStream(xml));
	}
	catch (IOException e)
	{
		throw new RuntimeException(e);
	}

	return handler.element;
}
 
开发者ID:westnordost,项目名称:StreetComplete,代码行数:18,代码来源:OverpassMapDataParserTest.java

示例11: applyEmptyActionToEventsMapping

import android.util.LongSparseArray; //导入依赖的package包/类
private static void applyEmptyActionToEventsMapping(
        final JSONObject action, final LongSparseArray<List<InputEventParams>> mapping)
        throws JSONException {
    final JSONArray actionItems = action.getJSONArray(ACTION_KEY_ACTIONS);
    long timeDelta = 0;
    for (int i = 0; i < actionItems.length(); i++) {
        final JSONObject actionItem = actionItems.getJSONObject(i);
        final String itemType = actionItem.getString(ACTION_ITEM_TYPE_KEY);
        if (!itemType.equals(ACTION_ITEM_TYPE_PAUSE)) {
            throw new ActionsParseException(String.format(
                    "Unexpected action item %s '%s' in action with id '%s'",
                    ACTION_ITEM_TYPE_KEY, itemType, action.getString(ACTION_KEY_ID)));
        }
        timeDelta += extractDuration(action, actionItem);
        recordEventParams(timeDelta, mapping, null);
    }
}
 
开发者ID:appium,项目名称:appium-uiautomator2-server,代码行数:18,代码来源:ActionsHelpers.java

示例12: actionsToInputEventsMapping

import android.util.LongSparseArray; //导入依赖的package包/类
public static LongSparseArray<List<InputEventParams>> actionsToInputEventsMapping(
        final JSONArray actions) throws JSONException {
    final LongSparseArray<List<InputEventParams>> result = new LongSparseArray<>();
    final List<JSONObject> pointerActions = filterActionsByType(actions, ACTION_TYPE_POINTER);
    for (int pointerIdx = 0; pointerIdx < pointerActions.size(); pointerIdx++) {
        applyPointerActionToEventsMapping(pointerActions.get(pointerIdx), pointerIdx, result);
    }
    final List<JSONObject> keyInputActions = filterActionsByType(actions, ACTION_TYPE_KEY);
    for (final JSONObject keyAction : keyInputActions) {
        applyKeyActionToEventsMapping(keyAction, result);
    }
    final List<JSONObject> emptyActions = filterActionsByType(actions, ACTION_TYPE_NONE);
    for (final JSONObject emptyAction : emptyActions) {
        applyEmptyActionToEventsMapping(emptyAction, result);
    }
    return result;
}
 
开发者ID:appium,项目名称:appium-uiautomator2-server,代码行数:18,代码来源:ActionsHelpers.java

示例13: verifyValidInputEventsChainIsCompiledForNoneAction

import android.util.LongSparseArray; //导入依赖的package包/类
@Test
public void verifyValidInputEventsChainIsCompiledForNoneAction() throws JSONException {
    final JSONArray actionJson = new JSONArray("[ {" +
            "\"type\": \"none\"," +
            "\"id\": \"none1\"," +
            "\"actions\": [" +
            "{\"type\": \"pause\", \"duration\": 200}," +
            "{\"type\": \"pause\", \"duration\": 20}]" +
            "} ]");
    final LongSparseArray<List<InputEventParams>> eventsChain = actionsToInputEventsMapping(
            preprocessActions(actionJson)
    );
    assertThat(eventsChain.size(), equalTo(2));

    assertThat(eventsChain.keyAt(0), equalTo(200L));
    assertThat(eventsChain.valueAt(0).size(), equalTo(0));

    assertThat(eventsChain.keyAt(1), equalTo(220L));
    assertThat(eventsChain.valueAt(1).size(), equalTo(0));
}
 
开发者ID:appium,项目名称:appium-uiautomator2-server,代码行数:21,代码来源:W3CActionsTransformationTests.java

示例14: CcDrawableCache

import android.util.LongSparseArray; //导入依赖的package包/类
public CcDrawableCache(Context context, LongSparseArray<Drawable.ConstantState> cache) {
    mResources = context.getApplicationContext().getResources();
    mPackageName = context.getApplicationContext().getPackageName();

    if (cache != null) {
        mCheckDependenciesKeys = new HashSet<>(cache.size());

        int N = cache.size();
        for (int i = 0; i < N; i++) {
            long key = cache.keyAt(i);
            mCheckDependenciesKeys.add(key);
            put(key, cache.valueAt(i));
        }
    } else {
        mCheckDependenciesKeys = new HashSet<>(0);
    }
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:18,代码来源:CcDrawableCache.java

示例15: CcColorCache

import android.util.LongSparseArray; //导入依赖的package包/类
public CcColorCache(Context context, LongSparseArray cache) {
    mResources = context.getApplicationContext().getResources();
    mPackageName = context.getApplicationContext().getPackageName();

    if (cache != null) {
        mCheckDependenciesKeys = new HashSet<>(cache.size());

        int N = cache.size();
        for (int i = 0; i < N; i++) {
            long key = cache.keyAt(i);
            mCheckDependenciesKeys.add(key);
            put(key, cache.valueAt(i));
        }
    } else {
        mCheckDependenciesKeys = new HashSet<>(0);
    }
}
 
开发者ID:Leao,项目名称:CodeColors,代码行数:18,代码来源:CcColorCache.java


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