EnsichatActivity.service should return option.
This commit is contained in:
parent
e66bccc044
commit
6042c3fb11
5 changed files with 8 additions and 7 deletions
|
@ -84,7 +84,7 @@ class AddContactsActivity extends EnsichatActivity with OnItemClickListener {
|
|||
runOnUiThread(new Runnable {
|
||||
override def run(): Unit = {
|
||||
adapter.clear()
|
||||
(service.connections().map(a => service.getUser(a)) -- database.getContacts)
|
||||
(service.get.connections().map(a => service.get.getUser(a)) -- database.getContacts)
|
||||
.foreach(adapter.add)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -58,8 +58,8 @@ class EnsichatActivity extends AppCompatActivity with ServiceConnection {
|
|||
/**
|
||||
* Returns the [[ChatService]].
|
||||
*
|
||||
* Should only be called after [[runOnServiceConnected]] callback was called.
|
||||
* Will only be set after [[runOnServiceConnected]].
|
||||
*/
|
||||
def service = chatService.get
|
||||
def service = chatService
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ class ChatFragment extends ListFragment with OnClickListener {
|
|||
super.onActivityCreated(savedInstanceState)
|
||||
|
||||
activity.runOnServiceConnected(() => {
|
||||
chatService = activity.service
|
||||
chatService = activity.service.get
|
||||
|
||||
database.getContact(address).foreach(c => getActivity.setTitle(c.name))
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ class ContactsFragment extends ListFragment with OnClickListener {
|
|||
toolbar.setNavigationIcon(R.drawable.ic_launcher)
|
||||
title = v.findViewById(R.id.title).asInstanceOf[TextView]
|
||||
subtitle = v.findViewById(R.id.subtitle).asInstanceOf[TextView]
|
||||
updateConnections()
|
||||
v
|
||||
}
|
||||
|
||||
|
@ -141,10 +142,10 @@ class ContactsFragment extends ListFragment with OnClickListener {
|
|||
* Updates TextViews in actionbar with current connections.
|
||||
*/
|
||||
private def updateConnections(): Unit = {
|
||||
val service = activity.service
|
||||
if (service == null || title == null)
|
||||
if (activity.service.isEmpty || title == null)
|
||||
return
|
||||
|
||||
val service = activity.service.get
|
||||
val connections = service.connections()
|
||||
val count = connections.size
|
||||
val color = count match {
|
||||
|
|
|
@ -69,7 +69,7 @@ class SettingsFragment extends PreferenceFragment with OnPreferenceChangeListene
|
|||
case KeyUserName | KeyUserStatus =>
|
||||
val service = getActivity.asInstanceOf[EnsichatActivity].service
|
||||
val ui = new UserInfo(prefs.getString(KeyUserName, ""), prefs.getString(KeyUserStatus, ""))
|
||||
database.getContacts.foreach(c => service.sendTo(c.address, ui))
|
||||
database.getContacts.foreach(c => service.get.sendTo(c.address, ui))
|
||||
}
|
||||
preference.setSummary(newValue.toString)
|
||||
true
|
||||
|
|
Reference in a new issue