Search in sources :

Example 6 with Painting

use of com.alexvasilkov.gestures.sample.ex.utils.Painting in project GestureViews by alexvasilkov.

the class RecyclerToPagerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.list_recycler_screen);
    final Painting[] paintings = Painting.list(getResources());
    // Initializing ListView
    list = findViewById(R.id.recycler_list);
    list.setLayoutManager(new LinearLayoutManager(this));
    list.setAdapter(new RecyclerAdapter(paintings, this::onPaintingClick));
    // Initializing ViewPager
    pager = findViewById(R.id.recycler_pager);
    pagerAdapter = new PagerAdapter(pager, paintings, getSettingsController());
    pager.setAdapter(pagerAdapter);
    pager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.view_pager_margin));
    // Initializing images animator. It requires us to provide FromTracker and IntoTracker items
    // that are used to find images views for particular item IDs in the list and in the pager
    // to keep them in sync.
    // In this example we will use SimpleTracker which will track images by their positions,
    // if you have a more complicated case see further examples.
    final SimpleTracker listTracker = new SimpleTracker() {

        @Override
        public View getViewAt(int position) {
            RecyclerView.ViewHolder holder = list.findViewHolderForLayoutPosition(position);
            return holder == null ? null : RecyclerAdapter.getImageView(holder);
        }
    };
    final SimpleTracker pagerTracker = new SimpleTracker() {

        @Override
        public View getViewAt(int position) {
            RecyclePagerAdapter.ViewHolder holder = pagerAdapter.getViewHolder(position);
            return holder == null ? null : PagerAdapter.getImageView(holder);
        }
    };
    animator = GestureTransitions.from(list, listTracker).into(pager, pagerTracker);
    // Setting up background animation during image transition
    background = findViewById(R.id.recycler_full_background);
    animator.addPositionUpdateListener((pos, isLeaving) -> applyImageAnimationState(pos));
}
Also used : RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclePagerAdapter(com.alexvasilkov.gestures.commons.RecyclePagerAdapter) RecyclePagerAdapter(com.alexvasilkov.gestures.commons.RecyclePagerAdapter) SimpleTracker(com.alexvasilkov.gestures.transition.tracker.SimpleTracker) Painting(com.alexvasilkov.gestures.sample.ex.utils.Painting)

Example 7 with Painting

use of com.alexvasilkov.gestures.sample.ex.utils.Painting in project GestureViews by alexvasilkov.

the class ImageCropActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_crop_screen);
    setTitle(R.string.example_image_cropping);
    getSupportActionBarNotNull().setDisplayHomeAsUpEnabled(true);
    imageView = findViewById(R.id.image_crop_viewer);
    cropView = findViewById(R.id.image_crop_area);
    cropView.setImageView(imageView);
    cropView.setRulesCount(gridRulesCount, gridRulesCount);
    resultView = findViewById(R.id.image_crop_result);
    initCropOptions();
    final Painting painting = Painting.list(getResources())[PAINTING_ID];
    GlideHelper.loadFull(imageView, painting.imageId, painting.thumbId);
}
Also used : Painting(com.alexvasilkov.gestures.sample.ex.utils.Painting)

Example 8 with Painting

use of com.alexvasilkov.gestures.sample.ex.utils.Painting in project GestureViews by alexvasilkov.

the class LayoutViewerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.layout_viewer_screen);
    setTitle(R.string.example_layout_viewer);
    layout = findViewById(R.id.frame_layout);
    // Initializing custom example settings
    setDefaultSettings(layout.getController().getSettings());
    // Loading sample image
    final ImageView imageView = findViewById(R.id.frame_layout_image);
    final Painting painting = Painting.list(getResources())[PAINTING_ID];
    GlideHelper.loadFull(imageView, painting.imageId, painting.thumbId);
    // Handling button click
    findViewById(R.id.frame_layout_button).setOnClickListener(view -> Toast.makeText(this, "Button clicked", Toast.LENGTH_SHORT).show());
}
Also used : ImageView(android.widget.ImageView) Painting(com.alexvasilkov.gestures.sample.ex.utils.Painting)

Example 9 with Painting

use of com.alexvasilkov.gestures.sample.ex.utils.Painting in project GestureViews by alexvasilkov.

the class ListAdapter method onBindImages.

private void onBindImages(ImagesViewHolder holder, ListItem item, int pos) {
    // Computing number of hidden images, starting with no visible images
    int hidden = item.paintings == null ? 0 : item.paintings.size();
    // Going through all available image views
    for (int i = 0, size = holder.images.length; i < size; i++) {
        // Getting painting for current position (if there is one)
        final Painting painting = item.paintings != null && i < item.paintings.size() ? item.paintings.get(i) : null;
        if (painting == null) {
            // No more paintings, hiding current image
            holder.images[i].setVisibility(View.GONE);
        } else {
            // Showing painting's image for current position
            holder.images[i].setVisibility(View.VISIBLE);
            GlideHelper.loadThumb(holder.images[i], painting.thumbId);
            hidden--;
        }
    }
    // Displaying number of hidden paintings, if any
    final String countText = "+" + hidden;
    holder.count.setText(countText);
    holder.count.setVisibility(hidden > 0 ? View.VISIBLE : View.GONE);
    holder.row.setTag(R.id.tag_item, pos);
}
Also used : Painting(com.alexvasilkov.gestures.sample.ex.utils.Painting)

Example 10 with Painting

use of com.alexvasilkov.gestures.sample.ex.utils.Painting in project GestureViews by alexvasilkov.

the class PagerAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
    settingsController.apply(holder.image);
    Painting painting = paintings.get(position);
    GlideHelper.loadFull(holder.image, painting.imageId, painting.thumbId);
}
Also used : Painting(com.alexvasilkov.gestures.sample.ex.utils.Painting)

Aggregations

Painting (com.alexvasilkov.gestures.sample.ex.utils.Painting)23 SpannableBuilder (com.alexvasilkov.android.commons.texts.SpannableBuilder)4 RecyclePagerAdapter (com.alexvasilkov.gestures.commons.RecyclePagerAdapter)3 SimpleTracker (com.alexvasilkov.gestures.transition.tracker.SimpleTracker)3 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1