Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on mainviewmodel enable minify #36

Merged
merged 6 commits into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'io.fabric'

ext.app = [
'version' : '2.1.1',
'version_code' : 16,
'version' : '2.1.5',
'version_code' : 22,
'compile_sdk_version': 28,
'min_sdk_version' : 21,
'target_sdk_version' : 28
Expand Down Expand Up @@ -44,8 +44,8 @@ android {
}

release {
shrinkResources false
minifyEnabled false
shrinkResources true
minifyEnabled true
}
}

Expand Down Expand Up @@ -76,58 +76,43 @@ androidExtensions {
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation deps.kotlin.stdlib
implementation deps.kotlin.coroutines

implementation deps.material_design

implementation deps.androidx.core_ktx
implementation deps.androidx.fragment
implementation deps.androidx.browser
implementation deps.androidx.lifecycle
kapt deps.androidx.lifecycle_compiler
implementation deps.androidx.paging

implementation deps.androidx.constraint_layout

implementation deps.room.runtime
kapt deps.room.compiler

implementation deps.dagger.core
implementation deps.dagger.android
implementation deps.dagger.android_support
kapt deps.dagger.compiler
kapt deps.dagger.processor

implementation deps.glide.core
kapt deps.glide.compiler

implementation deps.retrofit.core
implementation deps.retrofit.moshi_converter

implementation deps.okhttp.core
implementation deps.okhttp.logging_interceptor

implementation deps.crashlytics

implementation deps.lottie

implementation deps.firebase.core
implementation deps.firebase.config
implementation deps.firebase.firestore

implementation deps.jsoup
implementation deps.gson // quick fix for version conflict between room and firestore

testImplementation deps.mockito.core
testImplementation deps.mockito.inline
testImplementation deps.junit
testImplementation deps.kotlin.coroutines_test
testImplementation deps.testx.core
testImplementation deps.arch_testing

androidTestImplementation deps.arch_testing
androidTestImplementation deps.testx.core
androidTestImplementation deps.testx.runner
Expand All @@ -136,7 +121,6 @@ dependencies {
androidTestImplementation deps.testx.monitor
androidTestImplementation deps.testx.ext
androidTestImplementation deps.room.testing

detektPlugins deps.detekt_formatting
}

Expand Down
1 change: 0 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
-keepattributes SourceFile,LineNumberTable
-repackageclasses ''


-keep class com.crashlytics.** { *; }
-keepattributes *Annotation*,Signature,Exceptions

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.droidfeed.data.api.mailchimp

import androidx.annotation.Keep
import com.droidfeed.data.api.mailchimp.model.ErrorJson
import com.droidfeed.data.api.mailchimp.model.ErrorType
import com.droidfeed.data.api.mailchimp.model.MailchimpError
import com.droidfeed.util.logThrowable
import com.squareup.moshi.FromJson
import com.squareup.moshi.JsonDataException
Expand All @@ -21,6 +24,10 @@ internal class ErrorAdapter {
}
}

return MailchimpError(errorType, errorJson.status, errorJson.detail)
return MailchimpError(
errorType,
errorJson.status,
errorJson.detail
)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.droidfeed.data.api.mailchimp
package com.droidfeed.data.api.mailchimp.model

import androidx.annotation.Keep

