Skip to content

Instantly share code, notes, and snippets.

gabrielemariotti /
Last active Jan 26, 2016
Snippet: PreferenceActivity , PreferenceFragment and header... Please refer to this blog post
import android.os.Bundle;
import android.preference.PreferenceFragment;
public class GenericPreferenceFragment extends PreferenceFragment {
public void onCreate(Bundle savedInstanceState) {
gabrielemariotti / build.gradle
Last active Dec 24, 2015
Gradle configuration for Card library
View build.gradle
buildscript {
repositories {
dependencies {
classpath ''
apply plugin: 'android'
gabrielemariotti / build.gradle
Last active Apr 29, 2022
Use file which controls which keystore to use to sign the APK with gradle.
View build.gradle
android {
signingConfigs {
buildTypes {
release {
signingConfig signingConfigs.release
gabrielemariotti /
Last active Jan 1, 2016
Cardslib: Simple (raw and ugly) layouts for CardListView.It provides all custom layout for your list and your cards.
public class ListFragment extends Fragment {
//DAO datasource;
//List<Joke> values;
public ListFragment(){}
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.test_fragment_list, container, false);
gabrielemariotti / DismissCardWithSwipeAnimation
Created Feb 20, 2014
Cardslib: A code snippet to dismiss a Card in a listView with a Swipe Animation clicking a button.
View DismissCardWithSwipeAnimation
public class ListBaseFragment extends BaseFragment {
CardListView listView;
CardArrayAdapter mCardArrayAdapter;
int mAnimationTime=1;
private int mDismissAnimationRefCount = 0;
private List<PendingDismissData> mPendingDismisses = new ArrayList<PendingDismissData>();
private int mDownPosition;
gabrielemariotti / ExpandWholeCard
Created Mar 10, 2014
Cardslib: an example to expand cards clicking the whole card in a ListView.
View ExpandWholeCard
public class ExpandWholeCardFragment extends BaseFragment {
public void onActivityCreated(Bundle savedInstanceState) {
gabrielemariotti /
Last active Sep 13, 2020
Floating Action Button (requires Android-L preview)
public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
int size = getResources().getDimensionPixelSize(R.dimen.fab_size);
Outline outline = new Outline();
gabrielemariotti / AndroidManifest.xml
Last active Sep 28, 2017
Android Wear: Heart Rate and Samsung Gear Live. (basic example)
View AndroidManifest.xml
<!-- Declare the permission for body sensor -->
<uses-permission android:name="android.permission.BODY_SENSORS" />
gabrielemariotti /
Created Jul 15, 2014
Android Wear: small gist to get data from Battery
public class BatteryActivity extends Activity {
//UI Elements
private TextView mTextViewLevel;
private TextView mTextViewTemperature;
private TextView mTextViewVoltage;
private TextView mTextViewHealth;
//Battery details
private int level;
gabrielemariotti / mobile-AndroidManifest.xml
Last active Sep 15, 2020
Android Wear: small gist to start an Activity on the mobile handheld from the Android Wear device.
View mobile-AndroidManifest.xml
<service android:name=".ListenerServiceFromWear">
<action android:name="" />