Fixed NullPointerException and minor improvements

This commit is contained in:
2015-10-24 20:59:24 +02:00
parent f5bf5c8bca
commit 725089c604
4 changed files with 80 additions and 79 deletions

View File

@ -280,25 +280,27 @@ public class MessageListActivity extends AppCompatActivity
new SwitchDrawerItem()
.withName(R.string.full_node)
.withIcon(CommunityMaterial.Icon.cmd_cloud_outline)
.withChecked(BitmessageService.isRunning())
.withOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(IDrawerItem drawerItem, CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
try {
service.send(Message.obtain(null, MSG_START_NODE));
} catch (RemoteException e) {
LOG.error(e.getMessage(), e);
}
} else {
try {
service.send(Message.obtain(null, MSG_STOP_NODE));
} catch (RemoteException e) {
LOG.error(e.getMessage(), e);
if (messenger != null) {
if (isChecked) {
try {
service.send(Message.obtain(null, MSG_START_NODE));
} catch (RemoteException e) {
LOG.error(e.getMessage(), e);
}
} else {
try {
service.send(Message.obtain(null, MSG_STOP_NODE));
} catch (RemoteException e) {
LOG.error(e.getMessage(), e);
}
}
}
}
})
.withChecked(BitmessageService.isRunning())
)
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override

View File

@ -1,6 +1,5 @@
package ch.dissem.apps.abit.notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

View File

@ -91,7 +91,7 @@ public class BitmessageService extends Service {
@Override
public void onDestroy() {
bmc.shutdown();
if (bmc.isRunning()) bmc.shutdown();
running = false;
}