Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OnClickListener on Overlay buttons not working #8

Closed
Alecckie opened this issue Jan 15, 2019 · 2 comments
Closed

OnClickListener on Overlay buttons not working #8

Alecckie opened this issue Jan 15, 2019 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@Alecckie
Copy link

I have an overlay with a few options: Share,Delete
I set onclick listener as below but the buttons dont respond to click. Instead, the options disappear from the screen as they would when you click on the Imageviewer.

@OverRide
public void onClick(View view) {

                // Inflate the layout for this
                LayoutInflater inflater = LayoutInflater.from(mContext);
                final View frescoView = inflater.inflate(R.layout.activity_image_options, null);

                new StfalconImageViewer.Builder<>(mContext, imageList, new ImageLoader<Decode_images>() {
                    @Override
                    public void loadImage(ImageView imageView, Decode_images image) {
                        //Usage with picasso... you can use glide too
                        Picasso.get().load(URL_UploadPath+image.getResource_name()).into(imageView);

                    }
                })
                .withStartPosition(position)
                .withOverlayView(frescoView)
                .withImageChangeListener(new OnImageChangeListener() {
                    @Override
                    public void onImageChange(final int position) {
                        //Get actual pic name
                        pic_name=imageList.get(position).getResource_name();
                        pic_position=position;

                        //Set onclick listeners to the overlay buttons
                        make_cover = frescoView.findViewById(R.id.make_cover);
                        share_image = frescoView.findViewById(R.id.share_image);
                        delete_image = frescoView.findViewById(R.id.delete_image);

                        **make_cover.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                //Confirm alert
                                AlertDialog alertDialog = new AlertDialog.Builder(mContext).create();
                                alertDialog.setMessage("Make this image house cover image?");

                                alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Ok", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        //
                                        initialize_house_cover();
                                    }
                                });
                                alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialogInterface, int i) {

                                    }
                                });

                                alertDialog.show();
                            }
                        });**
@Alecckie Alecckie added the question Further information is requested label Jan 15, 2019
@Alecckie
Copy link
Author

I just noticed that the onclick listener fails to register after clicking an image but after swiping to the next image, it works. Guess it fails to register the click on first load of Imageviewer

@Alecckie
Copy link
Author

Solved the issue by defining the button click functions twice.
Once before the onImageChangeLister to handle the first image and
another inside the onImageChangeListener to handle the changing images

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants