This file contains hidden or 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
| private const val SCROLL_DX = 24f | |
| private const val REQUIRED_CARD_COUNT = 8 | |
| private class AutoScrollItem<T>( | |
| val id: String = UUID.randomUUID().toString(), | |
| val data: T | |
| ) | |
| @Composable | |
| fun <T : Any> AutoScrollingLazyRow( |
This file contains hidden or 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
| package com.canopas.nolonely.utils.log | |
| import android.util.Log | |
| import timber.log.Timber | |
| import java.io.ByteArrayOutputStream | |
| import java.io.File | |
| import java.io.FileOutputStream | |
| import java.io.FileWriter | |
| import java.io.IOException | |
| import java.io.RandomAccessFile |
This file contains hidden or 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
| private fun writeLog(logFile: File, log: String) { | |
| val writer = FileWriter(logFile, true) | |
| writer.append(log) | |
| writer.flush() | |
| writer.close() | |
| } |
This file contains hidden or 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
| @Throws(IOException::class) | |
| private fun ensureLogSize(logFile: File) { | |
| if (logFile.length() < maxLogSize) return | |
| // We remove first 25% part of logs | |
| val startIndex = logFile.length() / 4 | |
| val randomAccessFile = RandomAccessFile(logFile, "r") | |
| randomAccessFile.seek(startIndex) |
This file contains hidden or 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
| private fun writeLog(logFile: File, log: String) { | |
| val writer = FileWriter(logFile, true) | |
| writer.append(log) | |
| writer.flush() | |
| writer.close() | |
| } |
This file contains hidden or 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
| private fun getPriorityString(priority: Int): String { | |
| return when (priority) { | |
| Log.VERBOSE -> "VERBOSE" | |
| Log.DEBUG -> "DEBUG" | |
| Log.INFO -> "INFO" | |
| Log.WARN -> "WARN" | |
| Log.ERROR -> "ERROR" | |
| Log.ASSERT -> "ASSERT" | |
| else -> "" | |
| } |
This file contains hidden or 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
| private fun generateLog(priority: Int, tag: String?, message: String): String { | |
| val logTimeStamp = dateFormat.format(Date()) | |
| return StringBuilder().append(logTimeStamp).append(" ") | |
| .append(getPriorityString(priority)).append(": ") | |
| .append(tag).append(" - ") | |
| .append(message).append('\n').toString() | |
| } |
This file contains hidden or 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
| private val maxLogSize = 5 * 1024 * 1024 // 5 MB | |
| private val dateFormat = SimpleDateFormat("yyyy-MM-dd hh:mm:ss:SSS", Locale.US) | |
| override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { | |
| if (priority >= Log.DEBUG) { | |
| val log = generateLog(priority, tag, message) | |
| if (!logFile.exists()) { | |
| logFile.createNewFile() | |
| } | |
| writeLog(logFile, log) |
This file contains hidden or 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
| override fun onCreate() { | |
| super<Application>.onCreate() | |
| Timber.plant(CrashlyticsLogTree(FirebaseCrashlytics.getInstance())) | |
| } |
This file contains hidden or 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
| plugins { | |
| ... | |
| id 'com.google.firebase.crashlytics' | |
| } | |
| dependencies { | |
| ... | |
| implementation 'com.google.firebase:firebase-crashlytics-ktx' | |
| implementation "com.jakewharton.timber:timber:5.0.1" | |
| } |
NewerOlder