Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
SubhamTyagi committed Oct 1, 2024
1 parent a39a001 commit 57fbb42
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/io/github/subhamtyagi/ocr/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ private boolean downloadTrainingData(String dataType, String lang) {
handler.post(() -> {
mProgressSpinner.setVisibility(View.GONE);
mProgressBar.setVisibility(View.VISIBLE);
mProgressMessage.setText(String.format("%d %s %d", 0, getString(R.string.percentage_downloaded), size)); // Update message
mProgressMessage.setText("0"+ getString(R.string.percentage_downloaded)+ size);
mProgressBar.setProgress(0); // Reset progress bar to 0
});

Expand All @@ -625,7 +625,7 @@ private boolean downloadTrainingData(String dataType, String lang) {
int percentage = (downloaded * 100) / totalContentSize;
handler.post(() -> {
mProgressBar.setProgress(percentage);
mProgressMessage.setText(String.format("%d %s %d", percentage, getString(R.string.percentage_downloaded), size));
mProgressMessage.setText(percentage+getString(R.string.percentage_downloaded)+size+".");
});
}
output.flush();
Expand Down
24 changes: 9 additions & 15 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
tools:progress="20"
tools:visibility="visible" />

<RelativeLayout
<LinearLayout
android:id="@+id/download_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/download_layout"
android:foregroundGravity="center"
android:gravity="center_horizontal"
android:orientation="horizontal"
Expand All @@ -33,8 +33,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="Downloading language data"
android:textSize="18sp"
/>
android:textSize="18sp" />


<TextView
Expand All @@ -44,33 +43,28 @@
android:layout_below="@id/progress_title"
android:layout_centerHorizontal="true"
android:text="0% downloaded of total 10MB..."
android:textSize="16sp"
/>

android:textSize="16sp" />

<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress_spinner"
style="?android:attr/progressBarStyleLarge"
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/progress_message"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
app:indicatorColor="@color/colorAccent"
/>
android:layout_marginTop="16dp" />

<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
style="@style/Widget.MaterialComponents.LinearProgressIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/progress_spinner"
android:layout_marginTop="16dp"
android:max="100"
app:indicatorColor="@color/colorAccent"
/>
app:indicatorColor="@color/colorAccent" />

</RelativeLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
Expand Down

0 comments on commit 57fbb42

Please sign in to comment.