Fixed NullPointerException and minor improvements

This commit is contained in:
Christian Basler 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() new SwitchDrawerItem()
.withName(R.string.full_node) .withName(R.string.full_node)
.withIcon(CommunityMaterial.Icon.cmd_cloud_outline) .withIcon(CommunityMaterial.Icon.cmd_cloud_outline)
.withChecked(BitmessageService.isRunning())
.withOnCheckedChangeListener(new OnCheckedChangeListener() { .withOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(IDrawerItem drawerItem, CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(IDrawerItem drawerItem, CompoundButton buttonView, boolean isChecked) {
if (isChecked) { if (messenger != null) {
try { if (isChecked) {
service.send(Message.obtain(null, MSG_START_NODE)); try {
} catch (RemoteException e) { service.send(Message.obtain(null, MSG_START_NODE));
LOG.error(e.getMessage(), e); } catch (RemoteException e) {
} LOG.error(e.getMessage(), e);
} else { }
try { } else {
service.send(Message.obtain(null, MSG_STOP_NODE)); try {
} catch (RemoteException e) { service.send(Message.obtain(null, MSG_STOP_NODE));
LOG.error(e.getMessage(), e); } catch (RemoteException e) {
LOG.error(e.getMessage(), e);
}
} }
} }
} }
}) })
.withChecked(BitmessageService.isRunning())
) )
.withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {
@Override @Override

View File

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

View File

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

View File

@ -1,82 +1,82 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ScrollView <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent">
android:layout_width="match_parent">
<RelativeLayout <RelativeLayout
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:orientation="vertical">
<TextView
android:id="@+id/subject"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fitsSystemWindows="true"> android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
<TextView android:layout_alignParentTop="true"
android:id="@+id/subject" android:elegantTextHeight="false"
android:layout_width="match_parent" android:enabled="false"
android:layout_height="wrap_content" android:gravity="center_vertical"
android:textAppearance="?android:attr/textAppearanceLarge" android:padding="16dp"
android:gravity="center_vertical" android:text="Subject"
android:text="Subject" android:textAppearance="?android:attr/textAppearanceLarge" />
android:padding="16dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:elegantTextHeight="false"
android:enabled="false"/>
<View <View
android:id="@+id/divider" android:id="@+id/divider"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="2dip" android:layout_height="2dip"
android:layout_below="@id/subject" android:layout_below="@id/subject"
android:background="@color/divider"/> android:background="@color/divider" />
<ImageView <ImageView
android:id="@+id/avatar" android:id="@+id/avatar"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_below="@+id/divider" android:layout_alignParentLeft="true"
android:layout_alignParentLeft="true" android:layout_alignParentStart="true"
android:layout_alignParentStart="true" android:layout_below="@+id/divider"
android:src="@color/accent" android:layout_margin="16dp"
android:layout_margin="16dp"/> android:src="@color/accent" />
<TextView <TextView
android:id="@+id/sender" android:id="@+id/sender"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="20dp" android:layout_height="20dp"
android:text="Sender" android:layout_alignTop="@+id/avatar"
android:layout_alignTop="@+id/avatar" android:layout_toEndOf="@+id/avatar"
android:layout_toRightOf="@+id/avatar" android:layout_toRightOf="@+id/avatar"
android:layout_toEndOf="@+id/avatar" android:gravity="center_vertical"
android:gravity="center_vertical" android:paddingLeft="8dp"
android:paddingLeft="8dp" android:paddingRight="8dp"
android:paddingRight="8dp" android:text="Sender"
android:textStyle="bold"/> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/recipient" android:id="@+id/recipient"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="20dp" android:layout_height="20dp"
android:text="Recipient" android:layout_alignBottom="@+id/avatar"
android:gravity="center_vertical" android:layout_toEndOf="@+id/avatar"
android:paddingLeft="8dp" android:layout_toRightOf="@+id/avatar"
android:paddingRight="8dp" android:gravity="center_vertical"
android:layout_alignBottom="@+id/avatar" android:paddingLeft="8dp"
android:layout_toRightOf="@+id/avatar" android:paddingRight="8dp"
android:layout_toEndOf="@+id/avatar"/> android:text="Recipient" />
<TextView <TextView
android:id="@+id/text" android:id="@+id/text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="New Text" android:layout_alignParentLeft="true"
android:layout_marginLeft="16dp" android:layout_alignParentStart="true"
android:layout_marginRight="16dp" android:layout_below="@+id/avatar"
android:layout_marginTop="32dp" android:layout_marginLeft="16dp"
android:paddingBottom="64dp" android:layout_marginRight="16dp"
android:layout_below="@+id/avatar" android:layout_marginTop="32dp"
android:layout_alignParentLeft="true" android:paddingBottom="64dp"
android:layout_alignParentStart="true"/> android:text="New Text"
android:textIsSelectable="true" />
</RelativeLayout> </RelativeLayout>
</ScrollView> </ScrollView>