Skip to main content
public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.ViewHolder> 
{
    private ArrayList<Business> businessList;
    private ActivityFragmentActivity activity;
    private int layoutMolde,position;

    public ViewImageExtended viewImageExtended;
    public Bitmap bitmap = null;

    public GalleryAdapter(ActivityFragmentActivity activity, ArrayList<Business> list, int layout)
    {
        this.activity = activity;
        this.businessList = list;
        layoutMolde = layout;
    }

    @Override
    public GalleryAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
    {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_gallery_premium, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position)
    {

        if(businessList.size()==0){
            holder.Imggallerypremium.setVisibility(View.GONE);
        }else {
            Log.d("ARRAY", businessList.toString());
         Glide.with(activity).load(businessList.get(position).getImage())
                    .into(holder.Imggallerypremium);
        }



    }

    @Override

    public int getItemCount() {

        return (businessList == null) ? 0 : businessList.size();


    }



    public class ViewHolder extends RecyclerView.ViewHolder
    {

        public ImageView Imggallerypremium;

        public ViewHolder( View itemView)
        {
            super(itemView);
            Imggallerypremium = (ImageView) itemView.findViewById(R.id.imgGalleryPremium);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
 
                    bitmap = ((BitmapDrawable)(Imggallerypremium.getDrawable()).getBitmap();
                    if(viewImageExtended == null || viewImageExtended.getDialog() == null || !viewImageExtended.getDialog().isShowing()){

                        FragmentManager fm = GalleryAdapter.this.activity.getSupportFragmentManager();
                        Bundle arguments = new Bundle();

                        // Aqui le pasas el bitmap de la imagen
                        arguments.putParcelable("PROFILE_PICTURE", bitmap);
                        viewImageExtended = ViewImageExtended.newInstance(arguments);
                        viewImageExtended.show(fm, "ViewImageExtended");

                    }

                }
            });
        }
    }
}
public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.ViewHolder> 
{
    private ArrayList<Business> businessList;
    private Activity activity;
    private int layoutMolde,position;

    public ViewImageExtended viewImageExtended;
    public Bitmap bitmap = null;

    public GalleryAdapter(Activity activity, ArrayList<Business> list, int layout)
    {
        this.activity = activity;
        this.businessList = list;
        layoutMolde = layout;
    }

    @Override
    public GalleryAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
    {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_gallery_premium, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position)
    {

        if(businessList.size()==0){
            holder.Imggallerypremium.setVisibility(View.GONE);
        }else {
            Log.d("ARRAY", businessList.toString());
         Glide.with(activity).load(businessList.get(position).getImage())
                    .into(holder.Imggallerypremium);
        }



    }

    @Override

    public int getItemCount() {

        return (businessList == null) ? 0 : businessList.size();


    }



    public class ViewHolder extends RecyclerView.ViewHolder
    {

        public ImageView Imggallerypremium;

        public ViewHolder( View itemView)
        {
            super(itemView);
            Imggallerypremium = (ImageView) itemView.findViewById(R.id.imgGalleryPremium);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
 

                    if(viewImageExtended == null || viewImageExtended.getDialog() == null || !viewImageExtended.getDialog().isShowing()){

                        FragmentManager fm = GalleryAdapter.this.getSupportFragmentManager();
                        Bundle arguments = new Bundle();

                        // Aqui le pasas el bitmap de la imagen
                        arguments.putParcelable("PROFILE_PICTURE", bitmap);
                        viewImageExtended = ViewImageExtended.newInstance(arguments);
                        viewImageExtended.show(fm, "ViewImageExtended");

                    }

                }
            });
        }
    }
}
public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.ViewHolder> 
{
    private ArrayList<Business> businessList;
    private FragmentActivity activity;
    private int layoutMolde,position;

    public ViewImageExtended viewImageExtended;
    public Bitmap bitmap = null;

    public GalleryAdapter(FragmentActivity activity, ArrayList<Business> list, int layout)
    {
        this.activity = activity;
        this.businessList = list;
        layoutMolde = layout;
    }

    @Override
    public GalleryAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
    {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_gallery_premium, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position)
    {

        if(businessList.size()==0){
            holder.Imggallerypremium.setVisibility(View.GONE);
        }else {
            Log.d("ARRAY", businessList.toString());
         Glide.with(activity).load(businessList.get(position).getImage())
                    .into(holder.Imggallerypremium);
        }



    }

    @Override

    public int getItemCount() {

        return (businessList == null) ? 0 : businessList.size();


    }



    public class ViewHolder extends RecyclerView.ViewHolder
    {

        public ImageView Imggallerypremium;

        public ViewHolder( View itemView)
        {
            super(itemView);
            Imggallerypremium = (ImageView) itemView.findViewById(R.id.imgGalleryPremium);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    bitmap = ((BitmapDrawable)(Imggallerypremium.getDrawable()).getBitmap();
                    if(viewImageExtended == null || viewImageExtended.getDialog() == null || !viewImageExtended.getDialog().isShowing()){

                        FragmentManager fm = this.activity.getSupportFragmentManager();
                        Bundle arguments = new Bundle();

                        // Aqui le pasas el bitmap de la imagen
                        arguments.putParcelable("PROFILE_PICTURE", bitmap);
                        viewImageExtended = ViewImageExtended.newInstance(arguments);
                        viewImageExtended.show(fm, "ViewImageExtended");

                    }

                }
            });
        }
    }
}
se añadieron 6243 caracteres en el cuerpo
Origen Enlace
Heber Solis
  • 195
  • 1
  • 11

