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