Example usage for android.view View setTransitionName

List of usage examples for android.view View setTransitionName

Introduction

In this page you can find the example usage for android.view View setTransitionName.

Prototype

public final void setTransitionName(String transitionName) 

Source Link

Document

Sets the name of the View to be used to identify Views in Transitions.

Usage

From source file:app.jorge.mobile.com.transportalert.ScrollingActivity.java

private void addCard(LinearLayout item, CardFactory.TUBE_LINE line) {

    CardTube card = CardFactory.getCard(line);
    View child = getLayoutInflater().inflate(R.layout.tube_line, null);

    ImageView imageView = (ImageView) child.findViewById(R.id.iconTube);
    //imageView.setImageResource(card.getIcon());
    imageView.setImageBitmap(decodeSampledBitmapFromResource(getResources(), card.getIcon(), 100, 100));

    TextView lineName = (TextView) child.findViewById(R.id.tubeName);
    lineName.setText(card.getName());//w w w  . j  av  a2s  . c o  m
    lineName.setTextColor(Color.parseColor(card.getColour()));

    TextView text = (TextView) child.findViewById(R.id.tubeStatus);
    text.setText(card.getStatus());

    item.addView(child);

    child.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            View imageView = v.findViewById(R.id.iconTube);
            imageView.setTransitionName(getString(R.string.activity_image_trans));

            View textTubeNameView = v.findViewById(R.id.tubeName);
            textTubeNameView.setTransitionName(getString(R.string.activity_text_tube_name));

            View textStatusView = v.findViewById(R.id.tubeStatus);
            textStatusView.setTransitionName(getString(R.string.activity_text_tube_status));

            Intent intent = new Intent(ScrollingActivity.this, DetailActivity.class);
            Pair<View, String> pair1 = Pair.create(imageView, imageView.getTransitionName());
            Pair<View, String> pair2 = Pair.create(textTubeNameView, textTubeNameView.getTransitionName());
            Pair<View, String> pair3 = Pair.create(textStatusView, textStatusView.getTransitionName());

            ActivityOptionsCompat options = ActivityOptionsCompat
                    .makeSceneTransitionAnimation(ScrollingActivity.this, pair1, pair2, pair3);

            String line = ((TextView) textTubeNameView).getText().toString();
            String status = ((TextView) textStatusView).getText().toString();

            LineStatuses ls = tubeStatus.get(line);
            if ((ls != null) && (ls.getDisruption() != null)) {
                intent.putExtra(getString(R.string.activity_info_category), ls.getDisruption().getCategory());
                intent.putExtra(getString(R.string.activity_info_description),
                        ls.getDisruption().getDescription());
                intent.putExtra(getString(R.string.activity_info_additional),
                        ls.getDisruption().getAdditionalInfo());
                intent.putExtra(getString(R.string.activity_info_icon), line);
                intent.putExtra(getString(R.string.activity_info_status), status);

                startActivity(intent, options.toBundle());
            }

        }
    });

}

From source file:com.example.xyzreader.ui.articlelist.ArticleListAdapter.java

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(mContext).inflate(R.layout.article_list_item, parent, false);
    final ViewHolder vh = new ViewHolder(view);

    view.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w ww.  j ava2  s .  c o m*/
        public void onClick(View view) {
            final long itemId = getItemId(vh.getAdapterPosition());
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                // implement a transition if running on 21 or greater
                final ActivityOptionsCompat options;
                final View imageView = view.findViewById(R.id.article_list_image);

                final String imageTransitionName = mContext.getString(R.string.image_transition_name) + itemId;
                final Pair<View, String> p1 = Pair.create(imageView, imageTransitionName);
                //                    Log.d(LOG_TAG, "item click image transition name = '" + imageTransitionName + "'");
                imageView.setTransitionName(imageTransitionName);
                options = ActivityOptionsCompat.makeSceneTransitionAnimation((ArticleListActivity) mContext,
                        p1);
                mContext.startActivity(new Intent(Intent.ACTION_VIEW, ItemsContract.Items.buildItemUri(itemId)),
                        options.toBundle());
            } else {
                mContext.startActivity(
                        new Intent(Intent.ACTION_VIEW, ItemsContract.Items.buildItemUri(itemId)));
            }
        }
    });
    return vh;
}

