Summarize: show duration

This commit is contained in:
M66B 2024-05-14 08:08:44 +02:00
parent 0b66c0a45e
commit 34342bc96b
2 changed files with 25 additions and 7 deletions

View File

@ -38,6 +38,7 @@ import org.jsoup.nodes.Document;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class FragmentDialogSummarize extends FragmentDialogBase {
@ -47,6 +48,7 @@ public class FragmentDialogSummarize extends FragmentDialogBase {
final Context context = getContext();
final View view = LayoutInflater.from(context).inflate(R.layout.dialog_summarize, null);
final TextView tvSummary = view.findViewById(R.id.tvSummary);
final TextView tvElapsed = view.findViewById(R.id.tvElapsed);
final ContentLoadingProgressBar pbWait = view.findViewById(R.id.pbWait);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@ -62,12 +64,16 @@ public class FragmentDialogSummarize extends FragmentDialogBase {
new SimpleTask<String>() {
@Override
protected void onPreExecute(Bundle args) {
tvSummary.setVisibility(View.GONE);
tvElapsed.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE);
args.putLong("start", new Date().getTime());
}
@Override
protected void onPostExecute(Bundle args) {
pbWait.setVisibility(View.GONE);
args.putLong("elapsed", new Date().getTime() - args.getLong("start"));
}
@Override
@ -123,11 +129,15 @@ public class FragmentDialogSummarize extends FragmentDialogBase {
@Override
protected void onExecuted(Bundle args, String text) {
tvSummary.setText(text);
tvSummary.setVisibility(View.VISIBLE);
tvElapsed.setText(Helper.formatDuration(args.getLong("elapsed")));
tvElapsed.setVisibility(View.VISIBLE);
}
@Override
protected void onException(Bundle args, Throwable ex) {
tvSummary.setText(new ThrowableWrapper(ex).toSafeString());
tvSummary.setVisibility(View.VISIBLE);
}
}.execute(this, getArguments(), "message:summarize");

View File

@ -28,8 +28,6 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:focusable="false"
android:minHeight="60dp"
android:text="Text"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textIsSelectable="true"
@ -37,17 +35,27 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCaption" />
<TextView
android:id="@+id/tvElapsed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="1.23s"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textIsSelectable="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSummary" />
<eu.faircode.email.ContentLoadingProgressBar
android:id="@+id/pbWait"
style="@style/Base.Widget.AppCompat.ProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="24dp"
android:indeterminate="true"
app:layout_constraintBottom_toBottomOf="@id/tvSummary"
app:layout_constraintEnd_toEndOf="@id/tvSummary"
app:layout_constraintStart_toStartOf="@id/tvSummary"
app:layout_constraintTop_toTopOf="@id/tvSummary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvElapsed"
app:show_delay="0" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>