Skip to content

Instantly share code, notes, and snippets.

View cpeppas's full-sized avatar

Christos Peppas cpeppas

View GitHub Profile
/*
* Copyright 2016 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
@NikolaDespotoski
NikolaDespotoski / BottomNavigationBehavior.java
Last active December 19, 2022 06:14
Bottom Navigation behavior
/*
* BottomNavigationLayout library for Android
* Copyright (c) 2016. Nikola Despotoski (http://github.com/NikolaDespotoski).
* 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
@tinmegali
tinmegali / CircularFragReveal.java
Last active March 15, 2019 10:28
Add a circular Reveal and Unreveal transition animation to a Android Fragment
import android.animation.Animator;
import android.animation.TimeInterpolator;
import android.annotation.TargetApi;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewAnimationUtils;
@gtomek
gtomek / GetOkHttpCache.java
Last active October 20, 2015 15:43
Get saved OkHttp cache
/**
* Returns response cached by OkHttp.
*
* @param url URL used to make original request
*/
@Nullable
private List<PostModel> getCachedDataIfExist(final String url) {
// OkHttpClient saves cache using DiskLruCache, the cached data is stored in the cache dir in the files
// which names are created by md5 hash function, e.g. for
// http://www.yourserver.com/posts?filter[posts_per_page]=10&page=1
@koesie10
koesie10 / ApiModule.java
Created October 3, 2015 07:40
Retrofit 1 error handling behaviour in Retrofit 2
// Dagger 1 example
@Module(
complete = false,
library = true
)
public final class ApiModule {
@Provides
@Singleton
Retrofit provideRetrofit(Gson gson, Application app) {
return new Retrofit.Builder()
public class MyFragment {
boolean loaded;
private void maybeLoad() {
if (!loaded && getUserVisibleHint()) {
loaded = true;
loadMyData();
}
}
@Override
@ozodrukh
ozodrukh / Fragment.java
Created January 6, 2015 18:23
Fragment Circular Reveal animation
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.AccelerateInterpolator;
@seanKenkeremath
seanKenkeremath / Android Lollipop Widget Tinting Guide
Last active November 17, 2023 12:40
How base colors in Lollipop apply to different UI elements
Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21. To use the support version of these attributes, remove the android namespace. For instance, "android:colorControlNormal" becomes "colorControlNormal". These attributes will be propagated to their corresponding attributes within the android namespace for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix.
All Clickable Views:
-----------
* ripple effect (Lollipop only) -- "colorControlHighlight"
Status Bar:
------------
* background (Lollipop only) - "colorPrimaryDark"
@dlew
dlew / themes-debug.xml
Last active March 1, 2024 15:46
With the new theming in AppCompat, a lot of assets are tinted automatically for you via theme attributes. That has often led me to wonder "where the hell did this color come from?" You can replace your normal theme with this debug theme to help figure out the source of that color.
<!-- You can change the parent around to whatever you normally use -->
<style name="DebugColors" parent="Theme.AppCompat">
<!-- System colors -->
<item name="android:windowBackground">@color/__debugWindowBackground</item>
<item name="android:colorPressedHighlight">#FF4400</item>
<item name="android:colorLongPressedHighlight">#FF0044</item>
<item name="android:colorFocusedHighlight">#44FF00</item>
<item name="android:colorActivatedHighlight">#00FF44</item>
@sddamico
sddamico / build.gradle
Created October 24, 2014 00:37
Rename Android APK's to Something Useful
/* put this in your application's build.gradle after the android {} block
* output is in this format: "<projectName>-<buildType>-v<versionName>-<versionCode>.apk"
* e.g. "materiyolo-debug-v5.0.0-12345.apk"
* also, supports injecting jenkins ci's build number into apk, if available
* e.g. "materiyolo-debug-v5.0.0-12345-b6789.apk"
* you must specify your versionName and versionCode in your build.gradle for this to work
* see: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Manifest-entries */
// change this to whatever your app's name is...
project.archivesBaseName = 'materiyolo'