Skip to content

Commit

Permalink
Working on data object classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Romulus10 committed Oct 4, 2018
1 parent 02b1285 commit 67b714b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,24 @@ package io.github.romulus10.blckchnmsg.blckchnmsg.data
import java.util.ArrayList
import java.util.HashMap

/**
* Helper class for providing sample content for user interfaces created by
* Android template wizards.
*
* TODO: Replace all uses of this class before publishing your app.
*/
object Contact {

/**
* An array of sample (dummy) items.
*/
val ITEMS: MutableList<Contact> = ArrayList()

/**
* A map of sample (dummy) items, by ID.
*/
val ITEM_MAP: MutableMap<String, Contact> = HashMap()

private val COUNT = 25

init {
// Add some sample items.
for (i in 1..COUNT) {
addItem(createContact(i))
}
}

private fun addItem(item: Contact) {
ITEMS.add(item)
ITEM_MAP[item.id] = item
}

private fun createContact(position: Int): Contact {
return Contact(position.toString(), "Item $position", makeDetails(position))
}

private fun makeDetails(position: Int): String {
val builder = StringBuilder()
builder.append("Details about Item: ").append(position)
for (i in 0 until (position - 1)) {
builder.append("\nMore details information here.")
}
return builder.toString()
private fun createContact(id: String, uname: String, email: String, key: String): Contact {
return Contact(id, uname, email, key)
}

data class Contact(val id: String, val content: String, val details: String) {
override fun toString(): String = content
data class Contact(val id: String, val uname: String, val email: String, val key: String) {
override fun toString(): String = uname
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,25 @@ package io.github.romulus10.blckchnmsg.blckchnmsg.data
import java.util.ArrayList
import java.util.HashMap

/**
* Helper class for providing sample content for user interfaces created by
* Android template wizards.
*
* TODO: Replace all uses of this class before publishing your app.
*/
object Key {

/**
* An array of sample (dummy) items.
*/
val ITEMS: MutableList<Key> = ArrayList()

/**
* A map of sample (dummy) items, by ID.
*/
val ITEM_MAP: MutableMap<String, Key> = HashMap()

private val COUNT = 25

init {
// Add some sample items.
for (i in 1..COUNT) {
addItem(createKey(i))
}
}

private fun addItem(item: Key) {
ITEMS.add(item)
ITEM_MAP[item.id] = item
}

private fun createKey(position: Int): Key {
return Key(position.toString(), "Item $position", makeDetails(position))
}

private fun makeDetails(position: Int): String {
val builder = StringBuilder()
builder.append("Details about Item: ").append(position)
for (i in 0 until (position - 1)) {
builder.append("\nMore details information here.")
}
return builder.toString()
private fun createKey(id: String, user: Contact, key: String): Key {
return Key(id, user, key)
}

data class Key(val id: String, val content: String, val details: String) {
override fun toString(): String = content
data class Key(val id: String, val user: Contact, val key: String) {
override fun toString(): String = id
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,24 @@ package io.github.romulus10.blckchnmsg.blckchnmsg.data
import java.util.ArrayList
import java.util.HashMap

/**
* Helper class for providing sample content for user interfaces created by
* Android template wizards.
*
* TODO: Replace all uses of this class before publishing your app.
*/
object Message {

/**
* An array of sample (dummy) items.
*/
val ITEMS: MutableList<Message> = ArrayList()

/**
* A map of sample (dummy) items, by ID.
*/
val ITEM_MAP: MutableMap<String, Message> = HashMap()

private val COUNT = 25

init {
// Add some sample items.
for (i in 1..COUNT) {
addItem(createMessage(i))
}
}

private fun addItem(item: Message) {
ITEMS.add(item)
ITEM_MAP[item.id] = item
}

private fun createMessage(position: Int): Message {
return Message(position.toString(), "Item $position", makeDetails(position))
}

private fun makeDetails(position: Int): String {
val builder = StringBuilder()
builder.append("Details about Item: ").append(position)
for (i in 0 until (position - 1)) {
builder.append("\nMore details information here.")
}
return builder.toString()
private fun createMessage(id: String, to: Contact, from: Contact, message: String, signature: String): Message {
return Message(id, to, from, message, signature)
}

/**
* A dummy item representing a piece of content.
*/
data class Message(val id: String, val content: String, val details: String) {
override fun toString(): String = content
data class Message(val id: String, val to: Contact, val from: Contact, val message: String, val signature: String) {
override fun toString(): String = message
}
}

This file was deleted.

0 comments on commit 67b714b

Please sign in to comment.