use of net.iGap.fragments.WelcomeFragment in project iGap-Android by KianIranian-STDG.
the class ActivityRegistration method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registeration);
isStop = false;
isOnGetPermission = true;
G.updateResources(getBaseContext());
viewModel = ViewModelProviders.of(this, new ViewModelProvider.Factory() {
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
boolean showPro = false;
boolean isAddAccount = false;
if (getIntent() != null && getIntent().getExtras() != null) {
showPro = getIntent().getExtras().getBoolean(showProfile);
isAddAccount = getIntent().getBooleanExtra("add account", false);
}
return (T) new RegistrationViewModel(showPro, isAddAccount);
}
}).get(RegistrationViewModel.class);
viewModel.goToMainPage().observe(this, data -> {
if (data != null) {
if (data.isShowDialogDisableTwoStepVerification()) {
new DefaultRoundDialog(this).setTitle(R.string.warning).setMessage(R.string.two_step_verification_disable).setPositiveButton(R.string.dialog_ok, (dialog, which) -> goToMainPage(data.getUserId())).show();
} else {
goToMainPage(data.getUserId());
}
}
});
viewModel.goToContactPage().observe(this, userId -> {
if (!isFinishing() && userId != null) {
HelperTracker.sendTracker(HelperTracker.TRACKER_REGISTRATION_NEW_USER);
removeAllFragment();
FragmentSyncRegisteredContacts fragment = new FragmentSyncRegisteredContacts();
Bundle bundle = new Bundle();
bundle.putLong(FragmentSyncRegisteredContacts.ARG_USER_ID, userId);
fragment.setArguments(bundle);
loadFragment(fragment, true);
}
});
viewModel.getExistUser().observe(this, isExist -> {
if (isExist != null && isExist) {
new DefaultRoundDialog(this).setTitle(R.string.warning).setMessage(R.string.login_exist_account_error).setPositiveButton(R.string.dialog_ok, (dialog, which) -> {
}).show();
}
});
viewModel.goToWelcomePage().observe(this, userId -> {
if (userId != null) {
getSupportFragmentManager().popBackStack();
getSupportFragmentManager().popBackStack();
getSupportFragmentManager().popBackStack();
loadFragment(new WelcomeFragment(), true);
}
});
viewModel.getGrantPermission().observe(this, isGrantPermission -> {
if (isGrantPermission != null && isGrantPermission) {
viewModel.startApp(getSupportFragmentManager().getBackStackEntryCount());
}
});
viewModel.getGoToIntroduction().observe(this, isGo -> loadFragment(new FragmentIntroduce(), true));
viewModel.getGoToNicknamePage().observe(this, isGo -> loadFragment(new FragmentRegistrationNickname(), true));
viewModel.getGoToRegisterPage().observe(this, isGo -> loadFragment(new FragmentRegister(), true));
viewModel.getLoadFromBackStack().observe(this, isLoad -> {
if (isLoad != null && isLoad) {
loadFragment(getSupportFragmentManager().findFragmentByTag(getSupportFragmentManager().getBackStackEntryAt(getSupportFragmentManager().getBackStackEntryCount() - 1).getName()), false);
}
});
G.isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
getSupportFragmentManager().addOnBackStackChangedListener(new FragmentManager.OnBackStackChangedListener() {
@Override
public void onBackStackChanged() {
Log.wtf(this.getClass().getName(), "-----------------------------------------");
for (int i = 0; i < getSupportFragmentManager().getBackStackEntryCount(); i++) {
Log.wtf(this.getClass().getName(), "fragment: " + getSupportFragmentManager().getBackStackEntryAt(i).getName());
}
Log.wtf(this.getClass().getName(), "-----------------------------------------");
}
});
}
Aggregations