Skip to content

Commit

Permalink
* Revert: Fix a potential handler leak
Browse files Browse the repository at this point in the history
* Disable preference when no sensor is found
  • Loading branch information
kconger committed Mar 12, 2015
1 parent daab30c commit bc773ad
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 596 deletions.
24 changes: 0 additions & 24 deletions app/src/main/java/org/thecongers/mtpms/IStaticHandler.java

This file was deleted.

9 changes: 3 additions & 6 deletions app/src/main/java/org/thecongers/mtpms/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public class MainActivity extends ActionBarActivity {
static boolean hasSensor = false;
static SensorIdDatabase sensorDB;
private LogData logger = null;
private Handler sensorMessages;
private ConnectThread btConnectThread;
private Handler handler;

@SuppressLint("HandlerLeak")
@Override
Expand Down Expand Up @@ -204,8 +204,7 @@ public void onCreate(Bundle savedInstanceState) {
new AlertDialog.Builder(this).setTitle(R.string.alert_setup_title).setMessage(R.string.alert_setup_message).setNeutralButton(R.string.alert_setup_button, null).show();
}

IStaticHandler sensorMessages = new IStaticHandler() {
@Override
sensorMessages = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case RECEIVE_MESSAGE:
Expand Down Expand Up @@ -420,7 +419,6 @@ public void handleMessage(Message msg) {
}
}
};
handler = StaticHandlerFactory.create(sensorMessages);
// Light Sensor Stuff
SensorManager sensorManager
= (SensorManager)getSystemService(Context.SENSOR_SERVICE);
Expand Down Expand Up @@ -778,8 +776,7 @@ public void run() {
try {
// Read from the InputStream
bytes = btInStream.read(buffer); // Get number of bytes and message in "buffer"

handler.obtainMessage(RECEIVE_MESSAGE, bytes, -1, buffer).sendToTarget(); // Send to message queue Handler
sensorMessages.obtainMessage(RECEIVE_MESSAGE, bytes, -1, buffer).sendToTarget(); // Send to message queue Handler
} catch (IOException e) {
Log.d(TAG, "IO Exception while reading stream");
btConnectThread.cancel();
Expand Down
47 changes: 0 additions & 47 deletions app/src/main/java/org/thecongers/mtpms/StaticHandlerFactory.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void onCreate(final Bundle savedInstanceState)
// Disable auto night mode option when no sensor is found
if (!MainActivity.hasSensor){
getPreferenceScreen().findPreference("prefAutoNightMode").setEnabled(false);
getPreferenceScreen().findPreference("prefAutoNightModeDelay").setEnabled(false);
}
// Dynamically populate sensorID lists
final ListPreference listFrontIDPreference = (ListPreference) findPreference("prefFrontID");
Expand Down
129 changes: 0 additions & 129 deletions app/src/main/res/layout-small-land/activity_main.xml

This file was deleted.

129 changes: 0 additions & 129 deletions app/src/main/res/layout-small/activity_main.xml

This file was deleted.

Loading

0 comments on commit bc773ad

Please sign in to comment.