This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Adds support for creating, viewing, editing group details, deleting, editing members and leaders name and tasks of group
- Loading branch information
1 parent
5610a15
commit 592099e
Showing
58 changed files
with
3,618 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.apache.fineract.data | ||
|
||
/** | ||
* Created by Ahmad Jawid Muhammadi on 6/4/20 | ||
*/ | ||
enum class Status { | ||
LOADING, | ||
ERROR, | ||
DONE | ||
} |
45 changes: 45 additions & 0 deletions
45
app/src/main/java/org/apache/fineract/data/datamanager/api/DataManagerGroups.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.apache.fineract.data.datamanager.api | ||
|
||
import androidx.lifecycle.MutableLiveData | ||
import io.reactivex.Observable | ||
import io.reactivex.ObservableSource | ||
import io.reactivex.functions.Function | ||
import kotlinx.coroutines.Deferred | ||
import okhttp3.ResponseBody | ||
import org.apache.fineract.FakeRemoteDataSource | ||
import org.apache.fineract.data.local.PreferencesHelper | ||
import org.apache.fineract.data.models.Group | ||
import org.apache.fineract.data.models.customer.Command | ||
import org.apache.fineract.data.remote.BaseApiManager | ||
import javax.inject.Inject | ||
|
||
|
||
/* | ||
* Created by saksham on 15/June/2019 | ||
*/ | ||
|
||
class DataManagerGroups @Inject constructor(private val baseManagerApi: BaseApiManager, | ||
val dataManagerAuth: DataManagerAuth, | ||
val preferencesHelper: PreferencesHelper) | ||
: FineractBaseDataManager(dataManagerAuth, preferencesHelper) { | ||
|
||
fun getGroups(): MutableLiveData<ArrayList<Group>> { | ||
val groups = MutableLiveData<ArrayList<Group>>() | ||
|
||
groups.value = ArrayList(baseManagerApi.groupsService.getGroups() | ||
.onErrorResumeNext(Function<Throwable, ObservableSource<List<Group>>> { | ||
Observable.just(FakeRemoteDataSource.getGroups()) | ||
}).blockingFirst()) | ||
return groups | ||
} | ||
|
||
fun createGroup(group: Group): Deferred<ResponseBody> = baseManagerApi.groupsService.createGroup(group) | ||
|
||
fun updateGroup(identifier: String, group: Group): Deferred<ResponseBody> { | ||
return baseManagerApi.groupsService.updateGroup(identifier, group) | ||
} | ||
|
||
fun changeGroupStatus(identifier: String, command: Command): Deferred<ResponseBody> { | ||
return baseManagerApi.groupsService.changeGroupStatus(identifier, command) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/org/apache/fineract/data/models/Group.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.apache.fineract.data.models | ||
|
||
import android.os.Parcelable | ||
import kotlinx.android.parcel.Parcelize | ||
import org.apache.fineract.data.models.customer.Address | ||
|
||
/* | ||
* Created by saksham on 16/June/2019 | ||
*/ | ||
|
||
@Parcelize | ||
data class Group( | ||
var identifier: String? = null, | ||
var groupDefinitionIdentifier: String? = null, | ||
var name: String? = null, | ||
var leaders: List<String>? = null, | ||
var members: List<String>? = null, | ||
var office: String? = null, | ||
var assignedEmployee: String? = null, | ||
var weekday: Int? = null, | ||
var status: Status? = null, | ||
var address: Address? = null, | ||
var createdOn: String? = null, | ||
var createdBy: String? = null, | ||
var lastModifiedBy: String? = null, | ||
var lastModifiedOn: String? = null) : Parcelable { | ||
|
||
enum class Status { | ||
PENDING, | ||
ACTIVE, | ||
CLOSED | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/src/main/java/org/apache/fineract/data/services/GroupsService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.apache.fineract.data.services | ||
|
||
import io.reactivex.Observable | ||
import kotlinx.coroutines.Deferred | ||
import okhttp3.ResponseBody | ||
import org.apache.fineract.data.models.Group | ||
import org.apache.fineract.data.models.customer.Command | ||
import retrofit2.http.* | ||
|
||
/* | ||
* Created by saksham on 15/June/2019 | ||
*/ | ||
|
||
interface GroupsService { | ||
|
||
@GET("/groups") | ||
fun getGroups(): Observable<List<Group>> | ||
|
||
@POST("/groups") | ||
fun createGroup(@Body group: Group): Deferred<ResponseBody> | ||
|
||
@PUT("/groups/{identifier}") | ||
fun updateGroup(@Path("identifier") identifier: String, | ||
@Body group: Group): Deferred<ResponseBody> | ||
|
||
@PUT("/groups/{identifier}/commands") | ||
fun changeGroupStatus(@Path("identifier") identifier: String, | ||
@Body command: Command): Deferred<ResponseBody> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
app/src/main/java/org/apache/fineract/ui/adapters/GroupsAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package org.apache.fineract.ui.adapters | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import android.widget.LinearLayout | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.RecyclerView | ||
import kotlinx.android.synthetic.main.item_group.view.* | ||
import org.apache.fineract.R | ||
import org.apache.fineract.data.models.Group | ||
import org.apache.fineract.injection.ApplicationContext | ||
import org.apache.fineract.ui.base.OnItemClickListener | ||
import org.apache.fineract.utils.DateUtils | ||
import org.apache.fineract.utils.StatusUtils | ||
import javax.inject.Inject | ||
|
||
|
||
/* | ||
* Created by saksham on 16/June/2019 | ||
*/ | ||
|
||
class GroupsAdapter @Inject constructor(@ApplicationContext var context: Context?) | ||
: RecyclerView.Adapter<GroupsAdapter.ViewHolder>() { | ||
|
||
var groups = ArrayList<Group>() | ||
lateinit var onItemClickListener: OnItemClickListener | ||
|
||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | ||
return ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_group, parent, false)) | ||
} | ||
|
||
override fun getItemCount(): Int = groups.size | ||
|
||
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | ||
var group: Group = groups[position] | ||
|
||
StatusUtils.setGroupsStatusIcon(group.status, holder.ivTypeIndicator, context) | ||
|
||
holder.tvGroupIdentifier.text = group.identifier | ||
|
||
val modifiedBy = context?.getString(R.string.last_modified_by) + context?.getString(R.string.colon) + group.lastModifiedBy | ||
holder.tvLastModifiedBy.text = modifiedBy | ||
|
||
val lastModifiedOn = context?.getString(R.string.last_modified_on) + context?.getString(R.string.colon) + DateUtils.getDate(group.lastModifiedOn, | ||
DateUtils.INPUT_DATE_FORMAT, DateUtils.OUTPUT_DATE_FORMAT) | ||
holder.tvLastModifiedOn.text = lastModifiedOn | ||
} | ||
|
||
fun setGroupList(groups: ArrayList<Group>) { | ||
this.groups = groups | ||
notifyDataSetChanged() | ||
} | ||
|
||
fun setItemClickListener(onItemClickListener: OnItemClickListener) { | ||
this.onItemClickListener = onItemClickListener | ||
} | ||
|
||
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), | ||
View.OnClickListener { | ||
var llGroups: LinearLayout = itemView.ll_group | ||
var ivTypeIndicator: ImageView = itemView.iv_type_indicator | ||
var tvGroupIdentifier: TextView = itemView.tv_group_identifier | ||
var tvLastModifiedBy: TextView = itemView.tv_last_modified_by | ||
var tvLastModifiedOn: TextView = itemView.tv_last_modified_on | ||
|
||
init { | ||
llGroups.setOnClickListener(this) | ||
} | ||
|
||
override fun onClick(v: View?) { | ||
if (onItemClickListener != null) { | ||
onItemClickListener.onItemClick(v, adapterPosition) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.