// Path: WhatAndroid/src/main/java/what/whatandroid/WhatApplication.java
// public class WhatApplication extends Application {
// 
// 	//TODO: Developers put your local Gazelle install IP here instead of testing on the live site
// 	//I recommend setting up with Vagrant: https://github.com/dr4g0nnn/VagrantGazelle
// 	public static final String DEFAULT_SITE = "";
// 
// 	@Override
// 	public void onCreate() {
// 		super.onCreate();
// 
// 		initSoup(DEFAULT_SITE);
// 		if (SettingsActivity.lightThemeEnabled(getApplicationContext())) {
// 			AppCompatDelegate.setDefaultNightMode(
// 					AppCompatDelegate.MODE_NIGHT_NO);
// 		} else {
// 			AppCompatDelegate.setDefaultNightMode(
// 					AppCompatDelegate.MODE_NIGHT_YES);
// 		}
// 	}
// 
// 	/**
// 	 * Initialize MySoup so that we can start making API requests
// 	 */
// 	public void initSoup(String site) {
// 		MySoup.setSite(site, true);
// 		MySoup.setUserAgent("WhatAndroid Android");
// 	}
// 
// 	/**
// 	 * Main method for all image displaying operations
// 	 * Fail tracking is done here instead of wherever this method is called from.
// 	 */
// 
// 	public static void loadImage(Context context, final String url, final ImageView imageView, final ProgressBar spinner, final ImageLoadFailTracker failTracker, final Integer failImage) {
// 
// 		if (failTracker != null && failTracker.failed(url)) {
// 			if (spinner != null) spinner.setVisibility(View.GONE);
// 			if (failImage != null) {
// 				imageView.setImageResource(failImage);
// 			} else {
// 				imageView.setImageResource(R.drawable.no_artwork);
// 			}
// 		} else {
// 			if (spinner != null) spinner.setVisibility(View.VISIBLE);
// 			Glide.with(context)
// 					.load(url)
// 					.listener(new RequestListener<String, GlideDrawable>() {
// 						@Override
// 						public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
// 							if (spinner != null) {
// 								spinner.setVisibility(View.GONE);
// 							}
// 							if (failTracker != null) {
// 								failTracker.addFailed(url);
// 							}
// 							if (failImage != null) {
// 								imageView.setImageResource(failImage);
// 							} else {
// 								imageView.setImageResource(R.drawable.no_artwork);
// 							}
// 							return true;
// 						}
// 
// 						@Override
// 						public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
// 							if (spinner != null) {
// 								spinner.setVisibility(View.GONE);
// 							}
// //                            imageView.setImageDrawable(resource);
// 							return false;
// 						}
// 					})
// 					.into(imageView);
// 		}
// 
// 	}
// 
// }
// 
// Path: WhatAndroid/src/main/java/what/whatandroid/callbacks/ViewArtistCallbacks.java
// public interface ViewArtistCallbacks {
// 	/**
// 	 * Launch an artists activity viewing the artist
// 	 *
// 	 * @param id artist id to view
// 	 */
// 	public void viewArtist(int id);
// }