@Keep
data class ErrorJson(
val title: String,
val status: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.droidfeed.data.api.mailchimp
package com.droidfeed.data.api.mailchimp.model

import androidx.annotation.Keep

@Keep
enum class ErrorType {
MEMBER_ALREADY_EXIST,
INVALID_RESOURCE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.droidfeed.data.api.mailchimp
package com.droidfeed.data.api.mailchimp.model

import androidx.annotation.Keep

/**
* Defines base error response for Mailchimp API.
*/
@Keep
data class MailchimpError(
val type: ErrorType,
val code: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.droidfeed.data.api.mailchimp
package com.droidfeed.data.api.mailchimp.model

import androidx.annotation.Keep
import com.squareup.moshi.Json

@Keep
data class Subscriber(
@field:Json(name = "email_address")
var email: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.droidfeed.data.api.mailchimp
package com.droidfeed.data.api.mailchimp.model

import androidx.annotation.Keep
import com.squareup.moshi.Json

@Keep
enum class SubscriptionStatus(private val status: String) {
@Json(name = "subscribed")
SUBSCRIBED("subscribed"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.droidfeed.data.api.mailchimp
package com.droidfeed.data.api.mailchimp.model

import androidx.annotation.Keep
import com.squareup.moshi.Json

@Keep
data class UserResponse(
val id: String,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.droidfeed.data.api.mailchimp.service

import com.droidfeed.data.api.mailchimp.Subscriber
import com.droidfeed.data.api.mailchimp.UserResponse
import com.droidfeed.data.api.mailchimp.model.Subscriber
import com.droidfeed.data.api.mailchimp.model.UserResponse
import retrofit2.Call
import retrofit2.http.Body
import retrofit2.http.POST
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/com/droidfeed/data/repo/NewsletterRepo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.droidfeed.data.repo

import com.droidfeed.data.DataStatus
import com.droidfeed.data.api.mailchimp.ErrorAdapter
import com.droidfeed.data.api.mailchimp.MailchimpError
import com.droidfeed.data.api.mailchimp.Subscriber
import com.droidfeed.data.api.mailchimp.model.MailchimpError
import com.droidfeed.data.api.mailchimp.model.Subscriber
import com.droidfeed.data.api.mailchimp.service.NewsletterService
import com.droidfeed.util.extention.suspendingEnqueue
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
Expand All @@ -28,6 +28,7 @@ class NewsletterRepo @Inject constructor(
try {
val listId = remoteConfig.getString("mc_newsletter_list_id")
newsletterService.addSubscriber(listId, subscriber).suspendingEnqueue()

DataStatus.Successful()
} catch (e: HttpException) {
when (e.code()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ open class ConferenceViewHolder(
itemCard.setOnClickListener {
onItemClick(conference)
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ fun loadImage(
@BindingAdapter("app:displayUrl")
fun displayUrl(
webView: WebView,
url: String
url: String?
) {
webView.loadUrl(url)
url?.let { webView.loadUrl(it) }
}

@BindingAdapter("app:relativeTimestamp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class FeedFragment : BaseFragment("feed"), Scrollable {
.get(FeedViewModel::class.java)

mainViewModel = ViewModelProviders
.of(activity!!)
.of(activity!!, viewModelFactory)
.get(MainViewModel::class.java)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.droidfeed.ui.module.newsletter

import android.util.Log
import android.util.Patterns
import androidx.annotation.StringRes
import androidx.lifecycle.MutableLiveData
import com.droidfeed.BuildConfig
import com.droidfeed.R
import com.droidfeed.data.DataStatus
import com.droidfeed.data.api.mailchimp.ErrorType
import com.droidfeed.data.api.mailchimp.MailchimpError
import com.droidfeed.data.api.mailchimp.Subscriber
import com.droidfeed.data.api.mailchimp.SubscriptionStatus
import com.droidfeed.data.api.mailchimp.model.ErrorType
import com.droidfeed.data.api.mailchimp.model.MailchimpError
import com.droidfeed.data.api.mailchimp.model.Subscriber
import com.droidfeed.data.api.mailchimp.model.SubscriptionStatus
import com.droidfeed.data.repo.NewsletterRepo
import com.droidfeed.ui.common.BaseViewModel
import com.droidfeed.util.AnalyticsUtil
Expand Down Expand Up @@ -74,6 +75,8 @@ class NewsletterViewModel @Inject constructor(
}

private fun handleSignUpResponse(dataStatus: DataStatus<MailchimpError>) {
Log.e("JAMIRYO", "5---- $dataStatus")

when (dataStatus) {
is DataStatus.Successful -> {
isEmailInputVisible.postValue(false)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/droidfeed/util/DebugUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ private const val TAG = "DroidFeed"
*
* @param throwable
*/
fun logThrowable(throwable: Throwable) {
fun logThrowable(throwable: Throwable?) {
if (BuildConfig.DEBUG) {
throwable.printStackTrace()
throwable?.printStackTrace()
} else {
Crashlytics.logException(throwable)
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_newsletter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
android:layout_marginTop="@dimen/spacing_small"
android:layout_marginEnd="@dimen/spacing_xlarge"
android:backgroundTint="@color/colorAccent"
android:onClick="@{(v)->viewModel.signUp(edtEmail.getText().toString)}"
android:onClick="@{(v)->viewModel.signUp(edtEmail.getText().toString())}"
android:text="@string/sign_me_up"
app:isVisible="@{viewModel.isSignButtonVisible}"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
3 changes: 0 additions & 3 deletions app/src/test/java/com/droidfeed/OnBoardViewModelTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import org.junit.runners.JUnit4
import org.mockito.ArgumentMatchers
import org.mockito.Mockito.*


@Suppress("TestFunctionName")
@RunWith(JUnit4::class)
class OnBoardViewModelTest {
Expand Down Expand Up @@ -80,7 +79,6 @@ class OnBoardViewModelTest {
verify(observer).onChanged(false)
}


@Test
fun WHEN_continue_button_is_clicked_THEN_open_main_activity() {
runBlocking {
Expand All @@ -95,5 +93,4 @@ class OnBoardViewModelTest {

verify(observer, only()).onChanged(ArgumentMatchers.any())
}

}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.android.tools.build:gradle:3.3.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$versions.kotlin"
classpath "io.fabric.tools:gradle:$versions.fabric_gradle"
Expand Down
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ext.versions = [
crashlytics : '2.9.9',
detekt_ktlint : '1.0.0-RC14',
firebase_core : '16.0.7',
firebase_config : '16.3.0',
firebase_config : '16.1.3',
firebase_firestore : '18.0.1',
okHttp : '3.13.1',
jSoup : '1.11.3',
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx4096M
android.databinding.enableV2=true
android.enableR8 = true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
Expand Down