Search in sources :

Example 1 with Photo

use of com.example.android.unsplash.data.model.Photo in project atlas by alibaba.

the class PhotoAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(final PhotoViewHolder holder, final int position) {
    Photo data = photos.get(position);
    TextView authorview = holder.itemView.findViewById(R.id.author);
    ImageView photoview = holder.itemView.findViewById(R.id.photo);
    holder.setAuthor(data.author);
    photoview.setTransitionName(String.format(photoTransitionFormat, data.id));
    authorview.setText(data.author);
    authorview.setTransitionName(String.format(authorTransitionFormat, data.id));
    holder.setId(data.id);
    Glide.with(layoutInflater.getContext()).load(data.getPhotoUrl(requestedPhotoWidth)).placeholder(R.color.placeholder).override(ImageSize.NORMAL[0], ImageSize.NORMAL[1]).into((ImageView) holder.itemView.findViewById(R.id.photo));
}
Also used : Photo(com.example.android.unsplash.data.model.Photo) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 2 with Photo

use of com.example.android.unsplash.data.model.Photo in project atlas by alibaba.

the class DetailViewPagerAdapter method instantiateItem.

@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = layoutInflater.inflate(R.layout.detail_view, container, false);
    ThreeTwoImageView photoview = view.findViewById(R.id.photo);
    TextView authorview = view.findViewById(R.id.author);
    Photo photo = allPhotos.get(position);
    photoview.setTransitionName(String.format(photoTransitionFormat, photo.id));
    authorview.setText(photo.author);
    authorview.setTransitionName(String.format(authorTransitionFormat, photo.id));
    onViewBound(photoview, photo);
    container.addView(view);
    return view;
}
Also used : ThreeTwoImageView(com.example.android.unsplash.ui.ThreeTwoImageView) TextView(android.widget.TextView) Photo(com.example.android.unsplash.data.model.Photo) ImageView(android.widget.ImageView) TextView(android.widget.TextView) ThreeTwoImageView(com.example.android.unsplash.ui.ThreeTwoImageView) View(android.view.View)

Example 3 with Photo

use of com.example.android.unsplash.data.model.Photo in project atlas by alibaba.

the class DetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_detail);
    postponeEnterTransition();
    TransitionSet transitions = new TransitionSet();
    Slide slide = new Slide(Gravity.BOTTOM);
    slide.setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in));
    slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
    transitions.addTransition(slide);
    transitions.addTransition(new Fade());
    getWindow().setEnterTransition(transitions);
    Intent intent = getIntent();
    sharedElementCallback = new DetailSharedElementEnterCallback(intent);
    setEnterSharedElementCallback(sharedElementCallback);
    try {
        initialItem = Integer.parseInt(intent.getData().getLastPathSegment());
    } catch (NumberFormatException e) {
        initialItem = 0;
    }
    PhotoService.getInstance().getPhotosAsync(new PhotoService.PhotoCallback() {

        @Override
        public void success(ArrayList<Photo> photos) {
            setUpViewPager(photos);
            findViewById(android.R.id.empty).setVisibility(View.GONE);
        }

        @Override
        public void error() {
            finishAfterTransition();
        }
    });
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    toolbar.setNavigationOnClickListener(navigationOnClickListener);
    super.onCreate(savedInstanceState);
}
Also used : DetailSharedElementEnterCallback(com.example.android.unsplash.ui.DetailSharedElementEnterCallback) TransitionSet(android.transition.TransitionSet) Slide(android.transition.Slide) PhotoService(com.example.android.unsplash.data.PhotoService) Intent(android.content.Intent) Photo(com.example.android.unsplash.data.model.Photo) Fade(android.transition.Fade) Toolbar(android.widget.Toolbar)

Aggregations

Photo (com.example.android.unsplash.data.model.Photo)3 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 Intent (android.content.Intent)1 Fade (android.transition.Fade)1 Slide (android.transition.Slide)1 TransitionSet (android.transition.TransitionSet)1 View (android.view.View)1 Toolbar (android.widget.Toolbar)1 PhotoService (com.example.android.unsplash.data.PhotoService)1 DetailSharedElementEnterCallback (com.example.android.unsplash.ui.DetailSharedElementEnterCallback)1 ThreeTwoImageView (com.example.android.unsplash.ui.ThreeTwoImageView)1