This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SerializableObservable<T : Serializable>(private val onChange: (oldValue: T?, newValue: T?) -> Unit) : ReadWriteProperty<Any?, T?>, Serializable { | |
var value: T? = null | |
override fun getValue(thisRef: Any?, property: KProperty<*>): T? { | |
return value | |
} | |
override fun setValue(thisRef: Any?, property: KProperty<*>, value: T?) { | |
val old = this.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.view.View; | |
import com.google.android.apps.common.testing.ui.espresso.PerformException; | |
import com.google.android.apps.common.testing.ui.espresso.UiController; | |
import com.google.android.apps.common.testing.ui.espresso.ViewAction; | |
import com.google.android.apps.common.testing.ui.espresso.util.HumanReadables; | |
import com.google.android.apps.common.testing.ui.espresso.util.TreeIterables; | |
import org.hamcrest.Description; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SensorActivity extends Activity, implements SensorEventListener { | |
private final SensorManager sensorManager; | |
private final Sensor accelerometer; | |
public SensorActivity() { | |
sensorManager = (SensorManager)getSystemService(SENSOR_SERVICE); | |
accelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_LIGHT); //Датчик освещённости | |
} | |
protected void onResume() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LightSensorManager implements SensorEventListener { | |
private enum Environment {DAY, NIGHT} | |
public interface EnvironmentChangedListener { | |
void onDayDetected(); | |
void onNightDetected(); | |
} | |
private static final float SMOOTHING = 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LightSensorManager implements SensorEventListener { | |
private enum Environment {DAY, NIGHT} | |
public interface EnvironmentChangedListener { | |
void onDayDetected(); | |
void onNightDetected(); | |
} | |
private static final int THRESHOLD_DAY_LUX = 50; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LightSensorManager implements SensorEventListener { | |
private enum Environment {DAY, NIGHT} | |
public interface EnvironmentChangedListener { | |
void onDayDetected(); | |
void onNightDetected(); | |
} | |
private static final int THRESHOLD_LUX = 50; |