forked from hush/SilentDragonAndroid-old
15 changed files with 163 additions and 86 deletions
@ -0,0 +1,44 @@ |
|||||
|
package org.myhush.silentdragon |
||||
|
|
||||
|
import org.myhush.silentdragon.chat.Message |
||||
|
|
||||
|
object Addressbook { |
||||
|
class Contact { |
||||
|
var nickname = "" |
||||
|
var addressIn = "" |
||||
|
var addressOut = "" |
||||
|
val messageList = ArrayList<Message>() |
||||
|
|
||||
|
constructor(nickname: String, addressIn: String, addressOut: String) { |
||||
|
this.nickname = nickname |
||||
|
this.addressIn = addressIn |
||||
|
this.addressOut = addressOut |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
val contactList = ArrayList<Contact>() |
||||
|
|
||||
|
fun addContact(nickname: String, addressIn: String, addressOut: String) { |
||||
|
contactList.add(Contact(nickname, addressIn, addressOut)) |
||||
|
} |
||||
|
|
||||
|
fun findContactByInAddress(address: String): Contact? { |
||||
|
contactList.forEach { |
||||
|
if(it.addressIn == address) |
||||
|
return it |
||||
|
} |
||||
|
return null |
||||
|
} |
||||
|
|
||||
|
fun findContactByOutAddress(address: String): Contact? { |
||||
|
contactList.forEach { |
||||
|
if (it.addressOut == address) |
||||
|
return it |
||||
|
} |
||||
|
return null |
||||
|
} |
||||
|
|
||||
|
fun clear() { |
||||
|
contactList.clear() |
||||
|
} |
||||
|
} |
@ -1,27 +0,0 @@ |
|||||
package org.myhush.silentdragon.chat |
|
||||
|
|
||||
object Addressbook { |
|
||||
class Contact { |
|
||||
var addressList: ArrayList<String> = ArrayList() |
|
||||
val messageList: ArrayList<Message> = ArrayList() |
|
||||
var fullname = "" |
|
||||
var nickname = "" |
|
||||
|
|
||||
constructor(fullname: String, nickname: String){ |
|
||||
this.fullname = fullname |
|
||||
this.nickname = nickname |
|
||||
} |
|
||||
constructor(fullname: String, nickname: String, address: String){ |
|
||||
this.fullname = fullname |
|
||||
this.nickname = nickname |
|
||||
this.addressList.add(address) |
|
||||
} |
|
||||
constructor(fullname: String, nickname: String, addressList: ArrayList<String>){ |
|
||||
this.fullname = fullname |
|
||||
this.nickname = nickname |
|
||||
this.addressList = addressList |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
val contactList = ArrayList<Contact>() |
|
||||
} |
|
Loading…
Reference in new issue