當前位置: 首頁>>代碼示例>>Java>>正文


Java LongSparseArray.size方法代碼示例

本文整理匯總了Java中android.util.LongSparseArray.size方法的典型用法代碼示例。如果您正苦於以下問題:Java LongSparseArray.size方法的具體用法?Java LongSparseArray.size怎麽用?Java LongSparseArray.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.util.LongSparseArray的用法示例。


在下文中一共展示了LongSparseArray.size方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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.compareTo(ChoiceMode.NONE) == 0 ||
            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:CodePath-MAF,項目名稱:AndroidClient,代碼行數:25,代碼來源:TwoWayView.java

示例7: load

import android.util.LongSparseArray; //導入方法依賴的package包/類
public static void load(LongSparseArray<SwitchRadiusInfo[]> weirdBendedSwitchesInfo) {
    if (weirdBendedSwitchesInfo.size() == 0) {
        try {
            InputStream is = CurvesDB.class.getResourceAsStream("/curves.txt");
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "utf-8"));
            CurvesJson.Curves[] curves = new Gson().fromJson(reader, CurvesJson.class).curves;
            int pointsCount = 0;
            for (CurvesJson.Curves curve : curves) {
                SwitchRadiusInfo[] values = new SwitchRadiusInfo[curve.values.length / 2];
                for (int i = 0; i < curve.values.length; i += 2) {
                    values[i / 2] = new SwitchRadiusInfo(curve.values[i], curve.values[i + 1]);
                }
                pointsCount += curve.values.length / 2;
                weirdBendedSwitchesInfo.put(curve.key, values);
            }
            System.out.println("Loaded " + curves.length + " curves, " + pointsCount + " points.");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:ValleZ,項目名稱:hwo2014_FireEdge,代碼行數:22,代碼來源:CurvesDB.java

示例8: onPerformSync

import android.util.LongSparseArray; //導入方法依賴的package包/類
/**
 * Called periodically by the system in every {@code FULL_SYNC_FREQUENCY_SEC}.
 */
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
        ContentProviderClient provider, SyncResult syncResult) {
    Log.d(TAG, "onPerformSync(" + account + ", " + authority + ", " + extras + ")");
    String inputId = extras.getString(SyncAdapter.BUNDLE_KEY_INPUT_ID);
    if (inputId == null) {
        return;
    }
    XmlTvParser.TvListing listings = RichFeedUtil.getRichTvListings(mContext);
    LongSparseArray<XmlTvParser.XmlTvChannel> channelMap = TvContractUtils.buildChannelMap(
            mContext.getContentResolver(), inputId, listings.channels);
    boolean currentProgramOnly = extras.getBoolean(
            SyncAdapter.BUNDLE_KEY_CURRENT_PROGRAM_ONLY, false);
    long startMs = System.currentTimeMillis();
    long endMs = startMs + FULL_SYNC_WINDOW_SEC * 1000;
    if (currentProgramOnly) {
        // This is requested from the setup activity, in this case, users don't need to wait for
        // the full sync. Sync the current programs first and do the full sync later in the
        // background.
        endMs = startMs + SHORT_SYNC_WINDOW_SEC * 1000;
    }
    for (int i = 0; i < channelMap.size(); ++i) {
        Uri channelUri = TvContract.buildChannelUri(channelMap.keyAt(i));
        List<Program> programs = getPrograms(channelUri, channelMap.valueAt(i),
                listings.programs, startMs, endMs);
        updatePrograms(channelUri, programs);
    }
}
 
開發者ID:nejtv,項目名稱:androidtv-sample,代碼行數:32,代碼來源:SyncAdapter.java

示例9: writeSparseLongArray

