// Copyright 2015 Nikola Kovacevic <nikolak@outlook.com>
//
//    Licensed under the Apache License, Version 2.0 (the "License");
//    you may not use this file except in compliance with the License.
//    You may obtain a copy of the License at
//
//        http://www.apache.org/licenses/LICENSE-2.0
//
//    Unless required by applicable law or agreed to in writing, software
//    distributed under the License is distributed on an "AS IS" BASIS,
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//    See the License for the specific language governing permissions and
//    limitations under the License.

package com.nikolak.weatherapp;

public class Utils {

    public static Integer getIconFromValue(String iconValue) {
        Integer icon;
        switch (iconValue) {
            case "clear-day":
                icon = R.drawable.clearday;
                break;
            case "clear-night":
                icon = R.drawable.clearnight;
                break;
            case "rain":
                icon = R.drawable.rain;
                break;
            case "snow":
                icon = R.drawable.snow;
                break;
            case "sleet":
                icon = R.drawable.sleet;
                break;
            case "wind":
                icon = R.drawable.wind;
                break;
            case "fog":
                icon = R.drawable.fog;
                break;
            case "cloudy":
                icon = R.drawable.cloudy;
                break;
            case "partly-cloudy-day":
                icon = R.drawable.partlycloudyday;
                break;
            case "partly-cloudy-night":
                icon = R.drawable.partlycloudynight;
                break;
            default:
                //TODO: Add default icon
                icon = R.drawable.fog;

        }
        return icon;
    }
}

@@ -673,28 +673,257 @@
 p;%0A%0A
-public class Utils %7B
+import android.content.Context;%0Aimport android.location.Address;%0Aimport android.location.Geocoder;%0Aimport android.util.Log;%0A%0Aimport java.io.IOException;%0Aimport java.util.List;%0A%0Apublic class Utils %7B%0A%0A    public static final String TAG = %22UtilsClass%22;
 %0A%0A  
@@ -2130,11 +2130,713 @@
 n;%0A    %7D
+%0A%0A    public static String getCity(Double lat, Double lon, Context context)%7B%0A        Geocoder geocoder = new Geocoder(context);%0A        List%3CAddress%3E address = null;%0A        try %7B%0A            address = geocoder.getFromLocation(%0A                    lat,%0A                    lon,%0A                    1);%0A        %7D catch (IOException e) %7B%0A            Log.e(TAG, lat.toString()+lon.toString());%0A            e.printStackTrace();%0A        %7D%0A%0A        if (address == null %7C%7C address.size() %3C= 0) %7B%0A            Log.w(TAG, %22Could not find a location name%22);%0A            return null;%0A        %7D else %7B%0A            Address finalAddress = address.get(0);%0A            return finalAddress.getLocality();%0A        %7D%0A    %7D
 %0A%7D%0A

Move getCity to utils class