Use context.getContext instead of getActivity and get rid of potential NPE.
Also fix few style issues.