From 146177e8cc38fef6fecb0467658b7e2e9130d691 Mon Sep 17 00:00:00 2001 From: Janne Koschinski <janne@kuschku.de> Date: Mon, 25 Jan 2016 20:42:55 +0100 Subject: [PATCH] Added preconditions --- .../quasseldroid_ng/ui/chat/ChatActivity.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/QuasselDroidNG/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChatActivity.java b/QuasselDroidNG/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChatActivity.java index 844e39aca..c52f380c7 100644 --- a/QuasselDroidNG/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChatActivity.java +++ b/QuasselDroidNG/src/main/java/de/kuschku/quasseldroid_ng/ui/chat/ChatActivity.java @@ -39,6 +39,8 @@ import de.kuschku.util.DrawerUtils; import de.kuschku.util.instancestateutil.Storable; import de.kuschku.util.instancestateutil.Store; +import static de.kuschku.util.AndroidAssert.*; + @UiThread public class ChatActivity extends AppCompatActivity { @Bind(R.id.drawer_left) @@ -88,6 +90,9 @@ public class ChatActivity extends AppCompatActivity { private ServiceConnection serviceConnection = new ServiceConnection() { @UiThread public void onServiceConnected(@NonNull ComponentName cn, @NonNull IBinder service) { + assertNotNull(cn); + assertNotNull(service); + if (service instanceof QuasselService.LocalBinder) { ChatActivity.this.binder = (QuasselService.LocalBinder) service; if (binder.getBackgroundThread() != null) { @@ -98,6 +103,8 @@ public class ChatActivity extends AppCompatActivity { @UiThread public void onServiceDisconnected(@NonNull ComponentName cn) { + assertNotNull(cn); + backgroundThread = null; binder = null; } @@ -133,18 +140,24 @@ public class ChatActivity extends AppCompatActivity { } @Override - protected void onRestoreInstanceState(Bundle savedInstanceState) { + protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { + assertNotNull(savedInstanceState); + super.onRestoreInstanceState(savedInstanceState); status.onRestoreInstanceState(savedInstanceState); } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { + assertNotNull(outState); + super.onSaveInstanceState(outState); status.onSaveInstanceState(outState); } private void connectToThread(@NonNull ClientBackgroundThread backgroundThread) { + assertNotNull(backgroundThread); + if (this.backgroundThread != null) backgroundThread.provider.event.unregister(this); this.backgroundThread = backgroundThread; @@ -154,10 +167,14 @@ public class ChatActivity extends AppCompatActivity { } private void selectBufferViewConfig(@IntRange(from=-1) int bufferViewConfigId) { + assertTrue(bufferViewConfigId == -1 || null != this.backgroundThread.handler.client.getBufferViewManager().BufferViews.get(bufferViewConfigId)); + // TODO: Implement this } private void selectBuffer(@IntRange(from=-1) int bufferId) { + assertTrue(bufferId == -1 || null != this.backgroundThread.handler.client.getBuffer(bufferId)); + // TODO: Implement this } } -- GitLab