-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor #1458: migrated invoice from java to kotlin
- Loading branch information
1 parent
f34cb50
commit ef1abdb
Showing
12 changed files
with
571 additions
and
652 deletions.
There are no files selected for viewing
50 changes: 0 additions & 50 deletions
50
mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/InvoiceContract.java
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/InvoiceContract.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.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? | ||
} | ||
} |
57 changes: 0 additions & 57 deletions
57
...pay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/presenter/InvoicePresenter.java
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
mifospay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/presenter/InvoicePresenter.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,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) | ||
} | ||
}) | ||
} | ||
} |
66 changes: 0 additions & 66 deletions
66
...ay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/presenter/InvoicesPresenter.java
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
...spay/src/main/java/org/mifos/mobilewallet/mifospay/invoice/presenter/InvoicesPresenter.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,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 | ||
) | ||
} | ||
} |
Oops, something went wrong.