Skip to content

Instantly share code, notes, and snippets.

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);
@gabrielemariotti
gabrielemariotti / MaterialLargeImageCard.java
Created September 2, 2014 17:41
A simple gist to build a MaterialCard with cardslib v2.
//Create a Card, set the title over the image and set the thumbnail
MaterialLargeImageCard card = new MaterialLargeImageCard(getActivity());
card.setTextOverImage("Italian Beaches");
card.setDrawableCardThumbnail(R.drawable.sea);
//Set the title and subtitle in the card
card.setTitle("This is my favorite local beach");
card.setSubTitle("A wonderful place");
// Set supplemental actions
@gabrielemariotti
gabrielemariotti / README.md
Last active August 29, 2015 14:05
Code for Taylor Ling's UI ANIMATION IN PHOTOSHOP – TUTORIAL #1
@gabrielemariotti
gabrielemariotti / Readme.md
Last active June 14, 2018 08:40
SlideInOutLeftDefaultItemAnimator : a simple animator which applies a slide in/out from/to the left animation to item views in the `RecyclerView`

This class provides a simple animator which applies a slide in/out from/to the left animation to item views in the RecyclerView

This code is cloned from DefaultItemAnimator provided by Google, customizing the part highlighted as "Custom implementation".

Example:

   mRecyclerView.setItemAnimator(new SlideInOutLeftDefaultItemAnimator(mRecyclerView));
@gabrielemariotti
gabrielemariotti / Readme.md
Last active March 2, 2024 23:10
A SimpleSectionedRecyclerViewAdapter: use this class to realize a simple sectioned `RecyclerView.Adapter`.

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

The RecyclerView should use a LinearLayoutManager. You can use this code also with the TwoWayView with the ListLayoutManager (https://github.com/lucasr/twoway-view)

This is a porting of the class SimpleSectionedListAdapter provided by Google

Screen

Example:

@gabrielemariotti
gabrielemariotti / MyRecyclerViewAdapter.java
Created August 16, 2014 14:38
RecyclerView and ViewHolder based on viewType
public class MyRecyclerViewAdapter extends RecyclerView.Adapter<MyRecyclerView.MyViewHolder>{
public static class MyViewHolder extends RecyclerView.ViewHolder {
public MyViewHolder(View view) {
super(view);
}
}
@gabrielemariotti
gabrielemariotti / Toolbar.java
Created August 4, 2014 13:22
Android-L: A little example of the new Toolbar view.
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
//Title and subtitle
toolbar.setTitle("MY toolbar");
toolbar.setSubtitle("Subtitle");
//Menu
toolbar.inflateMenu(R.menu.toolbar_menu);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@gabrielemariotti
gabrielemariotti / mobile-AndroidManifest.xml
Last active August 29, 2015 14:04
Android Wear: small gist to start an Activity on the mobile handheld from the Android Wear device using the Teleport library. (https://github.com/Mariuxtheone/Teleport)
<service android:name=".ListenerServiceFromWear">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
@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 / mobile-AndroidManifest.xml
Last active September 15, 2020 11:33
Android Wear: small gist to start an Activity on the mobile handheld from the Android Wear device.
<service android:name=".ListenerServiceFromWear">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>