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
/** | |
* Parse a local date time string into a UTC date time object | |
* TODO: update to Java 8 time API https://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html, return java.time.Instant | |
*/ | |
fun String.toDate( | |
dateFormat: String = "yyyy-MM-dd'T'HH:mm:ss", | |
timeZone: TimeZone = TimeZone.getTimeZone("UTC") | |
): Date? { | |
val parser = SimpleDateFormat(dateFormat, Locale.getDefault()) | |
parser.timeZone = timeZone |
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 { | |
`android-base-app` | |
`android-base` | |
id("io.fabric") | |
} | |
android { | |
defaultConfig { | |
versionCode = 20 | |
versionName = "1.6.3" |
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
fun dowloadFile(url: String): Single<Long> { | |
val expectedId: Long = DownloadManager.Request(Uri.parse(builder.apkUrl)).run { downloadManager.enqueue(this) } | |
return downloadReceiver.map { | |
it.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1) | |
}.takeWhile { | |
it == expectedId | |
}.firstOrError().timeout(3, TimeUnit.MINUTES) | |
} |
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
import io.reactivex.Completable | |
import io.reactivex.Flowable | |
object FlowableEx { | |
/** | |
* Create a Flowable by chaining multiple completables and execute them in order. | |
* Note that the completables will be run in sequense. If previous completable fails, the next one will NOT run. | |
* For example: |
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.f3401pal.shb.android.ui; | |
import android.animation.Animator; | |
import android.animation.AnimatorListenerAdapter; | |
import android.animation.AnimatorSet; | |
import android.animation.ObjectAnimator; | |
import android.content.Context; | |
import android.content.res.TypedArray; | |
import android.graphics.Color; | |
import android.graphics.drawable.GradientDrawable; |
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
import android.animation.ValueAnimator; | |
import android.content.Context; | |
import android.graphics.Bitmap; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.LinearGradient; | |
import android.graphics.Paint; | |
import android.graphics.PorterDuff; | |
import android.graphics.PorterDuffXfermode; | |
import android.graphics.RectF; |