Skip to content

Commit 0ef4b87

Browse files
author
sundyzlh
committed
1 parent 696c3b9 commit 0ef4b87

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

sundyandroid/Demos/SundyAndroidDemo/res/layout/layout_asynctask.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
android:layout_width="fill_parent"
55
android:orientation="vertical"
66
android:layout_height="fill_parent">
7-
<EditText android:id="@+id/editTextState2" android:text="http://www.google.com" android:layout_height="wrap_content" android:layout_width="fill_parent"></EditText>
7+
<EditText android:id="@+id/editTextState2" android:text="http://www.baidu.com" android:layout_height="wrap_content" android:layout_width="fill_parent"></EditText>
88
<ProgressBar android:id="@+id/progress_bar2"
99
android:layout_width="200dip" android:layout_height="15dip"
1010
android:layout_gravity="center"

sundyandroid/Demos/SundyAndroidDemo/src/sundy/android/demo/processthread/AsyncTaskTestActivity.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import android.app.Activity;
1515
import android.os.AsyncTask;
1616
import android.os.Bundle;
17+
import android.util.Log;
1718
import android.view.View;
1819
import android.view.View.OnClickListener;
1920
import android.widget.Button;
@@ -69,7 +70,7 @@ protected void onPostExecute(String result) {
6970
@Override
7071
protected void onProgressUpdate(Integer... values) {
7172
// TODO Auto-generated method stub
72-
super.onProgressUpdate(values);
73+
//super.onProgressUpdate(values);
7374
asProgressBar.setProgress(values[0]) ;
7475
}
7576

@@ -85,7 +86,8 @@ protected String doInBackground(String... params) {
8586
HttpEntity entity = response.getEntity();
8687
long length = entity.getContentLength();
8788
InputStream is = entity.getContent();
88-
String s = null;
89+
String s = null;
90+
int toCase = 0 ;
8991
if (is != null) {
9092
ByteArrayOutputStream baos = new ByteArrayOutputStream();
9193
byte[] buf = new byte[128];
@@ -95,8 +97,9 @@ protected String doInBackground(String... params) {
9597
baos.write(buf, 0, ch);
9698
count += ch;
9799
if (length > 0) {
98-
// call publishProgress()update progress
99-
publishProgress((int) ((count / (float) length) * 100));
100+
// call publishProgress()update progress
101+
toCase = (int) ((count / (float) length) * 100) ;
102+
publishProgress(toCase);
100103
}
101104
// sleep 100
102105
Thread.sleep(100);

0 commit comments

Comments
 (0)