完善Android自定义加载页

master
gaoyunfei 2023-04-10 12:20:26 +08:00
parent 512175fd51
commit e8da56b290
4 changed files with 52 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package com.finogeeks.mop_example;
import android.content.Context;
import android.widget.TextView;
import com.finogeeks.lib.applet.modules.appletloadinglayout.IFinAppletLoadingPage;
@ -13,26 +14,27 @@ public class CustomLoadingPage extends IFinAppletLoadingPage {
@Override
public int getFailureLayoutRes() {
return 0;
return R.layout.layout_custom_loading_page_failure;
}
@Override
public int getLoadingLayoutRes() {
return 0;
return R.layout.layout_custom_loading_page;
}
@Override
public void onLoadingFailure(@NonNull String s) {
((TextView)getFailureLayout().findViewById(R.id.failMsg)).setText(s);
}
@Override
public void onLoadingFailure(@NonNull String s, @NonNull String s1) {
((TextView)getFailureLayout().findViewById(R.id.failTitle)).setText(s);
((TextView)getFailureLayout().findViewById(R.id.failMsg)).setText(s1);
}
@Override
public void onUpdate(@NonNull String s, @NonNull String s1) {
((TextView)getLoadingLayout().findViewById(R.id.loadingTitle)).setText(s);
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">
<ProgressBar
android:id="@+id/loadingWaiting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/Widget.AppCompat.ProgressBar"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/loadingTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Body2"
android:textStyle="bold"
android:layout_marginTop="16dp"
/>
</LinearLayout>

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:padding="24dp">
<TextView
android:id="@+id/failTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/failMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:layout_marginTop="16dp"
/>
</LinearLayout>

View File

@ -55,7 +55,7 @@ class _MyAppState extends State<MyApp> {
// capsuleConfig.capsuleRightMargin = 25;
uiconfig.capsuleConfig = capsuleConfig;
uiconfig.appletText = "applet";
uiconfig.loadingLayoutCls = "LoadingView";
uiconfig.loadingLayoutCls = "com.finogeeks.mop_example.CustomLoadingPage";
// if (Platform.isIOS) {
// final res = await Mop.instance.initialize(