Example usage for android.widget ImageView setTransitionName

List of usage examples for android.widget ImageView setTransitionName

Introduction

In this page you can find the example usage for android.widget ImageView 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:spit.matrix2017.Fragments.FavoritesFragment.java

@Override
public void onResume() {
    super.onResume();

    eventListAdapter = new EventListAdapter(getContext(), dbConnectionHelper.getData(String.valueOf(1), 12));
    mRecyclerView.swapAdapter(eventListAdapter, false);
    //12 is the index of favourites in the column array of DB. If value is 1, it has been set as a favourite event
    mRecyclerView.scrollToPosition(0);//from  w  w  w  .j  a  v a 2  s  .c om

    if (eventListAdapter.getItemCount() == 0) {
        blankTextview.setVisibility(View.VISIBLE);
    } else {
        blankTextview.setVisibility(View.GONE);
    }

    mRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(getContext(), mRecyclerView,
            new RecyclerItemClickListener.OnItemClickListener() {
                @Override
                public void onItemClick(View view, int position) {
                    Event event = (dbConnectionHelper.getData(String.valueOf(1), 12)).get(position);

                    Intent i = new Intent(getContext(), EventDetails.class);
                    i.putExtra("image", event.getImage());
                    i.putExtra("name", event.getName());
                    i.putExtra("description", event.getDescription());
                    i.putExtra("venue", event.getVenue());
                    i.putExtra("time", event.getTime());
                    i.putExtra("registration", event.getRegistration());
                    i.putExtra("prizes", event.getPrizes());
                    i.putExtra("contact1name", event.getContact1_name());
                    i.putExtra("contact1no", event.getContact1_no());
                    i.putExtra("contact2name", event.getContact2_name());
                    i.putExtra("contact2no", event.getContact2_no());
                    i.putExtra("favorite", event.getFavourite());
                    i.putExtra("reminder", event.getReminder());

                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        ImageView poster = (ImageView) view.findViewById(R.id.thumbnail);
                        poster.setTransitionName("poster");
                        Pair pair = new Pair<>(poster, ViewCompat.getTransitionName(poster));

                        ActivityOptionsCompat optionsCompat = ActivityOptionsCompat
                                .makeSceneTransitionAnimation(getActivity(), pair);
                        ActivityCompat.startActivity(getActivity(), i, optionsCompat.toBundle());
                    } else
                        getContext().startActivity(i);
                }

                @Override
                public void onLongItemClick(View view, int position) {
                    // do whatever
                }
            }));
}

From source file:spit.matrix2017.Fragments.EventListFragment.java

@Nullable
@Override//from ww w  .j  a  va 2 s . c  o m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.recyclerview_layout, container, false);
    final MatrixContentProvider.MatrixDBConnectionHelper dbConnectionHelper;
    matrixContentProvider = new MatrixContentProvider();
    dbConnectionHelper = new MatrixContentProvider().new MatrixDBConnectionHelper(getContext());

    mRecyclerView = (RecyclerView) view.findViewById(R.id.fragmentRecyclerView);
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());

    mRecyclerView.setAdapter(new EventListAdapter(getContext(), dbConnectionHelper.getData(category, 3)));
    mRecyclerView.scrollToPosition(0);

    mRecyclerView.addOnItemTouchListener(new RecyclerItemClickListener(getContext(), mRecyclerView,
            new RecyclerItemClickListener.OnItemClickListener() {
                @Override
                public void onItemClick(View view, int position) {
                    // do whatever
                    Event event = (dbConnectionHelper.getData(category, 3)).get(position);
                    Intent i = new Intent(getContext(), EventDetails.class);

                    i.putExtra("image", event.getImage());
                    i.putExtra("name", event.getName());
                    i.putExtra("description", event.getDescription());
                    i.putExtra("venue", event.getVenue());
                    i.putExtra("time", event.getTime());
                    i.putExtra("registration", event.getRegistration());
                    i.putExtra("prizes", event.getPrizes());
                    i.putExtra("contact1name", event.getContact1_name());
                    i.putExtra("contact1no", event.getContact1_no());
                    i.putExtra("contact2name", event.getContact2_name());
                    i.putExtra("contact2no", event.getContact2_no());
                    i.putExtra("favorite", event.getFavourite());
                    i.putExtra("reminder", event.getReminder());
                    i.putExtra("color", event.getColor());
                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                        ImageView poster = (ImageView) view.findViewById(R.id.thumbnail);
                        poster.setTransitionName("poster");
                        Pair pair = new Pair<>(poster, ViewCompat.getTransitionName(poster));

                        ActivityOptionsCompat optionsCompat = ActivityOptionsCompat
                                .makeSceneTransitionAnimation(getActivity(), pair);
                        ActivityCompat.startActivity(getActivity(), i, optionsCompat.toBundle());
                    } else
                        getContext().startActivity(i);
                }

                @Override
                public void onLongItemClick(View view, int position) {
                    // do whatever
                }
            }));

    return view;
}

