List of usage examples for android.util Pair Pair
public Pair(F first, S second)
From source file:com.fbartnitzek.tasteemall.location.ShowReviewMapFragment.java
@Nullable @Override//from w w w .j a v a2 s . c om public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { Log.v(LOG_TAG, "onCreateView, hashCode=" + this.hashCode() + ", " + "inflater = [" + inflater + "], container = [" + container + "], savedInstanceState = [" + savedInstanceState + "]"); super.onCreateView(inflater, container, savedInstanceState); // TODO: srollable below map... - done...? Bundle args = getArguments(); if (args == null) { Log.w(LOG_TAG, "onCreateView without args..."); } else { Log.v(LOG_TAG, "onCreateView with args: " + args); if (args.containsKey(REVIEW_URI)) { mBaseUri = args.getParcelable(REVIEW_URI); getLoaderManager().restartLoader(REVIEW_LOCATIONS_LOADER_ID, null, this); } } mReviewLocationAdapter = new ReviewLocationAdapter(getActivity(), new ReviewLocationAdapter.ReviewLocationAdapterClickHandler() { @Override public void onClick(String reviewLocationId, ReviewLocationAdapter.ViewHolder viewHolder, LatLng latLng, String formatted, String description) { addReviewLocationMarker(reviewLocationId, latLng, formatted, description); } }); mHeadingLocations = (TextView) mRootView.findViewById(R.id.heading_map_locations); mHeadingLocations.setText(R.string.label_list_map_locations_preview); RecyclerView locationRecyclerView = (RecyclerView) mRootView.findViewById(R.id.recyclerview_map_locations); locationRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); locationRecyclerView.setAdapter(mReviewLocationAdapter); mHeadingReviewsOfLocation = (TextView) mRootView.findViewById(R.id.heading_map_sub_list); mHeadingReviewsOfLocation.setText(R.string.label_list_map_reviews_of_location_preview); mReviewOfLocationAdapter = new ReviewOfLocationAdapter( new ReviewOfLocationAdapter.ReviewAdapterClickHandler() { @Override public void onClick(Uri contentUri, ReviewOfLocationAdapter.ViewHolder vh) { Bundle bundle = null; if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { bundle = ActivityOptions.makeSceneTransitionAnimation(getActivity(), new Pair<View, String>(vh.drinkNameView, vh.drinkNameView.getTransitionName()), new Pair<View, String>(vh.producerNameView, vh.producerNameView.getTransitionName())) .toBundle(); } startActivity(new Intent(getActivity(), ShowReviewActivity.class).setData(contentUri), bundle); } }, getActivity()); RecyclerView reviewsRecyclerView = (RecyclerView) mRootView.findViewById(R.id.recyclerview_map_sub_list); reviewsRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); reviewsRecyclerView.setAdapter(mReviewOfLocationAdapter); // Log.v(LOG_TAG, "onCreateView before MapFragment, hashCode=" + this.hashCode() + ", " + "inflater = [" + inflater + "], container = [" + container + "], savedInstanceState = [" + savedInstanceState + "]"); return mRootView; }
From source file:test.hugo.ui.ImgShowActivity.java
private void prepareScene(GlideDrawable resource, PhotoView imageView, int position) { float screenWidth = getResources().getDisplayMetrics().widthPixels; float screenHeight = getResources().getDisplayMetrics().heightPixels; float intrinsicWidth = resource.getIntrinsicWidth(); // float intrinsicHeight = resource.getIntrinsicHeight(); float scale = Math.min(screenWidth / intrinsicWidth, screenHeight / intrinsicHeight); float endPicWidth = (intrinsicWidth * scale); float endPicHeight = (intrinsicHeight * scale); pairs[position] = new Pair<>(endPicWidth, endPicHeight); // capture the end values in the destionation view // calculate the scale and positoin deltas float scaleX = mInit_width / endPicWidth; float scaleY = mInit_height / endPicHeight; float scaledPositionX = (screenWidth - mInit_width) / 2;/*+paddingwidth*/ float scaledPositionY = (screenHeight + 25 * 1.5f - mInit_height) / 2;/*+paddingHeight*/ imageView.setImageDrawable(resource); // scale and reposition the image imageView.setScaleX(scaleX);//from w ww.j a va 2 s . c om imageView.setScaleY(scaleY); imageView.setTranslationX(mLocation_left - scaledPositionX); imageView.setTranslationY(mLocation_top - scaledPositionY); isFirstInit = false; // We can now make it visible imageView.setVisibility(View.VISIBLE); // finally, run the animation imageView.animate().setDuration(300).setInterpolator(interpolator).scaleX(1f).scaleY(1f).translationX(0) .translationY(0).start(); }
From source file:conexionSiabra.ConexionSiabra.java
public JSONObject getListaPerfiles() { Pair<String, String> elemento = new Pair<String, String>("", ""); return oauth.peticionGet(elemento, url_obtener_lista_perfiles); }
From source file:org.runnerup.workout.WorkoutSerializer.java
private static Pair<Dimension, Double> getDuration(JSONObject obj, Intensity intensity) throws JSONException { Dimension dim = null;//from w w w.j ava 2 s . c om double val = 0; String endConditionTypeKey = obj.getString("endConditionTypeKey"); if (endConditionTypeKey.equalsIgnoreCase("lap.button")) { return NullDimensionPair; } else if (endConditionTypeKey.equalsIgnoreCase("iterations")) { val = SafeParse.parseDouble(getString(obj, "endConditionValue"), 1); } else if (endConditionTypeKey.equalsIgnoreCase("distance")) { dim = Dimension.DISTANCE; val = SafeParse.parseDouble(getString(obj, "endConditionValue"), 0); val = scale(val, obj, "endConditionUnitKey"); } else if (endConditionTypeKey.equalsIgnoreCase("time")) { dim = Dimension.TIME; val = SafeParse.parseDouble(getString(obj, "endConditionValue"), 0); val = scale(val, obj, "endConditionUnitKey"); } else if (endConditionTypeKey.equalsIgnoreCase("calories")) { // not implemented return NullDimensionPair; } else if (endConditionTypeKey.equalsIgnoreCase("heart.rate")) { // not implemented return NullDimensionPair; } return new Pair<Dimension, Double>(dim, val); }
From source file:com.zprogrammer.tool.ui.NavigationDrawerFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mDrawerListView = (ListView) inflater.inflate(R.layout.fragment_navigation_drawer, container, false); View view = LayoutInflater.from(getActivity()).inflate(R.layout.header_drawer_main, mDrawerListView, false); mDrawerListView.addHeaderView(view, null, false); userName = (TextView) view.findViewById(R.id.user_name); userPortraitPic = (ImageView) view.findViewById(R.id.user_portrait_pic); final MyUser user = BmobUser.getCurrentUser(getActivity(), MyUser.class); if (user != null) { BmobProFile portraitPic = BmobProFile.getInstance(getActivity()); portraitPic.submitThumnailTask(user.getPortraitPic(), 1, new ThumbnailListener() { @Override//from www . jav a2 s. co m public void onSuccess(String thumbnailName, String thumbnailUrl) { Picasso.with(getActivity()).load(thumbnailUrl).into(userPortraitPic); } @Override public void onError(int statuscode, String errormsg) { } }); userName.setText(user.getUsername()); } userPortraitPic.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (user == null) { UiUtil.startActivity(getActivity(), new Intent(getActivity(), LoginActivity.class), new Pair<>(userPortraitPic, "user_portrait_pic")); } } }); mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { selectItem(position); } }); /* mDrawerListView.setAdapter(new ArrayAdapter<>( getActivity(), android.R.layout.simple_list_item_activated_1, android.R.id.text1, new String[]{ getString(R.string.title_main), getString(R.string.title_search), getString(R.string.title_settings), //getString(R.string.title_write), }));*/ mDrawerListView.setAdapter(getAdapter()); mDrawerListView.setItemChecked(mCurrentSelectedPosition + 1, true); return mDrawerListView; }
From source file:conexionSiabra.ConexionSiabra.java
public JSONObject getInformacionOtroUsuario(String username) { Pair<String, String> elemento = new Pair<String, String>("username", username); return oauth.peticionGet(elemento, url_obtener_informacion_otro_usuario); }
From source file:co.nerdart.ourss.fragment.FeedsListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.feed_list_fragment, container, false); mListView = (DragNDropExpandableListView) rootView.findViewById(android.R.id.list); mListAdapter.setExpandableListView(mListView); mListView.setFastScrollEnabled(true); mListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override//from ww w.j a va 2s .c om public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { String title = ((TextView) view.findViewById(android.R.id.text1)).getText().toString(); Matcher m = Pattern.compile("(.*) \\([0-9]+\\)$").matcher(title); if (m.matches()) { title = m.group(1); } long feedId = mListView.getItemIdAtPosition(position); ActionMode actionMode; if (view.findViewById(R.id.indicator).getVisibility() == View.VISIBLE) { // This is a group actionMode = getActivity().startActionMode(mGroupActionModeCallback); } else { // This is a feed actionMode = getActivity().startActionMode(mFeedActionModeCallback); } actionMode.setTag(new Pair<Long, String>(feedId, title)); mListAdapter.setSelectedFeed(feedId); return true; } }); mListView.setAdapter(mListAdapter); mListView.setOnChildClickListener(new OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { mListAdapter.startFeedActivity(id); return false; } }); mListView.setDragNDropListener(new DragNDropListener() { boolean fromHasGroupIndicator = false; @Override public void onStopDrag(View itemView) { } @Override public void onStartDrag(View itemView) { fromHasGroupIndicator = itemView.findViewById(R.id.indicator).getVisibility() == View.VISIBLE; } @Override public void onDrop(final int flatPosFrom, final int flatPosTo) { final boolean fromIsGroup = ExpandableListView.getPackedPositionType(mListView .getExpandableListPosition(flatPosFrom)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP; final boolean toIsGroup = ExpandableListView.getPackedPositionType(mListView .getExpandableListPosition(flatPosTo)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP; final boolean fromIsFeedWithoutGroup = fromIsGroup && !fromHasGroupIndicator; View toView = mListView.getChildAt(flatPosTo - mListView.getFirstVisiblePosition()); boolean toIsFeedWithoutGroup = toIsGroup && toView.findViewById(R.id.indicator).getVisibility() != View.VISIBLE; final long packedPosTo = mListView.getExpandableListPosition(flatPosTo); final int packedGroupPosTo = ExpandableListView.getPackedPositionGroup(packedPosTo); if ((fromIsFeedWithoutGroup || !fromIsGroup) && toIsGroup && !toIsFeedWithoutGroup) { new AlertDialog.Builder(getActivity()) // .setTitle(R.string.to_group_title) // .setMessage(R.string.to_group_message) // .setPositiveButton(R.string.to_group_into, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ContentValues values = new ContentValues(); values.put(FeedColumns.PRIORITY, 1); values.put(FeedColumns.GROUP_ID, mListView.getItemIdAtPosition(flatPosTo)); ContentResolver cr = getActivity().getContentResolver(); cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)), values, null, null); cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null); } }).setNegativeButton(R.string.to_group_above, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo, packedGroupPosTo, flatPosFrom); } }).show(); } else { moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo, packedGroupPosTo, flatPosFrom); } } @Override public void onDrag(int x, int y, ListView listView) { } }); return rootView; }
From source file:com.github.gfx.android.orma.migration.SchemaDiffMigration.java
@NonNull private Pair<Integer, String> fetchSchemaVersions(Database db) { ensureHistoryTableExists(db);//from w w w . j a v a 2s. c o m Cursor cursor = db.query(MIGRATION_STEPS_TABLE, new String[] { kDbVersion, kSchemaHash }, null, null, null, null, kId + " DESC", "1"); try { if (cursor.moveToFirst()) { return new Pair<>(cursor.getInt(0), cursor.getString(1)); } else { return new Pair<>(0, ""); } } finally { cursor.close(); } }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.VideoObj.java
public Pair<JSONObject, byte[]> handleUnprocessed(Context context, JSONObject msg) { byte[] bytes = Base64.decode(msg.optString(DATA)); msg.remove(DATA);/*from w w w . java 2s . c o m*/ return new Pair<JSONObject, byte[]>(msg, bytes); }
From source file:com.android.contacts.common.ContactsUtils.java
/** * Returns the proper Intent for an ImDatItem. If available, a secondary intent is stored * in the second Pair slot/* w w w .j a va2s. c o m*/ */ public static Pair<Intent, Intent> buildImIntent(Context context, ImDataItem im) { Intent intent = null; Intent secondaryIntent = null; final boolean isEmail = im.isCreatedFromEmail(); if (!isEmail && !im.isProtocolValid()) { return new Pair<>(null, null); } final String data = im.getData(); if (TextUtils.isEmpty(data)) { return new Pair<>(null, null); } final int protocol = isEmail ? Im.PROTOCOL_GOOGLE_TALK : im.getProtocol(); if (protocol == Im.PROTOCOL_GOOGLE_TALK) { final int chatCapability = im.getChatCapability(); if ((chatCapability & Im.CAPABILITY_HAS_CAMERA) != 0) { intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("xmpp:" + data + "?message")); secondaryIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("xmpp:" + data + "?call")); } else if ((chatCapability & Im.CAPABILITY_HAS_VOICE) != 0) { // Allow Talking and Texting intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("xmpp:" + data + "?message")); secondaryIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("xmpp:" + data + "?call")); } else { intent = new Intent(Intent.ACTION_SENDTO, Uri.parse("xmpp:" + data + "?message")); } } else { // Build an IM Intent intent = getCustomImIntent(im, protocol); } return new Pair<>(intent, secondaryIntent); }