@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 onDestroy() { Log.d(TAG, "onDestroy() + " + this.hashCode()); super.onDestroy(); eventBusProvider.getEventBus().unregister(this); RadarBitmapView radarView = (RadarBitmapView) findViewById(R.id.radarView); if (radarView != null) { radarView.releaseBitmap(); } }
public void onEvent(AppMessage message) { // TODO: use different styles for errors vs. other types of messages int duration = Toast.LENGTH_LONG; if (message.getType() == AppMessage.Type.ERROR) { duration = Toast.LENGTH_LONG; Toast msgToast = Toast.makeText(this, message.getMessage(), duration); msgToast.show(); } else { // Forward to the view for display RadarBitmapView radarView = (RadarBitmapView) findViewById(R.id.radarView); radarView.onEvent(message); } }
public void onEvent(NexradUpdate update) { Log.d(TAG, "onEvent(NexradUpdate " + update.hashCode() + ") + " + this.hashCode()); RadarBitmapView radarView = (RadarBitmapView) findViewById(R.id.radarView); radarView.onEvent(update); }
public void onEvent(LocationChangeEvent location) { RadarBitmapView radarView = (RadarBitmapView) findViewById(R.id.radarView); radarView.onEvent(location); }
public void onEvent(BitmapEvent bitmapEvent) { RadarBitmapView radarView = (RadarBitmapView) findViewById(R.id.radarView); radarView.onEvent(bitmapEvent); }