From source file:com.example.xyzreader.ui.articledetail.ArticleDetailFragment.java

private void bindViews() {
    if (mRootView == null || mCursor == null) {
        return;/*from  ww w. ja  v a 2s  .c  o  m*/
    }
    final ImageView detailImageView = (ImageView) mRootView.findViewById(R.id.detail_image);
    final TextView articleTitle = (TextView) mRootView.findViewById(R.id.article_detail_title);
    final TextView articleByLine = (TextView) mRootView.findViewById(R.id.article_detail_byline);
    final TextView bodyView = (TextView) mRootView.findViewById(R.id.article_body);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        long itemId = mCursor.getLong(ArticleLoader.Query._ID);
        String imageTransitionName = mContext.getString(R.string.image_transition_name) + itemId;
        detailImageView.setTransitionName(imageTransitionName);
        //            Log.d(LOG_TAG, "detail image transition name = '" + imageTransitionName + "'");
    }

    Picasso.with(mContext).load(mCursor.getString(ArticleLoader.Query.PHOTO_URL)).into(detailImageView,
            new Callback() {
                @Override
                public void onSuccess() {
                    //                        Log.d(LOG_TAG, "successful image load");
                    mPalette = generatePalette(detailImageView);
                    if (getUserVisibleHint() && isResumed()) {
                        setAppBarColor();
                    }
                }

                @Override
                public void onError() {
                    //                        Log.d(LOG_TAG, "image load FAIL");
                }
            });

    articleTitle.setText(mCursor.getString(ArticleLoader.Query.TITLE));

    String byLine = DateUtils
            .getRelativeTimeSpanString(mCursor.getLong(ArticleLoader.Query.PUBLISHED_DATE),
                    System.currentTimeMillis(), DateUtils.HOUR_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL)
            .toString() + " by " + mCursor.getString(ArticleLoader.Query.AUTHOR);
    articleByLine.setText(byLine);

    // Light up the embedded links in the body of the article
    bodyView.setMovementMethod(LinkMovementMethod.getInstance());

    //        bodyView.setTypeface(Typeface.createFromAsset(getResources().getAssets(), "Rosario-Regular.ttf"));
    bodyView.setText(Html.fromHtml(mCursor.getString(ArticleLoader.Query.BODY)));
}

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());//from   w  w w. j a v a  2s  .  c  om
    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:app.jorge.mobile.com.transportalert.DetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);

    ImageView imageView = (ImageView) findViewById(R.id.iconTube);
    TextView textTubeName = (TextView) findViewById(R.id.tubeName);
    TextView textStatusView = (TextView) findViewById(R.id.tubeStatus);

    String category = getCategory(getIntent().getStringExtra(getString(R.string.activity_info_category)));
    String description = getDescription(
            getIntent().getStringExtra(getString(R.string.activity_info_description)));
    String additional = getIntent().getStringExtra(getString(R.string.activity_info_additional));
    String name = getIntent().getStringExtra(getString(R.string.activity_info_icon));
    String status = getIntent().getStringExtra(getString(R.string.activity_info_status));

    textTubeName.setText(name);/*from   w  w  w .j a va 2s  . co m*/
    textStatusView.setText(status);
    imageView.setBackgroundResource(getIconLine(name));

    TextView textCategoryView = (TextView) findViewById(R.id.category);
    textCategoryView.setText(category);

    TextView textDescriptionView = (TextView) findViewById(R.id.description);
    textDescriptionView.setText(description);

    TextView textAdditionalView = (TextView) findViewById(R.id.additional);
    textAdditionalView.setText(additional);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        imageView.setTransitionName(getString(R.string.activity_image_trans));
        textTubeName.setTransitionName(getString(R.string.activity_text_tube_name));
        textStatusView.setTransitionName(getString(R.string.activity_text_tube_status));

    }

}