Skip to content

Instantly share code, notes, and snippets.

@gabrielemariotti
gabrielemariotti / GenericPreferenceFragment.java
Last active Jan 26, 2016
Snippet: PreferenceActivity , PreferenceFragment and header... Please refer to this blog post http://gmariotti.blogspot.it/2013/01/preferenceactivity-preferencefragment.html
View GenericPreferenceFragment.java
package it.gmariotti.android.examples.preference;
import android.os.Bundle;
import android.preference.PreferenceFragment;
public class GenericPreferenceFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
@gabrielemariotti
gabrielemariotti / build.gradle
Last active Dec 24, 2015
Gradle configuration for Card library
View build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
@gabrielemariotti
gabrielemariotti / build.gradle
Last active Apr 29, 2022
Use signing.properties file which controls which keystore to use to sign the APK with gradle.
View build.gradle
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
@gabrielemariotti
gabrielemariotti / ListFragment.java
Last active Jan 1, 2016
Cardslib: Simple (raw and ugly) layouts for CardListView.It provides all custom layout for your list and your cards.
View ListFragment.java
public class ListFragment extends Fragment {
//DAO datasource;
//List<Joke> values;
public ListFragment(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.test_fragment_list, container, false);
@gabrielemariotti
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;
@Override
@gabrielemariotti
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 {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
initCard();
}
@gabrielemariotti
gabrielemariotti / Activity.java
Last active Sep 13, 2020
Floating Action Button (requires Android-L preview)
View Activity.java
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();
@gabrielemariotti
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
gabrielemariotti / BatteryActivity.java
Created Jul 15, 2014
Android Wear: small gist to get data from Battery
View BatteryActivity.java
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
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">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>