-
Notifications
You must be signed in to change notification settings - Fork 720
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor aboutus viewmodel to create repository
- Loading branch information
1 parent
212a23c
commit a4760c2
Showing
6 changed files
with
81 additions
and
40 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
10 changes: 10 additions & 0 deletions
10
app/src/main/java/org/mifos/mobile/repositories/AboutUsRepository.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,10 @@ | ||
package org.mifos.mobile.repositories | ||
|
||
import org.mifos.mobile.models.AboutUsItem | ||
|
||
|
||
interface AboutUsRepository { | ||
fun getAboutUsItems(): List<AboutUsItem> | ||
} | ||
|
||
|
51 changes: 51 additions & 0 deletions
51
app/src/main/java/org/mifos/mobile/repositories/AboutUsRepositoryImpl.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,51 @@ | ||
package org.mifos.mobile.repositories | ||
|
||
import android.content.Context | ||
import org.mifos.mobile.R | ||
import org.mifos.mobile.models.AboutUsItem | ||
import org.mifos.mobile.ui.enums.AboutUsListItemId | ||
import java.util.Calendar | ||
import javax.inject.Inject | ||
|
||
class AboutUsRepositoryImpl @Inject constructor( | ||
private val context: Context | ||
) : AboutUsRepository { | ||
|
||
override fun getAboutUsItems(): List<AboutUsItem> { | ||
val currentYear = Calendar.getInstance().get(Calendar.YEAR) | ||
val copyrightText = context.getString(R.string.copy_right_mifos) | ||
.replace("%1\$s", currentYear.toString()) | ||
|
||
return listOf( | ||
AboutUsItem( | ||
title = context.getString(R.string.app_version_text), | ||
itemId = AboutUsListItemId.APP_VERSION_TEXT | ||
), | ||
AboutUsItem( | ||
title = context.getString(R.string.official_website), | ||
iconUrl = R.drawable.ic_website, | ||
itemId = AboutUsListItemId.OFFICE_WEBSITE | ||
), | ||
AboutUsItem( | ||
title = context.getString(R.string.licenses), | ||
iconUrl = R.drawable.ic_law_icon, | ||
itemId = AboutUsListItemId.LICENSES | ||
), | ||
AboutUsItem( | ||
title = context.getString(R.string.privacy_policy), | ||
iconUrl = R.drawable.ic_privacy_policy, | ||
itemId = AboutUsListItemId.PRIVACY_POLICY | ||
), | ||
AboutUsItem( | ||
title = context.getString(R.string.sources), | ||
iconUrl = R.drawable.ic_source_code, | ||
itemId = AboutUsListItemId.SOURCE_CODE | ||
), | ||
AboutUsItem( | ||
title = copyrightText, | ||
subtitle = R.string.license_string_with_value, | ||
itemId = AboutUsListItemId.LICENSES_STRING_WITH_VALUE | ||
) | ||
) | ||
} | ||
} |
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