@Override
 protected void onCreate(Bundle savedInstanceState) {
   Log.d(TAG, "onCreate() + " + this.hashCode());
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_nexrad_view);
   eventBusProvider.getEventBus().register(this);
   mGoogleApiClient =
       new GoogleApiClient.Builder(this)
           .addConnectionCallbacks(this)
           .addOnConnectionFailedListener(this)
           .addApi(LocationServices.API)
           .build();
   // Create the LocationRequest object
   mLocationRequest =
       LocationRequest.create()
           .setPriority(LocationRequest.PRIORITY_LOW_POWER)
           .setInterval(10 * 60 * 1000) // 10 seconds, in milliseconds
           .setFastestInterval(1 * 60 * 1000); // 1 second, in milliseconds
   if (PackageManager.PERMISSION_GRANTED
       != ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)) {
     ActivityCompat.requestPermissions(this, INITIAL_PERMS, INITIAL_REQUEST);
   }
   if (PreferenceManager.getDefaultSharedPreferences(this)
           .getString(SettingsActivity.KEY_PREF_NEXRAD_EMAILADDRESS, null)
       == null) {
     startSettings(true);
   } else {
     if (((NexradApp) getApplication()).getLastKnownLocation() != null) {
       RadarBitmapView radarView = (RadarBitmapView) findViewById(R.id.radarView);
       radarView.onEvent(
           new LocationChangeEvent(((NexradApp) getApplication()).getLastKnownLocation()));
     }
   }
 }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setSupportActionBar(toolbar);
   setStatusBarColor(getResources().getColor(R.color.primary_dark));
   getSupportActionBar().setDisplayHomeAsUpEnabled(true);
   if (savedInstanceState == null) {
     Location currentLocation = getIntent().getExtras().getParcelable(CURRENT_LOCATION_ARG);
     Poi seed = (Poi) getIntent().getExtras().getSerializable(SEED_ARG);
     getSupportFragmentManager()
         .beginTransaction()
         .replace(R.id.content, RecommendedRouteFragment.newInstance(currentLocation, seed))
         .commit();
   }
 }
Exemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    // setSupportActionBar(toolbar);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      Window window = getWindow();
      window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
      window.setStatusBarColor(getResources().getColor(R.color.primary_dark));
    }

    Resources res = getResources();
    registerFirstName
        .getBackground()
        .setColorFilter(res.getColor(R.color.primary_light), PorterDuff.Mode.SRC_ATOP);
    registerLastName
        .getBackground()
        .setColorFilter(res.getColor(R.color.primary_light), PorterDuff.Mode.SRC_ATOP);
    registerPassword
        .getBackground()
        .setColorFilter(res.getColor(R.color.primary_light), PorterDuff.Mode.SRC_ATOP);
    registerEmail
        .getBackground()
        .setColorFilter(res.getColor(R.color.primary_light), PorterDuff.Mode.SRC_ATOP);
    loginEmail
        .getBackground()
        .setColorFilter(res.getColor(R.color.primary_light), PorterDuff.Mode.SRC_ATOP);
    loginPassword
        .getBackground()
        .setColorFilter(res.getColor(R.color.primary_light), PorterDuff.Mode.SRC_ATOP);

    // Animation to blend over from the login choice view to registerButton or login view
    animationDuration = res.getInteger(android.R.integer.config_shortAnimTime);

    // Remember the currently shown layout/view
    activeView = loginChoiceView;

    // The user can decide to login (with registerEmail and password)...
    chooseLoginButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            showView(loginView);
          }
        });

    // ... or to registerButton with a new account
    chooseRegisterButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            showView(registerView);
          }
        });

    // REGISTER LAYOUT
    registerButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            // Check if first and last name are entered
            if (TextUtils.isEmpty(registerFirstName.getText().toString())
                || TextUtils.isEmpty(registerLastName.getText().toString())) {
              Toast.makeText(
                      getApplication().getApplicationContext(),
                      getResources().getString(R.string.first_last_mandatory),
                      Toast.LENGTH_SHORT)
                  .show();
            }
            // Check the validity of the entered email address using Regex
            else if (!validate(registerEmail.getText().toString())) {
              Toast.makeText(
                      getApplication().getApplicationContext(),
                      getResources().getString(R.string.email_invalid),
                      Toast.LENGTH_SHORT)
                  .show();
            } else
              registerUser(
                  registerFirstName.getText().toString(),
                  registerLastName.getText().toString(),
                  registerEmail.getText().toString(),
                  registerPassword.getText().toString());
          }
        });

    // LOGIN LAYOUT
    loginButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View view) {
            loginUser(loginEmail.getText().toString(), loginPassword.getText().toString());
          }
        });

    // SKIP login
    findViewById(R.id.skip)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                setResult(RESULT_SKIPPED);
                finish();
              }
            });
  }
Exemplo n.º 4
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   lifecycleSubject.onNext(LifecycleEvent.CREATE);
 }