Skip to content

Commit

Permalink
#42: Added a RecyclerView to display all projects on the main screen.…
Browse files Browse the repository at this point in the history
… Created an appropriate adapter. Created the foundation for installing the Navigation Drawer.
  • Loading branch information
temnik15 committed Dec 24, 2020
1 parent 86f0c22 commit 958daec
Show file tree
Hide file tree
Showing 17 changed files with 455 additions and 276 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<activity
android:name=".ui.main.MainActivity"
android:screenOrientation="portrait">

</activity>

</application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ import so.codex.hawk.entity.Project

object ProjectProvider {
private val subject: BehaviorSubject<List<Project>> = BehaviorSubject.create()

init {
WorkspaceProvider.getWorkspaces()
.observeOn(Schedulers.io())
.subscribe{ workspaceList ->
.subscribe { workspaceList ->
subject.onNext(
workspaceList.flatMap {
it.projects
})
it.projects
}
)
}
}

fun getProjects(): Observable<List<Project>> {
return subject.hide()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,15 @@ object WorkspaceProvider {
w?.toWorkspace()
}
}
}.subscribe(
{
responseSource.onNext(it)
}, {
Timber.e(it)
})
}
.subscribe(
{
responseSource.onNext(it)
},
{
Timber.e(it)
}
)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/so/codex/hawk/entity/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ data class Project(
val id: String = "",
val name: String = "",
val description: String = "",
val image:String = "",
val image: String = "",
val unreadCount: Int = 0
)
2 changes: 1 addition & 1 deletion app/src/main/java/so/codex/hawk/entity/Workspace.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package so.codex.hawk.entity
data class Workspace(
val id: String = "",
val name: String = "",
val image:String = "",
val image: String = "",
val description: String = "",
val balance: Long = 0,
val projects: List<Project> = listOf()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/so/codex/hawk/entity/WorkspaceCut.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package so.codex.hawk.entity
data class WorkspaceCut(
val id: String = "",
val name: String = "",
val image:String ="",
val image: String = "",
val description: String = "",
val balance: Long = 0
)
33 changes: 20 additions & 13 deletions app/src/main/java/so/codex/hawk/extensions/domain/Utils.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package so.codex.hawk.extensions.domain

import android.content.Context
import android.graphics.Bitmap
import android.graphics.Color
import java.util.Locale

Expand Down Expand Up @@ -44,7 +42,11 @@ fun getColorById(id: String): Int {
}
}


/**
* The method of forming an abbreviation from the name.
*
* Example: Android application -> AA.
*/
fun getAbbreviationFromString(value: String): String {
if (value.isBlank()) {
return " "
Expand All @@ -57,7 +59,14 @@ fun getAbbreviationFromString(value: String): String {
}.toUpperCase(Locale.ROOT)
}


/**
* The method of forming an abbreviation from the Int
*
* Example:
* param: 1 -> return '1' (from 1 to 999)
* 1540 -> return '1 540' (from 1000 to 9999)
* 11267 -> return '11.3K' (over 9999)
*/
fun getAbbreviationFromInt(value: Int): String {
val maxNumberWithoutAbbreviation = 9999
return if (value <= maxNumberWithoutAbbreviation) {
Expand All @@ -70,14 +79,12 @@ fun getAbbreviationFromInt(value: Int): String {
} else {
val valueStr = value.toString()
var remainderToThousand = value % 1000
"${valueStr.substring(0, valueStr.length - 3)}." +
"${
if (remainderToThousand < 900 && remainderToThousand % 100 > 50) {
remainderToThousand += 100
remainderToThousand.toString()[0]
} else {
remainderToThousand.toString()[0]
}
}K"
val remainderStr = if (remainderToThousand < 900 && remainderToThousand % 100 > 50) {
remainderToThousand += 100
remainderToThousand.toString()[0]
} else {
remainderToThousand.toString()[0]
}
"${valueStr.substring(0, valueStr.length - 3)}.${remainderStr}K"
}
}
Loading

0 comments on commit 958daec

Please sign in to comment.