Prechádzať zdrojové kódy

update process info

JonaNorman 1 rok pred
rodič
commit
efcdf1560d

+ 6 - 1
app/src/main/java/com/norman/webviewup/demo/MainActivity.java

@@ -49,6 +49,8 @@ public class MainActivity extends Activity implements UpgradeCallback {
     TextView upgradeStatusTextView;
     TextView upgradeErrorTextView;
 
+    TextView upgradeProgressTextView;
+
     UpgradeInfo selectUpgradeInfo;
 
 
@@ -61,6 +63,7 @@ public class MainActivity extends Activity implements UpgradeCallback {
         upgradeWebViewPackageTextView = findViewById(R.id.upgradeWebViewPackageTextView);
         upgradeStatusTextView = findViewById(R.id.upgradeStatusTextView);
         upgradeErrorTextView = findViewById(R.id.upgradeErrorTextView);
+        upgradeProgressTextView =findViewById(R.id.upgradeProgressTextView);
         updateSystemWebViewPackageInfo();
         updateSystemWebViewPackageInfo();
         updateUpgradeWebViewStatus();
@@ -185,7 +188,9 @@ public class MainActivity extends Activity implements UpgradeCallback {
         } else {
             upgradeStatusTextView.setText("");
         }
-        progressBar.setProgress((int) (WebViewUpgrade.getUpgradeProcess() * 100));
+        int process = (int) (WebViewUpgrade.getUpgradeProcess() * 100);
+        progressBar.setProgress(process);
+        upgradeProgressTextView.setText(process+"%");
         Throwable throwable = WebViewUpgrade.getUpgradeError();
         if (throwable == null) {
             upgradeErrorTextView.setText("");

+ 19 - 5
app/src/main/res/layout/activity_main.xml

@@ -83,13 +83,27 @@
 
     </LinearLayout>
 
-    <ProgressBar
-        android:id="@+id/upgradeProgressBar"
-        style="?android:attr/progressBarStyleHorizontal"
+
+    <LinearLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:gravity="center_vertical"
+        android:orientation="horizontal"
         android:layout_marginTop="10dp"
-        android:max="100" />
+        android:layout_height="wrap_content">
+        <ProgressBar
+            android:id="@+id/upgradeProgressBar"
+            style="?android:attr/progressBarStyleHorizontal"
+            android:layout_width="0dp"
+            android:layout_weight="1"
+            android:layout_height="wrap_content"
+            android:max="100" />
+
+        <TextView
+            android:id="@+id/upgradeProgressTextView"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:layout_margin="5dp"/>
+    </LinearLayout>
 
     <LinearLayout
         android:layout_width="match_parent"