import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import java.util.List;
import api.torrents.torrents.Artist;
import api.torrents.torrents.EditionTorrents;
import api.torrents.torrents.MusicInfo;
import api.torrents.torrents.TorrentGroup;
import what.whatandroid.R;
import what.whatandroid.WhatApplication;
import what.whatandroid.callbacks.LoadingListener;
import what.whatandroid.callbacks.SetTitleCallback;
import what.whatandroid.callbacks.ViewArtistCallbacks;
import what.whatandroid.settings.SettingsActivity;
import what.whatandroid.views.ImageDialog;

	/**
	 * When the image in the header is clicked toggle expand/hide on it
	 */
	@Override
	public void onClick(View v) {
		if (group != null) {
			if (v.getId() == R.id.image) {
				ImageDialog dialog = ImageDialog.newInstance(group.getResponse().getGroup().getWikiImage());
				dialog.show(getChildFragmentManager(), "image_dialog");
			} else if (v.getId() == R.id.artist_a) {
				viewArtist.viewArtist(group.getResponse().getGroup().getMusicInfo().getArtists().get(0).getId().intValue());
			} else if (v.getId() == R.id.artist_b) {
				viewArtist.viewArtist(group.getResponse().getGroup().getMusicInfo().getArtists().get(1).getId().intValue());
			}
		}
	}

	/**
	 * Update all the torrent group information being shown
	 */
	public void populateViews() {
		List<EditionTorrents> editions = group.getEditions();
		setTitle.setTitle(group.getResponse().getGroup().getName());

		String imgUrl = group.getResponse().getGroup().getWikiImage();
		if (!SettingsActivity.imagesEnabled(getActivity())) {
			artContainer.setVisibility(View.GONE);
		} else {
			artContainer.setVisibility(View.VISIBLE);
// Path: WhatAndroid/src/main/java/what/whatandroid/WhatApplication.java
// public class WhatApplication extends Application {
// 
// 	//TODO: Developers put your local Gazelle install IP here instead of testing on the live site
// 	//I recommend setting up with Vagrant: https://github.com/dr4g0nnn/VagrantGazelle
// 	public static final String DEFAULT_SITE = "";
// 
// 	@Override
// 	public void onCreate() {
// 		super.onCreate();
// 
// 		initSoup(DEFAULT_SITE);
// 		if (SettingsActivity.lightThemeEnabled(getApplicationContext())) {
// 			AppCompatDelegate.setDefaultNightMode(
// 					AppCompatDelegate.MODE_NIGHT_NO);
// 		} else {
// 			AppCompatDelegate.setDefaultNightMode(
// 					AppCompatDelegate.MODE_NIGHT_YES);
// 		}
// 	}
// 
// 	/**
// 	 * Initialize MySoup so that we can start making API requests
// 	 */
// 	public void initSoup(String site) {
// 		MySoup.setSite(site, true);
// 		MySoup.setUserAgent("WhatAndroid Android");
// 	}
// 
// 	/**
// 	 * Main method for all image displaying operations
// 	 * Fail tracking is done here instead of wherever this method is called from.
// 	 */
// 
// 	public static void loadImage(Context context, final String url, final ImageView imageView, final ProgressBar spinner, final ImageLoadFailTracker failTracker, final Integer failImage) {
// 
// 		if (failTracker != null && failTracker.failed(url)) {
// 			if (spinner != null) spinner.setVisibility(View.GONE);
// 			if (failImage != null) {
// 				imageView.setImageResource(failImage);
// 			} else {
// 				imageView.setImageResource(R.drawable.no_artwork);
// 			}
// 		} else {
// 			if (spinner != null) spinner.setVisibility(View.VISIBLE);
// 			Glide.with(context)
// 					.load(url)
// 					.listener(new RequestListener<String, GlideDrawable>() {
// 						@Override
// 						public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
// 							if (spinner != null) {
// 								spinner.setVisibility(View.GONE);
// 							}
// 							if (failTracker != null) {
// 								failTracker.addFailed(url);
// 							}
// 							if (failImage != null) {
// 								imageView.setImageResource(failImage);
// 							} else {
// 								imageView.setImageResource(R.drawable.no_artwork);
// 							}
// 							return true;
// 						}
// 
// 						@Override
// 						public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
// 							if (spinner != null) {
// 								spinner.setVisibility(View.GONE);
// 							}
// //                            imageView.setImageDrawable(resource);
// 							return false;
// 						}
// 					})
// 					.into(imageView);
// 		}
// 
// 	}
// 
// }
// 
// Path: WhatAndroid/src/main/java/what/whatandroid/callbacks/ViewArtistCallbacks.java
// public interface ViewArtistCallbacks {
// 	/**
// 	 * Launch an artists activity viewing the artist
// 	 *
// 	 * @param id artist id to view
// 	 */
// 	public void viewArtist(int id);
// }


// Path: WhatAndroid/src/main/java/what/whatandroid/torrentgroup/group/TorrentGroupOverviewFragment.java
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import java.util.List;
import api.torrents.torrents.Artist;
import api.torrents.torrents.EditionTorrents;
import api.torrents.torrents.MusicInfo;
import api.torrents.torrents.TorrentGroup;
import what.whatandroid.R;
import what.whatandroid.WhatApplication;
import what.whatandroid.callbacks.LoadingListener;
import what.whatandroid.callbacks.SetTitleCallback;
import what.whatandroid.callbacks.ViewArtistCallbacks;
import what.whatandroid.settings.SettingsActivity;
import what.whatandroid.views.ImageDialog;


	/**
	 * When the image in the header is clicked toggle expand/hide on it
	 */
	@Override
	public void onClick(View v) {
		if (group != null) {
			if (v.getId() == R.id.image) {
				ImageDialog dialog = ImageDialog.newInstance(group.getResponse().getGroup().getWikiImage());
				dialog.show(getChildFragmentManager(), "image_dialog");
			} else if (v.getId() == R.id.artist_a) {
				viewArtist.viewArtist(group.getResponse().getGroup().getMusicInfo().getArtists().get(0).getId().intValue());
			} else if (v.getId() == R.id.artist_b) {
				viewArtist.viewArtist(group.getResponse().getGroup().getMusicInfo().getArtists().get(1).getId().intValue());
			}
		}
	}

	/**
	 * Update all the torrent group information being shown
	 */
	public void populateViews() {
		List<EditionTorrents> editions = group.getEditions();
		setTitle.setTitle(group.getResponse().getGroup().getName());

		String imgUrl = group.getResponse().getGroup().getWikiImage();
		if (!SettingsActivity.imagesEnabled(getActivity())) {
			artContainer.setVisibility(View.GONE);
		} else {
			artContainer.setVisibility(View.VISIBLE);
			WhatApplication.loadImage(getActivity(), imgUrl, image, spinner, null, null);