Skip to content

Commit

Permalink
design: design client list screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya-gupta99 committed Feb 14, 2024
1 parent 5b412a2 commit cec92e8
Show file tree
Hide file tree
Showing 31 changed files with 1,109 additions and 383 deletions.
8 changes: 8 additions & 0 deletions core/data/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
id("kotlin-parcelize")
}

android {
Expand Down Expand Up @@ -40,4 +42,10 @@ dependencies {
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")

//DBFlow dependencies
kapt("com.github.raizlabs.dbflow.dbflow:dbflow-processor:3.1.1")
implementation("com.github.raizlabs.dbflow.dbflow:dbflow:3.1.1")
kapt("com.github.raizlabs.dbflow:dbflow-processor:4.2.4")
}
111 changes: 111 additions & 0 deletions core/data/src/main/java/com/mifos/core/data/model/client/Client.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* This project is licensed under the open source MPL V2.
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data.model.client

import android.os.Parcelable
import com.mifos.core.data.model.database.MifosBaseModel
import com.mifos.core.data.model.database.MifosDatabase
import com.raizlabs.android.dbflow.annotation.Column
import com.raizlabs.android.dbflow.annotation.ForeignKey
import com.raizlabs.android.dbflow.annotation.ModelContainer
import com.raizlabs.android.dbflow.annotation.PrimaryKey
import com.raizlabs.android.dbflow.annotation.Table
import kotlinx.parcelize.Parcelize

/**
* Created by ishankhanna on 08/02/14.
*/
@Parcelize
@Table(database = MifosDatabase::class, useBooleanGetterSetters = false)
@ModelContainer
data class Client(
@PrimaryKey
var id: Int = 0,

@Column
@Transient
var groupId: Int? = 0,

@Column
var accountNo: String? = null,

var clientId: Int? = null,

@Column
@ForeignKey(saveForeignKeyModel = true)
var status: Status? = null,

@Column
@Transient
var sync: Boolean = false,

@Column
var active: Boolean = false,

@Column
@ForeignKey(saveForeignKeyModel = true)
var clientDate: ClientDate? = null,

var activationDate: List<Int?> = ArrayList(),

var dobDate: List<Int?> = ArrayList(),

var groups: List<Group?> = ArrayList(),

var mobileNo: String? = null,

@Column
var firstname: String? = null,

@Column
var middlename: String? = null,

@Column
var lastname: String? = null,

@Column
var displayName: String? = null,

@Column
var officeId: Int = 0,

@Column
var officeName: String? = null,

@Column
var staffId: Int = 0,

@Column
var staffName: String? = null,

var timeline: Timeline? = null,

@Column
var fullname: String? = null,

@Column
var imageId: Int = 0,

@Column
var imagePresent: Boolean = false,

@Column
var externalId: String? = null
) : MifosBaseModel(), Parcelable {

/**
* This method is returning the comma separated names of all the client's group
* in the form of a string.
*/
val groupNames: String
get() {
var groupNames = ""
if (groups.isEmpty()) return ""
for (group in groups) {
groupNames += group!!.name + ", "
}
return groupNames.substring(0, groupNames.length - 2)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.mifos.core.data.model.client

import android.os.Parcelable
import com.mifos.core.data.model.database.MifosBaseModel
import com.mifos.core.data.model.database.MifosDatabase
import com.raizlabs.android.dbflow.annotation.Column
import com.raizlabs.android.dbflow.annotation.ModelContainer
import com.raizlabs.android.dbflow.annotation.PrimaryKey
import com.raizlabs.android.dbflow.annotation.Table
import kotlinx.parcelize.Parcelize

/**
* Created by Rajan Maurya on 04/07/16.
*/
@Parcelize
@Table(database = MifosDatabase::class)
@ModelContainer
data class ClientDate(
@PrimaryKey
var clientId: Long = 0,

@PrimaryKey
var chargeId: Long = 0,

@Column
var day: Int = 0,

@Column
var month: Int = 0,

@Column
var year: Int = 0
) : MifosBaseModel(), Parcelable
77 changes: 77 additions & 0 deletions core/data/src/main/java/com/mifos/core/data/model/client/Group.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* This project is licensed under the open source MPL V2.
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data.model.client

import android.os.Parcelable
import com.mifos.core.data.model.database.MifosBaseModel
import com.mifos.core.data.model.database.MifosDatabase
import com.raizlabs.android.dbflow.annotation.Column
import com.raizlabs.android.dbflow.annotation.ForeignKey
import com.raizlabs.android.dbflow.annotation.ModelContainer
import com.raizlabs.android.dbflow.annotation.PrimaryKey
import com.raizlabs.android.dbflow.annotation.Table
import kotlinx.parcelize.Parcelize

/**
* This is the Groups Model Table
* Created by ishankhanna on 28/06/14.
*/
@Parcelize
@Table(database = MifosDatabase::class, useBooleanGetterSetters = false)
@ModelContainer
data class Group(
@PrimaryKey
var id: Int? = null,

@Column
var accountNo: String? = null,

@Column
@Transient
var sync: Boolean = false,

@Column
var name: String? = null,

var status: Status? = null,

@Column
var active: Boolean? = null,

@Column
@ForeignKey(saveForeignKeyModel = true)
@Transient
var groupDate: GroupDate? = null,

var activationDate: List<Int> = ArrayList(),

@Column
var officeId: Int? = null,

@Column
var officeName: String? = null,

@Column
var centerId: Int? = 0,

@Column
var centerName: String? = null,

@Column
var staffId: Int? = null,

@Column
var staffName: String? = null,

@Column
var hierarchy: String? = null,

@Column
var groupLevel: Int = 0,

var timeline: Timeline? = null,

var externalId: String? = null
) : MifosBaseModel(), Parcelable
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.mifos.core.data.model.client

import android.os.Parcelable
import com.mifos.core.data.model.database.MifosBaseModel
import com.mifos.core.data.model.database.MifosDatabase
import com.raizlabs.android.dbflow.annotation.Column
import com.raizlabs.android.dbflow.annotation.ModelContainer
import com.raizlabs.android.dbflow.annotation.PrimaryKey
import com.raizlabs.android.dbflow.annotation.Table
import kotlinx.parcelize.Parcelize

/**
* Created by Rajan Maurya on 18/09/16.
*/
@Parcelize
@Table(database = MifosDatabase::class)
@ModelContainer
data class GroupDate(
@PrimaryKey
var groupId: Long = 0,

@PrimaryKey
var chargeId: Long = 0,

@Column
var day: Int = 0,

@Column
var month: Int = 0,

@Column
var year: Int = 0
) : MifosBaseModel(), Parcelable
41 changes: 41 additions & 0 deletions core/data/src/main/java/com/mifos/core/data/model/client/Status.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* This project is licensed under the open source MPL V2.
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data.model.client

import android.os.Parcelable
import com.mifos.core.data.model.database.MifosBaseModel
import com.mifos.core.data.model.database.MifosDatabase
import com.raizlabs.android.dbflow.annotation.Column
import com.raizlabs.android.dbflow.annotation.PrimaryKey
import com.raizlabs.android.dbflow.annotation.Table
import kotlinx.parcelize.Parcelize

/**
* This Model is the common for Client and Group. So we can use it in both client and group
* database.
* Created by ishankhanna on 09/02/14.
*/
@Parcelize
@Table(database = MifosDatabase::class)
data class Status(
@PrimaryKey
var id: Int = 0,

@Column
var code: String? = null,

@Column
var value: String? = null,
) : MifosBaseModel(), Parcelable {


companion object {
private val STATUS_ACTIVE = "Active"

fun isActive(value: String): Boolean {
return value == STATUS_ACTIVE
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* This project is licensed under the open source MPL V2.
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.data.model.client

import android.os.Parcelable
import com.mifos.core.data.model.database.MifosBaseModel
import kotlinx.parcelize.Parcelize

/**
* Created by ishankhanna on 09/02/14.
*/
@Parcelize
class Timeline(
var submittedOnDate: MutableList<Int> = ArrayList(),

var submittedByUsername: String? = null,

var submittedByFirstname: String? = null,

var submittedByLastname: String? = null,

var activatedOnDate: MutableList<Int> = ArrayList(),

var activatedByUsername: String? = null,

var activatedByFirstname: String? = null,

var activatedByLastname: String? = null,

var closedOnDate: MutableList<Int> = ArrayList(),

var closedByUsername: String? = null,

var closedByFirstname: String? = null,

var closedByLastname: String? = null
) : MifosBaseModel(), Parcelable
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mifos.core.data.model.database

import com.google.gson.Gson
import com.raizlabs.android.dbflow.structure.BaseModel

/**
* Created by Rajan Maurya on 23/06/16.
*/
open class MifosBaseModel : BaseModel() {
override fun toString(): String {
return Gson().toJson(this)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.mifos.core.data.model.database

import com.raizlabs.android.dbflow.annotation.Database

/**
* Created by Rajan Maurya on 23/06/16.
*/
@Database(name = MifosDatabase.NAME, version = MifosDatabase.VERSION, foreignKeysSupported = true)
object MifosDatabase {
// database name will be Mifos.db
const val NAME = "Mifos"

//Always Increase the Version Number
const val VERSION = 2
}
Loading

0 comments on commit cec92e8

Please sign in to comment.