Skip to content

Instantly share code, notes, and snippets.

View XinyueZ's full-sized avatar
🙊
Make sense, don't touch

ChrisDEV XinyueZ

🙊
Make sense, don't touch
View GitHub Profile
@XinyueZ
XinyueZ / CoroutineTestRule.kt
Created October 16, 2019 22:18 — forked from AniketSK/CoroutineTestRule.kt
A test rule to allow testing coroutines that use the main dispatcher. Without this you'd run into "java.lang.IllegalStateException: Module with the Main dispatcher had failed to initialize. For tests Dispatchers.setMain from kotlinx-coroutines-test module can be used"
package com.aniketkadam.sharevideoshortcut
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
import org.junit.rules.TestRule
import org.junit.runner.Description
import org.junit.runners.model.Statement
@XinyueZ
XinyueZ / DetailViewModel.kt
Created September 13, 2018 07:44 — forked from chrisbanes/ScopedViewModel.kt
ScopedViewModel
class DetailViewModel : ScopedViewModel() {
fun startTask() {
launch {
// Switch the 'background' thread
withContext(Dispatchers.Default) {
// do your long-running thing
}
// We're now back on the Android's Main thread
updateUi()
@XinyueZ
XinyueZ / Animators.kt
Created July 2, 2018 12:49 — forked from chrisbanes/Animators.kt
Material Image Loading treatment for Android
/*
* Copyright 2018 Google, Inc.
*
* 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
/*
* Copyright (C) 2013 Square, Inc.
*
* 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
/*
* Copyright 2014 Google Inc.
*
* 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
public VideoFrameExtractor(Context context, String path, TextureView textureView) {
mVideoPath = path;
mTextureView = textureView;
textureView.setSurfaceTextureListener(this);
textureView.setTranslationX(-1920);
if (textureView.isAvailable()) {
initPlayer(textureView.getSurfaceTexture());
}
package android.support.v7.app;
import android.support.v7.appcompat.R;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.os.Build;