Skip to content

Instantly share code, notes, and snippets.

Gabriele Mariotti gabrielemariotti

Block or report user

Report or block gabrielemariotti

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@gabrielemariotti
gabrielemariotti / README.md
Last active Jan 24, 2019
How to manage the firebase libraries in a multi-module projects
View README.md

Centralize the firebase libraries dependencies in gradle

ext {
      firebaseVersion = '9.0.0';

      firebaseDependencies = [
              core :         "com.google.firebase:firebase-core:${firebaseVersion}",
              database :     "com.google.firebase:firebase-database:${firebaseVersion}",
              storage :      "com.google.firebase:firebase-storage:${firebaseVersion}",
@gabrielemariotti
gabrielemariotti / README.md
Last active Aug 26, 2019
How to manage the support libraries in a multi-module projects. Thanks to Fernando Cejas (http://fernandocejas.com/)
View README.md

Centralize the support libraries dependencies in gradle

Working with multi-modules project, it is very useful to centralize the dependencies, especially the support libraries.

A very good way is to separate gradle build files, defining something like:

root
  --gradleScript
  ----dependencies.gradle
View ColoredSnackBar.java
public class ColoredSnackBar {
private static final int red = 0xfff44336;
private static final int green = 0xff4caf50;
private static final int blue = 0xff2195f3;
private static final int orange = 0xffffc107;
private static View getSnackBarLayout(Snackbar snackbar) {
if (snackbar != null) {
@gabrielemariotti
gabrielemariotti / README.md
Last active Sep 4, 2019
A SectionedGridRecyclerViewAdapter: use this class to realize a simple sectioned grid `RecyclerView.Adapter`.
View README.md

You can use this class to realize a simple sectioned grid RecyclerView.Adapter without changing your code.

Screen

The RecyclerView has to use a GridLayoutManager.

This is a porting of the class SimpleSectionedListAdapter provided by Google

If you are looking for a sectioned list RecyclerView.Adapter you can take a look here

@gabrielemariotti
gabrielemariotti / gist:10716d3a7c0089f3c034
Created Jan 14, 2015
How to customize the MaterialLargeImageCard with a own class (requires cardslib 2.1.+)
View gist:10716d3a7c0089f3c034
//Create a Card, set the title over the image and set the thumbnail
CustomMaterialLargeImageCard card = (CustomMaterialLargeImageCard)
CustomMaterialLargeImageCard.with(getActivity())
.setTextOverImage("Italian Beaches "+i)
.setTitle("This is my favorite local beach "+i)
.setSubTitle("A wonderful place")
.useDrawableId(R.drawable.sea)
.setupSupplementalActions(R.layout.carddemo_native_material_supplemental_actions_large, actions)
//It is important to use this build method
.build(new CustomMaterialLargeImageCard(getActivity()));
@gabrielemariotti
gabrielemariotti / MainActivity.java
Last active Aug 27, 2019
How to obtain a CardView (support library) with a Image and rounded corners for API<21
View MainActivity.java
ImageView imageView = (ImageView) findViewById(R.id.card_thumbnail_image);
Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.rose);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
//Default
imageView.setBackgroundResource(R.drawable.rose);
} else {
//RoundCorners
RoundCornersDrawable round = new RoundCornersDrawable(mBitmap,
getResources().getDimension(R.dimen.cardview_default_radius), 0); //or your custom radius
@gabrielemariotti
gabrielemariotti / build.gradle
Created Oct 25, 2014
Gist for cardslib 2.0.0.RC1
View build.gradle
repositories {
mavenCentral()
//snapshot for rc1
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
//Core card library
compile 'com.github.gabrielemariotti.cards:cardslib-core:2.0.0-RC1-SNAPSHOT'
@gabrielemariotti
gabrielemariotti / Readme.md
Last active Dec 22, 2016
UndoBar with Material Design
View Readme.md

These layouts provide a simple undo bar with Material Design.

This gist does not contain any Android L API.

undobar with action undobar mobile
Screen Screen
View HelperUtil.java
public class HelperUtil {
private final HelperUtilImpl mImpl;
public HelperUtil (Context context) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
mImpl = new HelperUtilImplL(context);
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
mImpl = new HelperUtilImplKK(context);
View HelperUtil.java
public class HelperUtil {
public static HelperUtilBase getInstance(Context context) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
return new HelperUtilL(context);
} else if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
return new HelperUtilKK(context);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
return new HelperUtilJB(context);
You can’t perform that action at this time.