Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
:View Ledger feature added
Browse files Browse the repository at this point in the history
  • Loading branch information
miPlodder committed Aug 24, 2019
1 parent cafd55a commit 7e17847
Show file tree
Hide file tree
Showing 11 changed files with 380 additions and 18 deletions.
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@

<activity android:name=".ui.online.accounting.accounts.accountdetails.AccountDetailActivity" />

<activity android:name=".ui.online.accounting.ledgers.ledgerdetails.LedgerDetailActivity" />

<receiver
android:name=".jobs.JobsReceiver"
android:exported="false">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlinx.android.synthetic.main.item_ledger.view.*
import org.apache.fineract.R
import org.apache.fineract.data.models.accounts.Ledger
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
Expand All @@ -19,6 +20,7 @@ class LedgerAdapter @Inject constructor(@ApplicationContext val context: Context
: RecyclerView.Adapter<LedgerAdapter.ViewHolder>() {

private var ledgers: List<Ledger> = ArrayList()
private lateinit var onItemClickListener: OnItemClickListener

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {

Expand Down Expand Up @@ -54,12 +56,26 @@ class LedgerAdapter @Inject constructor(@ApplicationContext val context: Context
notifyDataSetChanged()
}

class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun setItemClickListener(onItemClickListener: OnItemClickListener) {
this.onItemClickListener = onItemClickListener
}

inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener {

val tvLedgerIdentifier: TextView = itemView.tv_ledger_identifier
val tvModifiedBy: TextView = itemView.tv_modified_by
val tvModifiedOn: TextView = itemView.tv_modified_on
val tvTotalValue: TextView = itemView.tv_total_value
val ivAccountTypeIndicator: AppCompatImageView = itemView.iv_type_indicator

init {
itemView.ll_ledger.setOnClickListener(this)
}

override fun onClick(v: View?) {
if (onItemClickListener != null) {
onItemClickListener.onItemClick(v, adapterPosition)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AccountDetailActivity : FineractBaseActivity() {
populateUserInterface()
}

fun populateUserInterface() {
private fun populateUserInterface() {
tvType.text = account.type.toString()
tvIdentifier.text = account.identifier
tvName.text = account.name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.apache.fineract.ui.online.accounting.ledgers.ledgerdetails

import android.os.Bundle
import android.widget.Toast
import kotlinx.android.synthetic.main.activity_ledger_detail.*
import org.apache.fineract.R
import org.apache.fineract.data.models.accounts.Ledger
import org.apache.fineract.ui.base.FineractBaseActivity
import org.apache.fineract.utils.ConstantKeys

class LedgerDetailActivity : FineractBaseActivity() {

lateinit var ledger: Ledger

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_ledger_detail)

ledger = intent.getParcelableExtra(ConstantKeys.LEDGER)
setToolbarTitle(getString(R.string.ledger_details))
showBackButton()
populateUserInterface()
}

private fun populateUserInterface() {
tvType.text = ledger.type.toString()
tvIdentifier.text = ledger.identifier
tvName.text = ledger.name
tvParentLedgerIdentifier.text = ledger.parentLedgerIdentifier
tvDescription.text = ledger.description
tvTotalValue.text = "$ ${ledger.totalValue}"
tvSubLedger.text = "\n"
if (ledger.subLedgers!!.size > 0) {
var ledgerIterator = ledger.subLedgers?.iterator()
while (ledgerIterator!!.hasNext())
tvSubLedger.append("${ledgerIterator.next()}\n")
} else {
tvSubLedger.text = getString(R.string.no_sub_ledger_available)
}
tvShowAccountInChart.text = ledger.showAccountsInChart.toString()
tvCreateOn.text = ledger.createdOn
tvCreatedBy.text = ledger.createdBy
tvLastModifiedOn.text = ledger.lastModifiedOn
tvLastModifiedBy.text = ledger.lastModifiedBy
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package org.apache.fineract.ui.online.accounting.ledgers

import android.app.SearchManager
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.appcompat.widget.SearchView
import android.text.TextUtils
import android.view.*
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.fragment_ledger.*
import kotlinx.android.synthetic.main.layout_exception_handler.*
Expand All @@ -17,13 +19,16 @@ import org.apache.fineract.data.models.accounts.Ledger
import org.apache.fineract.ui.adapters.LedgerAdapter
import org.apache.fineract.ui.base.FineractBaseActivity
import org.apache.fineract.ui.base.FineractBaseFragment
import org.apache.fineract.ui.base.OnItemClickListener
import org.apache.fineract.ui.online.accounting.accounts.LedgerContract
import org.apache.fineract.ui.online.accounting.ledgers.ledgerdetails.LedgerDetailActivity
import org.apache.fineract.utils.ConstantKeys
import javax.inject.Inject
import kotlin.collections.ArrayList


class LedgerFragment : FineractBaseFragment(), LedgerContract.View,
SwipeRefreshLayout.OnRefreshListener {
SwipeRefreshLayout.OnRefreshListener, OnItemClickListener {

@Inject
lateinit var ledgerAdapter: LedgerAdapter
Expand Down Expand Up @@ -75,6 +80,7 @@ class LedgerFragment : FineractBaseFragment(), LedgerContract.View,
rvLedger.setHasFixedSize(true)

rvLedger.adapter = ledgerAdapter
ledgerAdapter.setItemClickListener(this)

swipeContainer.setColorSchemeColors(*activity!!
.resources.getIntArray(R.array.swipeRefreshColors))
Expand Down Expand Up @@ -161,6 +167,16 @@ class LedgerFragment : FineractBaseFragment(), LedgerContract.View,
showFineractErrorUI(getString(R.string.ledger))
}

override fun onItemClick(childView: View?, position: Int) {
var intent = Intent(context, LedgerDetailActivity::class.java)
intent.putExtra(ConstantKeys.LEDGER, ledgerList[position])
startActivity(intent)
}

override fun onItemLongPress(childView: View?, position: Int) {

}

override fun onDestroyView() {
super.onDestroyView()
ledgerPresenter.detachView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ public class ConstantKeys {
public static final String PERMISSIONS_READ_EXTERNAL_STORAGE_STATUS = "read_status";

public static final String ACCOUNT = "account";
public static final String LEDGER = "ledger";
}
15 changes: 0 additions & 15 deletions app/src/main/res/layout/activity_account_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@
android:layout_marginStart="@dimen/start_margin"
android:textStyle="bold" />

<!--<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/grey_500" />-->

</LinearLayout>

</androidx.cardview.widget.CardView>
Expand Down Expand Up @@ -199,11 +194,6 @@
android:layout_marginStart="@dimen/start_margin"
android:textStyle="bold" />

<!--<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/grey_500" />-->

</LinearLayout>
</androidx.cardview.widget.CardView>

Expand Down Expand Up @@ -348,11 +338,6 @@
android:layout_marginStart="@dimen/start_margin"
android:textStyle="bold" />

<!--<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@color/grey_500" />-->

</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
Expand Down
Loading

0 comments on commit 7e17847

Please sign in to comment.