Giter VIP home page Giter VIP logo

androidbuttonprogress's People

Contributors

abdularis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

androidbuttonprogress's Issues

Button sets visibility to VISIBLE when setting state

I'm running the following code:

<com.github.abdularis.buttonprogress.DownloadButtonProgress
    android:id="@+id/button_synchronize"
    android:layout_width="32dp"
    android:layout_height="32dp"
    android:visibility="@{entry.canSynchronize() ? View.VISIBLE : View.GONE}"
    app:buttonState="@{entry.synchronizationState}"
    />

and using data-binding to synchronize the button state and visibility.

I'm using the following databinding adapter:

public class DownloadButtonStateBindingAdapter {
    @BindingAdapter("buttonState")
    public static void setMyAttr(DownloadButtonProgress myInnerView, int value) {
        switch (value) {
            case DownloadButtonProgress.STATE_IDLE:
                myInnerView.setIdle();
                break;
            case DownloadButtonProgress.STATE_INDETERMINATE:
                myInnerView.setIndeterminate();
                break;
            case DownloadButtonProgress.STATE_DETERMINATE:
                myInnerView.setDeterminate();
                break;
            case DownloadButtonProgress.STATE_FINISHED:
                myInnerView.setFinish();
                break;
            default:
                break;
        }
    }
}

unfortunately, the setIdle, ... methods do more than just setting the state.

    public void setIdle() {
        mCurrState = STATE_IDLE;
        setVisibility(VISIBLE);
        invalidate();
    }

This forces me to reset the visibility after each setIdle call. Why are you setting the visibility here? Could you please remove that call?

how button back to idle state when we click on cancle icon

sessionHolder.progressBar.addOnClickListener(new DownloadButtonProgress.OnClickListener() {
            @Override
            public void onIdleButtonClick(View view) {
                download(ccModel.getUrl(), ccModel.getText3()+".mp3",path,sessionHolder);

            }

            @Override
            public void onCancelButtonClick(View view) {

              PRDownloader.cancelAll();

            }

            @Override
            public void onFinishButtonClick(View view) {

            }
        });

 private void download(String url, String fileName, String dirPath,final SessionHolder sessionHolder){
        PRDownloaderConfig config = PRDownloaderConfig.newBuilder().setReadTimeout(30_000).setConnectTimeout(30_000).build();
PRDownloader.cancelAll();
        PRDownloader.initialize(mcontext.getApplicationContext(), config);
        PRDownloader.download(url, dirPath, fileName)
                .build()
                .setOnStartOrResumeListener(new OnStartOrResumeListener() {
                    @Override
                    public void onStartOrResume() {
                        // holder.progressBar.setVisibility(View.VISIBLE);
                    }
                })
                .setOnProgressListener(new OnProgressListener() {
                    @Override
                    public void onProgress(Progress progress) {
                        sessionHolder.progressBar.setDeterminate();
                        sessionHolder.progressBar.setCurrentProgress((int)(((float)progress.currentBytes/progress.totalBytes)*100));
                    }
                }).setOnCancelListener(new OnCancelListener() {
            @Override
            public void onCancel() {
                Drawable n = AppCompatResources.getDrawable(mcontext , R.drawable.ic_cloud_download_black_24dp);


                sessionHolder.progressBar.setCancelable(true);
            }
        }).start(new OnDownloadListener() {
                    @Override
                    public void onDownloadComplete() {
                        // holder.progressBar.setVisibility(View.GONE);
                        Toast.makeText(mcontext, "دانلود با موفقیت انجام شد", Toast.LENGTH_LONG).show();
           sessionHolder.progressBar.setFinish();
                    }

                    @Override
                    public void onError(Error error) {
                        Toast.makeText(mcontext, "اتصال به اینترنت را چک کنید", Toast.LENGTH_LONG).show();

                    }


                });
    }

onClick listener does not work with databinding

When using databinding like this:

<com.github.abdularis.buttonprogress.DownloadButtonProgress
    android:id="@+id/button_download"
    android:layout_width="32dp"
    android:layout_height="32dp"
    android:onClick="@{() -> viewModel.doSomething()}"   
    />

the doSomething method is never called.

My current workaround is to use a binding adapter.

@BindingAdapter("downloadButtonOnClick")
public static void setOnClickListener(DownloadButtonProgress myInnerView, View.OnClickListener listener) {
    myInnerView.setOnClickListener(listener);
}

and

<com.github.abdularis.buttonprogress.DownloadButtonProgress
    android:id="@+id/button_download"
    android:layout_width="32dp"
    android:layout_height="32dp"
    app:downloadButtonOnClick="@{() -> viewModel.doSomething()}"
    />

Attribute Conflict with AndroidX Upgrade

Is it possible that you can fix the below error in the next release?

capture

It requires re-naming the attribute progress to something else, to avoid compilation error due to conflicts with similar attirbutes already defined in AndroidX libraries. @abdularis

License should be added

As there is no license provided for this project, I am unsure as to I am able to use it. Anyone able to clear that up?

In Correct Dependency

Hello...First of all Nice Library...In your recent update having dependency
implementation 'com.github.abdularis:AndroidButtonProgress:1.0.1' has mistake that it includes capital letters which causes build failure...After minimizing it project builds succefully...So please correct it to implementation 'com.github.abdularis:androidbuttonprogress:1.0.1'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.