Skip to content
Snippets Groups Projects
Commit dc11fafb authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fixed several minor UI issues.

parent 1edd7908
Branches
Tags
No related merge requests found
Showing with 40 additions and 12 deletions
......@@ -452,8 +452,15 @@ public class MainActivity extends BoundActivity {
@Override
protected void onConnectToThread(@Nullable ClientBackgroundThread thread) {
super.onConnectToThread(thread);
if (thread == null)
connectToServer(manager.account(context.settings().preferenceLastAccount.get()));
if (thread == null) {
Account account = manager.account(context.settings().preferenceLastAccount.get());
if (account != null) {
connectToServer(account);
} else {
setResult(RESULT_CANCELED);
finish();
}
}
else {
if (context.client() != null && context.client().connectionStatus() == ConnectionChangeEvent.Status.CONNECTED) {
connected();
......
......@@ -236,6 +236,7 @@ public class BufferViewConfigAdapter extends ExpandableRecyclerAdapter<NetworkVi
if (config != null)
config.networkList().removeCallback(callback);
config = newconfig;
for (NetworkItem item : items) item.onDestroy();
items.clear();
itemMap.clear();
if (config != null) {
......
......@@ -33,6 +33,7 @@ import de.kuschku.libquassel.syncables.types.interfaces.QNetwork;
import de.kuschku.quasseldroid_ng.ui.theme.AppContext;
import de.kuschku.util.irc.IrcCaseMappers;
import de.kuschku.util.observables.callbacks.ElementCallback;
import de.kuschku.util.observables.callbacks.GeneralCallback;
import de.kuschku.util.observables.callbacks.UICallback;
import de.kuschku.util.observables.lists.ObservableSet;
import de.kuschku.util.observables.lists.ObservableSortedList;
......@@ -41,6 +42,7 @@ public class NetworkItem implements ParentListItem {
private final AppContext context;
private final QBufferViewConfig config;
private final QNetwork network;
private final BufferViewConfigAdapter bufferViewConfigAdapter;
private final ObservableSortedList<Buffer> buffers = new ObservableSortedList<>(new Comparator<Buffer>() {
@Override
public int compare(Buffer o1, Buffer o2) {
......@@ -86,15 +88,20 @@ public class NetworkItem implements ParentListItem {
public void notifyItemChanged(Integer element) {
}
};
private final UICallback callback1;
private final ElementCallback<Integer> callback2;
private final GeneralCallback<Boolean> booleanGeneralCallback;
private ObservableSet<Integer> backingSet;
public NetworkItem(AppContext context, QBufferViewConfig config, QNetwork network, BufferViewConfigAdapter bufferViewConfigAdapter) {
this.context = context;
this.config = config;
this.network = network;
bufferViewConfigAdapter.showAll().addCallback(object -> setShowAll(object));
this.bufferViewConfigAdapter = bufferViewConfigAdapter;
booleanGeneralCallback = object -> setShowAll(object);
bufferViewConfigAdapter.showAll().addCallback(booleanGeneralCallback);
setShowAll(bufferViewConfigAdapter.showAll().get());
this.buffers.addCallback(new UICallback() {
callback1 = new UICallback() {
@Override
public void notifyItemInserted(int position) {
bufferViewConfigAdapter.notifyChildItemInserted(NetworkItem.this, position);
......@@ -136,8 +143,9 @@ public class NetworkItem implements ParentListItem {
this.notifyItemRemoved(position);
}
}
});
context.client().bufferManager().bufferIds().addCallback(new ElementCallback<Integer>() {
};
this.buffers.addCallback(callback1);
callback2 = new ElementCallback<Integer>() {
@Override
public void notifyItemInserted(Integer element) {
}
......@@ -153,7 +161,8 @@ public class NetworkItem implements ParentListItem {
buffers.notifyItemChanged(buffer);
}
}
});
};
context.client().bufferManager().bufferIds().addCallback(callback2);
}
public void populateList(ObservableSet<Integer> backingSet) {
......@@ -193,4 +202,11 @@ public class NetworkItem implements ParentListItem {
public String toString() {
return String.valueOf(network);
}
public void onDestroy() {
this.backingSet.removeCallback(callback);
bufferViewConfigAdapter.showAll().removeCallback(booleanGeneralCallback);
this.buffers.removeCallback(callback1);
context.client().bufferManager().bufferIds().removeCallback(callback2);
}
}
......@@ -183,12 +183,12 @@ public class NetworkServerEditActivity extends BoundActivity {
useSSL.isChecked(),
0,
host.getText().toString(),
NumberHelper.parseInt(port.getText().toString(), -1),
NumberHelper.parseInt(port.getText().toString(), 0),
password.getText().toString(),
useProxy.isChecked(),
NetworkServer.ProxyType.fromId((int) proxyType.getSelectedItemId()),
proxyHost.getText().toString(),
NumberHelper.parseInt(proxyPort.getText().toString(), -1),
NumberHelper.parseInt(proxyPort.getText().toString(), 0),
proxyUser.getText().toString(),
proxyPassword.getText().toString()
)));
......
......@@ -87,7 +87,7 @@ public class ObservableSortedList<T> extends ArrayList<T> implements IObservable
@Override
public boolean add(T object) {
int position = addInternal(object);
callback.notifyItemInserted(position);
callback.notifyItemInserted(indexOf(object));
return position != -1;
}
......@@ -125,7 +125,7 @@ public class ObservableSortedList<T> extends ArrayList<T> implements IObservable
@Override
public boolean remove(Object object) {
int position = indexOf(object);
int position = super.indexOf(object);
if (position == -1) {
return false;
} else {
......
......@@ -51,5 +51,6 @@
android:layout_weight="1"
android:clickable="true"
android:textColor="?attr/colorForegroundAction"
android:textIsSelectable="true"
android:textStyle="italic"/>
</LinearLayout>
......@@ -52,5 +52,6 @@
android:layout_weight="1"
android:clickable="true"
android:textColor="?attr/colorForegroundError"
android:textIsSelectable="true"
android:textStyle="italic"/>
</LinearLayout>
......@@ -50,5 +50,6 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:textColor="?attr/colorForeground"/>
android:textColor="?attr/colorForeground"
android:textIsSelectable="true"/>
</LinearLayout>
......@@ -52,5 +52,6 @@
android:layout_weight="1"
android:clickable="true"
android:textColor="?attr/colorForegroundSecondary"
android:textIsSelectable="true"
android:textStyle="italic"/>
</LinearLayout>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment