Android Open Source - android-weather-station Main Activity






From Project

Back to project page android-weather-station.

License

The source code is released under:

Apache License

If you think the Android project android-weather-station listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package de.grundid.weather;
//w  w w  .j a  v  a  2  s. c  o  m
import android.app.Activity;
import android.os.Bundle;
import de.grundid.weather.io.AttachedDeviceHandler;
import de.grundid.weather.io.UsbConnectionException;
import de.grundid.weather.sensor.WeatherLogger;

public class MainActivity extends Activity {

  private Beeper beeper;
  private SerialDataHandler serialDataHandler;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initUi();
    SensorHandler sensorHandler = new SensorHandler(findViewById(R.id.inside), findViewById(R.id.outside),
        findViewById(R.id.pressure), findViewById(R.id.humidity), findViewById(R.id.inside_last_update),
        findViewById(R.id.outside_last_update), findViewById(R.id.pressure_last_update),
        findViewById(R.id.humidity_last_update));
    WeatherLogger weatherLogger = new WeatherLogger(sensorHandler);
    serialDataHandler = new SerialDataHandler(weatherLogger);
    AttachedDeviceHandler attachedDeviceHandler = new AttachedDeviceHandler(this, serialDataHandler);
    try {
      attachedDeviceHandler.handleIntent(getIntent());
    }
    catch (UsbConnectionException e) {
      throw new RuntimeException(e);
    }
  }

  private void initUi() {
    setContentView(R.layout.activity_main);
    beeper = new Beeper(this);
  }

  @Override
  protected void onStart() {
    super.onStart();
  }

  @Override
  protected void onStop() {
    super.onStop();
  }

  @Override
  protected void onDestroy() {
    serialDataHandler.releaseDevice();
    super.onDestroy();
  }

  public void beepTwice() {
    Thread t = new Thread(beeper);
    t.start();
  }
}




Java Source Code List

de.grundid.weather.Beeper.java
de.grundid.weather.Constants.java
de.grundid.weather.MainActivity.java
de.grundid.weather.SensorHandler.java
de.grundid.weather.SerialDataHandler.java
de.grundid.weather.io.AttachedDeviceHandler.java
de.grundid.weather.io.ConnectedUsbDevice.java
de.grundid.weather.io.PermissionBroadcastReceiver.java
de.grundid.weather.io.SerialReceiverListener.java
de.grundid.weather.io.SerialReceiver.java
de.grundid.weather.io.UsbConnectionException.java
de.grundid.weather.sensor.InsideSensor.java
de.grundid.weather.sensor.LightSensor.java
de.grundid.weather.sensor.OutsideSensor.java
de.grundid.weather.sensor.SensorFactory.java
de.grundid.weather.sensor.SensorListener.java
de.grundid.weather.sensor.Sensor.java
de.grundid.weather.sensor.WeatherLogger.java
de.grundid.weather.utils.Utils.java