ADAPTER

public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.ViewHolder> 
{
    private ArrayList<Business> businessList;
    private Activity activity;
    private int layoutMolde,position;

    public ViewImageExtended viewImageExtended;
    public Bitmap bitmap = null;

    public GalleryAdapter(Activity activity, ArrayList<Business> list, int layout)
    {
        this.activity = activity;
        this.businessList = list;
        layoutMolde = layout;
    }

    @Override
    public GalleryAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
    {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_gallery_premium, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position)
    {

        if(businessList.size()==0){
            holder.Imggallerypremium.setVisibility(View.GONE);
        }else {
            Log.d("ARRAY", businessList.toString());
         Glide.with(activity).load(businessList.get(position).getImage())
                    .into(holder.Imggallerypremium);
        }



    }

    @Override

    public int getItemCount() {

        return (businessList == null) ? 0 : businessList.size();


    }



    public class ViewHolder extends RecyclerView.ViewHolder
    {

        public ImageView Imggallerypremium;

        public ViewHolder( View itemView)
        {
            super(itemView);
            Imggallerypremium = (ImageView) itemView.findViewById(R.id.imgGalleryPremium);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {


                    if(viewImageExtended == null || viewImageExtended.getDialog() == null || !viewImageExtended.getDialog().isShowing()){

                        FragmentManager fm = GalleryAdapter.this.getSupportFragmentManager();
                        Bundle arguments = new Bundle();

                        // Aqui le pasas el bitmap de la imagen
                        arguments.putParcelable("PROFILE_PICTURE", bitmap);
                        viewImageExtended = ViewImageExtended.newInstance(arguments);
                        viewImageExtended.show(fm, "ViewImageExtended");

                    }

                }
            });
        }
    }
}

ACTIVITY

public class BusinessPremiumGallery extends AppCompatActivity
{
GalleryAdapter galleryAdapter;
    Gson gson;
    public ViewImageExtended viewImageExtended;
    public Bitmap bitmap = null;
    private static final Type BUSINESS_TYPE = new TypeToken<ArrayList<Business>>() {}.getType();

    JsonObject images;
    GridLayoutManager layoutManager;
    ArrayList<Business> arrayGallery;
   
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_business_premium_gallery);
        Bundle bundle = getIntent().getExtras();
        final int values = bundle.getInt("no");
        new PlifRequestBase(BusinessPremiumGallery.this) {

            @Override
            public JsonObject onHttpOk(JsonObject response) throws JSONException {
                JsonObject respuesta, details, location, geolocation, matrix, schedules_array;
                JsonArray data,branches, phones, schedules,extra_services,user_images;
                respuesta = response;
                int catalog_id;
                String catalog_descrip,catalog_name,catalog_image,image;

                Log.d("VALUES2",String.valueOf(values));
                arrayGallery=new ArrayList<Business>();
                gson=new Gson();
                user_images= respuesta.get("user_images").getAsJsonArray();


                if(user_images.size()<0){
                    arrayGallery=null;
                    images=null;

                }else {
                    arrayGallery=gson.fromJson(user_images,BUSINESS_TYPE);
                    for (int i = 0; i < user_images.size(); i++) {
                        images = user_images.get(i).getAsJsonObject();
                        image=images.get("image").getAsString();
                       Log.d("IMAGES",image);
                        Log.d("CATALOG",String.valueOf(images));

                    }


                }
                if (BusinessPremiumGallery.this == null)
                    return response;
                BusinessPremiumGallery.this.runOnUiThread(new Runnable() {
                    public void run() {
                        RecyclerView recycler = (RecyclerView) BusinessPremiumGallery.this.findViewById(R.id.recycler_gallery);
                        galleryAdapter = new GalleryAdapter(BusinessPremiumGallery.this, arrayGallery, R.layout.row_gallery_premium);
                        recycler.setNestedScrollingEnabled(false);
                        layoutManager = new GridLayoutManager(BusinessPremiumGallery.this, 2);
                        recycler.setLayoutManager(layoutManager);
                        recycler.setAdapter(galleryAdapter);
                    }

                });

                return respuesta;
            }

            @Override
            public void onHttpCreate(JsonObject response) throws JSONException
            {

            }
        }.execute("businesses/"+String.valueOf(values), "GET");
    }





}

ADAPTER

