本文整理汇总了Java中android.util.Pair类的典型用法代码示例。如果您正苦于以下问题:Java Pair类的具体用法?Java Pair怎么用?Java Pair使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Pair类属于android.util包,在下文中一共展示了Pair类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onProducerFinishWithCancellation
import android.util.Pair; //导入依赖的package包/类
@Override
public synchronized void onProducerFinishWithCancellation(
String requestId,
String producerName,
@Nullable Map<String, String> extraMap) {
if (FLog.isLoggable(FLog.VERBOSE)) {
Pair<String, String> mapKey = Pair.create(requestId, producerName);
Long startTime = mProducerStartTimeMap.remove(mapKey);
long currentTime = getTime();
FLog.v(
TAG,
"time %d: onProducerFinishWithCancellation: " +
"{requestId: %s, stage: %s, elapsedTime: %d ms, extraMap: %s}",
currentTime,
requestId,
producerName,
getElapsedTime(startTime, currentTime),
extraMap);
}
}
示例2: onRecorderCanceled
import android.util.Pair; //导入依赖的package包/类
@Override
public void onRecorderCanceled() {
Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(50);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
ListenableFuture<Pair<Uri, Long>> future = audioRecorder.stopRecording();
future.addListener(new ListenableFuture.Listener<Pair<Uri, Long>>() {
@Override
public void onSuccess(final Pair<Uri, Long> result) {
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... params) {
PersistentBlobProvider.getInstance(ConversationActivity.this).delete(result.first);
return null;
}
}.execute();
}
@Override
public void onFailure(ExecutionException e) {}
});
}
示例3: openFile
import android.util.Pair; //导入依赖的package包/类
@Override
public android.os.ParcelFileDescriptor openFile(android.net.Uri uri, java.lang.String mode)
throws java.io.FileNotFoundException {
Pair<UUID, String> callIdAndAttachmentName = parseCallIdAndAttachmentName(uri);
if (callIdAndAttachmentName == null) {
throw new FileNotFoundException();
}
try {
File file = NativeAppCallAttachmentStore.openAttachment(
callIdAndAttachmentName.first,
callIdAndAttachmentName.second);
return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
} catch (FileNotFoundException exception) {
Log.e(TAG, "Got unexpected exception:" + exception);
throw exception;
}
}
示例4: onCreate
import android.util.Pair; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAdapter = new ChannelSearchDialog.SuggestionsAdapter(this);
ListSearchView view = new ListSearchView(this, this);
view.setBackgroundColor(StyledAttributesHelper.getColor(this, R.attr.colorBackgroundFloating, 0));
view.setSuggestionsAdapter(mAdapter);
setContentView(view);
mAdapter.setItemClickListener((int index, Pair<ServerConnectionInfo, String> value) -> {
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra(MainActivity.ARG_SERVER_UUID, value.first.getUUID().toString());
intent.putExtra(MainActivity.ARG_CHANNEL_NAME, value.second);
intent.putExtra(Intent.EXTRA_TEXT, getIntent().getStringExtra(Intent.EXTRA_TEXT));
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
startActivity(intent);
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
finish();
});
}
示例5: setCommand
import android.util.Pair; //导入依赖的package包/类
/**
* Insert a new {@link CustomCommand} in the {@link DBCustomCommand} synchronising with a basic
* lock object in a vain attempt to prevent concurrency issues.
*
* @param ctx the application context
* @param customCommand to be set
* @return true if the insertion was successful
*/
public static Pair<Boolean, Long> setCommand(@NonNull final Context ctx, @NonNull final CustomCommand customCommand,
final long rowId) {
synchronized (lock) {
final Gson gson = new GsonBuilder().disableHtmlEscaping().create();
final String gsonString = gson.toJson(customCommand);
final DBCustomCommand dbCustomCommand = new DBCustomCommand(ctx);
final Pair<Boolean, Long> duplicatePair;
if (rowId > -1) {
duplicatePair = new Pair<>(true, rowId);
} else {
duplicatePair = commandExists(dbCustomCommand, customCommand);
}
return dbCustomCommand.insertPopulatedRow(customCommand.getKeyphrase(),
customCommand.getRegex(), gsonString, duplicatePair.first, duplicatePair.second);
}
}
示例6: EasyFirebaseAuth
import android.util.Pair; //导入依赖的package包/类
public EasyFirebaseAuth(GoogleApiClient googleApiClient) {
mAuth = FirebaseAuth.getInstance();
this.googleApiClient = googleApiClient;
mAuthListener = new FirebaseAuth.AuthStateListener() {
@Override
public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
final FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
if (firebaseUserSubscriber != null) {
firebaseUserSubscriber.onNext(new Pair<GoogleSignInAccount, FirebaseUser>(googleSignInAccount, user));
firebaseUserSubscriber.onCompleted();
}
if (loggedSubcriber != null) {
loggedSubcriber.onNext(user);
}
// User is signed in
Log.d("TAG", "onAuthStateChanged:signed_in:" + user.getUid());
} else {
// User is signed out
Log.d("TAG", "onAuthStateChanged:signed_out");
}
}
};
}
示例7: readImageSize
import android.util.Pair; //导入依赖的package包/类
/**
* We get the size from a generic image
*/
private Pair<Integer, Integer> readImageSize() {
InputStream inputStream = null;
Pair<Integer, Integer> dimensions = null;
try {
inputStream = getInputStream();
dimensions = BitmapUtil.decodeDimensions(inputStream);
if (dimensions != null) {
mWidth = dimensions.first;
mHeight = dimensions.second;
}
}finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// Head in the sand
}
}
}
return dimensions;
}
示例8: parseCallIdAndAttachmentName
import android.util.Pair; //导入依赖的package包/类
Pair<UUID, String> parseCallIdAndAttachmentName(Uri uri) {
try {
// We don't do explicit format checking here. Malformed URIs may generate NullPointerExceptions or
// array bounds exceptions, which we'll catch and return null. All of these will result in a
// FileNotFoundException being thrown in openFile.
String callIdAndAttachmentName = uri.getPath().substring(1);
String [] parts = callIdAndAttachmentName.split("/");
String callIdString = parts[0];
String attachmentName = parts[1];
UUID callId = UUID.fromString(callIdString);
return new Pair<UUID, String>(callId, attachmentName);
} catch (Exception exception) {
return null;
}
}
示例9: deleteList
import android.util.Pair; //导入依赖的package包/类
public boolean deleteList(List<Pair<String, String[]>> where) {
long start = System.currentTimeMillis();
lock.lock();
try {
database.beginTransaction();
for (Pair<String, String[]> pair : where) {
database.delete(getTableName(), pair.first, pair.second);
}
database.setTransactionSuccessful();
return true;
} catch (Exception e) {
OkLogger.printStackTrace(e);
} finally {
database.endTransaction();
lock.unlock();
OkLogger.v(TAG, System.currentTimeMillis() - start + " deleteList");
}
return false;
}
示例10: parsePivot
import android.util.Pair; //导入依赖的package包/类
private static Pair<Float, Float> parsePivot(@Nullable String transformOrigin,
int width, int height,int viewportW) {
if (!TextUtils.isEmpty(transformOrigin)) {
int firstSpace = transformOrigin.indexOf(FunctionParser.SPACE);
if (firstSpace != -1) {
int i = firstSpace;
for (; i < transformOrigin.length(); i++) {
if (transformOrigin.charAt(i) != FunctionParser.SPACE) {
break;
}
}
if (i < transformOrigin.length() && transformOrigin.charAt(i) != FunctionParser.SPACE) {
List<String> list = new ArrayList<>(2);
list.add(transformOrigin.substring(0, firstSpace).trim());
list.add(transformOrigin.substring(i, transformOrigin.length()).trim());
return parsePivot(list, width, height,viewportW);
}
}
}
return null;
}
示例11: loadConversationList
import android.util.Pair; //导入依赖的package包/类
/**
* load conversation list
*
* @return
+ */
protected List<EMConversation> loadConversationList(){
// get all conversations
Map<String, EMConversation> conversations = EMClient.getInstance().chatManager().getAllConversations();
List<Pair<Long, EMConversation>> sortList = new ArrayList<Pair<Long, EMConversation>>();
/**
* lastMsgTime will change if there is new message during sorting
* so use synchronized to make sure timestamp of last message won't change.
*/
synchronized (conversations) {
for (EMConversation conversation : conversations.values()) {
if (conversation.getAllMessages().size() != 0) {
sortList.add(new Pair<Long, EMConversation>(conversation.getLastMessage().getMsgTime(), conversation));
}
}
}
try {
// Internal is TimSort algorithm, has bug
sortConversationByLastChatTime(sortList);
} catch (Exception e) {
e.printStackTrace();
}
List<EMConversation> list = new ArrayList<EMConversation>();
for (Pair<Long, EMConversation> sortItem : sortList) {
list.add(sortItem.second);
}
return list;
}
示例12: decodeDimensions
import android.util.Pair; //导入依赖的package包/类
public static Pair<Integer, Integer> decodeDimensions(FileDescriptor fd) {
if (fd == null)
return null;
BitmapFactory.Options options = CompressKit.getDefaultDecodeBoundsOptions();
BitmapFactory.decodeFileDescriptor(fd, null, options);
return (options.outWidth == -1 || options.outHeight == -1) ?
null : Pair.create(options.outWidth, options.outHeight);
}
示例13: DynamicStickerBase
import android.util.Pair; //导入依赖的package包/类
public DynamicStickerBase(DstickerDataBean parama, String paramString1, String paramString2, String paramString3) {
super(paramString2, paramString3);
this.cE = paramString1;
this.cF = parama;
this.bh = this.cF.name;
String str = this.cE.substring("file://".length());
Pair localPair = MResFileReaderBase.tryGetMergeFile(str);
if (null != localPair) {
this.cG = new MResFileIndexReader(str + "/" + (String) localPair.first, str + "/" + (String) localPair.second);
}
}
示例14: onPageFinished
import android.util.Pair; //导入依赖的package包/类
@Override
public void onPageFinished(WebView view, String url) {
mWebView = view;
setUpWebView(view);
while (!mToInjectJavaScripts.isEmpty()) {
Pair<String, ValueCallback<String>> pair = mToInjectJavaScripts.poll();
inject(view, pair.first, pair.second);
}
super.onPageFinished(view, url);
}
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:11,代码来源:InjectableWebClient.java
示例15: showFragmentById
import android.util.Pair; //导入依赖的package包/类
private void showFragmentById(int id) {
final Class<? extends Fragment> target = FRAGMENTS.get(id);
final Fragment fragment = Fragment.instantiate(this, target.getName());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setupFragmentTransition(fragment);
}
final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction()
.replace(R.id.content_frame, fragment);
for (Pair<View, String> sharedElement : sharedElements) {
transaction.addSharedElement(sharedElement.first, sharedElement.second);
}
sharedElements = new ArrayList<>();
transaction.commit();
}