This is an old way to Upload an Image from camera or gallery in WebView. It was made a long time ago and is not maintened anymore. Use it at your own risk.
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
@Composable | |
fun TweetList(state: TweetListState) { | |
val context = LocalContext.current | |
val listState = rememberLazyListState() | |
val exoPlayer = remember { | |
SimpleExoPlayer.Builder(context).build().apply { | |
repeatMode = Player.REPEAT_MODE_ALL | |
} | |
} |
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 View.focusAndShowKeyboard(tryAgain: Boolean = true) { | |
/** | |
* This is to be called when the window already has focus. | |
*/ | |
fun View.showTheKeyboardNow() { | |
if (isFocused) { | |
post { | |
// We still post the call, just in case we are being notified of the windows focus | |
// but InputMethodManager didn't get properly setup yet. | |
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager |
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
class LifecycleGroup(val lifecycleOwner: LifecycleOwner) { | |
/** | |
* Recommended for the majority of use cases | |
* The crucial difference from [collect] is that when the original flow emits a new value, [block] for previous | |
* value is cancelled. | |
**/ | |
inline fun <T> Flow<T>.collectLatestWhenStarted(crossinline block: suspend (T) -> Unit): Job { | |
return lifecycleOwner.lifecycleScope.launchWhenStarted { | |
[email protected] { | |
block(it) |
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.exmaple | |
import android.graphics.* | |
import com.github.mikephil.charting.animation.ChartAnimator | |
import com.github.mikephil.charting.interfaces.dataprovider.BarDataProvider | |
import com.github.mikephil.charting.interfaces.datasets.IBarDataSet | |
import com.github.mikephil.charting.renderer.BarChartRenderer | |
import com.github.mikephil.charting.utils.Utils | |
import com.github.mikephil.charting.utils.ViewPortHandler |
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
// Take photo from camera and save it to public gallery | |
// Before Q and After Q implementations | |
// Answer riginally taken from this SO answer | |
// https://stackoverflow.com/a/59482148/5695091 | |
private val REQUEST_TAKE_PHOTO = 101 | |
private val REQUEST_PICK_PHOTO = 102 | |
private var photoURI : Uri? = null | |
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
// IMPORTANT! READ THIS FIRST | |
// Assisted Injection doesn't work with @HiltViewModel or @ViewModelInject | |
// Read more about the issue here: https://github.com/google/dagger/issues/2287 | |
// | |
// | |
// AssistedInject and Hilt working together in v2.28-alpha times | |
// Example of a ViewModel using AssistedInject injected in a Fragment by Hilt | |
// As AssistedInject isn't part of Dagger yet, we cannot use in | |
// conjuction with @ViewModelInject |
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.support.v7.widget.RecyclerView | |
import android.view.View | |
interface OnItemClickListener { | |
fun onItemClicked(position: Int, view: View) | |
} | |
fun RecyclerView.addOnItemClickListener(onClickListener: OnItemClickListener) { | |
this.addOnChildAttachStateChangeListener(object: RecyclerView.OnChildAttachStateChangeListener { | |
override fun onChildViewDetachedFromWindow(view: View?) { |
NewerOlder