-
Notifications
You must be signed in to change notification settings - Fork 7
kotlin/navigation #90
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
base: feature/kotlin
Are you sure you want to change the base?
Changes from all commits
b14bf1e
83604aa
104e81c
22ecf78
4d46789
115b65e
110e299
c3a1baa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /* | ||
| * Copyright (c) 2019 Touch Instinct | ||
| * | ||
| * This file is part of RoboSwag library. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
|
|
||
| package ru.touchin.roboswag.components.navigation | ||
|
|
||
| import android.app.Application | ||
| import android.content.Context | ||
| import android.os.StrictMode | ||
| import android.util.Log | ||
| import androidx.multidex.MultiDex | ||
| import com.crashlytics.android.Crashlytics | ||
| import io.fabric.sdk.android.Fabric | ||
| import net.danlew.android.joda.JodaTimeAndroid | ||
| import ru.touchin.roboswag.core.log.ConsoleLogProcessor | ||
| import ru.touchin.roboswag.core.log.CrashlyticsLogProcessor | ||
| import ru.touchin.roboswag.core.log.Lc | ||
| import ru.touchin.roboswag.core.log.LcGroup | ||
| import ru.touchin.roboswag.core.log.LcLevel | ||
|
|
||
| /** | ||
| * Base class of application to extends for Touch Instinct related projects. | ||
| */ | ||
| abstract class TouchinApp : Application() { | ||
|
|
||
| companion object { | ||
| private const val CRASHLYTICS_INITIALIZATION_ERROR = "Crashlytics initialization error! Did you forget to add\n" + | ||
| "compile('com.crashlytics.sdk.android:crashlytics:+') {\n" + | ||
| " transitive = true;\n" + | ||
| "}\n" + | ||
| "to your build.gradle?" | ||
| } | ||
|
|
||
| override fun attachBaseContext(base: Context) { | ||
| super.attachBaseContext(base) | ||
| MultiDex.install(base) | ||
| } | ||
|
|
||
| override fun onCreate() { | ||
| super.onCreate() | ||
| JodaTimeAndroid.init(this) | ||
| enableStrictMode() | ||
| initCrashlytics() | ||
| } | ||
|
|
||
| private fun enableStrictMode() { | ||
| if (BuildConfig.DEBUG) { | ||
| StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder() | ||
| .detectAll() | ||
| .permitDiskReads() | ||
| .permitDiskWrites() | ||
| .penaltyLog() | ||
| .build()) | ||
| StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder() | ||
| .detectAll() | ||
| .penaltyLog() | ||
| .build()) | ||
| } | ||
| } | ||
|
|
||
| private fun initCrashlytics() { | ||
| if (BuildConfig.DEBUG) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В отдельный метод |
||
| Lc.initialize(ConsoleLogProcessor(LcLevel.VERBOSE), true) | ||
| LcGroup.UI_LIFECYCLE.disable() | ||
| } else { | ||
| try { | ||
| val crashlytics = Crashlytics() | ||
| Fabric.with(this, crashlytics) | ||
| Fabric.getLogger().logLevel = Log.ERROR | ||
| Lc.initialize(CrashlyticsLogProcessor(crashlytics), false) | ||
| } catch (error: NoClassDefFoundError) { | ||
| Lc.initialize(ConsoleLogProcessor(LcLevel.INFO), false) | ||
| Lc.e(CRASHLYTICS_INITIALIZATION_ERROR, error) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package ru.touchin.roboswag.components.navigation.activities | ||
|
|
||
| interface OnBackPressedListener { | ||
|
|
||
| fun onBackPressed(): Boolean | ||
|
|
||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Пустая строка в конце |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,13 +25,15 @@ abstract class KeyboardResizeableViewController<TActivity : BaseActivity, TState | |
|
|
||
| private var isKeyboardVisible: Boolean = false | ||
|
|
||
| private val keyboardHideListener = OnBackPressedListener { | ||
| if (isKeyboardVisible) { | ||
| UiUtils.OfViews.hideSoftInput(activity) | ||
| true | ||
| } else { | ||
| false | ||
| } | ||
| private val keyboardHideListener = object : OnBackPressedListener { | ||
|
|
||
| override fun onBackPressed(): Boolean = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Совмести 30 и 31 |
||
| if (isKeyboardVisible) { | ||
| UiUtils.OfViews.hideSoftInput(activity) | ||
| true | ||
| } else { | ||
| false | ||
| } | ||
| } | ||
|
|
||
| private var isHideKeyboardOnBackEnabled = false | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package ru.touchin.roboswag.core.log | ||
|
|
||
| import android.util.Log | ||
| import com.crashlytics.android.Crashlytics | ||
| import ru.touchin.roboswag.core.utils.ShouldNotHappenException | ||
|
|
||
| class CrashlyticsLogProcessor(private val crashlytics: Crashlytics) : LogProcessor(LcLevel.INFO) { | ||
|
|
||
| override fun processLogMessage( | ||
| group: LcGroup, | ||
| level: LcLevel, | ||
| tag: String, | ||
| message: String, | ||
| throwable: Throwable? | ||
| ) { | ||
| when { | ||
| group === LcGroup.UI_LIFECYCLE -> { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В одну строку |
||
| crashlytics.core.log(level.priority, tag, message) | ||
| } | ||
| !level.lessThan(LcLevel.ASSERT) && level == LcLevel.ERROR -> { | ||
| Log.e(tag, message) | ||
| if (throwable != null) { | ||
| crashlytics.core.log(level.priority, tag, message) | ||
| crashlytics.core.logException(throwable) | ||
| } else { | ||
| val exceptionToLog = ShouldNotHappenException("$tag:$message") | ||
| reduceStackTrace(exceptionToLog) | ||
| crashlytics.core.logException(exceptionToLog) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun reduceStackTrace(throwable: Throwable) { | ||
| val stackTrace = throwable.stackTrace | ||
| val reducedStackTraceList = arrayListOf<StackTraceElement>() | ||
| for (i in stackTrace.indices.reversed()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. write in kotlin style without for |
||
| val stackTraceElement = stackTrace[i] | ||
| if (stackTraceElement.className.contains(javaClass.simpleName) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Условие внутри if в отдельный метод |
||
| || stackTraceElement.className.contains(LcGroup::class.java.name) | ||
| || stackTraceElement.className.contains(Lc::class.java.name)) { | ||
| break | ||
| } | ||
| reducedStackTraceList.add(0, stackTraceElement) | ||
| } | ||
| throwable.stackTrace = reducedStackTraceList.toTypedArray() | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Добавь пустую строку