android: fix Fragment be created twice
This commit is contained in:
parent
e8e344ed21
commit
774d3160a9
@ -143,6 +143,9 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
||||
AsyncCall.ensureRunInHandler(uiHandler, new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() {
|
||||
if (maskView == null) {
|
||||
return null;
|
||||
}
|
||||
maskView.setVisibility(View.GONE);
|
||||
return null;
|
||||
}
|
||||
@ -153,9 +156,18 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
||||
AsyncCall.ensureRunInHandler(uiHandler, new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() {
|
||||
if (maskView == null) {
|
||||
return null;
|
||||
}
|
||||
maskView.setVisibility(View.VISIBLE);
|
||||
maskView.findViewById(R.id.doric_mask_loading).setVisibility(View.VISIBLE);
|
||||
maskView.findViewById(R.id.doric_mask_error).setVisibility(View.GONE);
|
||||
View loading = maskView.findViewById(R.id.doric_mask_loading);
|
||||
View error = maskView.findViewById(R.id.doric_mask_error);
|
||||
if (loading != null) {
|
||||
loading.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (error != null) {
|
||||
error.setVisibility(View.GONE);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@ -165,9 +177,18 @@ public class DoricPanelFragment extends Fragment implements IDoricNavigator {
|
||||
AsyncCall.ensureRunInHandler(uiHandler, new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() {
|
||||
if (maskView == null) {
|
||||
return null;
|
||||
}
|
||||
View loading = maskView.findViewById(R.id.doric_mask_loading);
|
||||
View error = maskView.findViewById(R.id.doric_mask_error);
|
||||
maskView.setVisibility(View.VISIBLE);
|
||||
maskView.findViewById(R.id.doric_mask_loading).setVisibility(View.GONE);
|
||||
maskView.findViewById(R.id.doric_mask_error).setVisibility(View.VISIBLE);
|
||||
if (loading != null) {
|
||||
loading.setVisibility(View.GONE);
|
||||
}
|
||||
if (error != null) {
|
||||
error.setVisibility(View.VISIBLE);
|
||||
}
|
||||
View retryView = maskView.findViewById(R.id.doric_mask_error_retry);
|
||||
if (retryView != null) {
|
||||
retryView.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -9,8 +9,7 @@
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/doric_navigation" />
|
||||
app:defaultNavHost="true" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/doric_mask"
|
||||
|
@ -20,7 +20,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
getIntent().putExtra("alias", BUNDLE_NAME);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
if (savedInstanceState == null) {
|
||||
this.getSupportFragmentManager().beginTransaction().add(R.id.container, new DoricFragment()).commit();
|
||||
}
|
||||
BaseDoricNavBar doricNavBar = findViewById(R.id.doric_nav_bar);
|
||||
doricNavBar.setBackIconVisible(false);
|
||||
|
||||
|
@ -20,7 +20,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
getIntent().putExtra("alias", BUNDLE_NAME);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
if (savedInstanceState == null) {
|
||||
this.getSupportFragmentManager().beginTransaction().add(R.id.container, new DoricFragment()).commit();
|
||||
}
|
||||
BaseDoricNavBar doricNavBar = findViewById(R.id.doric_nav_bar);
|
||||
doricNavBar.setBackIconVisible(false);
|
||||
|
||||
|
Reference in New Issue
Block a user