daimajia / NumberProgressBar

A beautiful, slim Android ProgressBar.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onProgressChange not called

ntaloventi opened this issue · comments

hi, i'm using your library to download file and when its reached 100% install apk or view image, but onProgressChange not being called, how to know which part that was miss by me?

xml
<com.daimajia.numberprogressbar.NumberProgressBar android:id="@+id/npb" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_margin="10dp" android:padding="10dp" custom:progress_max="100" style="@style/NumberProgressBar_Warning_Red"/>

change listener
@Override public void onProgressChange(int current, int max) { if (current == max){ //instal on apps new Handler().postDelayed(new Runnable() { @Override public void run() { installOnDevice(); npb.setProgress(0); } }, 2000); } }

in asynctask
protected void onProgressUpdate(String... progress) { // setting progress percentage npb.setProgress(Integer.parseInt(progress[0])); }

install or view
private void installOnDevice(){ File downloadedFile = new File(Environment.getExternalStorageDirectory() + "/" + fileName); Log.d(TAG, "filename: " + fileName); if (fileName.contains(".apk")){ Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(downloadedFile), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else if (fileName.contains(".jpg")){ Log.d(TAG, "set image to image view"); Glide.with(getActivity()).load(downloadedFile).into(ivBackground); } enableTap = true; }

thanks b4

I'm a little late to the party, but the issue is with setProgress. It does not call onProgressChangeListener. onProgerssChange will only be called as a result of incrementProgressBy.