package com.veinhorn.scrollgalleryview.example.builder;

import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import android.widget.Toast;

import com.veinhorn.scrollgalleryview.MediaInfo;
import com.veinhorn.scrollgalleryview.ScrollGalleryView;
import com.veinhorn.scrollgalleryview.builder.GallerySettings;
import com.veinhorn.scrollgalleryview.loader.picasso.PicassoImageLoader;

import static com.veinhorn.scrollgalleryview.loader.picasso.dsl.DSL.*;

public class MainActivity extends FragmentActivity {
    private ScrollGalleryView galleryView;

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

        galleryView = ScrollGalleryView
                .from((ScrollGalleryView) findViewById(R.id.scroll_gallery_view))
                .settings(
                        GallerySettings
                                .from(getSupportFragmentManager())
                                .thumbnailSize(100)
                                .enableZoom(true)
                                .build()
                )
                .onImageClickListener(new ScrollGalleryView.OnImageClickListener() {
                    @Override
                    public void onClick(int position) {
                        Toast.makeText(MainActivity.this, "image position = " + position, Toast.LENGTH_SHORT).show();
                    }
                })
                .onImageLongClickListener(new ScrollGalleryView.OnImageLongClickListener() {
                    @Override
                    public void onClick(int position) {
                        Toast.makeText(MainActivity.this, "image position = " + position, Toast.LENGTH_SHORT).show();
                    }
                })
                .add(image("http://povodu.ru/wp-content/uploads/2016/04/pochemu-korabl-derzitsa-na-vode.jpg"))
                .add(video("http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4", R.mipmap.default_video))
                .add(image(
                        "https://i.pinimg.com/originals/1b/d3/f0/1bd3f0e146da86f9c504e89a0b7e1403.jpg",
                        "Old Ship"
                ))
                .build();

                galleryView.addMedia(MediaInfo.mediaLoader(
                        new PicassoImageLoader("https://upload.wikimedia.org/wikipedia/commons/thumb/8/81/USRC_Salmon_P_Chase_-_LoC_4a25817u.jpg/1200px-USRC_Salmon_P_Chase_-_LoC_4a25817u.jpg"),
                        "The word barque entered English via French, which in turn came from the Latin barca by way of Occitan, Catalan, Spanish or Italian."
                ));
    }
}

@@ -124,16 +124,83 @@
 Bundle;%0A
+import android.support.v4.view.ViewPager;%0Aimport android.util.Log;%0A
 import a
@@ -220,16 +220,16 @@
 .Toast;%0A
-
 %0Aimport 
@@ -589,16 +589,85 @@
 ivity %7B%0A
+    private static final String TAG = MainActivity.class.getName();%0A%0A
     priv
@@ -1943,32 +1943,98 @@
              %7D)%0A
+                .onPageChangeListener(new CustomOnPageListener())%0A
                 
@@ -2879,16 +2879,16 @@
 alian.%22%0A
-
         
@@ -2904,11 +2904,237 @@
 );%0A    %7D
+%0A%0A    private class CustomOnPageListener extends ViewPager.SimpleOnPageChangeListener %7B%0A        @Override%0A        public void onPageSelected(int position) %7B%0A            Log.i(TAG, %22page selected #%22 + position);%0A        %7D%0A    %7D
 %0A%7D%0A

update builder_example