// Path: amaroKontrol_wear/mobile/src/main/java/com/mv2studio/amarok/kontrol/helpers/CommonHelper.java
// public class CommonHelper {
// 	
// 	public static boolean isOnline(Context context) {
// 		ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// 		NetworkInfo netInfo = cm.getActiveNetworkInfo();
// 		return (netInfo != null && netInfo.isConnectedOrConnecting());
// 	}
// 	
// 	public static boolean isWifiConnected(Context context) {
// 		ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// 		return cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected();
// 	}
// 
// 	public static String getStringFromHttp(String url) {
//         OkHttpClient client = new OkHttpClient();
//         Request request = new Request.Builder().url(url).build();
// 
//         try {
//             Response response = client.newCall(request).execute();
//             return response.body().string();
//         } catch (IOException e) {
//             return "";
//         }
// 	}
// 
//     /**
//      * Returns screen width and height in array
//      * @param context
//      * @return
//      */
//     public static int[] getScreenSize(Context context) {
//         WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
//         Display display = wm.getDefaultDisplay();
//         Point size = new Point();
//         display.getSize(size);
//         return new int[]{size.x, size.y};
// 
//     }
// 
//     public static boolean isServiceRunning(Class<?> serviceClass) {
//         ActivityManager manager = (ActivityManager) App.getInstance().getSystemService(Context.ACTIVITY_SERVICE);
//         for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
//             if (serviceClass.getName().equals(service.service.getClassName())) {
//                 return true;
//             }
//         }
//         return false;
//     }
// }
// 
// Path: amaroKontrol_wear/mobile/src/main/java/com/mv2studio/amarok/kontrol/tasks/GetCollectionPhotosTask.java
// public static class CommunicationException extends Exception {
// 
// 	private static final long serialVersionUID = 1L;
// 
// }


import android.content.Context;
import com.mv2studio.amarok.kontrol.helpers.CommonHelper;
import com.mv2studio.amarok.kontrol.tasks.GetCollectionPhotosTask.CommunicationException;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
package com.mv2studio.amarok.kontrol.photosbrowser;





public class LastFmParser {

	private String artist;
	private String apiKey = "2b4245fbf37ec558fcd0c688725f2134";
	private Context context;
	
	public LastFmParser(String artist, Context context) {
		this.context = context;
        this.artist = artist;
	}
	
	public String getLink() throws CommunicationException {
		String json = getJSON();

		if(json.isEmpty()) return null;
		
		try {
			JSONObject mainObj = new JSONObject(json);
// Path: amaroKontrol_wear/mobile/src/main/java/com/mv2studio/amarok/kontrol/helpers/CommonHelper.java
// public class CommonHelper {
// 	
// 	public static boolean isOnline(Context context) {
// 		ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// 		NetworkInfo netInfo = cm.getActiveNetworkInfo();
// 		return (netInfo != null && netInfo.isConnectedOrConnecting());
// 	}
// 	
// 	public static boolean isWifiConnected(Context context) {
// 		ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
// 		return cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected();
// 	}
// 
// 	public static String getStringFromHttp(String url) {
//         OkHttpClient client = new OkHttpClient();
//         Request request = new Request.Builder().url(url).build();
// 
//         try {
//             Response response = client.newCall(request).execute();
//             return response.body().string();
//         } catch (IOException e) {
//             return "";
//         }
// 	}
// 
//     /**
//      * Returns screen width and height in array
//      * @param context
//      * @return
//      */
//     public static int[] getScreenSize(Context context) {
//         WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
//         Display display = wm.getDefaultDisplay();
//         Point size = new Point();
//         display.getSize(size);
//         return new int[]{size.x, size.y};
// 
//     }
// 
//     public static boolean isServiceRunning(Class<?> serviceClass) {
//         ActivityManager manager = (ActivityManager) App.getInstance().getSystemService(Context.ACTIVITY_SERVICE);
//         for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
//             if (serviceClass.getName().equals(service.service.getClassName())) {
//                 return true;
//             }
//         }
//         return false;
//     }
// }
// 
// Path: amaroKontrol_wear/mobile/src/main/java/com/mv2studio/amarok/kontrol/tasks/GetCollectionPhotosTask.java
// public static class CommunicationException extends Exception {
// 
// 	private static final long serialVersionUID = 1L;
// 
// }


// Path: amaroKontrol_wear/mobile/src/main/java/com/mv2studio/amarok/kontrol/photosbrowser/LastFmParser.java
import android.content.Context;
import com.mv2studio.amarok.kontrol.helpers.CommonHelper;
import com.mv2studio.amarok.kontrol.tasks.GetCollectionPhotosTask.CommunicationException;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

package com.mv2studio.amarok.kontrol.photosbrowser;





public class LastFmParser {

	private String artist;
	private String apiKey = "2b4245fbf37ec558fcd0c688725f2134";
	private Context context;
	
	public LastFmParser(String artist, Context context) {
		this.context = context;
        this.artist = artist;
	}
	
	public String getLink() throws CommunicationException {
		String json = getJSON();

		if(json.isEmpty()) return null;
		
		try {
			JSONObject mainObj = new JSONObject(json);
			JSONArray pictsArray = mainObj.getJSONObject("artist").getJSONArray("image");