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,9 +280,11 @@ 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 (messenger != null) {
if (isChecked) { if (isChecked) {
try { try {
service.send(Message.obtain(null, MSG_START_NODE)); service.send(Message.obtain(null, MSG_START_NODE));
@ -297,8 +299,8 @@ public class MessageListActivity extends AppCompatActivity
} }
} }
} }
}
}) })
.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,28 +1,27 @@
<?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_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:fitsSystemWindows="true"> android:fitsSystemWindows="true"
android:orientation="vertical">
<TextView <TextView
android:id="@+id/subject" 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:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:text="Subject"
android:padding="16dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:elegantTextHeight="false" android:elegantTextHeight="false"
android:enabled="false"/> android:enabled="false"
android:gravity="center_vertical"
android:padding="16dp"
android:text="Subject"
android:textAppearance="?android:attr/textAppearanceLarge" />
<View <View
android:id="@+id/divider" android:id="@+id/divider"
@ -35,48 +34,49 @@
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:src="@color/accent" android:layout_below="@+id/divider"
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_toRightOf="@+id/avatar"
android:layout_toEndOf="@+id/avatar" android:layout_toEndOf="@+id/avatar"
android:layout_toRightOf="@+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:layout_toEndOf="@+id/avatar"
android:layout_toRightOf="@+id/avatar"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"
android:layout_alignBottom="@+id/avatar" android:text="Recipient" />
android:layout_toRightOf="@+id/avatar"
android:layout_toEndOf="@+id/avatar"/>
<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_alignParentStart="true"
android:layout_below="@+id/avatar"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:layout_marginTop="32dp" android:layout_marginTop="32dp"
android:paddingBottom="64dp" android:paddingBottom="64dp"
android:layout_below="@+id/avatar" android:text="New Text"
android:layout_alignParentLeft="true" android:textIsSelectable="true" />
android:layout_alignParentStart="true"/>
</RelativeLayout> </RelativeLayout>
</ScrollView> </ScrollView>