Skip to content

Instantly share code, notes, and snippets.

/**
* Creates a linear gradient with the provided colors
* and angle.
*
* @param colors Colors of gradient
* @param stops Offsets to determine how the colors are dispersed throughout
* the vertical gradient
* @param tileMode Determines the behavior for how the shader is to fill a region outside
* its bounds. Defaults to [TileMode.Clamp] to repeat the edge pixels
* @param angleInDegrees Angle of a gradient in degrees
public class SoftInputAssist {
private View rootView;
private ViewGroup contentContainer;
private ViewTreeObserver viewTreeObserver;
private ViewTreeObserver.OnGlobalLayoutListener listener = () -> possiblyResizeChildOfContent();
private Rect contentAreaOfWindowBounds = new Rect();
private FrameLayout.LayoutParams rootViewLayout;
private int usableHeightPrevious = 0;
public SoftInputAssist(Activity activity) {
@yoyfook
yoyfook / DialogFragment+FullscreenWithCustomStatusBarColor.kt
Created December 25, 2024 06:16 — forked from diegohkd/DialogFragment+FullscreenWithCustomStatusBarColor.kt
Show DialogFragment in full screen with status bar, change status bar background color and update status bar components color depending on background color to make them more readable
...
import androidx.fragment.app.DialogFragment
...
class MyDialogFragmentDialog : DialogFragment() {
...
private val statusBarColorRes = R.color.colorPrimaryDark
private var previousSystemUiVisibility: Int? = null
...
override fun getTheme(): Int = R.style.FullscreenDialog
...
@yoyfook
yoyfook / Demo.java
Created November 14, 2015 10:08 — forked from lovelycateyes/Demo.java
Android load local image to webview
InputStream is;
try {
is = openFileInput(fileName);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[10240];
int count;
while(-1 != (count = is.read(buffer, 0, buffer.length))) {
baos.write(buffer, 0, count);
}