Skip to content

Instantly share code, notes, and snippets.

View almozavr's full-sized avatar

Oleksii Malovanyi almozavr

  • Lviv, UA
View GitHub Profile
@AnderWeb
AnderWeb / Simple setup for item backgrounds pre - post lollipop
Last active January 12, 2024 18:04
Simple setup for item backgrounds pre/post lollipop
AppCompat-v7:21 provides a very useful way of dealing with pressed/focused/activated states maintaining backwards compatibility downto API-7, but there's a small issue (big for some) with the default selectableItemBackground: It uses some PNGs and/or default values for API<21.
The main reason is that android drawable resource definitions (prior API 21) CANNOT use theme attributes at all, so there's no way of making something like:
<shape android:shape="rectangle">
<solid android:color="?attr/colorControlHighlight" />
</shape>
For this, I've put this simple mockup on how to give your app better drawables that the appcompat defaults.
@JakeWharton
JakeWharton / README.md
Last active January 8, 2020 02:13
A special activity which facilitates restarting your application process.
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.Canvas;
@imminent
imminent / ExampleActivity.java
Last active October 23, 2017 07:39
Gist for a modified approach to integrating Palette with Picasso proposed by Jake Wharton for the interim while Picasso doesn't have a supported way to pass meta data along the pipeline. http://jakewharton.com/coercing-picasso-to-play-with-palette/
package your.package;
import android.app.Activity;
import android.os.Bundle;
import android.support.v7.graphics.Palette;
import com.squareup.picasso.Picasso;
import your.package.PaletteTransformation;
import static your.package.PaletteTransformation.PaletteCallback;
@chrisbanes
chrisbanes / SystemUiHelper.java
Last active March 2, 2024 18:57
SystemUiHelper
/*
* Copyright (C) 2014 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
@JakeWharton
JakeWharton / AutoGson.java
Last active November 28, 2021 12:32
A Gson TypeAdapterFactory which allows serialization of @autovalue types. Apache 2 licensed.
import com.google.auto.value.AutoValue;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Marks an {@link AutoValue @AutoValue}-annotated type for proper Gson serialization.
* <p>
@gabrielemariotti
gabrielemariotti / GridActivity.java
Created July 27, 2014 21:38
Android Wear: How to use a simple a GridViewPager with a FragmentGridPagerAdapter.
public class GridActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.grid);
final GridViewPager mGridPager = (GridViewPager) findViewById(R.id.pager);
mGridPager.setAdapter(new SampleGridPagerAdapter(this, getFragmentManager()));
}
@gabrielemariotti
gabrielemariotti / Activity.java
Last active November 27, 2022 09:27
Floating Action Button (requires Android-L preview)
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layoutfab);
//Outline
int size = getResources().getDimensionPixelSize(R.dimen.fab_size);
Outline outline = new Outline();
@staltz
staltz / introrx.md
Last active May 2, 2024 12:31
The introduction to Reactive Programming you've been missing
public class CircularProgressDrawable extends Drawable
implements Animatable {
private static final Interpolator ANGLE_INTERPOLATOR = new LinearInterpolator();
private static final Interpolator SWEEP_INTERPOLATOR = new DecelerateInterpolator();
private static final int ANGLE_ANIMATOR_DURATION = 2000;
private static final int SWEEP_ANIMATOR_DURATION = 600;
private static final int MIN_SWEEP_ANGLE = 30;
private final RectF fBounds = new RectF();