gitsindonesia / baso

ProgressBar view with image and retry button
Apache License 2.0
155 stars 19 forks source link

Retry Button OnClick listener didn't work following docs #1

Closed fujianto closed 8 years ago

fujianto commented 8 years ago

Hello, First of all, thanks for the nice little library. Really save a lot of times when implementing Progress with refresh button.

I've tried following the docs to implement onClick listener on retry button. When it's clicked, nothing really happened. I'm trying to implement the click listener inside onFailure on Retrofit.

            @Override
            public void onFailure(Call<Fortune> call, Throwable t) {
                t.printStackTrace();
                basoProgressView = (BasoProgressView) findViewById(R.id.baso_ProgressView);
                basoProgressView.stopAndError("Oops. Something happened. Failure "+t.getMessage());
                basoProgressView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        refreshApi();
                        Toast.makeText(v.getContext(), "Refresh CLICKED", Toast.LENGTH_SHORT).show();
                        Log.d("~~Loading", "Refresh CLICKED");
                    }
                });

                Log.d("~~~ Failure", "Failure");
            }

Instead of using basoProgressView to implement onClick, I'm using baso_StoppedButton to implement onClick and it is working when the retry button pressed .

Any idea how it happened? Am I doing something wrong? Currently I'm using baso_StoppedButton to target onClick instead of basoProgressView since baso_StoppedButton is the one that worked.

Regards.

iboen commented 8 years ago

@fujianto , you call the wrong method. You have to call setOnButtonClickListener instead of setOnClickListener. Please try and let me know the result

fujianto commented 8 years ago

My bad, It's working now. Thanks @iboen