-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor #1460: migrate notfication from java to kotlin
- Loading branch information
1 parent
f173b77
commit 6007ce7
Showing
8 changed files
with
238 additions
and
271 deletions.
There are no files selected for viewing
26 changes: 0 additions & 26 deletions
26
...spay/src/main/java/org/mifos/mobilewallet/mifospay/notification/NotificationContract.java
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
mifospay/src/main/java/org/mifos/mobilewallet/mifospay/notification/NotificationContract.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,19 @@ | ||
package org.mifos.mobilewallet.mifospay.notification | ||
|
||
import org.mifos.mobilewallet.core.domain.model.NotificationPayload | ||
import org.mifos.mobilewallet.mifospay.base.BasePresenter | ||
import org.mifos.mobilewallet.mifospay.base.BaseView | ||
|
||
/** | ||
* Created by ankur on 24/July/2018 | ||
*/ | ||
interface NotificationContract { | ||
interface NotificationPresenter : BasePresenter { | ||
fun fetchNotifications() | ||
} | ||
|
||
interface NotificationView : BaseView<NotificationPresenter?> { | ||
fun fetchNotificationsSuccess(notificationPayloadList: List<NotificationPayload?>?) | ||
fun fetchNotificationsError(message: String?) | ||
} | ||
} |
53 changes: 0 additions & 53 deletions
53
...in/java/org/mifos/mobilewallet/mifospay/notification/presenter/NotificationPresenter.java
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
...main/java/org/mifos/mobilewallet/mifospay/notification/presenter/NotificationPresenter.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.notification.presenter | ||
|
||
import org.mifos.mobilewallet.core.base.UseCase.UseCaseCallback | ||
import org.mifos.mobilewallet.core.base.UseCaseHandler | ||
import org.mifos.mobilewallet.core.domain.usecase.notification.FetchNotifications | ||
import org.mifos.mobilewallet.mifospay.base.BaseView | ||
import org.mifos.mobilewallet.mifospay.data.local.LocalRepository | ||
import org.mifos.mobilewallet.mifospay.notification.NotificationContract | ||
import org.mifos.mobilewallet.mifospay.notification.NotificationContract.NotificationView | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Created by ankur on 24/July/2018 | ||
*/ | ||
class NotificationPresenter @Inject constructor( | ||
private val mUseCaseHandler: UseCaseHandler, | ||
private val mLocalRepository: LocalRepository | ||
) : NotificationContract.NotificationPresenter { | ||
var mNotificationView: NotificationView? = null | ||
|
||
@JvmField | ||
@Inject | ||
var fetchNotificationsUseCase: FetchNotifications? = null | ||
override fun attachView(baseView: BaseView<*>?) { | ||
mNotificationView = baseView as NotificationView? | ||
mNotificationView?.setPresenter(this) | ||
} | ||
|
||
override fun fetchNotifications() { | ||
mUseCaseHandler.execute(fetchNotificationsUseCase, | ||
FetchNotifications.RequestValues( | ||
mLocalRepository.clientDetails.clientId | ||
), | ||
object : UseCaseCallback<FetchNotifications.ResponseValue?> { | ||
override fun onSuccess(response: FetchNotifications.ResponseValue?) { | ||
mNotificationView?.fetchNotificationsSuccess( | ||
response?.notificationPayloadList | ||
) | ||
} | ||
|
||
override fun onError(message: String) { | ||
mNotificationView?.fetchNotificationsError(message) | ||
} | ||
}) | ||
} | ||
} |
114 changes: 0 additions & 114 deletions
114
...y/src/main/java/org/mifos/mobilewallet/mifospay/notification/ui/NotificationActivity.java
This file was deleted.
Oops, something went wrong.
102 changes: 102 additions & 0 deletions
102
...pay/src/main/java/org/mifos/mobilewallet/mifospay/notification/ui/NotificationActivity.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,102 @@ | ||
package org.mifos.mobilewallet.mifospay.notification.ui | ||
|
||
import android.os.Bundle | ||
import android.view.View | ||
import android.widget.TextView | ||
import androidx.recyclerview.widget.DividerItemDecoration | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import butterknife.BindView | ||
import butterknife.ButterKnife | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import org.mifos.mobilewallet.core.domain.model.NotificationPayload | ||
import org.mifos.mobilewallet.mifospay.R | ||
import org.mifos.mobilewallet.mifospay.base.BaseActivity | ||
import org.mifos.mobilewallet.mifospay.notification.NotificationContract | ||
import org.mifos.mobilewallet.mifospay.notification.NotificationContract.NotificationView | ||
import org.mifos.mobilewallet.mifospay.notification.presenter.NotificationPresenter | ||
import org.mifos.mobilewallet.mifospay.utils.Constants | ||
import org.mifos.mobilewallet.mifospay.utils.DebugUtil | ||
import org.mifos.mobilewallet.mifospay.utils.Toaster | ||
import javax.inject.Inject | ||
|
||
/** | ||
* This activity is to view notifications record. | ||
* Notifications Datatable is populated automatically by server when an event happens. | ||
* This feature is yet to be implemented on the server side. | ||
*/ | ||
@AndroidEntryPoint | ||
class NotificationActivity : BaseActivity(), NotificationView { | ||
@JvmField | ||
@Inject | ||
var mPresenter: NotificationPresenter? = null | ||
var mNotificationPresenter: NotificationContract.NotificationPresenter? = null | ||
|
||
@JvmField | ||
@BindView(R.id.rv_notification) | ||
var mRvNotification: RecyclerView? = null | ||
|
||
@JvmField | ||
@BindView(R.id.tv_placeholder) | ||
var tvplaceholder: TextView? = null | ||
|
||
@JvmField | ||
@Inject | ||
var mNotificationAdapter: NotificationAdapter? = null | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_notification) | ||
ButterKnife.bind(this) | ||
setToolbarTitle("Notifications") | ||
showColoredBackButton(Constants.BLACK_BACK_BUTTON) | ||
setupRecyclerView() | ||
setupSwipeRefreshLayout() | ||
mPresenter?.attachView(this) | ||
showSwipeProgress() | ||
mNotificationPresenter?.fetchNotifications() | ||
} | ||
|
||
private fun setupRecyclerView() { | ||
mRvNotification?.layoutManager = LinearLayoutManager(this) | ||
mRvNotification?.adapter = mNotificationAdapter | ||
mRvNotification?.addItemDecoration( | ||
DividerItemDecoration( | ||
this, | ||
DividerItemDecoration.VERTICAL | ||
) | ||
) | ||
} | ||
|
||
private fun setupSwipeRefreshLayout() { | ||
setSwipeRefreshEnabled(true) | ||
swipeLayout.setOnRefreshListener { mNotificationPresenter?.fetchNotifications() } | ||
} | ||
|
||
override fun fetchNotificationsSuccess(notificationPayloadList: List<NotificationPayload?>?) { | ||
hideSwipeProgress() | ||
if (notificationPayloadList.isNullOrEmpty()) { | ||
DebugUtil.log("null") | ||
mRvNotification?.visibility = View.GONE | ||
tvplaceholder?.visibility = View.VISIBLE | ||
} else { | ||
DebugUtil.log("yes") | ||
mRvNotification?.visibility = View.VISIBLE | ||
tvplaceholder?.visibility = View.GONE | ||
mNotificationAdapter?.setNotificationPayloadList(notificationPayloadList as List<NotificationPayload>) | ||
} | ||
mNotificationAdapter?.setNotificationPayloadList(notificationPayloadList as List<NotificationPayload>) | ||
} | ||
|
||
override fun fetchNotificationsError(message: String?) { | ||
hideSwipeProgress() | ||
showToast(message) | ||
} | ||
|
||
override fun setPresenter(presenter: NotificationContract.NotificationPresenter?) { | ||
mNotificationPresenter = presenter | ||
} | ||
|
||
fun showToast(message: String?) { | ||
Toaster.showToast(this, message) | ||
} | ||
} |
Oops, something went wrong.