import android.util.LongSparseArray; //導入方法依賴的package包/類
private void writeSparseLongArray(LongSparseArray<Integer> array,
		Parcel out) {
	if (LOG_ENABLED) {
		Log.i(TAG, "writeSparseLongArray");
	}
	final int N = array != null ? array.size() : 0;
	out.writeInt(N);
	for (int i = 0; i < N; i++) {
		out.writeLong(array.keyAt(i));
		out.writeInt(array.valueAt(i));
	}
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:13,代碼來源:AbsHListView.java

示例10: LongSparseArrayIterator

import android.util.LongSparseArray; //導入方法依賴的package包/類
private LongSparseArrayIterator(LongSparseArray<E> array, int location) {
    this.array = array;
    if (location < 0) {
        cursor = -1;
        cursorNowhere = true;
    } else if (location < array.size()) {
        cursor = location;
        cursorNowhere = false;
    } else {
        cursor = array.size() - 1;
        cursorNowhere = true;
    }
}
 
開發者ID:andreynovikov,項目名稱:trekarta,代碼行數:14,代碼來源:LongSparseArrayIterator.java

示例11: iterate

import android.util.LongSparseArray; //導入方法依賴的package包/類
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN)
public static <T> Iterable<T> iterate(final LongSparseArray<T> array) {
	return new Iterable<T>() { @Override public Iterator<T> iterator() {
		return new Iterator<T>() {
			@Override public boolean hasNext() { return i < array.size(); }
			@Override public T next() { return array.valueAt(i ++); }
			int i = 0;
		};
	}};
}
 
開發者ID:oasisfeng,項目名稱:deagle,代碼行數:11,代碼來源:SparseArrays.java

示例12: doInBackground

import android.util.LongSparseArray; //導入方法依賴的package包/類
@Override
protected Void doInBackground(Void... voids) {
    if (isCancelled()) {
        return null;
    }

    PersistableBundle extras = params.getExtras();
    String inputId = extras.getString(SyncJobService.BUNDLE_KEY_INPUT_ID);
    if (inputId == null) {
        return null;
    }
    XmlTvParser.TvListing listings = RichFeedUtil.getRichTvListings(mContext);
    LongSparseArray<XmlTvParser.XmlTvChannel> channelMap = TvContractUtils.buildChannelMap(
            mContext.getContentResolver(), inputId, listings.channels);
    if (channelMap == null) {
        return null;
    }
    boolean currentProgramOnly = extras.getBoolean(
            SyncJobService.BUNDLE_KEY_CURRENT_PROGRAM_ONLY, false);
    long startMs = System.currentTimeMillis();
    long endMs = startMs + FULL_SYNC_WINDOW_SEC * 1000;
    if (currentProgramOnly) {
        // This is requested from the setup activity, in this case, users don't need to wait
        // for the full sync. Sync the current programs first and do the full sync later in
        // the background.
        endMs = startMs + SHORT_SYNC_WINDOW_SEC * 1000;
    }
    for (int i = 0; i < channelMap.size(); ++i) {
        Uri channelUri = TvContract.buildChannelUri(channelMap.keyAt(i));
        if (isCancelled()) {
            return null;
        }
        List<Program> programs = getPrograms(channelUri, channelMap.valueAt(i),
                listings.programs, startMs, endMs);
        // Double check if the job is cancelled, so that this task can be finished faster
        // after cancel() is called.
        if (isCancelled()) {
            return null;
        }
        updatePrograms(channelUri, programs);
    }
    return null;
}
 
開發者ID:nejtv,項目名稱:androidtv-sample,代碼行數:44,代碼來源:SyncJobService.java

示例13: clearTask

