Skip to content

Instantly share code, notes, and snippets.

View Flywith24's full-sized avatar
🎯
Focusing

Flywith24 Flywith24

🎯
Focusing
View GitHub Profile
@Flywith24
Flywith24 / Framework
Last active July 1, 2020 11:37
Framework 层常用定制功能 Gist
这里记录了 Framework 定制的常用方法
@Flywith24
Flywith24 / SmsCode
Created February 27, 2020 05:45
kotlin协程验证码倒计时
viewLifecycleOwner.lifecycleScope.launch {
send.isEnabled = false
for (i in 60 downTo 1) {
send.text = getString(R.string.login_resend, i)
delay(1000)
}
send.isEnabled = true
send.text = getString(R.string.login_send_code)
}
@Flywith24
Flywith24 / Event.kt
Created February 27, 2020 05:26
LiveData粘性事件包装
package com.whdx.library_login.bean
/**
* @author yyz (杨云召)
* @date 2020/2/27
* time 11:34
* description
* Used as a wrapper for data that is exposed via a LiveData that represents an event.
*/
@Flywith24
Flywith24 / DataBindingListAdapter.kt
Last active February 27, 2020 06:00
DataBindingAdapter基类
/*
* Copyright (C) 2017 The Android Open Source Project
*
* 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
@Flywith24
Flywith24 / ForegroundAppUtil.kt
Created February 15, 2020 06:09
获取栈顶应用
package cn.whdx.mdm.utils
import android.app.usage.UsageStats
import android.app.usage.UsageStatsManager
import android.content.Context
import android.text.TextUtils
import cn.bcbook.baselibrary.utils.LogUtil
/**
* @author yyz (杨云召)
@Flywith24
Flywith24 / RealCall.execute.kt
Last active February 5, 2020 09:07
[okhttp-RealCall] RealCall #okhttp #RealCall
/**
* 请求前校验逻辑,仅能执行一次,和过期时间逻辑判断逻辑
* 通知请求start事件,便于metrics 指标数据收集
* 将call加入分发器的同步请求队列中
* 通过拦截器责任链模式进行请求和返回一系列逻辑处理
*/
override fun execute(): Response {
// 检查是否已经执行
synchronized(this) {
check(!executed) { "Already Executed" }