android:add mask for DoricActivity,show loading view
This commit is contained in:
@@ -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;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user