import android.util.LongSparseArray; //導入方法依賴的package包/類
private void clearTask(LongSparseArray<UpdateCurrentProgramForChannelTask> tasks) {
    for (int i = 0; i < tasks.size(); i++) {
        tasks.valueAt(i).cancel(true);
    }
    tasks.clear();
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:7,代碼來源:ProgramDataManager.java

示例14: performSync

import android.util.LongSparseArray; //導入方法依賴的package包/類
public void performSync(TvInputProvider provider, String inputId) {
    Log.d(TAG, "Actually begin the sync");
    List<Channel> allChannels = provider.getAllChannels(getContext());
    if(allChannels == null) {
        //You have no channels!!
        return;
    }
    Log.d(TAG, allChannels.toString());
    for (int i = 0; i < allChannels.size(); i++) {
        if (allChannels.get(i).getOriginalNetworkId() == 0)
            allChannels.get(i).setOriginalNetworkId(i + 1);
        if (allChannels.get(i).getTransportStreamId() == 0)
            allChannels.get(i).setTransportStreamId(i + 1);
    }
    TvContractUtils.updateChannels(getContext(), inputId, allChannels);

    LongSparseArray<Channel> channelMap = TvContractUtils.buildChannelMap(
            mContext.getContentResolver(), inputId, allChannels);
    if (channelMap == null) {
        Log.d(TAG, "?");
        Handler h = new Handler(Looper.getMainLooper()) {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                Toast.makeText(getContext(), "Couldn't find any channels. Uh-oh.", Toast.LENGTH_SHORT).show();
            }
        };
        h.sendEmptyMessage(0);
        //Let's not continue running
        return;
    }
    long startMs = new Date().getTime();
    long endMs = startMs + FULL_SYNC_WINDOW_SEC * 1000;
    Log.d(TAG, "Now start to get programs");
    for (int i = 0; i < channelMap.size(); ++i) {
        Uri channelUri = TvContract.buildChannelUri(channelMap.keyAt(i));
        List<Program> programList = provider.getProgramsForChannel(getContext(), channelUri, channelMap.valueAt(i), startMs, endMs);
        Log.d(TAG, "Okay, we NEED to set the channel id first");
        for(Program p: programList) {
            p.setChannelId(channelMap.keyAt(i));
        }
        Log.d(TAG, "For " + channelMap.valueAt(i).toString());
        Log.d(TAG, programList.toString());
        updatePrograms(channelUri, programList);
        //Let's double check programs
        Uri programEditor = TvContract.buildProgramsUriForChannel(channelUri);
    }
    Log.d(TAG, "Sync performed");
}
 
開發者ID:Fleker,項目名稱:ChannelSurfer,代碼行數:50,代碼來源:SyncAdapter.java

示例15: fetch

import android.util.LongSparseArray; //導入方法依賴的package包/類
private void fetch (Subscriber<? super Contact> subscriber) {
    LongSparseArray<Contact> contacts = new LongSparseArray<>();
    // Create a new cursor and go to the first position
    Cursor cursor = createCursor();
    cursor.moveToFirst();
    // Get the column indexes
    int idxId = cursor.getColumnIndex(ContactsContract.Data.CONTACT_ID);
    int idxInVisibleGroup = cursor.getColumnIndex(ContactsContract.Data.IN_VISIBLE_GROUP);
    int idxDisplayNamePrimary = cursor.getColumnIndex(ContactsContract.Data.DISPLAY_NAME_PRIMARY);
    int idxStarred = cursor.getColumnIndex(ContactsContract.Data.STARRED);
    int idxPhoto = cursor.getColumnIndex(ContactsContract.Data.PHOTO_URI);
    int idxThumbnail = cursor.getColumnIndex(ContactsContract.Data.PHOTO_THUMBNAIL_URI);
    int idxMimetype = cursor.getColumnIndex(ContactsContract.Data.MIMETYPE);
    int idxData1 = cursor.getColumnIndex(ContactsContract.Data.DATA1);
    // Map the columns to the fields of the contact
    while (!cursor.isAfterLast()) {
        // Get the id and the contact for this id. The contact may be a null.
        long id = cursor.getLong(idxId);
        Contact contact = contacts.get(id, null);
        if (contact == null) {
            // Create a new contact
            contact = new Contact(id);
            // Map the non collection attributes
            mapInVisibleGroup(cursor, contact, idxInVisibleGroup);
            mapDisplayName(cursor, contact, idxDisplayNamePrimary);
            mapStarred(cursor, contact, idxStarred);
            mapPhoto(cursor, contact, idxPhoto);
            mapThumbnail(cursor, contact, idxThumbnail);
            // Add the contact to the collection
            contacts.put(id, contact);
        }

        // map phone number or email address
        String mimetype = cursor.getString(idxMimetype);
        switch (mimetype) {
            case ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE: {
                mapEmail(cursor, contact, idxData1);
                break;
            }
            case ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE: {
                mapPhoneNumber(cursor, contact, idxData1);
                break;
            }
        }

        cursor.moveToNext();
    }
    // Close the cursor
    cursor.close();
    // Emit the contacts
    for (int i = 0; i < contacts.size(); i++) {
        subscriber.onNext(contacts.valueAt(i));
    }
    subscriber.onCompleted();
}
 
開發者ID:UlrichRaab,項目名稱:rx-contacts,代碼行數:56,代碼來源:RxContacts.java


注:本文中的android.util.LongSparseArray.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。