A Pen by João Gabriel on CodePen.
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
import android.app.NotificationManager | |
import android.content.Context | |
import android.graphics.BitmapFactory | |
import android.support.v4.app.NotificationCompat | |
import br.com.project.R | |
import br.com.project | |
import com.google.firebase.messaging.FirebaseMessagingService | |
import com.google.firebase.messaging.RemoteMessage | |
import javax.inject.Inject |
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
task switchToDebug(type: Copy) { | |
description = 'Switches to DEBUG google-services.json' | |
from "src/debug" | |
include "google-services.json" | |
into "." | |
} | |
task switchToHomolog(type: Copy) { | |
description = 'Switches to HOMOLOG google-services.json' | |
from "src/homolog" |
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
buildTypes { | |
debug { | |
buildConfigField "String", "SERVER_URL_EXTERNAL", '"URL_DEBUG"' | |
buildConfigField "int", "TRACKER", '0' | |
} | |
homolog { | |
buildConfigField "String", "SERVER_URL_EXTERNAL", '"URL_HOMOLOGAÇÃO"' | |
buildConfigField "int", "TRACKER", '1' | |
signingConfig signingConfigs.homolog |
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
fun <T> Observable<Response<T>>.subscribeTreatment(onNext: (T?) -> Unit, onError: (Throwable) -> Unit): Disposable { | |
return this.subscribe({ | |
if (!it.isSuccessful) { | |
onError(Throwable(it.message(), Throwable())) | |
} else { | |
onNext(it.body()) | |
} | |
}, { | |
when (it) { | |
is UnknownHostException, |
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
import android.os.SystemClock | |
import android.view.View | |
class SafeClickListener( | |
private var defaultInterval: Int = 1500, | |
private val onSafeCLick: (View) -> Unit | |
) : View.OnClickListener { | |
private var lastTimeClicked: Long = 0 | |
override fun onClick(v: View) { |
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
class AnimationUtil { | |
companion object { | |
fun startAnimation(view: View, idAnimation: Int, start: (() -> Unit)? = null , repeat: (() -> Unit)? = null, end: (() -> Unit)? = null) { | |
val anim = AnimationUtils.loadAnimation(Application.context, idAnimation) | |
anim.setAnimationListener(object : Animation.AnimationListener { | |
override fun onAnimationStart(animation: Animation?) { | |
start?.invoke() | |
} |
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
package digital.solutis.base.gamechanger | |
import androidx.arch.core.executor.testing.InstantTaskExecutorRule | |
import androidx.lifecycle.Observer | |
import digital.solutis.gamechanger.model.Service | |
import digital.solutis.gamechanger.model.consulta.LoginConsulta | |
import digital.solutis.gamechanger.model.entidade.Usuario | |
import digital.solutis.gamechanger.viewmodel.LoginViewModel | |
import io.reactivex.Observable | |
import org.junit.Before |
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
fun Long.calculateDisplayTimeStamp(): String { | |
val now = System.currentTimeMillis() / 1000 | |
val diff = now - this | |
val dayInMilli: Long = 23 * 59 * 60 | |
return if (diff < 60) { | |
"Agora" | |
} else if (diff > 60 && diff < 59 * 60) { | |
"${diff / 60} minutos atrás" | |
} else if (diff > 59 * 60 && diff < 23 * 59 * 60) { |
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
class MainViewModel(private val charactersUseCase: GetCharactersUseCase) : ViewModel() { | |
val viewState = ViewState() | |
fun dispatchAction(action: ViewAction) = when (action) { | |
is ViewAction.Init -> getCharacters() | |
is ViewAction.Refresh -> getCharacters() | |
} | |
private fun getCharacters() { |
OlderNewer