From source file:org.sufficientlysecure.keychain.ui.linked.LinkedIdCreateGithubFragment.java

private void step2PostGist(final String accessToken, final String gistText) {

    setState(State.POST_PROCESS);

    new AsyncTask<Void, Void, JSONObject>() {

        Exception mException;//from w  w  w.j  a v a2  s .c o  m

        @Override
        protected JSONObject doInBackground(Void... dummy) {
            try {

                long timer = System.currentTimeMillis();

                JSONObject file = new JSONObject();
                file.put("content", gistText);

                JSONObject files = new JSONObject();
                files.put("openpgp.txt", file);

                JSONObject params = new JSONObject();
                params.put("public", true);
                params.put("description", getString(R.string.linked_gist_description));
                params.put("files", files);

                JSONObject result = jsonHttpRequest("https://api.github.com/gists", params, accessToken);

                // ux flow: this operation should take at last a second
                timer = System.currentTimeMillis() - timer;
                if (timer < 1000)
                    try {
                        Thread.sleep(1000 - timer);
                    } catch (InterruptedException e) {
                        // never mind
                    }

                return result;

            } catch (IOException | HttpResultException e) {
                mException = e;
            } catch (JSONException e) {
                throw new AssertionError("json error, this is a bug!");
            }
            return null;
        }

        @Override
        protected void onPostExecute(JSONObject result) {
            super.onPostExecute(result);

            Log.d(Constants.TAG, "response: " + result);

            Activity activity = getActivity();
            if (activity == null) {
                // we couldn't show an error anyways
                return;
            }

            if (result == null) {
                setState(State.POST_ERROR);
                showRetryForOAuth();

                if (mException instanceof SocketTimeoutException) {
                    Notify.create(activity, R.string.linked_error_timeout, Style.ERROR).show();
                } else if (mException instanceof HttpResultException) {
                    Notify.create(activity, activity.getString(R.string.linked_error_http,
                            ((HttpResultException) mException).mResponse), Style.ERROR).show();
                } else if (mException instanceof IOException) {
                    Notify.create(activity, R.string.linked_error_network, Style.ERROR).show();
                }

                return;
            }

            GithubResource resource;

            try {
                String gistId = result.getString("id");
                JSONObject owner = result.getJSONObject("owner");
                String gistLogin = owner.getString("login");

                URI uri = URI.create("https://gist.github.com/" + gistLogin + "/" + gistId);
                resource = GithubResource.create(uri);
            } catch (JSONException e) {
                setState(State.POST_ERROR);
                return;
            }

            View linkedItem = mButtonContainer.getChildAt(2);
            if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
                linkedItem.setTransitionName(resource.toUri().toString());
            }

            // we only need authorization for this one operation, drop it afterwards
            revokeToken(accessToken);

            step3EditKey(resource);
        }

    }.execute();

}

From source file:org.sufficientlysecure.keychain.ui.adapter.LinkedIdsAdapter.java

@Override
public void bindView(View view, Context context, Cursor cursor) {

    ViewHolder holder = (ViewHolder) view.getTag();

    if (!mIsSecret) {
        int isVerified = cursor.getInt(INDEX_VERIFIED);
        switch (isVerified) {
        case Certs.VERIFIED_SECRET:
            KeyFormattingUtils.setStatusImage(mContext, holder.vVerified, null, State.VERIFIED,
                    KeyFormattingUtils.DEFAULT_COLOR);
            break;
        case Certs.VERIFIED_SELF:
            KeyFormattingUtils.setStatusImage(mContext, holder.vVerified, null, State.UNVERIFIED,
                    KeyFormattingUtils.DEFAULT_COLOR);
            break;
        default:/*from ww w .  j a  va  2s .c  o m*/
            KeyFormattingUtils.setStatusImage(mContext, holder.vVerified, null, State.INVALID,
                    KeyFormattingUtils.DEFAULT_COLOR);
            break;
        }
    }

    UriAttribute id = getItemAtPosition(cursor);
    holder.setData(mContext, id);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        view.setTransitionName(id.mUri.toString());
    }

}