package ir.almahdi.sandogh_bsa_aza.login;

import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Handler;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import ir.almahdi.sandogh_bsa_aza.R;

public class splashactivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splashactivity);

   new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                if (is_network_connection()) {

try {
    startActivity(new Intent(getApplicationContext(), login.class));

} catch (Exception e) {
       e.printStackTrace();
}

                    finish();
                } else {
                    Toast.makeText(getApplicationContext(), "خطا در اتصال به اینترنت", Toast.LENGTH_LONG).show();
                }
            }
        }, 5000);
    }
    private boolean is_network_connection(){
        ConnectivityManager connectivityManager= (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
     assert connectivityManager != null;
        NetworkInfo networkInfo =connectivityManager.getActiveNetworkInfo();
        return networkInfo != null;

    }
}
