android:add mask for DoricActivity,show loading view
This commit is contained in:
parent
3aaa5a8708
commit
5586c8f189
@ -19,6 +19,7 @@ import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
@ -43,6 +44,8 @@ public class DoricFragment extends Fragment {
|
||||
return fragment;
|
||||
}
|
||||
|
||||
private View maskView = null;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -69,6 +72,13 @@ public class DoricFragment extends Fragment {
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
if (this.maskView != null) {
|
||||
FrameLayout maskView = view.findViewById(R.id.doric_mask);
|
||||
maskView.addView(this.maskView);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMaskView(View view) {
|
||||
this.maskView = view;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,8 @@
|
||||
package pub.doric;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -26,6 +28,9 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.navigation.NavController;
|
||||
import androidx.navigation.Navigation;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import pub.doric.async.AsyncCall;
|
||||
import pub.doric.async.AsyncResult;
|
||||
import pub.doric.loader.DoricJSLoaderManager;
|
||||
import pub.doric.navbar.BaseDoricNavBar;
|
||||
@ -39,6 +44,7 @@ import pub.doric.utils.DoricLog;
|
||||
*/
|
||||
public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
||||
private DoricPanel doricPanel;
|
||||
private Handler uiHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
@ -50,6 +56,7 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
if (doricPanel == null) {
|
||||
showLoadingMask();
|
||||
doricPanel = view.findViewById(R.id.doric_panel);
|
||||
Bundle argument = getArguments();
|
||||
if (argument == null) {
|
||||
@ -72,6 +79,7 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
||||
context.setDoricNavigator(DoricPanelFragment.this);
|
||||
BaseDoricNavBar navBar = requireActivity().getWindow().getDecorView().findViewById(R.id.doric_nav_bar);
|
||||
context.setDoricNavBar(navBar);
|
||||
hideLoadingMask();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -135,4 +143,24 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
||||
doricPanel.onActivityDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
private void hideLoadingMask() {
|
||||
AsyncCall.ensureRunInHandler(uiHandler, new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() {
|
||||
requireActivity().getWindow().getDecorView().findViewById(R.id.doric_mask).setVisibility(View.GONE);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showLoadingMask() {
|
||||
AsyncCall.ensureRunInHandler(uiHandler, new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() {
|
||||
requireActivity().getWindow().getDecorView().findViewById(R.id.doric_mask).setVisibility(View.VISIBLE);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<pub.doric.navbar.BaseDoricNavBar
|
||||
android:id="@+id/doric_nav_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</LinearLayout>
|
@ -1,14 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<pub.doric.navbar.BaseDoricNavBar
|
||||
android:id="@+id/doric_nav_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp" />
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_host"
|
||||
@ -18,4 +12,9 @@
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/doric_navigation" />
|
||||
|
||||
</LinearLayout>
|
||||
<FrameLayout
|
||||
android:id="@+id/doric_mask"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="visible" />
|
||||
</FrameLayout>
|
Reference in New Issue
Block a user