ILog v0.1 is here

ILog is a simple logging library for both Android and JavaSE platforms.

ILog Levels:

  • DEBUG
  • INFO
  • WARN
  • ERROR
  • VERBOSE

ILog Main Features:

  • Works on both Android and JavaSE platforms.
  • File Logging (Text or Html or your own format)
  • Easy tag creation (log.setTag())
  • Enable/Disable Levels (log.getSettings().setLevels(Level.ERROR))
  • Current Method Logging (log.d())

Usage and Samples:

1- Simple

public static class MyView {     ILog log = new ILog();     public void doSomeStuff() {       log.d("doing some stuff");       //... doing stuff      }   }

Result:

2014-06-20 02:53:54   -Debug     MyView   doing some stuff

Notice that didn’t set the tag value, so ILog got the tag from current Class name (MyView).


2- Smart

public static class Utility {   ILog log = new ILog();   public void calculateMiles() {     log.d();     //...calculating   } }

Result:

2014-06-20 03:13:29   -Debug     Utility   [51:com.sample.Utility] calculateMiles()

The result did print the current method (claculateMiles()) and the line number (51) also the class path (com.sample.Utility)


3- Controls

public static class UserProfile {    ILog log = new ILog();    public UserProfile() {     log.getSettings().setLevels(Level.ERROR);     }    public void creatNewUser() {     log.d("creating new user");     //...something went wrong     log.e("couldn't create user profile");    } }

Result:

2014-06-20 03:24:15   -Error     UserProfile   couldn't create user profile

4- File Logging

public static class GpsTracker {    ILog log = new ILog();    public GpsTracker() {       HtmlFileLogger htmlLogger = new HtmlFileLogger();       htmlLogger.createLogFile("/users/logging_directory/");       log.setFileLogger(htmlLogger);     }   public void onPositionChanged(long lng, long lat) {     log.d("longitude " + lng + " ,latitude " + lat);     } }

Result:

2014-06-20 03:38:45 -Debug GpsTracker longitude 110000023 ,latitude 1232444444 2014-06-20 03:38:45 -Debug GpsTracker longitude 110000444 ,latitude 1232444443 2014-06-20 03:38:45 -Debug GpsTracker longitude 110000554 ,latitude 1232444442

log file name:

ILog_2014_06_20__03_38_45_709.html

Snapshot of the html logging fileScreen-Shot-2014-06-20-at-3.38.52-AM

Get the library on Github here https://github.com/MoshDev/ILog

Simple Android Twitter® Feeds Reader

I got interview with a company last week, and they requested me to do a sample code to read Twitter feeds for a user, also search through Twitter.

The problem it was a very busy week since I have full time job as Android Developer.
So you will notice that the app is very simple which contains two main screens only (additionally to Splash screen):

  1. UserFeedsFragment

  2. SearchFragment

its a good sample for beginners to know a good practiced app flow, and how to work with multiple fragments and navigate through them.

and there is a good utility classes i’ve created  to use:

  • AbstractRequest to deal with http request using AQuery (you can derive it to any Http Library).
  • FontChanger to change TextViews typeface on runtime

you can find the code on GitHub herehttps://github.com/MoshDev/TwitterFeedReaderSample

I really appreciate your comments on the code.

 

Here some snapshots of the app

device-2014-06-15-235619-168x300 device-2014-06-15-235635-168x300

ICurl, Simple Java Library Curl Request Generator

You can find the library on Github https://github.com/MoshDev/ICurl

This simple tool will help you generate simple requests for CURL

Sample Java Code:

 ICurl curl=new ICurl("http://www.google.com"); curl.setHeader("country", "jo"); curl.setParameter("user", "moshx"); curl.enableResponseLogging(); curl.enableVerbose(); String curlString = curl.toCurl(); System.out.println(curlString);

The output will be:

<strong> curl -H "country: jo" -d "user=moshx" -i -v -X GET "http://www.google.com"  </strong>

For now it only support:

  • Headers (-H)
  • Parameters (-d)
  • Cookies (-c)
  • Request Method (GET,POST,DELETE,PUT)
  • Verbose logging (-v)
  • Response Logging (-i)

Also the package contains ICurlWrapper class which will help you wrap network libraries like ION and OkHttp but unfortunately I tried to do this withAQuery and ION but both of them doesn’t give access to request parameters.

For more info about CURL please check http://curl.haxx.se/ andhttp://en.wikipedia.org/wiki/CURL