public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.ViewHolder> 
{
    private ArrayList<Business> businessList;
    private Activity activity;
    private int layoutMolde,position;

    public ViewImageExtended viewImageExtended;
    public Bitmap bitmap = null;

    public GalleryAdapter(Activity activity, ArrayList<Business> list, int layout)
    {
        this.activity = activity;
        this.businessList = list;
        layoutMolde = layout;
    }

    @Override
    public GalleryAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
    {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_gallery_premium, parent, false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, final int position)
    {

        if(businessList.size()==0){
            holder.Imggallerypremium.setVisibility(View.GONE);
        }else {
            Log.d("ARRAY", businessList.toString());
         Glide.with(activity).load(businessList.get(position).getImage())
                    .into(holder.Imggallerypremium);
        }



    }

    @Override

    public int getItemCount() {

        return (businessList == null) ? 0 : businessList.size();


    }



    public class ViewHolder extends RecyclerView.ViewHolder
    {

        public ImageView Imggallerypremium;

        public ViewHolder( View itemView)
        {
            super(itemView);
            Imggallerypremium = (ImageView) itemView.findViewById(R.id.imgGalleryPremium);
            itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {


                    if(viewImageExtended == null || viewImageExtended.getDialog() == null || !viewImageExtended.getDialog().isShowing()){

                        FragmentManager fm = GalleryAdapter.this.getSupportFragmentManager();
                        Bundle arguments = new Bundle();

                        // Aqui le pasas el bitmap de la imagen
                        arguments.putParcelable("PROFILE_PICTURE", bitmap);
                        viewImageExtended = ViewImageExtended.newInstance(arguments);
                        viewImageExtended.show(fm, "ViewImageExtended");

                    }

                }
            });
        }
    }
}

ACTIVITY

public class BusinessPremiumGallery extends AppCompatActivity
{
GalleryAdapter galleryAdapter;
    Gson gson;
    public ViewImageExtended viewImageExtended;
    public Bitmap bitmap = null;
    private static final Type BUSINESS_TYPE = new TypeToken<ArrayList<Business>>() {}.getType();

    JsonObject images;
    GridLayoutManager layoutManager;
    ArrayList<Business> arrayGallery;
   
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_business_premium_gallery);
        Bundle bundle = getIntent().getExtras();
        final int values = bundle.getInt("no");
        new PlifRequestBase(BusinessPremiumGallery.this) {

            @Override
            public JsonObject onHttpOk(JsonObject response) throws JSONException {
                JsonObject respuesta, details, location, geolocation, matrix, schedules_array;
                JsonArray data,branches, phones, schedules,extra_services,user_images;
                respuesta = response;
                int catalog_id;
                String catalog_descrip,catalog_name,catalog_image,image;

                Log.d("VALUES2",String.valueOf(values));
                arrayGallery=new ArrayList<Business>();
                gson=new Gson();
                user_images= respuesta.get("user_images").getAsJsonArray();


                if(user_images.size()<0){
                    arrayGallery=null;
                    images=null;

                }else {
                    arrayGallery=gson.fromJson(user_images,BUSINESS_TYPE);
                    for (int i = 0; i < user_images.size(); i++) {
                        images = user_images.get(i).getAsJsonObject();
                        image=images.get("image").getAsString();
                       Log.d("IMAGES",image);
                        Log.d("CATALOG",String.valueOf(images));

                    }


                }
                if (BusinessPremiumGallery.this == null)
                    return response;
                BusinessPremiumGallery.this.runOnUiThread(new Runnable() {
                    public void run() {
                        RecyclerView recycler = (RecyclerView) BusinessPremiumGallery.this.findViewById(R.id.recycler_gallery);
                        galleryAdapter = new GalleryAdapter(BusinessPremiumGallery.this, arrayGallery, R.layout.row_gallery_premium);
                        recycler.setNestedScrollingEnabled(false);
                        layoutManager = new GridLayoutManager(BusinessPremiumGallery.this, 2);
                        recycler.setLayoutManager(layoutManager);
                        recycler.setAdapter(galleryAdapter);
                    }

                });

                return respuesta;
            }

            @Override
            public void onHttpCreate(JsonObject response) throws JSONException
            {

            }
        }.execute("businesses/"+String.valueOf(values), "GET");
    }





}
se añadieron 30 caracteres en el cuerpo
Origen Enlace
cnbandicoot
  • 2.8k
  • 11
  • 24

Tengo una galeriagalería en mi app, con un gridlayoutGridLayout y quiero que cuando el usuario le de clic a alguna imagen tenga esteeste efecto https://i.sstatic.net/dewYt.jpg, como se logra¿Cómo puedo lograr eso?, si Si me pudieran decir que efecto seria ese o alguna librerialibrería que lo hace seria de gran ayuda muchas gracias

Tengo una galeria en mi app, con un gridlayout y quiero que cuando el usuario le de clic a alguna imagen tenga este efecto https://i.sstatic.net/dewYt.jpg, como se logra eso?, si me pudieran decir que efecto seria ese o alguna libreria que lo hace seria de gran ayuda muchas gracias

Tengo una galería en mi app, con un GridLayout y quiero que cuando el usuario le de clic a alguna imagen tenga este efecto , ¿Cómo puedo lograr eso? Si me pudieran decir que efecto seria ese o alguna librería que lo hace seria de gran ayuda muchas gracias

Origen Enlace
Heber Solis
  • 195
  • 1
  • 11
Loading