本文整理汇总了Java中android.util.Pair.create方法的典型用法代码示例。如果您正苦于以下问题:Java Pair.create方法的具体用法?Java Pair.create怎么用?Java Pair.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.Pair
的用法示例。
在下文中一共展示了Pair.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findSystemApk
import android.util.Pair; //导入方法依赖的package包/类
static Pair<String, Resources> findSystemApk(String action, PackageManager pm) {
final Intent intent = new Intent(action);
for (ResolveInfo info : pm.queryBroadcastReceivers(intent, 0)) {
if (info.activityInfo != null &&
(info.activityInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
final String packageName = info.activityInfo.packageName;
try {
final Resources res = pm.getResourcesForApplication(packageName);
return Pair.create(packageName, res);
} catch (NameNotFoundException e) {
e.printStackTrace();
}
}
}
return null;
}
示例2: parseEdts
import android.util.Pair; //导入方法依赖的package包/类
/**
* Parses the edts atom (defined in 14496-12 subsection 8.6.5).
*
* @param edtsAtom edts (edit box) atom to decode.
* @return Pair of edit list durations and edit list media times, or a pair of nulls if they are
* not present.
*/
private static Pair<long[], long[]> parseEdts(Atom.ContainerAtom edtsAtom) {
Atom.LeafAtom elst;
if (edtsAtom == null || (elst = edtsAtom.getLeafAtomOfType(Atom.TYPE_elst)) == null) {
return Pair.create(null, null);
}
ParsableByteArray elstData = elst.data;
elstData.setPosition(Atom.HEADER_SIZE);
int fullAtom = elstData.readInt();
int version = Atom.parseFullAtomVersion(fullAtom);
int entryCount = elstData.readUnsignedIntToInt();
long[] editListDurations = new long[entryCount];
long[] editListMediaTimes = new long[entryCount];
for (int i = 0; i < entryCount; i++) {
editListDurations[i] =
version == 1 ? elstData.readUnsignedLongToLong() : elstData.readUnsignedInt();
editListMediaTimes[i] = version == 1 ? elstData.readLong() : elstData.readInt();
int mediaRateInteger = elstData.readShort();
if (mediaRateInteger != 1) {
// The extractor does not handle dwell edits (mediaRateInteger == 0).
throw new IllegalArgumentException("Unsupported media rate.");
}
elstData.skipBytes(2);
}
return Pair.create(editListDurations, editListMediaTimes);
}
示例3: start
import android.util.Pair; //导入方法依赖的package包/类
public static void start(final GarlandViewMainActivity activity,
final String name, final String address, final String url,
final View card, final View avatar) {
Intent starter = new Intent(activity, GarlandViewDetailsActivity.class);
starter.putExtra(BUNDLE_NAME, name);
starter.putExtra(BUNDLE_INFO, address);
starter.putExtra(BUNDLE_AVATAR_URL, url);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final Pair<View, String> p1 = Pair.create(card, activity.getString(R.string.gv_transition_card));
final Pair<View, String> p2 = Pair.create(avatar, activity.getString(R.string.gv_transition_avatar_border));
final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(activity, p1, p2);
activity.startActivity(starter, options.toBundle());
} else {
activity.startActivity(starter);
}
}
示例4: getLicenseDurationRemainingSec
import android.util.Pair; //导入方法依赖的package包/类
/**
* Returns the remaining license and playback durations in seconds, for an offline license.
*
* @param offlineLicenseKeySetId The key set id of the license.
* @return The remaining license and playback durations, in seconds.
* @throws DrmSessionException Thrown when a DRM session error occurs.
*/
public synchronized Pair<Long, Long> getLicenseDurationRemainingSec(byte[] offlineLicenseKeySetId)
throws DrmSessionException {
Assertions.checkNotNull(offlineLicenseKeySetId);
DrmSession<T> drmSession = openBlockingKeyRequest(DefaultDrmSessionManager.MODE_QUERY,
offlineLicenseKeySetId, null);
DrmSessionException error = drmSession.getError();
Pair<Long, Long> licenseDurationRemainingSec =
WidevineUtil.getLicenseDurationRemainingSec(drmSession);
drmSessionManager.releaseSession(drmSession);
if (error != null) {
if (error.getCause() instanceof KeysExpiredException) {
return Pair.create(0L, 0L);
}
throw error;
}
return licenseDurationRemainingSec;
}
示例5: onProducerEvent
import android.util.Pair; //导入方法依赖的package包/类
@Override
public synchronized void onProducerEvent(
String requestId, String producerName, String producerEventName) {
if (FLog.isLoggable(FLog.VERBOSE)) {
Pair<String, String> mapKey = Pair.create(requestId, producerName);
Long startTime = mProducerStartTimeMap.get(mapKey);
long currentTime = getTime();
FLog.v(
TAG,
"time %d: onProducerEvent: {requestId: %s, stage: %s, eventName: %s; elapsedTime: %d ms}",
getTime(),
requestId,
producerName,
producerEventName,
getElapsedTime(startTime, currentTime));
}
}
示例6: start
import android.util.Pair; //导入方法依赖的package包/类
public static void start(Activity activity,
String url, String name, String info, String status,
View avatar, View card, View image, View list,
ArrayList<DetailsData> listData) {
Intent starter = new Intent(activity, ProfileActivity.class);
starter.putExtra(BUNDLE_NAME, name);
starter.putExtra(BUNDLE_INFO, info);
starter.putExtra(BUNDLE_STATUS, status);
starter.putExtra(BUNDLE_AVATAR_URL, url);
starter.putParcelableArrayListExtra(BUNDLE_LIST_DATA, listData);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final Pair<View, String> p1 = Pair.create(avatar, activity.getString(R.string.transition_avatar_border));
final Pair<View, String> p2 = Pair.create(card, activity.getString(R.string.transition_card));
final Pair<View, String> p3 = Pair.create(image, activity.getString(R.string.transition_background));
final Pair<View, String> p4 = Pair.create(list, activity.getString(R.string.transition_list));
final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(activity, p1, p2, p3, p4);
activity.startActivity(starter, options.toBundle());
} else {
activity.startActivity(starter);
}
}
示例7: onRequestStart
import android.util.Pair; //导入方法依赖的package包/类
@Override
public void onRequestStart(
ImageRequest request,
Object callerContext,
String requestId,
boolean isPrefetch) {
if (!Systrace.isTracing(Systrace.TRACE_TAG_REACT_FRESCO)) {
return;
}
StringBuilder entryName = new StringBuilder();
entryName.append("FRESCO_REQUEST_");
entryName.append(request.getSourceUri().toString().replace(':', '_'));
Pair<Integer,String> requestPair = Pair.create(mCurrentID, entryName.toString());
Systrace.beginAsyncSection(
Systrace.TRACE_TAG_REACT_FRESCO,
requestPair.second,
mCurrentID);
mRequestsID.put(requestId, requestPair);
mCurrentID++;
}
示例8: buildExecutionTimesFromXml
import android.util.Pair; //导入方法依赖的package包/类
/**
* Convenience function to read out and convert deadline and delay from xml into elapsed real
* time.
*
* @return A {@link android.util.Pair}, where the first value is the earliest elapsed runtime
* and the second is the latest elapsed runtime.
*/
private Pair<Long, Long> buildExecutionTimesFromXml(XmlPullParser parser) throws NumberFormatException {
// Pull out execution time data.
final long nowWallclock = System.currentTimeMillis();
final long nowElapsed = SystemClock.elapsedRealtime();
long earliestRunTimeElapsed = JobStatus.NO_EARLIEST_RUNTIME;
long latestRunTimeElapsed = JobStatus.NO_LATEST_RUNTIME;
String val = parser.getAttributeValue(null, "deadline");
if (val != null) {
long latestRuntimeWallclock = Long.parseLong(val);
long maxDelayElapsed = Math.max(latestRuntimeWallclock - nowWallclock, 0);
latestRunTimeElapsed = nowElapsed + maxDelayElapsed;
}
val = parser.getAttributeValue(null, "delay");
if (val != null) {
long earliestRuntimeWallclock = Long.parseLong(val);
long minDelayElapsed = Math.max(earliestRuntimeWallclock - nowWallclock, 0);
earliestRunTimeElapsed = nowElapsed + minDelayElapsed;
}
return Pair.create(earliestRunTimeElapsed, latestRunTimeElapsed);
}
示例9: parseAvcCodecPrivate
import android.util.Pair; //导入方法依赖的package包/类
/**
* Builds initialization data for a {@link MediaFormat} from H.264 (AVC) codec private data.
*
* @return The initialization data for the {@link MediaFormat}.
* @throws ParserException If the initialization data could not be built.
*/
private static Pair<List<byte[]>, Integer> parseAvcCodecPrivate(ParsableByteArray buffer)
throws ParserException {
try {
// TODO: Deduplicate with AtomParsers.parseAvcCFromParent.
buffer.setPosition(4);
int nalUnitLengthFieldLength = (buffer.readUnsignedByte() & 0x03) + 1;
if (nalUnitLengthFieldLength == 3) {
throw new ParserException();
}
List<byte[]> initializationData = new ArrayList<>();
int numSequenceParameterSets = buffer.readUnsignedByte() & 0x1F;
for (int i = 0; i < numSequenceParameterSets; i++) {
initializationData.add(NalUnitUtil.parseChildNalUnit(buffer));
}
int numPictureParameterSets = buffer.readUnsignedByte();
for (int j = 0; j < numPictureParameterSets; j++) {
initializationData.add(NalUnitUtil.parseChildNalUnit(buffer));
}
return Pair.create(initializationData, nalUnitLengthFieldLength);
} catch (ArrayIndexOutOfBoundsException e) {
throw new ParserException("Error parsing AVC codec private");
}
}
示例10: parseCipherText
import android.util.Pair; //导入方法依赖的package包/类
public static Pair<EncryptionType, String> parseCipherText(String cipherText) {
if (cipherText == null || cipherText.isEmpty()) {
return null;
}
if (cipherText.startsWith("[")) {
return Pair.create(LEGACY_TOKEN, cipherText);
}
if (cipherText.startsWith(APP_ID_KEY.prefixWithBracket)) {
return Pair.create(
APP_ID_KEY, cipherText.substring(APP_ID_KEY.prefixWithBracket.length() - 1));
}
return null;
}
示例11: parseTrex
import android.util.Pair; //导入方法依赖的package包/类
/**
* Parses a trex atom (defined in 14496-12).
*/
private static Pair<Integer, DefaultSampleValues> parseTrex(ParsableByteArray trex) {
trex.setPosition(Atom.FULL_HEADER_SIZE);
int trackId = trex.readInt();
int defaultSampleDescriptionIndex = trex.readUnsignedIntToInt() - 1;
int defaultSampleDuration = trex.readUnsignedIntToInt();
int defaultSampleSize = trex.readUnsignedIntToInt();
int defaultSampleFlags = trex.readInt();
return Pair.create(trackId, new DefaultSampleValues(defaultSampleDescriptionIndex,
defaultSampleDuration, defaultSampleSize, defaultSampleFlags));
}
示例12: getKey
import android.util.Pair; //导入方法依赖的package包/类
protected Pair<CacheKey, ImageRequest.RequestLevel> getKey(
ProducerContext producerContext) {
return Pair.create(
mCacheKeyFactory.getBitmapCacheKey(
producerContext.getImageRequest(),
producerContext.getCallerContext()),
producerContext.getLowestPermittedRequestLevel());
}
示例13: parseMdhd
import android.util.Pair; //导入方法依赖的package包/类
/**
* Parses an mdhd atom (defined in 14496-12).
*
* @param mdhd The mdhd atom to parse.
* @return A pair consisting of the media timescale defined as the number of time units that pass
* in one second, and the language code.
*/
private static Pair<Long, String> parseMdhd(ParsableByteArray mdhd) {
mdhd.setPosition(Atom.HEADER_SIZE);
int fullAtom = mdhd.readInt();
int version = Atom.parseFullAtomVersion(fullAtom);
mdhd.skipBytes(version == 0 ? 8 : 16);
long timescale = mdhd.readUnsignedInt();
mdhd.skipBytes(version == 0 ? 4 : 8);
int languageCode = mdhd.readUnsignedShort();
String language = "" + (char) (((languageCode >> 10) & 0x1F) + 0x60)
+ (char) (((languageCode >> 5) & 0x1F) + 0x60)
+ (char) (((languageCode) & 0x1F) + 0x60);
return Pair.create(timescale, language);
}
示例14: doInBackground
import android.util.Pair; //导入方法依赖的package包/类
@Override
public Pair<Integer, Boolean> doInBackground(Void...voids) {
DownloadManager manager =
(DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
Cursor c = manager.query(new DownloadManager.Query().setFilterById(
mDownloadItem.getSystemDownloadId()));
int statusIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS);
int reasonIndex = c.getColumnIndex(DownloadManager.COLUMN_REASON);
int titleIndex = c.getColumnIndex(DownloadManager.COLUMN_TITLE);
int status = DownloadManager.STATUS_FAILED;
Boolean canResolve = false;
if (c.moveToNext()) {
status = c.getInt(statusIndex);
String title = c.getString(titleIndex);
if (mDownloadInfo == null) {
// Chrome has been killed, reconstruct a DownloadInfo.
mDownloadInfo = new DownloadInfo.Builder()
.setFileName(title)
.setDescription(c.getString(
c.getColumnIndex(DownloadManager.COLUMN_DESCRIPTION)))
.setMimeType(c.getString(
c.getColumnIndex(DownloadManager.COLUMN_MEDIA_TYPE)))
.setContentLength(Long.parseLong(c.getString(
c.getColumnIndex(DownloadManager.COLUMN_TOTAL_SIZE_BYTES))))
.build();
}
if (status == DownloadManager.STATUS_SUCCESSFUL) {
mDownloadInfo = DownloadInfo.Builder.fromDownloadInfo(mDownloadInfo)
.setFileName(title)
.build();
mDownloadItem.setDownloadInfo(mDownloadInfo);
canResolve = canResolveDownloadItem(mContext, mDownloadItem, false);
} else if (status == DownloadManager.STATUS_FAILED) {
mFailureReason = c.getInt(reasonIndex);
manager.remove(mDownloadItem.getSystemDownloadId());
}
}
c.close();
return Pair.create(status, canResolve);
}
示例15: parseCsdBuffer
import android.util.Pair; //导入方法依赖的package包/类
/**
* Parses the {@link MediaFormat} and frame duration from a csd buffer.
*
* @param csdBuffer The csd buffer.
* @return A pair consisting of the {@link MediaFormat} and the frame duration in microseconds, or
* 0 if the duration could not be determined.
*/
private static Pair<MediaFormat, Long> parseCsdBuffer(CsdBuffer csdBuffer) {
byte[] csdData = Arrays.copyOf(csdBuffer.data, csdBuffer.length);
int firstByte = csdData[4] & 0xFF;
int secondByte = csdData[5] & 0xFF;
int thirdByte = csdData[6] & 0xFF;
int width = (firstByte << 4) | (secondByte >> 4);
int height = (secondByte & 0x0F) << 8 | thirdByte;
float pixelWidthHeightRatio = 1f;
int aspectRatioCode = (csdData[7] & 0xF0) >> 4;
switch(aspectRatioCode) {
case 2:
pixelWidthHeightRatio = (4 * height) / (float) (3 * width);
break;
case 3:
pixelWidthHeightRatio = (16 * height) / (float) (9 * width);
break;
case 4:
pixelWidthHeightRatio = (121 * height) / (float) (100 * width);
break;
default:
// Do nothing.
break;
}
MediaFormat format = MediaFormat.createVideoFormat(null, MimeTypes.VIDEO_MPEG2,
MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, width, height,
Collections.singletonList(csdData), MediaFormat.NO_VALUE, pixelWidthHeightRatio);
long frameDurationUs = 0;
int frameRateCodeMinusOne = (csdData[7] & 0x0F) - 1;
if (0 <= frameRateCodeMinusOne && frameRateCodeMinusOne < FRAME_RATE_VALUES.length) {
double frameRate = FRAME_RATE_VALUES[frameRateCodeMinusOne];
int sequenceExtensionPosition = csdBuffer.sequenceExtensionPosition;
int frameRateExtensionN = (csdData[sequenceExtensionPosition + 9] & 0x60) >> 5;
int frameRateExtensionD = (csdData[sequenceExtensionPosition + 9] & 0x1F);
if (frameRateExtensionN != frameRateExtensionD) {
frameRate *= (frameRateExtensionN + 1d) / (frameRateExtensionD + 1);
}
frameDurationUs = (long) (C.MICROS_PER_SECOND / frameRate);
}
return Pair.create(format, frameDurationUs);
}