Skip to main content


Showing posts from 2014

Registering your app in facebook to use SDK in development - Hash key Issue

This should be trivial but sometimes things don't work and for me this was one of the days where multiple things go wrong some from me and others from facebook and android to make a solid challenge. In summary I wanted to implement facebook share in android app, I had the sdk but it wasn't plugged in my app, and to do that you need to follow the facebook get started guide by creating an app and adding the id in the manifest   <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/> now at one step facebook tells you to generate a Hash key as signature for your app.. they tell you to use openSSL utility, that just didn't work with me and generated wrong hash so after research I was able to fix my issues and integration with facebook worked. That day I wrote the below answer to this stack overflow question on this specific issue :

Android RecyclerView - Adding Empty View

So RecyclerView was introduced to replace List view and it's optimized to reuse existing views and so it's faster and more efficient as stated in the documentation: While using it, I faced the issue of missing a useful functionality that is implemented in ListView. that feature is setting an empty view in case there was no records. In ListView it was as simple as this View emptyView = findViewById(; ListView  myList = .... myList.setEmptyView(emptyView); but this method doesn't exist for recycler view so we need a work around until android team fixes this. and here are the screen shots of both list view and recycler view fix List view : Recycler view : here is how I fixed it: here is the content of empty_view, it can be anything. Enjoy.

Developer Productivity tools

This post will serve as a reference for different tools that help the developer to be more productive and make his life easier, most for Java, others are general I'll also list some popular libraries IDEs and Editors VSCode [ ] Notepad ++ [ ] Eclipse [ ] Webstorm [Java script IDE : ] Graphics  online photo editor [ ] 3D design : Blender [ ] Mocking & wire framing invision [ ]  UML tools [ ] Visual Paradigm [ ] Windows tools Tabbed windows explorer [ Clover 3 : ]  Tabbed CMD  [ ConEmu : ] Browsers Extensions: FireFox, Dark reader (dark mode for any website) performance testing JMeter [ ] Sched

Java Validation standard JSR-303

Every application needs to do some validation, and it varies from simple checking on values to complex business rules, like verifying if the user bill has been paid and payment received before we are able to call the print bill API.  So the java people have created a standard for us under the number JSR-303 that creates a pretty nice way to validate our entities. javax.validatio, inside the validation-api.jar, is the API package for this standard. The most popular implementation for that API is Hibernate-validator gradle dependencies : compile 'org.hibernate:hibernate-validator:5.0.1.Final' What mainly is in the validation-api jar are the constraints and the generic interface ConstraintValidator, these are what I'm going to work with here. there are two methods in this interface the one that does the work is the isValid method, this what will be called, and this what we need to implement  if we need a custom validation rule. the standard rules are the fol

Spring 4 and mybatis 3 for data tier

Personally I think Hibernate has its complications and doesn't fit an enterprise SOA applications, It will need a lot of customization that will take the essence of why Hibernate is for. So I prefer to use another framework for SQL databases and it's Mybatis. Mybatis in short is an SQL mapping framework that will handle the conversion from SQL to Java and the other way around. it relies on the concept of SQL maps, which are "originally" xml files that define the mapping between our DAO methods and the queries we execute and describe the results and how they are mapped. example on a simple map : now let's see how to use this query from our java code. first we have to place our xml file in the classpath, in my case I use gradle as build system and the src/main/resources folder is the best choice for me. now in some package I should have an interface that will call this map: [

Spring 4 + Hibernate 4 / Java configuration / rest service example with gradle

In this post I'll explain the required work to create a rest API utilizing both spring and hibernate version 4, and the configuration will be using java configuration classes not XML. I'll use gradle to build and for dependency management, it's way easier than maven and keeps you focused on the application, if you are not familiar with gradle and interested in it see my previous post about it. The first part which is dependency management is covered in gradle post mentioned above. I'll skip to explain each tier of the project and its configurations: As you can see we have 4 tiers: 1) DAO tier / data tier In this tier we configure the datasource and hibernate, I used HSQL in memory db it can be easily substituted with other db engine providing the right dependencies The DaoConfig defines the data source, transaction manager, session factory and  hibernate properties The most important part is the annotations : 1)  @Configuration  : to tell spring th

Gradle : Next-gen build tool introduction

I've been recently reading about maven 3 and from a page to another I read a bit about gradle, and got interested in it, so I want to try it now and see how it feels and works in practice so to get started you need to download gradle from here: then add the path to gradle bin directory to the PATH system variable and go to CMD/shell then run: > gradle if it worked and you got build successful let's move to setup our project structure. a word about gradle first, is that it promises to keep the great conventions Maven provided but with the flexibility ANT  had since Maven can give you a hard time if you need to customize something. it's a convention over configuration, yet flexible. so back to the track, what I want to do in this project is to setup a full spring-mvc rest API server, with multiple tiers (projects) that contains DAOs, Business Entities, Services, and REST tier. o---[ REST ] -- uses --> [Services] -- uses --&g

Using git hub with eclipse (EGit)

UPDATE: the first section talks about dealing with existing local repo I added a new section to clone a repo from the scratch by EGit without using any external tool like Git Bash Section 1 : Working with existing Repo Today I'm going to try EGit to integrate a local and remote repository with eclipse let's start by running eclipse > File > Import : 1 2 3 4 5 6 Then I added a Class called Tester to this project and committed it through git bash ( to test if eclipse will sync if I use git bash) 7 8 9  Until then the project didn't look like it was connected with my local repository, I right-clicked the project in eclipse > Team > share project : 10 11 After I clicked finish the source control icons in eclipse appeared : 12 so eclipse connected well to the local repository without loosing any info as you can see '' is appearing as committed. Now we wi