I found an excellent UnZip class with progress bar support for Android. However the progress bar does not update when clicking extract in my app. The Unzipping works fine.
Can someone please tell me what I am doing wrong?
public class UnZip1 extends AsyncTask<Void, Integer, Integer> {
{
}
private String _zipFile;
private String _location;
private ProgressDialog mProgressDialog;
private int per = 0;
private Context _conti;
private ProgressBar bar1;
public UnZip1(Context conti,String zipFile, String location) {
_conti = conti;
_zipFile = zipFile;
_location = location;
bar1 = (ProgressBar)findViewById(R.id.pb1);
_dirChecker("");
}
public void streamCopy(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[32 * 1024]; // play with sizes..
int readCount;
while ((readCount = in.read(buffer)) != -1) {
out.write(buffer, 0, readCount);
}
}
protected Integer doInBackground(Void... params) {
try {
ZipFile zip = new ZipFile(_zipFile);
FileInputStream fin = new FileInputStream(_zipFile);
ZipInputStream zin = new ZipInputStream(fin);
ZipEntry ze = null;
while ((ze = zin.getNextEntry()) != null) {
Log.v("Decompress", "Unzipping " + ze.getName());
if(ze.isDirectory()) {
_dirChecker(ze.getName());
} else {
// Here I am doing the update of my progress bar
Log.v("Decompress", "more " + ze.getName());
per++;
publishProgress(per);
FileOutputStream fout = new FileOutputStream(_location + ze.getName());
streamCopy(zin, fout);
zin.closeEntry();
fout.close();
} }
zin.close();
} catch(Exception e) {
Log.e("Decompress", "unzip", e);
}
return null;
}
protected void onProgressUpdate(Integer... progress) {
bar1.setProgress(per);
}
protected void onPostExecute(Integer... result) {
Log.i("UnZip" ,"Completed. Total size: "+result);
}
private void _dirChecker(String dir) {
File f = new File(_location + dir);
if(!f.isDirectory()) {
f.mkdirs();
}
}
}
}
You have to use the ProgressDialog with STYLE_HORIZONTAL
if you want to see the actual progress.
You can add the initialization in your preExecute():
#Override
protected void onPreExecute()
{
super.onPreExecute();
mProgressDialog = new ProgressDialog(MainActivity.this);
mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener()
{
public void onCancel(DialogInterface dialog)
{
}
});
mProgressDialog.setCancelable(true);
mProgressDialog.setMessage("Progress");
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setProgress(1);
mProgressDialog.show();
}
MainActivity is the name of my activity class.
Then set the progress on the onProgressUpdate function.
protected void onProgressUpdate(Integer... progress)
{
mProgressDialog.setProgress(progress[0]);
}
Can you try this :
#Override
protected void onProgressUpdate(Integer... progress) {
// TODO Auto-generated method stub
super.onProgressUpdate(values);
bar1.setProgress(progress[0])
}
Related
I want to read my recorded wav file and use it for signal processing with the following processing method:
//SIGNAL PROCESSING
private void proccessSignal(double[] signalIN){
double samplefreq = 44100;
double[] signal = signalIN;
Bessel bandpassfilter = new Bessel(signal,samplefreq);
double[] filteredSignal = bandpassfilter.lowPassFilter(1,150);
Bessel newsignalfiltered = new Bessel(filteredSignal,samplefreq);
double[] needsAmplifianceSignal = newsignalfiltered.bandPassFilter(1,200,500);
double[] amplifiedSignal = needsAmplifianceSignal;
for (int i=0;i<=needsAmplifianceSignal.length;i++){
amplifiedSignal[i]=amplifiedSignal[i]*1000;
amplifiedSignal[i]=amplifiedSignal[i]*amplifiedSignal[i];
}
Hilbert h = new Hilbert(amplifiedSignal);
h.hilbertTransform();
double[][] analytical_signal = h.getOutput();
Log.d("Endsignal", "proccessSignal: "+analytical_signal);
double threshold = 0.0052;
int apneaCount = 0;
for (int i=0; i<=analytical_signal.length;i++)
{
for (int j=0; j<=analytical_signal.length;j++){
if (threshold<=analytical_signal[i][j]){
}else {
apneaCount++;
if (apneaCount>=10){
apneaview.setText("YOU HAVE APNEA, CONTACT YOUR DOCTOR");
break;
}
}
}
}
if (apneaCount < 10){
apneaview.setText("YOU DO NOT HAVE APNEA");
}
}
The recording and everything works but it looks like the signal is always null so it never gets to my processing method, here's my Logcat to get a piece of detailed information about this issue:
W/System.err: com.github.psambit9791.wavfile.WavFileException: Invalid Wav Header data, incorrect riff chunk ID
W/System.err: at com.github.psambit9791.wavfile.WavFile.openWavFile(WavFile.java:257)
W/System.err: at com.github.psambit9791.jdsp.io.Wav.readWav(Wav.java:70)
W/System.err: at com.example.appnea.DetailedStat.onCreate(DetailedStat.java:82)
and here's the full activity for better understanding:
// TEST
#RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detailed_stat);
Intent receivedFromList = getIntent();
name = receivedFromList.getStringExtra("recordName");
path = receivedFromList.getStringExtra("recordPath");
nameview = findViewById(R.id.NAME);
pathview = findViewById(R.id.PATH);
apneaview = findViewById(R.id.APNEA);
nameview.setText("Record date: " + name);
pathview.setText("Record path: " + path);
apneaview.setText("INITIALISING DATA");
File audiofile = new File(path);
double[] signal = new double[0];
try {
String mMime = "audio/3gpp";
MediaCodec codec = MediaCodec.createDecoderByType(mMime);
/**
*
*
*/
Wav objRead1 = new Wav();
objRead1.readWav(path);
Hashtable<String, Long> propsOut = objRead1.getProperties(); // Gets the WAV file properties
double[][] signal1 = objRead1.getData("int"); // Can be 'int', 'long' 'double'
try {
loadFFMpegLibrary();
} catch (FFmpegNotSupportedException e) {
e.printStackTrace();
}
MediaExtractor mx = new MediaExtractor();
try {
mx.setDataSource(path);
} catch (IOException e) {
e.printStackTrace();
}
/**
* Finals
*/
MediaFormat mMediaFormat = mx.getTrackFormat(0);
byte[] bufbytes = new byte[(int) audiofile.length()];
BufferedInputStream buf = new BufferedInputStream(new FileInputStream(audiofile));
buf.read(bufbytes, 0, bufbytes.length);
buf.close();
mMediaFormat.setByteBuffer("3gp", ByteBuffer.wrap(bufbytes));
codec.setCallback(new MediaCodec.Callback() {
#Override
public void onInputBufferAvailable(#NonNull MediaCodec codec, int index) {
}
#Override
public void onOutputBufferAvailable(#NonNull MediaCodec codec, int index, #NonNull MediaCodec.BufferInfo info) {
}
#Override
public void onError(#NonNull MediaCodec codec, #NonNull MediaCodec.CodecException e) {
}
#Override
public void onOutputFormatChanged(#NonNull MediaCodec codec, #NonNull MediaFormat format) {
}
});
codec.configure(mMediaFormat, null, null, 0);
codec.start();
new Thread(() -> {
MediaCodec.BufferInfo buf_info = new MediaCodec.BufferInfo();
int outputBufferIndex = codec.dequeueOutputBuffer(buf_info, 0);
byte[] pcm = new byte[buf_info.size];
ByteBuffer[] mOutputBuffers = new ByteBuffer[buf_info.size];
mOutputBuffers[outputBufferIndex].get(pcm, 0, buf_info.size);
}).start();
sampleDir = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "/OfficeRecordings/");
if (!sampleDir.exists()) {
sampleDir.mkdirs();
}
outputFile = sampleDir+"/"+"sample_record.3gp";
finalFile = sampleDir+"/"+"final_record.wav";
final String[] cmd = new String[]{"-y", "-i", outputFile, finalFile};
execFFmpegBinary(cmd);
} catch (IOException | WavFileException e) {
e.printStackTrace();
}
Log.d("AUDIO", "onCreate: AUDIO FILE EXIST?" + audiofile.exists());
//proccessSignal(signal);
}
private void execFFmpegBinary(final String[] command) {
FFmpeg ffmpeg = FFmpeg.getInstance(this);
try {
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
#Override
public void onStart() {
Log.d("audio", "starting to load binary");
}
#Override
public void onFailure() {
Log.d("audio", "failed to load binary");
}
#Override
public void onSuccess() {
Log.d("audio", "loaded binary");
try {
ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
#Override
public void onStart() {
Log.d("audio", " starting to get audio " + "");
}
#Override
public void onProgress(String message) {
Log.d("audio", " progress getting audio from ");
}
#Override
public void onFailure(String message) {
Log.d("audio", " failed to get audio ");
}
#Override
public void onSuccess(String message) {
Log.d("audio", " success getting audio from video");
}
#Override
public void onFinish() {
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
e.printStackTrace();
}
}
#Override
public void onFinish() {
}
});
} catch (FFmpegNotSupportedException e) {
// Handle if FFmpeg is not supported by device
}
}
// TRYING THE FFMPEG METHOD
public void loadFFMpegLibrary() throws FFmpegNotSupportedException {
if (fFmpeg == null)
fFmpeg = FFmpeg.getInstance(this);
fFmpeg.loadBinary(new FFmpegLoadBinaryResponseHandler() {
#Override
public void onFailure() {
Toast.makeText(getApplicationContext(), "Library failed to load", Toast.LENGTH_LONG).show();
}
#Override
public void onSuccess() {
Toast.makeText(getApplicationContext(), "Library loaded successfully", Toast.LENGTH_LONG).show();
}
#Override
public void onStart() {
}
#Override
public void onFinish() {
}
});
}
public void executeCommand(final String[] command) throws FFmpegCommandAlreadyRunningException {
fFmpeg.execute(command, new ExecuteBinaryResponseHandler() {
#Override
public void onSuccess(String message) {
}
#Override
public void onProgress(String message) {
}
#Override
public void onFailure(String message) {
}
#Override
public void onStart() {
}
#Override
public void onFinish() {
}
});
}
//CONVERTING TO DOUBLE ARRAY FROM BYTEARRAY
public static double[] toDoubleArray(byte[] byteArray){
int times = Double.SIZE / Byte.SIZE;
double[] doubles = new double[byteArray.length / times];
for(int i=0;i<doubles.length;i++){
doubles[i] = ByteBuffer.wrap(byteArray, i*times, times).getDouble();
}
return doubles;
}
private void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1){
out.write(buffer, 0, read);
}
}
//SIGNAL PROCESSING
private void proccessSignal(double[] signalIN){
double samplefreq = 44100;
double[] signal = signalIN;
Bessel bandpassfilter = new Bessel(signal,samplefreq);
double[] filteredSignal = bandpassfilter.lowPassFilter(1,150);
Bessel newsignalfiltered = new Bessel(filteredSignal,samplefreq);
double[] needsAmplifianceSignal = newsignalfiltered.bandPassFilter(1,200,500);
double[] amplifiedSignal = needsAmplifianceSignal;
for (int i=0;i<=needsAmplifianceSignal.length;i++){
amplifiedSignal[i]=amplifiedSignal[i]*1000;
amplifiedSignal[i]=amplifiedSignal[i]*amplifiedSignal[i];
}
Hilbert h = new Hilbert(amplifiedSignal);
h.hilbertTransform();
double[][] analytical_signal = h.getOutput();
Log.d("Endsignal", "proccessSignal: "+analytical_signal);
double threshold = 0.0052;
int apneaCount = 0;
for (int i=0; i<=analytical_signal.length;i++)
{
for (int j=0; j<=analytical_signal.length;j++){
if (threshold<=analytical_signal[i][j]){
}else {
apneaCount++;
if (apneaCount>=10){
apneaview.setText("YOU HAVE APNEA, CONTACT YOUR DOCTOR");
break;
}
}
}
}
if (apneaCount < 10){
apneaview.setText("YOU DO NOT HAVE APNEA");
}
}
}
Thank you so much for your time, I really appreciate it. Please let me know if you need any other information!
I hired someone to code my app. It loads a instrumental downloaded from the internet to my app. To download the instrumental it is fast but when loading the instrumental it takes a really long time at least a minute or more. I looked over the code to see where it would be slowing it down but i can't seem to figure it out. Any help is appreciated.
Code:
//File loading task
class SaveInputStreamTask extends AsyncTask<String, Integer, String> {
private Context context;
ProgressDialog mProgressDialog;
public SaveInputStreamTask(Context context) {
this.context = context;
}
#Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
// mProgressDialog = new ProgressDialog(context);
//mProgressDialog.setMessage("Beat Will Take A Minute To Load When Mixing So Start Recording");
mProgressDialog = ProgressDialog.show(context, getResources().getString(R.string.app_name), "Beat Will Take Up To A Minute To Load. In The Meantime How's Your Day?");
mProgressDialog.show();
}
#Override
protected String doInBackground(String... sUrl) {
try
{
File file = new File(instrument_file_name);
long totalFilesize = file.length();
long readSize = 0;
FileInputStream fis = new FileInputStream(file);
saveInputStream(fis);
return "SUCCESS";
}
catch(Exception ex)
{
ex.printStackTrace();
}
return null;
}
#Override
protected void onProgressUpdate(Integer... progress) {
super.onProgressUpdate(progress);
// if we get here, length is known, now set indeterminate to false
mProgressDialog.setIndeterminate(false);
mProgressDialog.setMax(100);
mProgressDialog.setProgress(progress[0]);
}
#Override
protected void onPostExecute(String result) {
mProgressDialog.dismiss();
if(result == null){
Toast.makeText(context, "Loading Beat failed. Please try again", Toast.LENGTH_SHORT).show();
RecordRap.this.finish();
}
else
{
}
}
public void saveInputStream(InputStream is) throws IOException
{
int n = 0;
DataInputStream in1;
in1 = new DataInputStream(is);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try
{
while ((n = in1.read()) != -1)
{
bos.write(n);
}
}
catch (IOException e)
{
e.printStackTrace();
}
ByteBuffer bb = ByteBuffer.wrap(bos.toByteArray());
bb.order(ByteOrder.LITTLE_ENDIAN);
ShortBuffer sb = bb.asShortBuffer();
for (int i = 0; i < sb.capacity(); i++) {
beatsShortList.add(sb.get(i));
}
}
}
So thanks to #Stephen C the problem was while ((n = in1.read()) != -1) so i added a buffer and changed the code to the following and the problem is fixed now loading only takes a few seconds. Thanks to Stephen C for the help and as Ratul Sharker.
Updated code:
byte[] buffer = new byte[0xFFFF];
while ((n = in1.read(buffer)) != -1)
{
bos.write(buffer, 0, n);
}
for (int i = 0; i < sb.capacity(); i++) {
beatsShortList.add(sb.get(i));
}
This is the culprit what are you looking for :)
I'm using Apache's FTPClient to upload files to my server (images from the gallery if it matters)
I'm having a small and pretty insignificant problem, but I would still like to solve it.
The problem is that the bar is filled and reaches 100% before the upload actually completes, causing the dialog to show 100% for an extra 2-3 seconds on small files (and could be a lot more on files weighing several MBs).
I'm guessing it's because of the conversion from long to int, but that's just a guess.
Here's the code:
#Override
protected void onPreExecute() {
super.onPreExecute();
dialog = new ProgressDialog(UploadActivity.this);
dialog.setOnCancelListener(new OnCancelListener() {
#Override
public void onCancel(DialogInterface dialog) {
uploadImage.cancel(true);
}
});
dialog.setMessage("Uploading...\nPlease Wait.");
dialog.setIndeterminate(false);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setProgress(0);
dialog.setCancelable(false);
dialog.setMax((int)(file.length()/1024));
dialog.setProgressNumberFormat ("%1dKB/%2dKB");
dialog.show();
}
#Override
protected String doInBackground(Void... params) {
CopyStreamAdapter streamListener = new CopyStreamAdapter() {
#Override // THIS PART IS RESPONSIBLE FOR UPDATING THE PROGRESS
public void bytesTransferred(long totalBytesTransferred, int bytesTransferred, long streamSize) {
int percent = (int) (totalBytesTransferred * 100 / file.length());
publishProgress(percent);
}
};
String name = null;
ftp.setCopyStreamListener(streamListener);
FileInputStream fis = null;
try {
String extension = "";
String fileName = file.getName();
int i = fileName.lastIndexOf('.');
int p = Math.max(fileName.lastIndexOf('/'), fileName.lastIndexOf('\\'));
if (i > p) {
extension = fileName.substring(i + 1);
}
SimpleDateFormat sdf = new SimpleDateFormat("ddMMyy-hhmmss-SSS");
name = String.format("File-%s.%s", sdf.format(new Date()), extension);
ftp.connect(FTP_SERVER);
ftp.enterLocalPassiveMode();
ftp.login(ftpUser, ftpPassword);
ftp.setFileType(FTP.BINARY_FILE_TYPE);
fis = new FileInputStream(file);
if (!ftp.storeFile(name, fis)) {
showToast("Failed uploading");
return null;
}
ftp.logout();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return name;
}
#Override
protected void onProgressUpdate(Integer... values) {
dialog.setProgress(values[0]);
}
Thanks!
Dear stackOverflow members i have recently started a new project called "RootBox" and it is an app that needs "su" perms and i have successfully allowed the app "su" or "root" access and im trying to download and replace a system file in "/system/media and i have setup my downloader but the download progress dialog pops up and closes which im guessing is the result of the file not being able to written to the system directory and i have Re-mounted the system as r-w before starting the download an i have searched all over the internet and was unable to find help thats why i have come here.
This is the activity executing the download
public static final int DIALOG_DOWNLOAD_PROGRESS = 0;
private Button startBtn;
private ProgressDialog mProgressDialog;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bootmation);
startBtn = (Button)findViewById(R.id.startBtn);
startBtn.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
startDownload();
RootTools.remount("/system/", "rw");
}
});
}
private void startDownload() {
String url = "http://www.filehosting.org/file/details/430746/bootanimation.zip";
new DownloadFileAsync().execute(url);
}
#Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_DOWNLOAD_PROGRESS:
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage("Downloading file..");
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
mProgressDialog.setCancelable(false);
mProgressDialog.show();
return mProgressDialog;
default:
return null;
}
}
class DownloadFileAsync extends AsyncTask {
#Override
protected void onPreExecute() {
super.onPreExecute();
showDialog(DIALOG_DOWNLOAD_PROGRESS);
}
#Override
protected String doInBackground(String... aurl) {
int count;
try {
URL url = new URL(aurl[0]);
URLConnection conexion = url.openConnection();
conexion.connect();
int lenghtOfFile = conexion.getContentLength();
Log.d("ANDRO_ASYNC", "Lenght of file: " + lenghtOfFile);
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream("/system/media/bootanimation.zip");
byte data[] = new byte[1024];
long total = 0;
while ((count = input.read(data)) != -1) {
total += count;
publishProgress(""+(int)((total*100)/lenghtOfFile));
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
} catch (Exception e) {}
return null;
}
protected void onProgressUpdate(String... progress) {
Log.d("ANDRO_ASYNC",progress[0]);
mProgressDialog.setProgress(Integer.parseInt(progress[0]));
}
#Override
protected void onPostExecute(String unused) {
dismissDialog(DIALOG_DOWNLOAD_PROGRESS);
}
}
}
for this u have to allow in manifest for permission for writing as
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
URL u = new URL(fUrls[i]);
HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestMethod("GET");
c.setDoOutput(true);
c.connect();
I am fairly new to Android development so I thought I would start off with a basic app. When a button is pressed, it copies a file to the location written in the code (see my code below). When I press the install button and the file is copied to its location, I want a toast message to display "Successfully Installed or Error while copying file". How would I implement this?
public class TrialActivity extends Activity {
private ProgressDialog progressDialog;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
runDialog(5);
}
private void runDialog(final int seconds)
{
progressDialog = ProgressDialog.show(this, "Please Wait...", "unpacking patch in progress");
new Thread(new Runnable(){
public void run(){
try {
Thread.sleep(seconds * 1000);
progressDialog.dismiss();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}).start();
((Button)findViewById(R.id.button1)).setOnClickListener(new View.OnClickListener()
{
public void onClick(View paramView)
{
}
{
InputStream in = null;
OutputStream out = null;
String filename="savegame.bin";
try {
in = getResources().openRawResource(R.raw.savegame);
out = new FileOutputStream("/sdcard/Android/data/files/" + filename);
copyFile(in, out);
in.close();
in = null;
out.flush();
out.close();
out = null;
} catch(Exception e) {
Log.e("tag", e.getMessage());
}
}
private void copyFile(InputStream in, OutputStream out) throws IOException {
byte[] buffer = new byte[1024];
int read;
while((read = in.read(buffer)) != -1){
out.write(buffer, 0, read);
}
}
}
);
}
}
use next code:
private class AsyncTaskDialog extends AsyncTask<Void, Void, Void> {
Toast toastSuccess;
boolean flagSuccessCopy =false;
protected void onPreExecute() {
super.onPreExecute();
}
}
protected Boolean doInBackground(Void... params) {
copyFiles();
return null;
}
#Override
protected void onPostExecute(Boolean result) {
super.onPostExecute(result);
if (getActivity() != null) {
if(flagSuccessCopy){
toastSuccess = Toast.makeText(context, "Success", duration);
}else{
toastSuccess = Toast.makeText(context, "Error", duration);
}
toast.show();
}
}
Allows to copy any file from any application to SD card
import ru.gelin.android.sendtosd.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.widget.ProgressBar;
import android.widget.TextView;
public class ProgressDialog extends AlertDialog implements Progress {
/** Activity for which the dialog is created */
Activity activity;
/** Progress manager for the dialog */
ProgressManager manager = new ProgressManager();
/**
* Creates the customized progress dialog for
* activity.
*/
protected ProgressDialog(Activity activity) {
super(activity);
}
#Override
public void setFiles(int files) {
synchronized (manager) {
manager.setFiles(files);
}
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
synchronized (manager) {
updateTotalProgress();
}
}
});
}
#Override
public void nextFile(final File file) {
synchronized (manager) {
manager.nextFile(file);
}
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
synchronized (manager) {
updateFileName(file);
updateFileProgress();
updateTotalProgress();
}
}
});
}
#Override
public void processBytes(long bytes) {
synchronized (manager) {
manager.processBytes(bytes);
}
activity.runOnUiThread(new Runnable() {
#Override
public void run() {
synchronized (manager) {
updateFileProgress();
}
}
});
}
void updateTotalProgress() {
ProgressBar progress = (ProgressBar)findViewById(R.id.total_progress);
progress.setMax(manager.getFiles());
progress.setProgress(manager.getFile());
TextView text = (TextView)findViewById(R.id.total_files);
text.setText(getContext().getString(R.string.files_progress,
manager.getFile(), manager.getFiles()));
}
void updateFileName(File file) {
if (file == null) {
return;
}
TextView view = (TextView)findViewById(R.id.file_name);
view.setText(file.getName());
}
void updateFileProgress() {
ProgressBar progress = (ProgressBar)findViewById(R.id.file_progress);
if (manager.getProgressInUnits() < 0) {
progress.setIndeterminate(true);
} else {
progress.setIndeterminate(false);
progress.setMax((int)(manager.getSizeInUnits() * 10));
progress.setProgress((int)(manager.getProgressInUnits() * 10));
}
TextView text = (TextView)findViewById(R.id.file_size);
text.setText(getContext().getString(manager.getSizeUnit().progressString,
manager.getProgressInUnits(), manager.getSizeInUnits()));
}
}
source: http://code.google.com/p/sendtosd-android/source/browse/src/ru/gelin/android/sendtosd/progress/ProgressDialog.java?spec=svn0933973391a12bee4759a32f5776864c64022d71&r=0933973391a12bee4759a32f5776864c64022d71