当前位置: 首页>>代码示例>>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;未经允许,请勿转载。