Implementato splashscreen.
Implementato blocco quando si usano etichette anonime che non sono dell'anno corrente.
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
package it.integry.integrywmsnative;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.os.Handler;
|
||||
import android.text.SpannableString;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import it.integry.integrywmsnative.core.settings.SettingsManager;
|
||||
import it.integry.integrywmsnative.core.utility.PermissionsHelper;
|
||||
import it.integry.integrywmsnative.gest.login.LoginActivity;
|
||||
import it.integry.integrywmsnative.view.dialogs.DialogSimpleMessageHelper;
|
||||
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
|
||||
@BindView(R.id.app_version_textview)
|
||||
TextView appVersionTextView;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_splash);
|
||||
|
||||
ButterKnife.bind(this);
|
||||
|
||||
initAppVersion();
|
||||
|
||||
|
||||
PermissionsHelper.askPermissions(this, () -> {
|
||||
init();
|
||||
}, permanentlyDenied -> {
|
||||
if(permanentlyDenied) {
|
||||
DialogSimpleMessageHelper.makeErrorDialog(this,
|
||||
new SpannableString(getText(R.string.permissions_permanrntly_denied)), null, () -> {
|
||||
this.finish();
|
||||
}).show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initAppVersion() {
|
||||
try {
|
||||
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
String version = pInfo.versionName;
|
||||
appVersionTextView.setText("v" + version);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if(SettingsManager.i().user.username == null && SettingsManager.i().user.password == null){
|
||||
startLoginActivity();
|
||||
} else {
|
||||
startMainActivity();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void startLoginActivity(){
|
||||
Intent myIntent = new Intent(this, LoginActivity.class);
|
||||
startActivity(myIntent);
|
||||
this.finish();
|
||||
}
|
||||
|
||||
private void startMainActivity(){
|
||||
new Handler().postDelayed(() -> {
|
||||
Intent myIntent = new Intent(this, MainActivity.class);
|
||||
startActivity(myIntent);
|
||||
this.finish();
|
||||
}, 3000);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user