Month: October 2014

Java Gradle Template

2014-10-17 Gradle, Java No comments

Some time ago, I had some troubles with configuring Java project with Gradle in IntelliJ IDEA CE. There is possibility to create new Gradle project in mentioned IDE, but for some reason it didn’t worked out-of-the box in my case on Ubuntu. I wanted to have pure, clean Java project with Gradle build system ready to open in IntelliJ IDEA. I found well configured simple project at: https://github.com/quinnliu/SampleGradleProject. Basing on that project, I created my simple template. I modified this project a little bit, added FEST assertions and wrote a few Unit Tests. In addition, I configured main class in build.gradle file in order to execute it via ./gradlew run command. My project template also has gradle wrapper, which is very convenient practice.

You can find my project template at: https://github.com/pwittchen/java-gradle-template
If you want to compile project, run the following command: ./gradlew clean build
If you want to start tests, run the following command: ./gradlew test
Actually build command will run tests as well.
If you want to run application, use the following command: ./gradlew run.
You can also run application, tests or start compilation from the IntelliJ IDEA IDE.

I hope, you will find that template useful and handy.

Square is advocating against Android fragments

2014-10-12 Android No comments

Recently, Square engineers confirmed my doubts I always had about fragments. I definitely knew that something was wrong with them, but Google introduced fragments into Android API, so I thought it must be okay for some reason and I tried to live with them feeling pain. Finally, concrete company have written an article criticizing Android Fragments and I totally agree with them. Read the article at:
http://corner.squareup.com/2014/10/advocating-against-android-fragments.html.

The Future of Programming

2014-10-12 Software Development, Video Talks No comments

I highly recommend you to watch a short lecture presented by Bret Victor at Dropbox’s DBX conference on July 9, 2013. It really broadens the mind.

Bret Victor – The Future of Programming from Bret Victor on Vimeo.

References: http://worrydream.com/dbx/

Different build config for debug and release version of the Android app

2014-10-08 Android, Gradle No comments

Sometimes we may want to set different address of the back-end web service for debuggable and release version of our Android app. E.g. predefined static host and port for release version of the application and our local IP address and predefined port for debuggable version of the application. In second case, we can deploy back-end webservice on our local machine for testing purposes. We can customize all of that in build.gradle file. We can use variant.buildType.isDebuggable() instruction to check build type of the app. I described way of Updating Android XML resources before compilation via Gradle in one of my previous posts, so you can check it if you don’t understand replaceBackendAddressInResources(variant, host, port) method. After proper configuration, setting of the back-end url is straightforward. Please check the code between // configuration of the back-end address - begin
and // configuration of the back-end address - end comments.

Now, you can create release and debug version of the app with different addresses of the web service what is very useful during the process of development and deployment of the project. We can use this trick also for setting different parameters depending on our needs.

Weather Icons for Android applications

2014-10-02 Android, Design No comments

Some time ago I found Weather Icons project by Erik Flowers. It’s customized font with appropriate CSS, which allows you to use weather icons on the website. In addition, those icons can be customized. They can have different size or color. Moreover, they are compatible with the Bootstrap.

687474703a2f2f7765732e696f2f57654d352f707265766965772e706e67

I thought, that it would be nice, if I had something like that for Android applications. That’s why I created simple open-source project called Weather Icon View. It’s customized view for Android, which allows you to use weather icons in mobile apps in similar way as in web apps. When you add mentioned library to your project, you can use it in XML layout in the following way:

You can also use it programmatically as it’s presented below.

Icons reference can be found at: http://erikflowers.github.io/weather-icons/.
For more details visit: https://github.com/pwittchen/WeatherIconView.