Skip to content

Commit

Permalink
refactor #1458: migrated invoice from java to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
PratyushSingh07 committed Jan 8, 2024
1 parent f34cb50 commit ef1abdb
Show file tree
Hide file tree
Showing 12 changed files with 571 additions and 652 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.mifos.mobilewallet.mifospay.invoice

import android.net.Uri
import org.mifos.mobilewallet.core.data.fineract.entity.Invoice
import org.mifos.mobilewallet.mifospay.base.BasePresenter
import org.mifos.mobilewallet.mifospay.base.BaseView

/**
* Created by ankur on 07/June/2018
*/
interface InvoiceContract {
interface InvoiceView : BaseView<InvoicePresenter?> {
fun showInvoiceDetails(invoice: Invoice?, merchantId: String?, paymentLink: String?)
fun showSnackbar(message: String?)
fun showToast(message: String?)
}

interface InvoicePresenter : BasePresenter {
fun getInvoiceDetails(data: Uri?)
}

interface InvoicesView : BaseView<InvoicesPresenter?> {
fun showSnackbar(message: String?)
fun showInvoices(invoiceList: List<Invoice?>?)
fun showErrorStateView(drawable: Int, title: Int, subtitle: Int)
fun showFetchingProcess()
}

interface InvoicesPresenter : BasePresenter {
fun fetchInvoices()
fun getUniqueInvoiceLink(id: Long): Uri?
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.mifos.mobilewallet.mifospay.invoice.presenter

import android.net.Uri
import org.mifos.mobilewallet.core.base.UseCase.UseCaseCallback
import org.mifos.mobilewallet.core.base.UseCaseHandler
import org.mifos.mobilewallet.core.domain.usecase.invoice.FetchInvoice
import org.mifos.mobilewallet.mifospay.base.BaseView
import org.mifos.mobilewallet.mifospay.data.local.PreferencesHelper
import org.mifos.mobilewallet.mifospay.invoice.InvoiceContract
import org.mifos.mobilewallet.mifospay.invoice.InvoiceContract.InvoiceView
import javax.inject.Inject

/**
* Created by ankur on 07/June/2018
*/
class InvoicePresenter @Inject constructor(
private val mUseCaseHandler: UseCaseHandler,
private val mPreferencesHelper: PreferencesHelper
) : InvoiceContract.InvoicePresenter {
var mInvoiceView: InvoiceView? = null

@JvmField
@Inject
var fetchInvoiceUseCase: FetchInvoice? = null
override fun attachView(baseView: BaseView<*>?) {
mInvoiceView = baseView as InvoiceView?
mInvoiceView!!.setPresenter(this)
}

override fun getInvoiceDetails(data: Uri?) {
mUseCaseHandler.execute(fetchInvoiceUseCase, FetchInvoice.RequestValues(data),
object : UseCaseCallback<FetchInvoice.ResponseValue?> {
override fun onSuccess(response: FetchInvoice.ResponseValue?) {
mInvoiceView!!.showInvoiceDetails(
response?.invoices?.get(0),
mPreferencesHelper.fullName + " "
+ mPreferencesHelper.clientId, data.toString()
)
}

override fun onError(message: String) {
mInvoiceView!!.showToast(message)
}
})
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.mifos.mobilewallet.mifospay.invoice.presenter

import android.net.Uri
import org.mifos.mobilewallet.core.base.UseCase.UseCaseCallback
import org.mifos.mobilewallet.core.base.UseCaseHandler
import org.mifos.mobilewallet.core.domain.usecase.invoice.FetchInvoices
import org.mifos.mobilewallet.mifospay.R
import org.mifos.mobilewallet.mifospay.base.BaseView
import org.mifos.mobilewallet.mifospay.data.local.PreferencesHelper
import org.mifos.mobilewallet.mifospay.invoice.InvoiceContract
import org.mifos.mobilewallet.mifospay.invoice.InvoiceContract.InvoicesView
import org.mifos.mobilewallet.mifospay.utils.Constants
import javax.inject.Inject

/**
* Created by ankur on 11/June/2018
*/
class InvoicesPresenter @Inject constructor(
private val mUseCaseHandler: UseCaseHandler,
private val mPreferencesHelper: PreferencesHelper
) : InvoiceContract.InvoicesPresenter {
@JvmField
@Inject
var fetchInvoicesUseCase: FetchInvoices? = null
private var mInvoicesView: InvoicesView? = null
override fun attachView(baseView: BaseView<*>?) {
mInvoicesView = baseView as InvoicesView?
mInvoicesView!!.setPresenter(this)
}

override fun fetchInvoices() {
mInvoicesView!!.showFetchingProcess()
mUseCaseHandler.execute(fetchInvoicesUseCase,
FetchInvoices.RequestValues(mPreferencesHelper.clientId.toString() + ""),
object : UseCaseCallback<FetchInvoices.ResponseValue?> {
override fun onSuccess(response: FetchInvoices.ResponseValue?) {
mInvoicesView!!.showInvoices(response?.invoiceList)
}

override fun onError(message: String) {
mInvoicesView!!.showErrorStateView(
R.drawable.ic_error_state,
R.string.error_oops,
R.string.error_no_invoices_found
)
}
})
}

override fun getUniqueInvoiceLink(id: Long): Uri? {
return Uri.parse(
Constants.INVOICE_DOMAIN + mPreferencesHelper.clientId + "/" + id
)
}
}
Loading

0 comments on commit ef1abdb

Please sign in to comment.