Java Code Examples for android.support.v4.util.Pair#create()
The following examples show how to use
android.support.v4.util.Pair#create() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransitionUtils.java From AndroidPlusJava with GNU General Public License v3.0 | 6 votes |
public static void transitionToQuestionDetail(Activity activity, Question question, View title, View questionDes) { //获取字符串标识转场的控件 String titleTransitionName = activity.getResources().getString(R.string.question_title_transition); Pair<View, String> titlePair = Pair.create(title, titleTransitionName); ActivityOptionsCompat activityOptionsCompat = null; //如果问题描述控件不可见,则不执行动画效果 if (questionDes.getVisibility() == View.VISIBLE) { String descTransitionName = activity.getResources().getString(R.string.question_des_transition); Pair<View, String> descPair = Pair.create(questionDes, descTransitionName); activityOptionsCompat= ActivityOptionsCompat .makeSceneTransitionAnimation(activity, titlePair, descPair); } else { activityOptionsCompat= ActivityOptionsCompat .makeSceneTransitionAnimation(activity, titlePair); } Intent intent = new Intent(activity, QuestionDetailActivity.class); intent.putExtra(Constant.EXTRA_QUESTION, question.toString()); ActivityCompat.startActivity(activity, intent, activityOptionsCompat.toBundle()); }
Example 2
Source File: NavDestination.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Determines if this NavDestination has a deep link matching the given Uri. * @param uri The Uri to match against all deep links added in {@link #addDeepLink(String)} * @return The matching {@link NavDestination} and the appropriate {@link Bundle} of arguments * extracted from the Uri, or null if no match was found. */ @Nullable Pair<NavDestination, Bundle> matchDeepLink(@NonNull Uri uri) { if (mDeepLinks == null) { return null; } for (NavDeepLink deepLink : mDeepLinks) { Bundle matchingArguments = deepLink.getMatchingArguments(uri); if (matchingArguments != null) { return Pair.create(this, matchingArguments); } } return null; }
Example 3
Source File: CreateTaskCircularRevealChangeHandler.java From mosby-conductor with Apache License 2.0 | 5 votes |
private Pair<Integer, Integer> getFabPosition(View fromView, View containerView) { int[] fromLocation = new int[2]; fromView.getLocationInWindow(fromLocation); int[] containerLocation = new int[2]; containerView.getLocationInWindow(containerLocation); int relativeLeft = fromLocation[0] - containerLocation[0]; int relativeTop = fromLocation[1] - containerLocation[1]; int mCx = fromView.getWidth() / 2 + relativeLeft; int mCy = fromView.getHeight() / 2 + relativeTop; return Pair.create(mCx, mCy); }
Example 4
Source File: DateTimePickerCircularRevealChangeHandler.java From mosby-conductor with Apache License 2.0 | 5 votes |
private Pair<Integer, Integer> getViewPosition(View fromView, View containerView) { int[] fromLocation = new int[2]; fromView.getLocationInWindow(fromLocation); int[] containerLocation = new int[2]; containerView.getLocationInWindow(containerLocation); int relativeLeft = fromLocation[0] - containerLocation[0]; int relativeTop = fromLocation[1] - containerLocation[1]; int mCx = relativeLeft + 20; int mCy = fromView.getHeight() / 2 + relativeTop; return Pair.create(mCx, mCy); }
Example 5
Source File: ActivityUtils.java From AndroidUtilCode with Apache License 2.0 | 5 votes |
private static Bundle getOptionsBundle(final Activity activity, final View[] sharedElements) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return null; if (sharedElements == null) return null; int len = sharedElements.length; if (len <= 0) return null; @SuppressWarnings("unchecked") Pair<View, String>[] pairs = new Pair[len]; for (int i = 0; i < len; i++) { pairs[i] = Pair.create(sharedElements[i], sharedElements[i].getTransitionName()); } return ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pairs).toBundle(); }
Example 6
Source File: BackStackManager.java From android-multibackstack with Apache License 2.0 | 5 votes |
@Nullable public Pair<Integer, BackStackEntry> pop() { BackStack backStack = peekBackStack(); if (backStack == null) { return null; } return Pair.create(backStack.hostId, pop(backStack)); }
Example 7
Source File: AlbumAdapter.java From RetroMusicPlayer with GNU General Public License v3.0 | 5 votes |
@Override public void onClick(View v) { if (isInQuickSelectMode()) { toggleChecked(getAdapterPosition()); } else { Pair[] albumPairs = new Pair[]{ Pair.create(image, activity.getResources().getString(R.string.transition_album_art) )}; NavigationUtil.goToAlbum(activity, dataSet.get(getAdapterPosition()).getId(), albumPairs); } }
Example 8
Source File: SongAdapter.java From RetroMusicPlayer with GNU General Public License v3.0 | 5 votes |
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; }
Example 9
Source File: IssueDetailActivity.java From OpenHub with GNU General Public License v3.0 | 5 votes |
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()); }
Example 10
Source File: ToDayAdapter.java From ToDay with MIT License | 5 votes |
private Pair<EventGroup, Integer> findGroup(long timeMillis) { int position = 0; // TODO improve searching for (int i = 0; i < mEventGroups.size(); i++) { EventGroup group = mEventGroups.get(i); if (group.mTimeMillis == timeMillis) { return Pair.create(group, position); } else { position += group.itemCount() + 1; } } return null; }
Example 11
Source File: ArtistAdapter.java From Orin with GNU General Public License v3.0 | 5 votes |
@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); } }
Example 12
Source File: AlbumAdapter.java From Orin with GNU General Public License v3.0 | 5 votes |
@Override public void onClick(View v) { if (isInQuickSelectMode()) { toggleChecked(getAdapterPosition()); } else { Pair[] albumPairs = new Pair[]{ Pair.create(image, activity.getResources().getString(R.string.transition_album_art) )}; NavigationUtil.goToAlbum(activity, dataSet.get(getAdapterPosition()).getId(), albumPairs); } }
Example 13
Source File: CustomPlaylistSongAdapter.java From Orin with GNU General Public License v3.0 | 5 votes |
@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); }
Example 14
Source File: JobServiceConnectionTest.java From firebase-jobdispatcher-android with Apache License 2.0 | 5 votes |
@Override public void start(Bundle invocationData, IJobCallback callback) throws RemoteException { startArguments = Pair.create(invocationData, callback); if (startException.isPresent()) { throw startException.get(); } }
Example 15
Source File: VideoBrowserFragment.java From cast-videos-android with Apache License 2.0 | 5 votes |
@Override public void itemClicked(View view, MediaItem item, int position) { 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.toBundle()); intent.putExtra("shouldStart", false); ActivityCompat.startActivity(getActivity(), intent, options.toBundle()); }
Example 16
Source File: ActivityUtils.java From Android-utils with Apache License 2.0 | 5 votes |
private Bundle getOptionsBundle(final Activity activity, final View[] sharedElements) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return null; if (sharedElements == null) return null; int len = sharedElements.length; if (len <= 0) return null; @SuppressWarnings("unchecked") Pair<View, String>[] pairs = new Pair[len]; for (int i = 0; i < len; i++) { pairs[i] = Pair.create(sharedElements[i], sharedElements[i].getTransitionName()); } return ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pairs).toBundle(); }
Example 17
Source File: NavigationSourceUtility.java From scene with Apache License 2.0 | 5 votes |
public static Pair<SceneLifecycleManager<NavigationScene>, NavigationScene> createFromInitSceneLifecycleManager(final Scene rootScene) { ActivityController<TestActivity> controller = Robolectric.buildActivity(TestActivity.class).create().start().resume(); TestActivity testActivity = controller.get(); NavigationScene navigationScene = new NavigationScene(); NavigationSceneOptions options = new NavigationSceneOptions(rootScene.getClass()); navigationScene.setArguments(options.toBundle()); Scope.RootScopeFactory rootScopeFactory = new Scope.RootScopeFactory() { @Override public Scope getRootScope() { return Scope.DEFAULT_ROOT_SCOPE_FACTORY.getRootScope(); } }; SceneComponentFactory sceneComponentFactory = new SceneComponentFactory() { @Override public Scene instantiateScene(ClassLoader cl, String className, Bundle bundle) { if (className.equals(rootScene.getClass().getName())) { return rootScene; } return null; } }; navigationScene.setDefaultNavigationAnimationExecutor(new NoAnimationExecutor()); navigationScene.setRootSceneComponentFactory(sceneComponentFactory); SceneLifecycleManager<NavigationScene> sceneLifecycleManager = new SceneLifecycleManager<>(); sceneLifecycleManager.onActivityCreated(testActivity, testActivity.mFrameLayout, navigationScene, rootScopeFactory, false, null); return Pair.create(sceneLifecycleManager, navigationScene); }
Example 18
Source File: MatrixUtil.java From Synapse with Apache License 2.0 | 4 votes |
public static Pair<Integer, Double> findMax(Matrix matrix) { final int index = argmax(matrix); return Pair.create(index, matrix.getArray()[index]); }
Example 19
Source File: BackStackActivity.java From android-multibackstack with Apache License 2.0 | 4 votes |
@Nullable protected Pair<Integer, Fragment> popFragmentFromBackStack() { Pair<Integer, BackStackEntry> pair = backStackManager.pop(); return pair != null ? Pair.create(pair.first, pair.second.toFragment(this)) : null; }
Example 20
Source File: QuantitySelection.java From android-kubernetes-blockchain with Apache License 2.0 | 4 votes |
public void getTransactionResult(final String resultId, final int attemptNumber) { if (attemptNumber < 60) { final Activity activity = this; // GET THE TRANSACTION RESULT JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, BACKEND_URL + "/api/results/" + resultId, null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { BackendResult backendResult = gson.fromJson(response.toString(), BackendResult.class); // Check status of queued request if (backendResult.status.equals("pending")) { // if it is still pending, check again new Handler().postDelayed(new Runnable() { @Override public void run() { getTransactionResult(resultId,attemptNumber + 1); } },500); } else if (backendResult.status.equals("done")) { // when blockchain is done processing the request, get the contract model and start activity ResultOfMakePurchase resultOfMakePurchase = gson.fromJson(backendResult.result, ResultOfMakePurchase.class); ContractModel contractModel = gson.fromJson(resultOfMakePurchase.result.results.payload, ContractModel.class); // start activity of contract details Intent intent = new Intent(getApplicationContext(), ContractDetails.class); intent.putExtra("CONTRACT_JSON", new Gson().toJson(contractModel, ContractModel.class)); Pair<View, String> pair1 = Pair.create(findViewById(R.id.productImageInQuantity),"productImage"); ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, pair1); activity.startActivity(intent,options.toBundle()); } else { Log.d(TAG, "Response is: " + response.toString()); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.d(TAG, "That didn't work!"); } }); queue.add(jsonObjectRequest); } }