public class MainActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Security.createDeviceCode(this);
// if (!checkRegistration()) {
// showRegisterActivity();
// return;
// }
App.onChangeSetting = this;
activity = this;
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
DrawerLayout drawer = findViewById(R.id.drawer_layout);
toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = findViewById(R.id.nav_view);
View header = navigationView.getHeaderView(0);
txt_version_name = header.findViewById(R.id.txt_version_name);
txt_fio = header.findViewById(R.id.txt_fio);
versionName = GlobalProc.getVersionName(this);
txt_version_name.setText(String.format("Версия: %s", versionName));
FragmentManager fragmentManager = getFragmentManager();
navigationView.setNavigationItemSelectedListener(this);
navigationView.getMenu().getItem(0).setChecked(true);
fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
getFragmentManager().beginTransaction()
.replace(R.id.contentMain, new StatisticsFragment())
.commit();
mMyBroadcastReceiver = new MyBroadcastReceiver();
// регистрируем BroadcastReceiver
IntentFilter intentFilter = new IntentFilter(GetParamsIntentService.BROADCAST_ACTION);
intentFilter.addCategory(Intent.CATEGORY_DEFAULT);
registerReceiver(mMyBroadcastReceiver, intentFilter);
String fio = GlobalProc.getPref(this, R.string.pref_nameManager);
if (fio != null && !fio.isEmpty()) {
txt_fio.setText(fio);
}
String region = App.getRegion(this);
String code = App.get(this).getCodeAgent();
if (fio != null && !fio.isEmpty() &&
region != null && !region.isEmpty() &&
code != null && !code.isEmpty() && !code.equals(getString(R.string.lb_zero_code_manager))) {
initFireBase(region,fio,code);
AuthManager.getInstance().signInExplicitly(code);
new GetVersionCode().execute();
getInstalledApplications();
}
mCallbacks = (ICallbacks)getFragmentManager().findFragmentById(R.id.contentMain);
fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
getFragmentManager().beginTransaction()
.replace(R.id.contentMain, new StatisticsFragment())
.commit();