Created
March 11, 2012 11:32
-
-
Save ligi/2016097 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.ligi.gpluswall.tv; | |
import android.app.Activity; | |
import android.os.Handler; | |
import android.widget.ProgressBar; | |
public class ProgressUpdaterThread implements Runnable { | |
private Handler hndl=new Handler(); | |
private int pause_time; | |
private long pause_start; | |
private Activity activity; | |
private ProgressBar progress; | |
public ProgressUpdaterThread(Activity act,int pause_time,ProgressBar progress) { | |
this.pause_time=pause_time; | |
this.pause_start=System.currentTimeMillis(); | |
this.activity=act; | |
this.progress=progress; | |
} | |
@Override | |
public void run() { | |
while ((System.currentTimeMillis()-pause_start)<pause_time) { | |
try { | |
Thread.sleep(10); | |
} catch (InterruptedException e) { } | |
hndl.post(new ProgressUpdater()); | |
} | |
activity.finish(); | |
} | |
public class ProgressUpdater implements Runnable { | |
@Override | |
public void run() { | |
progress.setProgress(progress.getMax()-(int)(System.currentTimeMillis()-pause_start)); | |
float percentage=1.0f-(float)(progress.getMax()-(int)(System.currentTimeMillis()-pause_start))/(float)progress.getMax(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment