mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-17 19:29:02 +00:00
update detekt and fix some code smell 👃
This commit is contained in:
parent
7b50d4c3b4
commit
e3ccaa50cd
39 changed files with 216 additions and 259 deletions
|
|
@ -150,7 +150,7 @@ android {
|
|||
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
|
||||
|
||||
versionCode 2255
|
||||
versionName "2.1.1"
|
||||
versionName "2.2pl"
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
|
|
|
|||
|
|
@ -4,11 +4,9 @@ import android.text.Editable
|
|||
import android.text.TextWatcher
|
||||
|
||||
class OnChangeTextWatcher(private var function: (CharSequence?, Int, Int, Int) -> Unit) : TextWatcher {
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
}
|
||||
override fun afterTextChanged(s: Editable?) { /* no-on */ }
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
}
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { /* no-on */ }
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
function(s, start, before, count)
|
||||
|
|
@ -16,15 +14,13 @@ class OnChangeTextWatcher(private var function: (CharSequence?, Int, Int, Int) -
|
|||
}
|
||||
|
||||
class BeforeChangeTextWatcher(private var function: (CharSequence?, Int, Int, Int) -> Unit) : TextWatcher {
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
}
|
||||
override fun afterTextChanged(s: Editable?) { /* no-on */ }
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
function(s, start, count, after)
|
||||
}
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
}
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { /* no-on */ }
|
||||
}
|
||||
|
||||
class AfterChangeTextWatcher(private var function: (Editable?) -> Unit) : TextWatcher {
|
||||
|
|
@ -32,9 +28,7 @@ class AfterChangeTextWatcher(private var function: (Editable?) -> Unit) : TextWa
|
|||
function(s)
|
||||
}
|
||||
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
|
||||
}
|
||||
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { /* no-on */ }
|
||||
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
}
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { /* no-on */ }
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ class PurchaseHandler(activity: Activity, val crashlyticsProxy: CrashlyticsProxy
|
|||
whenCheckoutReady?.invoke()
|
||||
}
|
||||
|
||||
override fun onReady(requests: BillingRequests, product: String, billingSupported: Boolean) {}
|
||||
override fun onReady(requests: BillingRequests, product: String, billingSupported: Boolean) { /* no-op */ }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -53,10 +53,6 @@ class PurchaseHandler(activity: Activity, val crashlyticsProxy: CrashlyticsProxy
|
|||
getSKUs(ProductTypes.IN_APP, PurchaseTypes.allGemTypes, onSuccess)
|
||||
}
|
||||
|
||||
fun getAllSubscriptionSKUs(onSuccess: ((List<Sku>) -> Unit)) {
|
||||
getSKUs(ProductTypes.SUBSCRIPTION, PurchaseTypes.allSubscriptionTypes, onSuccess)
|
||||
}
|
||||
|
||||
fun getAllSubscriptionProducts(onSuccess: ((Inventory.Product) -> Unit)) {
|
||||
getProduct(ProductTypes.SUBSCRIPTION, PurchaseTypes.allSubscriptionTypes, onSuccess)
|
||||
}
|
||||
|
|
@ -69,10 +65,6 @@ class PurchaseHandler(activity: Activity, val crashlyticsProxy: CrashlyticsProxy
|
|||
getSKU(ProductTypes.IN_APP, identifier, onSuccess)
|
||||
}
|
||||
|
||||
fun getSubscriptionSKU(identifier: String, onSuccess: ((Sku) -> Unit)) {
|
||||
getSKU(ProductTypes.SUBSCRIPTION, identifier, onSuccess)
|
||||
}
|
||||
|
||||
|
||||
private fun getSKUs(type: String, identifiers: List<String>, onSuccess: ((List<Sku>) -> Unit)) {
|
||||
getProduct(type, identifiers) {
|
||||
|
|
@ -110,7 +102,7 @@ class PurchaseHandler(activity: Activity, val crashlyticsProxy: CrashlyticsProxy
|
|||
}
|
||||
}
|
||||
|
||||
override fun onError(i: Int, e: Exception) {}
|
||||
override fun onError(i: Int, e: Exception) { crashlyticsProxy.fabricLogE("Purchase", "Consume", e) }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -145,8 +137,7 @@ class PurchaseHandler(activity: Activity, val crashlyticsProxy: CrashlyticsProxy
|
|||
billingRequests?.purchase(ProductTypes.IN_APP, identifier, null, it.createOneShotPurchaseFlow(object : RequestListener<Purchase> {
|
||||
override fun onSuccess(result: Purchase) {
|
||||
billingRequests?.consume(result.token, object : RequestListener<Any> {
|
||||
override fun onSuccess(o: Any) {
|
||||
}
|
||||
override fun onSuccess(o: Any) { /* no-op */ }
|
||||
|
||||
override fun onError(i: Int, e: Exception) {
|
||||
crashlyticsProxy.fabricLogE("PurchaseConsumeException", "Consume", e)
|
||||
|
|
@ -166,8 +157,7 @@ class PurchaseHandler(activity: Activity, val crashlyticsProxy: CrashlyticsProxy
|
|||
billingRequests?.purchase(ProductTypes.IN_APP, sku.id.code, null, it.createOneShotPurchaseFlow(object : RequestListener<Purchase> {
|
||||
override fun onSuccess(result: Purchase) {
|
||||
billingRequests?.consume(result.token, object : RequestListener<Any> {
|
||||
override fun onSuccess(o: Any) {
|
||||
}
|
||||
override fun onSuccess(o: Any) { /* no-op */ }
|
||||
|
||||
override fun onError(i: Int, e: Exception) {
|
||||
crashlyticsProxy.fabricLogE("PurchaseConsumeException", "Consume", e)
|
||||
|
|
@ -175,9 +165,7 @@ class PurchaseHandler(activity: Activity, val crashlyticsProxy: CrashlyticsProxy
|
|||
})
|
||||
}
|
||||
|
||||
override fun onError(response: Int, e: java.lang.Exception) {
|
||||
|
||||
}
|
||||
override fun onError(response: Int, e: java.lang.Exception) { /* no-op */ }
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
@ -185,7 +173,7 @@ class PurchaseHandler(activity: Activity, val crashlyticsProxy: CrashlyticsProxy
|
|||
fun consumePurchase(purchase: Purchase) {
|
||||
if (PurchaseTypes.allGemTypes.contains(purchase.sku) || PurchaseTypes.allSubscriptionNoRenewTypes.contains(purchase.sku)) {
|
||||
billingRequests?.consume(purchase.token, object : RequestListener<Any> {
|
||||
override fun onSuccess(result: Any) {}
|
||||
override fun onSuccess(result: Any) { /* no-op */ }
|
||||
|
||||
override fun onError(response: Int, e: Exception) {
|
||||
crashlyticsProxy.fabricLogE("PurchaseConsumeException", "Consume", e)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ class PushNotificationManager(var apiClient: ApiClient, private val sharedPrefer
|
|||
this.user = user
|
||||
}
|
||||
|
||||
//@TODO: Use preferences
|
||||
fun addPushDeviceUsingStoredToken() {
|
||||
if (this.refreshedToken.isEmpty()) {
|
||||
this.refreshedToken = FirebaseInstanceId.getInstance().token ?: ""
|
||||
|
|
@ -55,16 +54,12 @@ class PushNotificationManager(var apiClient: ApiClient, private val sharedPrefer
|
|||
}
|
||||
|
||||
private fun userHasPushDevice(): Boolean {
|
||||
if (this.user?.pushDevices == null) {
|
||||
return true
|
||||
}
|
||||
|
||||
for (pushDevice in this.user?.pushDevices ?: emptyList()) {
|
||||
if (pushDevice.regId == this.refreshedToken) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return this.user?.pushDevices == null
|
||||
}
|
||||
|
||||
fun displayNotification(remoteMessage: RemoteMessage) {
|
||||
|
|
@ -89,8 +84,6 @@ class PushNotificationManager(var apiClient: ApiClient, private val sharedPrefer
|
|||
private fun userIsSubscribedToNotificationType(type: String?): Boolean {
|
||||
var key = ""
|
||||
|
||||
//@TODO: If user has push turned off to send
|
||||
|
||||
if (type == null) {
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,4 +28,8 @@ open class Tag : RealmObject() {
|
|||
}
|
||||
return super.equals(o)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return id.hashCode()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,6 @@ open class Task : RealmObject, Parcelable {
|
|||
//todos
|
||||
@SerializedName("date")
|
||||
var dueDate: Date? = null
|
||||
//TODO: private String lastCompleted;
|
||||
// used for buyable items
|
||||
var specialTag: String? = ""
|
||||
@Ignore
|
||||
|
|
@ -175,29 +174,21 @@ open class Task : RealmObject, Parcelable {
|
|||
}
|
||||
|
||||
val nextDate = nextDue?.firstOrNull()
|
||||
if (nextDate != null && !isDisplayedActive) {
|
||||
return if (nextDate != null && !isDisplayedActive) {
|
||||
val nextDueCalendar = GregorianCalendar()
|
||||
nextDueCalendar.time = nextDate
|
||||
newTime.set(nextDueCalendar.get(Calendar.YEAR), nextDueCalendar.get(Calendar.MONTH), nextDueCalendar.get(Calendar.DAY_OF_MONTH))
|
||||
return newTime.time
|
||||
newTime.time
|
||||
} else if (isDisplayedActive) {
|
||||
newTime.time
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
return if (isDisplayedActive) newTime.time else null
|
||||
}
|
||||
|
||||
fun parseMarkdown() {
|
||||
try {
|
||||
this.parsedText = MarkdownParser.parseMarkdown(this.text)
|
||||
} catch (e: NullPointerException) {
|
||||
this.parsedText = this.text
|
||||
}
|
||||
|
||||
try {
|
||||
this.parsedNotes = MarkdownParser.parseMarkdown(this.notes)
|
||||
} catch (e: NullPointerException) {
|
||||
this.parsedNotes = this.notes
|
||||
}
|
||||
|
||||
parsedText = MarkdownParser.parseMarkdown(text)
|
||||
parsedNotes = MarkdownParser.parseMarkdown(notes)
|
||||
}
|
||||
|
||||
fun markdownText(callback: (CharSequence) -> Unit): CharSequence {
|
||||
|
|
@ -214,20 +205,17 @@ open class Task : RealmObject, Parcelable {
|
|||
}
|
||||
|
||||
fun markdownNotes(callback: (CharSequence) -> Unit): CharSequence? {
|
||||
if (this.parsedNotes != null) {
|
||||
return this.parsedNotes as CharSequence
|
||||
if (parsedNotes != null) {
|
||||
return parsedNotes
|
||||
}
|
||||
|
||||
if (this.notes?.isEmpty() == true) {
|
||||
return null
|
||||
if (notes?.isNotEmpty() == true) {
|
||||
MarkdownParser.parseMarkdownAsync(notes, Consumer { parsedText ->
|
||||
parsedNotes = parsedText
|
||||
callback(parsedText)
|
||||
})
|
||||
}
|
||||
|
||||
MarkdownParser.parseMarkdownAsync(this.notes, Consumer { parsedText ->
|
||||
this.parsedNotes = parsedText
|
||||
callback(parsedText)
|
||||
})
|
||||
|
||||
return this.notes
|
||||
return notes
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
|
@ -236,10 +224,11 @@ open class Task : RealmObject, Parcelable {
|
|||
}
|
||||
return if (Task::class.java.isAssignableFrom(other.javaClass)) {
|
||||
val otherTask = other as? Task
|
||||
if (!this.isValid || otherTask?.isValid != true) {
|
||||
return false
|
||||
if (this.isValid && otherTask?.isValid == true) {
|
||||
this.id == otherTask.id
|
||||
} else {
|
||||
false
|
||||
}
|
||||
this.id == otherTask.id
|
||||
} else {
|
||||
super.equals(other)
|
||||
}
|
||||
|
|
@ -259,14 +248,14 @@ open class Task : RealmObject, Parcelable {
|
|||
dest.writeString(this.attribute)
|
||||
dest.writeString(this.type)
|
||||
dest.writeDouble(this.value)
|
||||
dest.writeList(this.tags as List<*>?)
|
||||
dest.writeList(this.tags as? List<*>)
|
||||
dest.writeLong(this.dateCreated?.time ?: -1)
|
||||
dest.writeInt(this.position)
|
||||
dest.writeValue(this.up)
|
||||
dest.writeValue(this.down)
|
||||
dest.writeByte(if (this.completed) 1.toByte() else 0.toByte())
|
||||
dest.writeList(this.checklist as List<*>?)
|
||||
dest.writeList(this.reminders as List<*>?)
|
||||
dest.writeList(this.checklist as? List<*>)
|
||||
dest.writeList(this.reminders as? List<*>)
|
||||
dest.writeString(this.frequency)
|
||||
dest.writeValue(this.everyX)
|
||||
dest.writeValue(this.streak)
|
||||
|
|
@ -300,7 +289,7 @@ open class Task : RealmObject, Parcelable {
|
|||
this.checklist = RealmList()
|
||||
`in`.readList(this.checklist as List<*>, ChecklistItem::class.java.classLoader)
|
||||
this.reminders = RealmList()
|
||||
`in`.readList(this.reminders as List<*>, RemindersItem::class.java.classLoader)
|
||||
`in`.readList(this.reminders as MutableList<Any?>, RemindersItem::class.java.classLoader)
|
||||
this.frequency = `in`.readString()
|
||||
this.everyX = `in`.readValue(Int::class.java.classLoader) as? Int ?: 1
|
||||
this.streak = `in`.readValue(Int::class.java.classLoader) as? Int ?: 0
|
||||
|
|
@ -369,7 +358,7 @@ open class Task : RealmObject, Parcelable {
|
|||
return daysOfMonth
|
||||
}
|
||||
|
||||
companion object CREATOR: Parcelable.Creator<Task> {
|
||||
companion object CREATOR : Parcelable.Creator<Task> {
|
||||
override fun createFromParcel(source: Parcel): Task = Task(source)
|
||||
|
||||
override fun newArray(size: Int): Array<Task?> = arrayOfNulls(size)
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
package com.habitrpg.android.habitica.ui.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import android.view.MenuItem
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import android.view.MenuItem
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.ui.fragments.AboutFragment
|
||||
|
|
@ -49,13 +49,9 @@ class AboutActivity : BaseActivity() {
|
|||
pager.currentItem = tab.position
|
||||
}
|
||||
|
||||
override fun onTabUnselected(tab: TabLayout.Tab) {
|
||||
override fun onTabUnselected(tab: TabLayout.Tab) { /* no-on */ }
|
||||
|
||||
}
|
||||
|
||||
override fun onTabReselected(tab: TabLayout.Tab) {
|
||||
|
||||
}
|
||||
override fun onTabReselected(tab: TabLayout.Tab) { /* no-on */ }
|
||||
})
|
||||
|
||||
tabLayout.setupWithViewPager(pager)
|
||||
|
|
@ -80,7 +76,7 @@ class AboutActivity : BaseActivity() {
|
|||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
private inner class PagerAdapter(fm: FragmentManager, internal var mNumOfTabs: Int) : FragmentStatePagerAdapter(fm) {
|
||||
private inner class PagerAdapter(fm: FragmentManager, internal var mNumOfTabs: Int) : FragmentStatePagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
|
||||
|
||||
override fun getItem(position: Int): Fragment {
|
||||
return when (position) {
|
||||
|
|
|
|||
|
|
@ -334,9 +334,7 @@ class ChallengeFormActivity : BaseActivity() {
|
|||
checkPrizeAndMinimumForTavern()
|
||||
}
|
||||
|
||||
override fun onNothingSelected(adapterView: AdapterView<*>) {
|
||||
|
||||
}
|
||||
override fun onNothingSelected(adapterView: AdapterView<*>) { /* no-on */ }
|
||||
}
|
||||
createChallengePrize.setOnKeyListener { _, _, _ ->
|
||||
checkPrizeAndMinimumForTavern()
|
||||
|
|
|
|||
|
|
@ -129,13 +129,11 @@ class FullProfileActivity : BaseActivity() {
|
|||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
// app icon in action bar clicked; goto parent activity.
|
||||
this.finish()
|
||||
return true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
return if (item.itemId == android.R.id.home) {
|
||||
finish()
|
||||
true
|
||||
} else {
|
||||
super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,7 @@ class GuidelinesActivity: BaseActivity() {
|
|||
|
||||
override fun getLayoutResId(): Int = R.layout.activity_guidelines
|
||||
|
||||
override fun injectActivity(component: UserComponent?) {
|
||||
}
|
||||
override fun injectActivity(component: UserComponent?) { /* no-on */ }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class IntroActivity : BaseActivity(), View.OnClickListener, ViewPager.OnPageChan
|
|||
finish()
|
||||
}
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { /* no-on */ }
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
if (position == 2) {
|
||||
|
|
@ -82,11 +82,9 @@ class IntroActivity : BaseActivity(), View.OnClickListener, ViewPager.OnPageChan
|
|||
}
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
override fun onPageScrollStateChanged(state: Int) { /* no-on */ }
|
||||
|
||||
}
|
||||
|
||||
private inner class PagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm), IconPagerAdapter {
|
||||
private inner class PagerAdapter(fm: FragmentManager) : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT), IconPagerAdapter {
|
||||
|
||||
override fun getItem(position: Int): Fragment {
|
||||
val fragment = IntroFragment()
|
||||
|
|
|
|||
|
|
@ -56,9 +56,6 @@ import io.reactivex.schedulers.Schedulers
|
|||
import java.io.IOException
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
* @author Mickael Goubin
|
||||
*/
|
||||
class LoginActivity : BaseActivity(), Consumer<UserAuthResponse> {
|
||||
|
||||
@Inject
|
||||
|
|
@ -171,12 +168,11 @@ class LoginActivity : BaseActivity(), Consumer<UserAuthResponse> {
|
|||
object : FacebookCallback<LoginResult> {
|
||||
override fun onSuccess(loginResult: LoginResult) {
|
||||
val accessToken = AccessToken.getCurrentAccessToken()
|
||||
apiClient.connectSocial("facebook", accessToken.userId, accessToken.token)
|
||||
.subscribe(this@LoginActivity, RxErrorHandler.handleEmptyError())
|
||||
compositeSubscription.add(apiClient.connectSocial("facebook", accessToken.userId, accessToken.token)
|
||||
.subscribe(this@LoginActivity, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
override fun onCancel() {
|
||||
}
|
||||
override fun onCancel() { /* no-on */ }
|
||||
|
||||
override fun onError(exception: FacebookException) {
|
||||
exception.printStackTrace()
|
||||
|
|
@ -490,9 +486,9 @@ class LoginActivity : BaseActivity(), Consumer<UserAuthResponse> {
|
|||
val showLoginAlphaAnimation = ObjectAnimator.ofFloat<View>(showLoginButton, View.ALPHA, 1.toFloat()).setDuration(700)
|
||||
val scaleLogoAnimation = ValueAnimator.ofInt(logoView.measuredHeight, (logoView.measuredHeight * 1.333333).toInt())
|
||||
scaleLogoAnimation.addUpdateListener { valueAnimator ->
|
||||
val value = valueAnimator.animatedValue as Int
|
||||
val value = valueAnimator.animatedValue as? Int
|
||||
val layoutParams = logoView.layoutParams
|
||||
layoutParams.height = value
|
||||
layoutParams.height = value ?: 0
|
||||
logoView.layoutParams = layoutParams
|
||||
}
|
||||
showLoginAlphaAnimation.startDelay = 300
|
||||
|
|
@ -543,9 +539,6 @@ class LoginActivity : BaseActivity(), Consumer<UserAuthResponse> {
|
|||
|
||||
companion object {
|
||||
internal const val REQUEST_CODE_PICK_ACCOUNT = 1000
|
||||
private const val TAG_ADDRESS = "address"
|
||||
private const val TAG_USERID = "user"
|
||||
private const val TAG_APIKEY = "key"
|
||||
private const val REQUEST_CODE_RECOVER_FROM_PLAY_SERVICES_ERROR = 1001
|
||||
private const val PLAY_SERVICES_RESOLUTION_REQUEST = 9000
|
||||
|
||||
|
|
|
|||
|
|
@ -85,9 +85,10 @@ class NotificationsActivity : BaseActivity(), androidx.swiperefreshlayout.widget
|
|||
|
||||
notification_items.removeAllViewsInLayout()
|
||||
|
||||
when {
|
||||
notifications.isEmpty() -> displayNoNotificationsView()
|
||||
else -> displayNotificationsListView(notifications)
|
||||
if (notifications.isEmpty()) {
|
||||
displayNoNotificationsView()
|
||||
} else {
|
||||
displayNotificationsListView(notifications)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,18 +201,22 @@ class ItemRecyclerAdapter(data: OrderedRealmCollection<OwnedItem>?, autoUpdate:
|
|||
if (!this.canHatch) {
|
||||
return
|
||||
}
|
||||
val firstItem = item ?: return
|
||||
if (firstItem is Egg) {
|
||||
val potion = hatchingItem as HatchingPotion
|
||||
hatchPetSubject.onNext(Pair(potion, firstItem))
|
||||
} else if (firstItem is HatchingPotion) {
|
||||
val egg = hatchingItem as Egg
|
||||
hatchPetSubject.onNext(Pair(firstItem, egg))
|
||||
item?.let { firstItem ->
|
||||
if (firstItem is Egg) {
|
||||
(hatchingItem as? HatchingPotion)?.let {potion ->
|
||||
hatchPetSubject.onNext(Pair(potion, firstItem))
|
||||
}
|
||||
} else if (firstItem is HatchingPotion) {
|
||||
(hatchingItem as? Egg)?.let {egg ->
|
||||
hatchPetSubject.onNext(Pair(firstItem, egg))
|
||||
}
|
||||
}
|
||||
return@let
|
||||
}
|
||||
} else if (isFeeding) {
|
||||
val event = FeedCommand()
|
||||
event.usingPet = feedingPet
|
||||
event.usingFood = item as Food
|
||||
event.usingFood = item as? Food
|
||||
EventBus.getDefault().post(event)
|
||||
fragment?.dismiss()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,6 +104,7 @@ class ShopRecyclerAdapter(private val configManager: AppConfigManager) : android
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("ReturnCount")
|
||||
override fun onBindViewHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
|
||||
val obj = getItem(position)
|
||||
if (obj != null) {
|
||||
|
|
|
|||
|
|
@ -33,15 +33,12 @@ class StableRecyclerAdapter : androidx.recyclerview.widget.RecyclerView.Adapter<
|
|||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): androidx.recyclerview.widget.RecyclerView.ViewHolder =
|
||||
when (viewType) {
|
||||
0 -> {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.customization_section_header, parent, false)
|
||||
SectionViewHolder(view)
|
||||
}
|
||||
else -> {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.animal_overview_item, parent, false)
|
||||
StableViewHolder(view)
|
||||
}
|
||||
if (viewType == 0) {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.customization_section_header, parent, false)
|
||||
SectionViewHolder(view)
|
||||
} else {
|
||||
val view = LayoutInflater.from(parent.context).inflate(R.layout.animal_overview_item, parent, false)
|
||||
StableViewHolder(view)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: androidx.recyclerview.widget.RecyclerView.ViewHolder, position: Int) {
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ class AchievementProfileAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>(
|
|||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
val obj = this.itemList[position]
|
||||
if (obj.javaClass == String::class.java) {
|
||||
(holder as SectionViewHolder).bind(obj as String)
|
||||
(holder as? SectionViewHolder)?.bind(obj as String)
|
||||
} else {
|
||||
(holder as AchievementViewHolder).bind(itemList[position] as Achievement)
|
||||
(holder as? AchievementViewHolder)?.bind(itemList[position] as Achievement)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ class AchievementProfileAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>(
|
|||
draweeView.controller = Fresco.newDraweeControllerBuilder()
|
||||
.setUri(iconUrl)
|
||||
.setControllerListener(object : BaseControllerListener<ImageInfo>() {
|
||||
override fun onFailure(id: String?, throwable: Throwable?) {}
|
||||
override fun onFailure(id: String?, throwable: Throwable?) { /* no-on */ }
|
||||
})
|
||||
.build()
|
||||
|
||||
|
|
@ -97,8 +97,7 @@ class AchievementProfileAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>(
|
|||
val context = itemView.context
|
||||
val alert = HabiticaAlertDialog(context)
|
||||
|
||||
val customView = LayoutInflater.from(context)
|
||||
.inflate(R.layout.dialog_achievement_details, null)
|
||||
val customView = LayoutInflater.from(context).inflate(R.layout.dialog_achievement_details, null)
|
||||
val achievementImage = customView.findViewById<View>(R.id.achievement_image) as? ImageView
|
||||
achievementImage?.setImageDrawable(draweeView.drawable)
|
||||
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ class RewardsRecyclerViewAdapter(private var customRewards: OrderedRealmCollecti
|
|||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
override fun filter() {}
|
||||
override fun filter() { /* no-on */ }
|
||||
|
||||
override fun getTaskIDAt(position: Int): String? {
|
||||
return customRewards?.get(position)?.id
|
||||
|
|
|
|||
|
|
@ -110,8 +110,7 @@ abstract class BaseFragment : DialogFragment() {
|
|||
override fun onDestroy() {
|
||||
try {
|
||||
tutorialRepository.close()
|
||||
} catch (exception: UninitializedPropertyAccessException) {
|
||||
}
|
||||
} catch (exception: UninitializedPropertyAccessException) {/* no-on */ }
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class AvatarOverviewFragment : BaseMainFragment(), AdapterView.OnItemSelectedLis
|
|||
}
|
||||
}
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>) {}
|
||||
override fun onNothingSelected(parent: AdapterView<*>) { /* no-on */ }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,9 +28,7 @@ class PushNotificationsPreferencesFragment : BasePreferencesFragment(), SharedPr
|
|||
preferenceScreen.sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
|
||||
}
|
||||
|
||||
override fun setupPreferences() {
|
||||
|
||||
}
|
||||
override fun setupPreferences() { /* no-on */ }
|
||||
|
||||
override fun setUser(user: User?) {
|
||||
super.setUser(user)
|
||||
|
|
|
|||
|
|
@ -94,9 +94,9 @@ class AvatarSetupFragment : BaseFragment() {
|
|||
loadCustomizations()
|
||||
}
|
||||
|
||||
override fun onTabUnselected(tab: TabLayout.Tab) {}
|
||||
override fun onTabUnselected(tab: TabLayout.Tab) { /* no-on */ }
|
||||
|
||||
override fun onTabReselected(tab: TabLayout.Tab) {}
|
||||
override fun onTabReselected(tab: TabLayout.Tab) { /* no-on */ }
|
||||
})
|
||||
|
||||
bodyButton?.setOnClickListener { selectedBodyCategory() }
|
||||
|
|
@ -149,9 +149,9 @@ class AvatarSetupFragment : BaseFragment() {
|
|||
|
||||
private fun selectedBodyCategory() {
|
||||
activateButton(bodyButton)
|
||||
this.activeCategory = "body"
|
||||
this.activeCategory = CATEGORY_BODY
|
||||
this.subCategoryTabs?.removeAllTabs()
|
||||
this.subcategories = listOf("size", "shirt")
|
||||
this.subcategories = listOf(SUBCATEGORY_SIZE, SUBCATEGORY_SHIRT)
|
||||
subCategoryTabs?.newTab()?.setText(R.string.avatar_size)?.let { this.subCategoryTabs?.addTab(it) }
|
||||
subCategoryTabs?.newTab()?.setText(R.string.avatar_shirt)?.let { this.subCategoryTabs?.addTab(it) }
|
||||
loadCustomizations()
|
||||
|
|
@ -159,18 +159,18 @@ class AvatarSetupFragment : BaseFragment() {
|
|||
|
||||
private fun selectedSkinCategory() {
|
||||
activateButton(skinButton)
|
||||
this.activeCategory = "skin"
|
||||
this.activeCategory = CATEGORY_SKIN
|
||||
this.subCategoryTabs?.removeAllTabs()
|
||||
this.subcategories = listOf("color")
|
||||
this.subcategories = listOf(SUBCATEGORY_COLOR)
|
||||
subCategoryTabs?.newTab()?.setText(R.string.avatar_skin_color)?.let { this.subCategoryTabs?.addTab(it) }
|
||||
loadCustomizations()
|
||||
}
|
||||
|
||||
private fun selectedHairCategory() {
|
||||
activateButton(hairButton)
|
||||
this.activeCategory = "hair"
|
||||
this.activeCategory = CATEGORY_HAIR
|
||||
this.subCategoryTabs?.removeAllTabs()
|
||||
this.subcategories = Arrays.asList("bangs", "color", "ponytail")
|
||||
this.subcategories = listOf(SUBCATEGORY_BANGS, SUBCATEGORY_COLOR, SUBCATEGORY_PONYTAIL)
|
||||
subCategoryTabs?.newTab()?.setText(R.string.avatar_hair_bangs)?.let { this.subCategoryTabs?.addTab(it) }
|
||||
subCategoryTabs?.newTab()?.setText(R.string.avatar_hair_color)?.let { this.subCategoryTabs?.addTab(it) }
|
||||
subCategoryTabs?.newTab()?.setText(R.string.avatar_hair_ponytail)?.let { this.subCategoryTabs?.addTab(it) }
|
||||
|
|
@ -179,9 +179,9 @@ class AvatarSetupFragment : BaseFragment() {
|
|||
|
||||
private fun selectedExtrasCategory() {
|
||||
activateButton(extrasButton)
|
||||
this.activeCategory = "extras"
|
||||
this.activeCategory = CATEGORY_EXTRAS
|
||||
this.subCategoryTabs?.removeAllTabs()
|
||||
this.subcategories = Arrays.asList("glasses", "flower", "wheelchair")
|
||||
this.subcategories = listOf(SUBCATEGORY_GLASSES, SUBCATEGORY_FLOWER, SUBCATEGORY_WHEELCHAIR)
|
||||
subCategoryTabs?.newTab()?.setText(R.string.avatar_glasses)?.let { this.subCategoryTabs?.addTab(it) }
|
||||
subCategoryTabs?.newTab()?.setText(R.string.avatar_flower)?.let { this.subCategoryTabs?.addTab(it) }
|
||||
subCategoryTabs?.newTab()?.setText(R.string.avatar_wheelchair)?.let { this.subCategoryTabs?.addTab(it) }
|
||||
|
|
@ -191,14 +191,14 @@ class AvatarSetupFragment : BaseFragment() {
|
|||
private fun randomizeCharacter() {
|
||||
val user = this.user ?: return
|
||||
val updateData = HashMap<String, Any>()
|
||||
updateData["preferences.size"] = chooseRandomKey(customizationRepository.getCustomizations("body", "size", user), false)
|
||||
updateData["preferences.shirt"] = chooseRandomKey(customizationRepository.getCustomizations("body", "shirt", user), false)
|
||||
updateData["preferences.skin"] = chooseRandomKey(customizationRepository.getCustomizations("skin", "color", user), false)
|
||||
updateData["preferences.hair.color"] = chooseRandomKey(customizationRepository.getCustomizations("hair", "color", user), false)
|
||||
updateData["preferences.hair.base"] = chooseRandomKey(customizationRepository.getCustomizations("hair", "ponytail", user), false)
|
||||
updateData["preferences.hair.bangs"] = chooseRandomKey(customizationRepository.getCustomizations("hair", "bangs", user), false)
|
||||
updateData["preferences.hair.flower"] = chooseRandomKey(customizationRepository.getCustomizations("extras", "flower", user), true)
|
||||
updateData["preferences.chair"] = chooseRandomKey(customizationRepository.getCustomizations("extras", "wheelchair", user), true)
|
||||
updateData["preferences.size"] = chooseRandomKey(customizationRepository.getCustomizations(CATEGORY_BODY, SUBCATEGORY_SIZE, user), false)
|
||||
updateData["preferences.shirt"] = chooseRandomKey(customizationRepository.getCustomizations(CATEGORY_BODY, SUBCATEGORY_SHIRT, user), false)
|
||||
updateData["preferences.skin"] = chooseRandomKey(customizationRepository.getCustomizations(CATEGORY_SKIN, SUBCATEGORY_COLOR, user), false)
|
||||
updateData["preferences.hair.color"] = chooseRandomKey(customizationRepository.getCustomizations(CATEGORY_HAIR, SUBCATEGORY_COLOR, user), false)
|
||||
updateData["preferences.hair.base"] = chooseRandomKey(customizationRepository.getCustomizations(CATEGORY_HAIR, SUBCATEGORY_PONYTAIL, user), false)
|
||||
updateData["preferences.hair.bangs"] = chooseRandomKey(customizationRepository.getCustomizations(CATEGORY_HAIR, SUBCATEGORY_BANGS, user), false)
|
||||
updateData["preferences.hair.flower"] = chooseRandomKey(customizationRepository.getCustomizations(CATEGORY_EXTRAS, SUBCATEGORY_FLOWER, user), true)
|
||||
updateData["preferences.chair"] = chooseRandomKey(customizationRepository.getCustomizations(CATEGORY_EXTRAS, SUBCATEGORY_WHEELCHAIR, user), true)
|
||||
compositeSubscription.add(userRepository.updateUser(user, updateData).subscribeWithErrorHandler(Consumer {}))
|
||||
}
|
||||
|
||||
|
|
@ -229,4 +229,20 @@ class AvatarSetupFragment : BaseFragment() {
|
|||
params?.marginStart = location[0] + px
|
||||
this.caretView?.layoutParams = params
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val CATEGORY_BODY = "body"
|
||||
const val CATEGORY_SKIN = "skin"
|
||||
const val CATEGORY_HAIR = "hair"
|
||||
const val CATEGORY_EXTRAS = "extras"
|
||||
|
||||
const val SUBCATEGORY_SIZE = "size"
|
||||
const val SUBCATEGORY_SHIRT = "shirt"
|
||||
const val SUBCATEGORY_COLOR = "color"
|
||||
const val SUBCATEGORY_PONYTAIL = "ponytail"
|
||||
const val SUBCATEGORY_BANGS = "bangs"
|
||||
const val SUBCATEGORY_FLOWER = "flower"
|
||||
const val SUBCATEGORY_WHEELCHAIR = "wheelchair"
|
||||
const val SUBCATEGORY_GLASSES = "glasses"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,15 +83,15 @@ class TaskSetupFragment : BaseFragment() {
|
|||
}
|
||||
|
||||
private fun setTasks() {
|
||||
this.taskGroups = listOf(listOf(getString(R.string.setup_group_work), "work"), listOf(getString(R.string.setup_group_exercise), "exercise"), listOf(getString(R.string.setup_group_health), "healthWellness"), listOf(getString(R.string.setup_group_school), "school"), listOf(getString(R.string.setup_group_teams), "teams"), listOf(getString(R.string.setup_group_chores), "chores"), listOf(getString(R.string.setup_group_creativity), "creativity"), listOf(getString(R.string.setuP_group_other), "other"))
|
||||
this.taskGroups = listOf(listOf(getString(R.string.setup_group_work), TYPE_WORK), listOf(getString(R.string.setup_group_exercise), TYPE_EXERCISE), listOf(getString(R.string.setup_group_health), TYPE_HEALTH), listOf(getString(R.string.setup_group_school), TYPE_SCHOOL), listOf(getString(R.string.setup_group_teams), TYPE_TEAMS), listOf(getString(R.string.setup_group_chores), TYPE_CHORES), listOf(getString(R.string.setup_group_creativity), TYPE_CREATIVITY), listOf(getString(R.string.setuP_group_other), TYPE_OTHER))
|
||||
|
||||
this.tasks = listOf(listOf("work", Task.TYPE_HABIT, getString(R.string.setup_task_work_1), true, false), listOf("work", Task.TYPE_DAILY, getString(R.string.setup_task_work_2)), listOf("work", Task.TYPE_TODO, getString(R.string.setup_task_work_3)),
|
||||
listOf("exercise", Task.TYPE_HABIT, getString(R.string.setup_task_exercise_1), true, false), listOf("exercise", Task.TYPE_DAILY, getString(R.string.setup_task_exercise_2)), listOf("exercise", Task.TYPE_TODO, getString(R.string.setup_task_exercise_3)),
|
||||
listOf("healthWellness", Task.TYPE_HABIT, getString(R.string.setup_task_healthWellness_1), true, true), listOf("healthWellness", Task.TYPE_DAILY, getString(R.string.setup_task_healthWellness_2)), listOf("healthWellness", Task.TYPE_TODO, getString(R.string.setup_task_healthWellness_3)),
|
||||
listOf("school", Task.TYPE_HABIT, getString(R.string.setup_task_school_1), true, true), listOf("school", Task.TYPE_DAILY, getString(R.string.setup_task_school_2)), listOf("school", Task.TYPE_TODO, getString(R.string.setup_task_school_3)),
|
||||
listOf("teams", Task.TYPE_HABIT, getString(R.string.setup_task_teams_1), true, false), listOf("teams", Task.TYPE_DAILY, getString(R.string.setup_task_teams_2)), listOf("teams", Task.TYPE_TODO, getString(R.string.setup_task_teams_3)),
|
||||
listOf("chores", Task.TYPE_HABIT, getString(R.string.setup_task_chores_1), true, false), listOf("chores", Task.TYPE_DAILY, getString(R.string.setup_task_chores_2)), listOf("chores", Task.TYPE_TODO, getString(R.string.setup_task_chores_3)),
|
||||
listOf("creativity", Task.TYPE_HABIT, getString(R.string.setup_task_creativity_1), true, false), listOf("creativity", Task.TYPE_DAILY, getString(R.string.setup_task_creativity_2)), listOf("creativity", Task.TYPE_TODO, getString(R.string.setup_task_creativity_3)))
|
||||
this.tasks = listOf(listOf(TYPE_WORK, Task.TYPE_HABIT, getString(R.string.setup_task_work_1), true, false), listOf(TYPE_WORK, Task.TYPE_DAILY, getString(R.string.setup_task_work_2)), listOf(TYPE_WORK, Task.TYPE_TODO, getString(R.string.setup_task_work_3)),
|
||||
listOf(TYPE_EXERCISE, Task.TYPE_HABIT, getString(R.string.setup_task_exercise_1), true, false), listOf(TYPE_EXERCISE, Task.TYPE_DAILY, getString(R.string.setup_task_exercise_2)), listOf(TYPE_EXERCISE, Task.TYPE_TODO, getString(R.string.setup_task_exercise_3)),
|
||||
listOf(TYPE_HEALTH, Task.TYPE_HABIT, getString(R.string.setup_task_healthWellness_1), true, true), listOf(TYPE_HEALTH, Task.TYPE_DAILY, getString(R.string.setup_task_healthWellness_2)), listOf(TYPE_HEALTH, Task.TYPE_TODO, getString(R.string.setup_task_healthWellness_3)),
|
||||
listOf(TYPE_SCHOOL, Task.TYPE_HABIT, getString(R.string.setup_task_school_1), true, true), listOf(TYPE_SCHOOL, Task.TYPE_DAILY, getString(R.string.setup_task_school_2)), listOf(TYPE_SCHOOL, Task.TYPE_TODO, getString(R.string.setup_task_school_3)),
|
||||
listOf(TYPE_TEAMS, Task.TYPE_HABIT, getString(R.string.setup_task_teams_1), true, false), listOf(TYPE_TEAMS, Task.TYPE_DAILY, getString(R.string.setup_task_teams_2)), listOf(TYPE_TEAMS, Task.TYPE_TODO, getString(R.string.setup_task_teams_3)),
|
||||
listOf(TYPE_CHORES, Task.TYPE_HABIT, getString(R.string.setup_task_chores_1), true, false), listOf(TYPE_CHORES, Task.TYPE_DAILY, getString(R.string.setup_task_chores_2)), listOf(TYPE_CHORES, Task.TYPE_TODO, getString(R.string.setup_task_chores_3)),
|
||||
listOf(TYPE_CREATIVITY, Task.TYPE_HABIT, getString(R.string.setup_task_creativity_1), true, false), listOf(TYPE_CREATIVITY, Task.TYPE_DAILY, getString(R.string.setup_task_creativity_2)), listOf(TYPE_CREATIVITY, Task.TYPE_TODO, getString(R.string.setup_task_creativity_3)))
|
||||
}
|
||||
|
||||
fun createSampleTasks(): List<Task> {
|
||||
|
|
@ -150,4 +150,15 @@ class TaskSetupFragment : BaseFragment() {
|
|||
return task
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TYPE_EXERCISE = "exercise"
|
||||
const val TYPE_HEALTH = "healthWellness"
|
||||
const val TYPE_WORK = "work"
|
||||
const val TYPE_SCHOOL = "school"
|
||||
const val TYPE_TEAMS = "teams"
|
||||
const val TYPE_CHORES = "chores"
|
||||
const val TYPE_CREATIVITY = "creativity"
|
||||
const val TYPE_OTHER = "other"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class GuildDetailFragment : BaseFragment() {
|
|||
if (data?.getBooleanExtra(GroupInviteActivity.IS_EMAIL_KEY, false) == true) {
|
||||
val emails = data.getStringArrayExtra(GroupInviteActivity.EMAILS_KEY)
|
||||
val invites = ArrayList<HashMap<String, String>>()
|
||||
for (email in emails) {
|
||||
emails?.forEach { email ->
|
||||
val invite = HashMap<String, String>()
|
||||
invite["name"] = ""
|
||||
invite["email"] = email
|
||||
|
|
@ -138,8 +138,8 @@ class GuildDetailFragment : BaseFragment() {
|
|||
inviteData["emails"] = invites
|
||||
} else {
|
||||
val userIDs = data?.getStringArrayExtra(GroupInviteActivity.USER_IDS_KEY)
|
||||
val invites = ArrayList<String>()
|
||||
Collections.addAll(invites, *userIDs)
|
||||
val invites = mutableListOf<String>()
|
||||
userIDs?.forEach { invites.add(it) }
|
||||
inviteData["usernames"] = invites
|
||||
}
|
||||
viewModel?.inviteToGroup(inviteData)
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class GuildFragment : BaseMainFragment() {
|
|||
private fun setViewPagerAdapter() {
|
||||
val fragmentManager = childFragmentManager
|
||||
|
||||
viewPager?.adapter = object : FragmentPagerAdapter(fragmentManager) {
|
||||
viewPager?.adapter = object : FragmentPagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
|
||||
|
||||
override fun getItem(position: Int): Fragment {
|
||||
|
||||
|
|
@ -174,9 +174,7 @@ class GuildFragment : BaseMainFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
|
||||
}
|
||||
override fun onPageScrollStateChanged(state: Int) { /* no-on */ }
|
||||
})
|
||||
|
||||
tabLayout?.setupWithViewPager(viewPager)
|
||||
|
|
|
|||
|
|
@ -152,7 +152,6 @@ class QuestDetailFragment : BaseMainFragment() {
|
|||
return
|
||||
}
|
||||
questTitleView?.text = questContent.text
|
||||
//TODO: FIX
|
||||
questDescriptionView?.text = MarkdownParser.parseMarkdown(questContent.notes)
|
||||
DataBindingUtils.loadImage(questScrollImageView, "inventory_quest_scroll_" + questContent.key)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class PartyFragment : BaseMainFragment() {
|
|||
if (data?.getBooleanExtra(GroupInviteActivity.IS_EMAIL_KEY, false) == true) {
|
||||
val emails = data.getStringArrayExtra(GroupInviteActivity.EMAILS_KEY)
|
||||
val invites = ArrayList<HashMap<String, String>>()
|
||||
for (email in emails) {
|
||||
emails?.forEach { email ->
|
||||
val invite = HashMap<String, String>()
|
||||
invite["name"] = ""
|
||||
invite["email"] = email
|
||||
|
|
@ -201,7 +201,7 @@ class PartyFragment : BaseMainFragment() {
|
|||
} else {
|
||||
val userIDs = data?.getStringArrayExtra(GroupInviteActivity.USER_IDS_KEY)
|
||||
val invites = ArrayList<String>()
|
||||
Collections.addAll(invites, *userIDs)
|
||||
userIDs?.forEach { invites.add(it) }
|
||||
inviteData["usernames"] = invites
|
||||
}
|
||||
viewModel.inviteToGroup(inviteData)
|
||||
|
|
@ -216,7 +216,7 @@ class PartyFragment : BaseMainFragment() {
|
|||
return
|
||||
}
|
||||
|
||||
viewPagerAdapter = object : FragmentPagerAdapter(fragmentManager) {
|
||||
viewPagerAdapter = object : FragmentPagerAdapter(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
|
||||
|
||||
override fun getItem(position: Int): Fragment {
|
||||
return when (position) {
|
||||
|
|
@ -282,9 +282,7 @@ class PartyFragment : BaseMainFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
|
||||
}
|
||||
override fun onPageScrollStateChanged(state: Int) { /* no-op */ }
|
||||
})
|
||||
tabLayout?.setupWithViewPager(viewPager)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,9 +51,10 @@ class PartyInviteFragment : BaseFragment() {
|
|||
|
||||
resetViews()
|
||||
|
||||
when {
|
||||
isEmailInvite -> inviteDescription?.text = getString(R.string.invite_email_description)
|
||||
else -> inviteDescription?.text = getString(R.string.invite_username_description)
|
||||
if (isEmailInvite) {
|
||||
inviteDescription?.text = getString(R.string.invite_email_description)
|
||||
} else {
|
||||
inviteDescription?.text = getString(R.string.invite_username_description)
|
||||
}
|
||||
|
||||
addInviteField()
|
||||
|
|
@ -68,12 +69,11 @@ class PartyInviteFragment : BaseFragment() {
|
|||
private fun addInviteField() {
|
||||
val editText = EditText(context)
|
||||
|
||||
when {
|
||||
isEmailInvite -> {
|
||||
editText.setHint(R.string.email)
|
||||
editText.inputType = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
||||
}
|
||||
else -> editText.setHint(R.string.username)
|
||||
if (isEmailInvite) {
|
||||
editText.setHint(R.string.email)
|
||||
editText.inputType = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
||||
} else {
|
||||
editText.setHint(R.string.username)
|
||||
}
|
||||
invitationWrapper?.addView(editText)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ open class TaskRecyclerViewFragment : BaseFragment(), androidx.swiperefreshlayou
|
|||
return true
|
||||
}
|
||||
|
||||
override fun onSwiped(viewHolder: androidx.recyclerview.widget.RecyclerView.ViewHolder, direction: Int) {}
|
||||
override fun onSwiped(viewHolder: androidx.recyclerview.widget.RecyclerView.ViewHolder, direction: Int) { /* no-on */ }
|
||||
|
||||
//defines the enabled move directions in each state (idle, swiping, dragging).
|
||||
override fun getMovementFlags(recyclerView: androidx.recyclerview.widget.RecyclerView, viewHolder: androidx.recyclerview.widget.RecyclerView.ViewHolder): Int {
|
||||
|
|
|
|||
|
|
@ -220,18 +220,14 @@ class TasksFragment : BaseMainFragment(), SearchView.OnQueryTextListener {
|
|||
}
|
||||
|
||||
viewPager?.addOnPageChangeListener(object : androidx.viewpager.widget.ViewPager.OnPageChangeListener {
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
|
||||
}
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) { /* no-op */ }
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
bottomNavigation?.selectedPosition = position
|
||||
updateFilterIcon()
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
|
||||
}
|
||||
override fun onPageScrollStateChanged(state: Int) { /* no-op */ }
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,19 +34,19 @@ object MarkdownParser {
|
|||
if (input == null) {
|
||||
return ""
|
||||
}
|
||||
val html = try {
|
||||
processor.markdownToHtml(EmojiParser.parseEmojis(input.trim { it <= ' ' }))
|
||||
val output: SpannableStringBuilder = try {
|
||||
val html = processor.markdownToHtml(EmojiParser.parseEmojis(input.trim { it <= ' ' }))
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
Html.fromHtml(html, FROM_HTML_MODE_LEGACY) as? SpannableStringBuilder
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
(Html.fromHtml(html) as? SpannableStringBuilder)
|
||||
} ?: SpannableStringBuilder()
|
||||
} catch (e: UnsatisfiedLinkError) {
|
||||
return input
|
||||
SpannableStringBuilder(input)
|
||||
} catch (e: NoClassDefFoundError) {
|
||||
return input
|
||||
SpannableStringBuilder(input)
|
||||
}
|
||||
val output: SpannableStringBuilder = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||
Html.fromHtml(html, FROM_HTML_MODE_LEGACY) as? SpannableStringBuilder
|
||||
} else {
|
||||
@Suppress("DEPRECATION")
|
||||
(Html.fromHtml(html) as? SpannableStringBuilder)
|
||||
} ?: SpannableStringBuilder()
|
||||
|
||||
val matcher = regex.matcher(output)
|
||||
while (matcher.find()) {
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@ open class NotificationsViewModel : BaseViewModel() {
|
|||
@Inject
|
||||
lateinit var socialRepository: SocialRepository
|
||||
|
||||
/**
|
||||
* A list of notification types handled by this component.
|
||||
* NOTE: Those not listed here won't be shown in the notification panel (except the custom ones)
|
||||
*/
|
||||
private val supportedNotificationTypes = listOf(
|
||||
Notification.Type.NEW_STUFF.type,
|
||||
Notification.Type.NEW_CHAT_MESSAGE.type,
|
||||
|
|
@ -41,25 +37,14 @@ open class NotificationsViewModel : BaseViewModel() {
|
|||
Notification.Type.UNALLOCATED_STATS_POINTS.type
|
||||
)
|
||||
|
||||
/**
|
||||
* A list of notification types that are "actionable" (ones that have accept/reject buttons).
|
||||
*/
|
||||
private val actionableNotificationTypes = listOf(
|
||||
Notification.Type.GUILD_INVITATION.type,
|
||||
Notification.Type.PARTY_INVITATION.type,
|
||||
Notification.Type.QUEST_INVITATION.type
|
||||
)
|
||||
|
||||
/**
|
||||
* Keep track of users party so we can determine which chat notifications are party chat
|
||||
* instead of guild chat notifications.
|
||||
*/
|
||||
private var party: UserParty? = null
|
||||
|
||||
/**
|
||||
* Custom notification types created by this class (from user data).
|
||||
* Will be combined with the notifications coming from server.
|
||||
*/
|
||||
private val customNotifications: BehaviorSubject<List<Notification>> = BehaviorSubject.create()
|
||||
|
||||
override fun inject(component: UserComponent) {
|
||||
|
|
@ -326,7 +311,7 @@ open class NotificationsViewModel : BaseViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
fun acceptGroupInvitation(groupId: String?) {
|
||||
private fun acceptGroupInvitation(groupId: String?) {
|
||||
groupId?.let {
|
||||
disposable.add(socialRepository.joinGroup(it)
|
||||
.flatMap { userRepository.retrieveUser(false) }
|
||||
|
|
@ -367,10 +352,10 @@ open class NotificationsViewModel : BaseViewModel() {
|
|||
}
|
||||
|
||||
private fun acceptTaskApproval(notification: Notification) {
|
||||
val data = notification.data as? GroupTaskRequiresApprovalData
|
||||
notification.data as? GroupTaskRequiresApprovalData
|
||||
}
|
||||
|
||||
private fun rejectTaskApproval(notification: Notification) {
|
||||
val data = notification.data as? GroupTaskRequiresApprovalData
|
||||
notification.data as? GroupTaskRequiresApprovalData
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,12 +14,10 @@ class LockableScrollView(context: Context, attrs: AttributeSet) : ScrollView(con
|
|||
}
|
||||
|
||||
override fun onTouchEvent(ev: MotionEvent): Boolean {
|
||||
return when (ev.action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
if (isScrollable) super.onTouchEvent(ev) else isScrollable
|
||||
// mScrollable is always false at this point
|
||||
}
|
||||
else -> super.onTouchEvent(ev)
|
||||
return if (ev.action == MotionEvent.ACTION_DOWN) {
|
||||
if (isScrollable) super.onTouchEvent(ev) else isScrollable
|
||||
} else {
|
||||
super.onTouchEvent(ev)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
this.user = user
|
||||
currencyView.gold = user.stats?.gp ?: 0.0
|
||||
currencyView.gems = user.gemCount.toDouble()
|
||||
currencyView.hourglasses = user.hourglassCount?.toDouble() ?: 0.0
|
||||
currencyView.hourglasses = user.hourglassCount.toDouble()
|
||||
|
||||
if ("gems" == shopItem.purchaseType) {
|
||||
val maxGems = user.purchased?.plan?.totalNumberOfGems() ?: 0
|
||||
|
|
@ -202,10 +202,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
|
||||
private fun onBuyButtonClicked() {
|
||||
val snackbarText = arrayOf("")
|
||||
if (shopItem.isValid) {
|
||||
if (shopItem.locked) {
|
||||
return
|
||||
}
|
||||
if (shopItem.isValid && !shopItem.locked) {
|
||||
val gemsLeft = if (shopItem.limitedNumberLeft != null) shopItem.limitedNumberLeft else 0
|
||||
if ((gemsLeft == 0 && shopItem.purchaseType == "gems") || shopItem.canAfford(user, false)) {
|
||||
val observable: Flowable<Any>
|
||||
|
|
|
|||
|
|
@ -29,12 +29,11 @@ class UsernameLabel(context: Context?, attrs: AttributeSet?) : LinearLayout(cont
|
|||
set(value) {
|
||||
field = value
|
||||
textView.setTextColor(PlayerTier.getColorForTier(context, value))
|
||||
when (value) {
|
||||
0 -> tierIconView.visibility = View.GONE
|
||||
else -> {
|
||||
tierIconView.visibility = View.VISIBLE
|
||||
tierIconView.setImageBitmap(HabiticaIconsHelper.imageOfContributorBadge(value.toFloat(), false))
|
||||
}
|
||||
if (value == 0) {
|
||||
tierIconView.visibility = View.GONE
|
||||
} else {
|
||||
tierIconView.visibility = View.VISIBLE
|
||||
tierIconView.setImageBitmap(HabiticaIconsHelper.imageOfContributorBadge(value.toFloat(), false))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,9 +84,9 @@ class StatsSliderView(context: Context, attrs: AttributeSet?) : LinearLayout(con
|
|||
}
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar?) {}
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar?) { /* no-on */ }
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar?) {}
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar?) { /* no-on */ }
|
||||
})
|
||||
|
||||
currentValue = 0
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class ChecklistItemFormView @JvmOverloads constructor(
|
|||
rotate.duration = animDuration
|
||||
rotate.interpolator = LinearInterpolator()
|
||||
rotate.setAnimationListener(object : Animation.AnimationListener {
|
||||
override fun onAnimationRepeat(animation: Animation?) {}
|
||||
override fun onAnimationRepeat(animation: Animation?) { /* no-on */ }
|
||||
|
||||
override fun onAnimationEnd(animation: Animation?) {
|
||||
button.rotation = if (value) {
|
||||
|
|
@ -66,7 +66,7 @@ class ChecklistItemFormView @JvmOverloads constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun onAnimationStart(animation: Animation?) {}
|
||||
override fun onAnimationStart(animation: Animation?) { /* no-on */ }
|
||||
})
|
||||
button.startAnimation(rotate)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ abstract class TaskListFactory internal constructor(val context: Context, intent
|
|||
HabiticaBaseApplication.userComponent?.inject(this)
|
||||
this.loadData()
|
||||
}
|
||||
override fun onDestroy() {}
|
||||
override fun onDestroy() { /* no-op */ }
|
||||
|
||||
override fun onDataSetChanged() {
|
||||
if (this.reloadData) {
|
||||
|
|
|
|||
27
build.gradle
27
build.gradle
|
|
@ -11,12 +11,12 @@ buildscript {
|
|||
maven { url "https://plugins.gradle.org/m2/" }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
classpath 'com.android.tools.build:gradle:3.5.1'
|
||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
|
||||
classpath 'com.google.gms:google-services:4.3.1'
|
||||
classpath "io.realm:realm-gradle-plugin:5.14.0"
|
||||
classpath 'com.google.gms:google-services:4.3.2'
|
||||
classpath "io.realm:realm-gradle-plugin:5.15.0"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "gradle.plugin.io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.0.0.RC4-3"
|
||||
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.1.0"
|
||||
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0"
|
||||
classpath 'com.google.firebase:perf-plugin:1.3.1'
|
||||
}
|
||||
|
|
@ -32,9 +32,20 @@ allprojects {
|
|||
}
|
||||
|
||||
detekt {
|
||||
profile("main") {
|
||||
input = "$projectDir/Habitica/src/main/java"
|
||||
config = "$projectDir/detekt.yml"
|
||||
output = "$projectDir/reports/detekt"
|
||||
input = files("Habitica/src/main/java")
|
||||
config = files("detekt.yml")
|
||||
reports {
|
||||
xml {
|
||||
enabled = true // Enable/Disable XML report (default: true)
|
||||
destination = file("build/reports/detekt.xml") // Path where XML report will be stored (default: `build/reports/detekt/detekt.xml`)
|
||||
}
|
||||
html {
|
||||
enabled = true // Enable/Disable HTML report (default: true)
|
||||
destination = file("build/reports/detekt.html") // Path where HTML report will be stored (default: `build/reports/detekt/detekt.html`)
|
||||
}
|
||||
txt {
|
||||
enabled = true // Enable/Disable TXT report (default: true)
|
||||
destination = file("build/reports/detekt.txt") // Path where TXT report will be stored (default: `build/reports/detekt/detekt.txt`)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue