本文整理汇总了Java中android.support.v4.util.Pair.create方法的典型用法代码示例。如果您正苦于以下问题:Java Pair.create方法的具体用法?Java Pair.create怎么用?Java Pair.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.util.Pair
的用法示例。
在下文中一共展示了Pair.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getViewBlockAttrs
import android.support.v4.util.Pair; //导入方法依赖的package包/类
private Pair<Integer, String> getViewBlockAttrs(AttributeSet attrs) {
int resourceId = NO_ID;
String name = null;
TypedArray array = getContext().obtainStyledAttributes(attrs, AndroidAttrs.ATTRS);
int indexCount = array.getIndexCount();
for (int i = 0; i < indexCount; i++) {
int index = array.getIndex(i);
switch (index) {
case AndroidAttrs.ID_INDEX:
resourceId = array.getResourceId(index, NO_ID);
break;
case AndroidAttrs.NAME_INDEX:
name = array.getString(index);
break;
case AndroidAttrs.BLOCK_CLASS_INDEX:
name = array.getString(index);
break;
}
}
array.recycle();
return Pair.create(resourceId, name);
}
示例2: itemClicked
import android.support.v4.util.Pair; //导入方法依赖的package包/类
@Override
public void itemClicked(View view, MediaInfo item, int position) {
if (view instanceof ImageButton) {
Utils.showQueuePopup(getActivity(), view, item);
} else {
String transitionName = getString(R.string.transition_image);
VideoListAdapter.ViewHolder viewHolder =
(VideoListAdapter.ViewHolder) mRecyclerView.findViewHolderForPosition(position);
Pair<View, String> imagePair = Pair
.create((View) viewHolder.getImageView(), transitionName);
ActivityOptionsCompat options = ActivityOptionsCompat
.makeSceneTransitionAnimation(getActivity(), imagePair);
Intent intent = new Intent(getActivity(), LocalPlayerActivity.class);
intent.putExtra("media", item);
intent.putExtra("shouldStart", false);
ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
}
}
示例3: onClick
import android.support.v4.util.Pair; //导入方法依赖的package包/类
/**
* When the user clicks/touches an app card, we launch the {@link AppDetails2} activity in response.
*/
@Override
public void onClick(View v) {
if (currentApp == null) {
return;
}
Intent intent = new Intent(activity, AppDetails2.class);
intent.putExtra(AppDetails2.EXTRA_APPID, currentApp.packageName);
if (Build.VERSION.SDK_INT >= 21) {
Pair<View, String> iconTransitionPair = Pair.create((View) icon,
activity.getString(R.string.transition_app_item_icon));
@SuppressWarnings("unchecked") // the right type is passed as 2nd varargs arg: Pair<View, String>
Bundle b = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, iconTransitionPair).toBundle();
activity.startActivity(intent, b);
} else {
activity.startActivity(intent);
}
}
示例4: onClick
import android.support.v4.util.Pair; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
if (currentApp == null) {
return;
}
Intent intent = new Intent(activity, AppDetails2.class);
intent.putExtra(AppDetails2.EXTRA_APPID, currentApp.packageName);
if (Build.VERSION.SDK_INT >= 21) {
String transitionAppIcon = activity.getString(R.string.transition_app_item_icon);
Pair<View, String> iconTransitionPair = Pair.create((View) icon, transitionAppIcon);
Bundle bundle = ActivityOptionsCompat
.makeSceneTransitionAnimation(activity, iconTransitionPair).toBundle();
activity.startActivity(intent, bundle);
} else {
activity.startActivity(intent);
}
}
示例5: onItemClick
import android.support.v4.util.Pair; //导入方法依赖的package包/类
@Override
public void onItemClick(int item, ProfesoresAdapter.ViewHolder view) {
View imageView = view.profile;
Intent intent = new Intent(ProfesoresActivity.this, ProfesoresViewActivity.class);
Gson gson = new Gson();
intent.putExtra("JDATA", gson.toJson(teachers.get(item)));
overridePendingTransition(R.anim.fade_in,R.anim.fade_out);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Pair<View, String> pair1 = Pair.create(imageView, getString(R.string.activity_profesores_image_trans));
ActivityOptionsCompat options = ActivityOptionsCompat.
makeSceneTransitionAnimation(ProfesoresActivity.this, pair1);
startActivity(intent, options.toBundle());
}
else {
startActivity(intent);
}
}
示例6: onClick
import android.support.v4.util.Pair; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
if (isInQuickSelectMode()) {
toggleChecked(getAdapterPosition());
} else {
Pair[] artistPairs = new Pair[]{Pair.create(image, activity.getResources().getString(R.string.transition_artist_image))};
NavigationUtil.goToArtist(activity, dataSet.get(getAdapterPosition()).getId(), artistPairs);
}
}
示例7: onItemClick
import android.support.v4.util.Pair; //导入方法依赖的package包/类
@Override
public void onItemClick(PokeRecyclerAdapter adapter, int position, PokeItemViewHolder
viewHolder) {
Pokemon p = adapter.getItem(position);
Intent intent = PokeDetailActivity.createIntent(this, p, viewHolder.imPokemon.getDrawable());
Pair<View, String> pairIm = Pair.create(viewHolder.imPokemon, getString(R.string
.transition_name_im_poke));
Pair<View, String> pairTv = Pair.create(viewHolder.tvPokemonName, getString(R
.string.transition_name_tv_poke_name));
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(this,
pairIm, pairTv);
ActivityCompat.startActivity(this, intent, options.toBundle());
}
示例8: onSongMenuItemClick
import android.support.v4.util.Pair; //导入方法依赖的package包/类
protected boolean onSongMenuItemClick(MenuItem item) {
if (image != null && image.getVisibility() == View.VISIBLE) {
switch (item.getItemId()) {
case R.id.action_go_to_album:
Pair[] albumPairs = new Pair[]{
Pair.create(image, activity.getResources().getString(R.string.transition_album_art))
};
NavigationUtil.goToAlbum(activity, getSong().albumId, albumPairs);
return true;
}
}
return false;
}
示例9: onSongMenuItemClick
import android.support.v4.util.Pair; //导入方法依赖的package包/类
@Override
protected boolean onSongMenuItemClick(MenuItem item) {
if (item.getItemId() == R.id.action_go_to_album) {
Pair[] albumPairs = new Pair[]{
Pair.create(image, activity.getString(R.string.transition_album_art))
};
NavigationUtil.goToAlbum(activity, dataSet.get(getAdapterPosition()).albumId, albumPairs);
return true;
}
return super.onSongMenuItemClick(item);
}
示例10: onSongMenuItemClick
import android.support.v4.util.Pair; //导入方法依赖的package包/类
protected boolean onSongMenuItemClick(MenuItem item) {
if (image != null && image.getVisibility() == View.VISIBLE) {
switch (item.getItemId()) {
case R.id.action_go_to_album:
Pair[] albumPairs = new Pair[]{
Pair.create(imageContainer, activity.getResources().getString(R.string.transition_album_art))
};
NavigationUtil.goToAlbum(activity, getSong().albumId, albumPairs);
return true;
}
}
return false;
}
示例11: onClick
import android.support.v4.util.Pair; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
if (isInQuickSelectMode()) {
toggleChecked(getAdapterPosition());
} else {
Pair[] artistPairs = new Pair[]{
Pair.create(image,
activity.getResources().getString(R.string.transition_artist_image)
)};
NavigationUtil.goToArtist(activity, dataSet.get(getAdapterPosition()).getId(), artistPairs);
}
}
示例12: onDetachLayout
import android.support.v4.util.Pair; //导入方法依赖的package包/类
@Nullable
@Override
protected final Pair<Integer, Float> onDetachLayout(final boolean tabsOnly) {
Pair<Integer, Float> result = null;
if (getTabSwitcher().isSwitcherShown() && getFirstVisibleIndex() != -1) {
TabItem tabItem =
TabItem.create(getModel(), getTabViewRecycler(), getFirstVisibleIndex());
Tag tag = tabItem.getTag();
if (tag.getState() != State.HIDDEN) {
float position = tag.getPosition();
float draggingAxisSize =
getArithmetics().getTabContainerSize(Axis.DRAGGING_AXIS, false);
float orthogonalAxisSize =
getArithmetics().getTabContainerSize(Axis.ORTHOGONAL_AXIS, false);
result = Pair.create(getFirstVisibleIndex(),
position / Math.max(draggingAxisSize, orthogonalAxisSize));
}
}
contentViewRecycler.removeAll();
contentViewRecycler.clearCache();
tabRecyclerAdapter.clearCachedPreviews();
detachEmptyView();
if (!tabsOnly) {
getModel().removeListener(tabRecyclerAdapter);
}
return result;
}
示例13: show
import android.support.v4.util.Pair; //导入方法依赖的package包/类
public static void show(@NonNull Activity activity, @NonNull View avatarView,
@NonNull View titleView, @NonNull Issue issue) {
Intent intent = new Intent(activity, IssueDetailActivity.class);
Pair<View, String> avatarPair = Pair.create(avatarView, "userAvatar");
Pair<View, String> titlePair = Pair.create(titleView, "issueTitle");
ActivityOptionsCompat optionsCompat = ActivityOptionsCompat
.makeSceneTransitionAnimation(activity, avatarPair, titlePair);
intent.putExtras(BundleHelper.builder().put("issue", issue).build());
activity.startActivity(intent, optionsCompat.toBundle());
}
示例14: onDetachLayout
import android.support.v4.util.Pair; //导入方法依赖的package包/类
@Nullable
@Override
protected final Pair<Integer, Float> onDetachLayout(final boolean tabsOnly) {
Pair<Integer, Float> result = null;
if (getModel().isSwitcherShown() && firstVisibleIndex != -1) {
TabItem tabItem = TabItem.create(getModel(), viewRecycler, firstVisibleIndex);
Tag tag = tabItem.getTag();
if (tag.getState() != State.HIDDEN) {
float firstVisibleTabPosition = tabItem.getTag().getPosition();
result = Pair.create(firstVisibleIndex, firstVisibleTabPosition);
}
}
childViewRecycler.removeAll();
childViewRecycler.clearCache();
viewRecycler.removeAll();
viewRecycler.clearCache();
recyclerAdapter.clearCachedPreviews();
if (!tabsOnly) {
getModel().removeListener(recyclerAdapter);
getTabSwitcher().removeView(toolbar);
getTabSwitcher().removeView(tabContainer);
}
return result;
}
示例15: sharedElement
import android.support.v4.util.Pair; //导入方法依赖的package包/类
@Override
public Pair<View, String> sharedElement() {
DetailsKey detailsKey = getKey();
String transitionName = detailsKey.transitionName();
if(image == null) {
return null; // View is not yet initialized.
}
return Pair.create(image, transitionName);
}