Showing posts from September, 2013

Publish an aar file to Maven Central with Gradle

In the last days I tried to publish ChangeLog Lib as aar(Android Archive) to Maven Central.
First of all, I am a newbie in Gradle and Maven.I always used repo as a final user, so there could be better solutions.

My first step was to find an approved repository.
I decided to use the Sonatype OSS Repository, which is an approved repository provided by Sonatype.

1. Register your project at Sonatype
It is easy. You can use the official guide.
You have to follow the 2nd and 3th section.
In this way you can create your user, and your project.

When you create your project, pay attention to groupId. It is very important.
Here you can find a some tips about it.
If you don't own a domain, you can choose a groupId that reflects your project hosting, something like com.github.gabrielemariotti.

You can't use it immediately; Sonatype have to prepare repo and normally it takes 1-2 business days.

Then you can write your gradle scripts to upload aar file.

2. Gradle script maven_push.gradle
I use…

A Card Library

In the last weeks I tried to collect my code and build a Card library.
I wanted something that could realize many types of Card (not all, of course), with some built-in features without having to rewrite each time a lot of code.
I am still developing but a first version is presentable

Card Library provides a custom tag CardView to display a UI Card.

It provides different parts as a Header, a Thumbnail, a Shadow, a MainContentArea where you can inflate your custom layoutYou can customize the global layout as you likeYou can have some built-in features as OnClickListener, OnSwipeListener , OnLongClickListenerCardHeader` provides an overflow button with a PopupMenuListener, a button to expand/collapse an area, or a customizable button with its listener.CardThumbnail` load a Bitmap with a resource ID or with a URL using `LRUCache` and an `AsyncTask`
Create a `Card` is is pretty simple.

First, you need an XML layout that will display the `Card`.

Then create a model:
//Create a Card…

Expand and collapse animation

If you search a simple code to expand and collpse a View with an animation you'll find a lot of example. Almost all of the examples extend Animation class.

Instead I would like to use an Animator and its listeners.

Where I come from they say I'm discovering the hot water. I know, but it might be useful to someone.
Here you can see a short video:

The code is very simple:
We'll use two LinearLayout. .... ..... ..... In our Activity we simply add a OnClickListener to our Header View. public class MainActivity extends Activity { LinearLayout mLinearLayout; LinearLayout mLinearLayoutHeader; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mLinearLayout = (LinearLayout) findViewById(; //set visibility to GONE mLinearLayout.setVisibility(View.GONE); m…