// Path: lampshade/src/main/java/eu/prismsw/lampshade/BaseActivity.java
// public class BaseActivity extends FragmentActivity {
// 	TropesApplication application;
// 	
// 	@Override
// 	public void onCreate(Bundle savedInstanceState) {
//         this.application = (TropesApplication) getApplication(); 
//         this.switchTheme();
// 		
// 		super.onCreate(savedInstanceState);
// 	}
// 	
// 	public void switchTheme() {
// 		String theme = getThemeName();
// 		
// 		if(theme.equalsIgnoreCase("HoloDark")) {
// 			setTheme(R.style.LampshadeDark);
// 		}
//         else if(theme.equalsIgnoreCase("HoloDarkActionBar")) {
//             setTheme(R.style.LampshadeLightDarkActionBar);
//         }
// 	}
// 
//     public Boolean isDarkActionBar() {
//         Boolean darkAB = false;
//         darkAB = getThemeName().contains("Dark");
// 
//         return darkAB;
//     }
// 
//     public Boolean isDarkTheme() {
//         Boolean isDark = false;
//         isDark = getThemeName().equalsIgnoreCase("HoloDark");
// 
//         return isDark;
//     }
// 
//     public String getThemeName() {
//         SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
//         String theme = preferences.getString("preference_theme", "HoloLight");
//         return theme;
//     }
// 
// 	public void showDialogFragment(DialogFragment fragment) {
// 		FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
// 	    Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
// 	    if (prev != null) {
// 	        ft.remove(prev);
// 	    }
// 	    ft.addToBackStack(null);
// 
// 	    fragment.show(ft, "dialog");
// 	}
// 
//     public boolean isTablet() {
//         boolean xlarge = ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE);
//         boolean large = ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
//         return (xlarge || large);
//     }
// 
//     public void loadPage(Uri url) {
//         if(TropesHelper.isTropesLink(url)) {
//             String page = TropesHelper.titleFromUrl(url);
// 
//             if(TropesHelper.isIndex(page)) {
//                 loadIndex(url);
//             }
//             else {
//                 loadArticle(url);
//             }
//         }
//         else {
//             loadWebsite(url);
//         }
//     }
// 
//     /** Opens a page as an article, and only as an article **/
//     public void loadArticle(Uri url) {
//         Intent articleIntent = new Intent(getApplicationContext(), ArticleActivity.class);
//         articleIntent.putExtra(TropesApplication.loadAsArticle, true);
//         articleIntent.setData(url);
//         articleIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//         startActivity(articleIntent);
//     }
// 
//     public void loadIndex(Uri url) {
//         Intent indexIntent = new Intent(getApplicationContext(), ArticleActivity.class);
//         indexIntent.setData(url);
//         indexIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//         startActivity(indexIntent);
//     }
// 
//     public void loadWebsite(Uri url) {
//         Intent websiteIntent = new Intent(Intent.ACTION_VIEW);
//         websiteIntent.setData(url);
//         websiteIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//         startActivity(websiteIntent);
//     }
// 
// }


import android.net.Uri;
import android.os.Bundle;
import android.view.*;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.ShareActionProvider;
import com.koushikdutta.async.future.Future;
import com.koushikdutta.async.future.FutureCallback;
import com.koushikdutta.ion.Ion;
import com.koushikdutta.ion.Response;
import eu.prismsw.lampshade.BaseActivity;
import eu.prismsw.lampshade.R;
import eu.prismsw.tropeswrapper.*;
package eu.prismsw.lampshade.fragments;


public class IndexFragment extends TropesFragment {
	
	public static IndexFragment newInstance(Uri url) {
		IndexFragment f = new IndexFragment();
		Bundle bundle = new Bundle(2);
		bundle.putParcelable(PASSED_URL, url);
		bundle.putParcelable(TRUE_URL, url);
		f.setArguments(bundle);
		return f;
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle bundle) {
		return inflater.inflate(R.layout.index_fragment, group, false);
	}
	
    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.tropes_fragment_menu, menu);
        inflater.inflate(R.menu.index_fragment_menu, menu);

        MenuItem shareItem = menu.findItem(R.id.share_article);
        shareProvider = (ShareActionProvider) shareItem.getActionProvider();
    }
	
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(!loadingIsFinished()) {
            return true;
        }
        else if (item.getItemId() == R.id.index_as_article) {
// Path: lampshade/src/main/java/eu/prismsw/lampshade/BaseActivity.java
// public class BaseActivity extends FragmentActivity {
// 	TropesApplication application;
// 	
// 	@Override
// 	public void onCreate(Bundle savedInstanceState) {
//         this.application = (TropesApplication) getApplication(); 
//         this.switchTheme();
// 		
// 		super.onCreate(savedInstanceState);
// 	}
// 	
// 	public void switchTheme() {
// 		String theme = getThemeName();
// 		
// 		if(theme.equalsIgnoreCase("HoloDark")) {
// 			setTheme(R.style.LampshadeDark);
// 		}
//         else if(theme.equalsIgnoreCase("HoloDarkActionBar")) {
//             setTheme(R.style.LampshadeLightDarkActionBar);
//         }
// 	}
// 
//     public Boolean isDarkActionBar() {
//         Boolean darkAB = false;
//         darkAB = getThemeName().contains("Dark");
// 
//         return darkAB;
//     }
// 
//     public Boolean isDarkTheme() {
//         Boolean isDark = false;
//         isDark = getThemeName().equalsIgnoreCase("HoloDark");
// 
//         return isDark;
//     }
// 
//     public String getThemeName() {
//         SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
//         String theme = preferences.getString("preference_theme", "HoloLight");
//         return theme;
//     }
// 
// 	public void showDialogFragment(DialogFragment fragment) {
// 		FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
// 	    Fragment prev = getSupportFragmentManager().findFragmentByTag("dialog");
// 	    if (prev != null) {
// 	        ft.remove(prev);
// 	    }
// 	    ft.addToBackStack(null);
// 
// 	    fragment.show(ft, "dialog");
// 	}
// 
//     public boolean isTablet() {
//         boolean xlarge = ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_XLARGE);
//         boolean large = ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) == Configuration.SCREENLAYOUT_SIZE_LARGE);
//         return (xlarge || large);
//     }
// 
//     public void loadPage(Uri url) {
//         if(TropesHelper.isTropesLink(url)) {
//             String page = TropesHelper.titleFromUrl(url);
// 
//             if(TropesHelper.isIndex(page)) {
//                 loadIndex(url);
//             }
//             else {
//                 loadArticle(url);
//             }
//         }
//         else {
//             loadWebsite(url);
//         }
//     }
// 
//     /** Opens a page as an article, and only as an article **/
//     public void loadArticle(Uri url) {
//         Intent articleIntent = new Intent(getApplicationContext(), ArticleActivity.class);
//         articleIntent.putExtra(TropesApplication.loadAsArticle, true);
//         articleIntent.setData(url);
//         articleIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//         startActivity(articleIntent);
//     }
// 
//     public void loadIndex(Uri url) {
//         Intent indexIntent = new Intent(getApplicationContext(), ArticleActivity.class);
//         indexIntent.setData(url);
//         indexIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//         startActivity(indexIntent);
//     }
// 
//     public void loadWebsite(Uri url) {
//         Intent websiteIntent = new Intent(Intent.ACTION_VIEW);
//         websiteIntent.setData(url);
//         websiteIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//         startActivity(websiteIntent);
//     }
// 
// }


// Path: lampshade/src/main/java/eu/prismsw/lampshade/fragments/IndexFragment.java
import android.net.Uri;
import android.os.Bundle;
import android.view.*;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.ShareActionProvider;
import com.koushikdutta.async.future.Future;
import com.koushikdutta.async.future.FutureCallback;
import com.koushikdutta.ion.Ion;
import com.koushikdutta.ion.Response;
import eu.prismsw.lampshade.BaseActivity;
import eu.prismsw.lampshade.R;
import eu.prismsw.tropeswrapper.*;

package eu.prismsw.lampshade.fragments;


public class IndexFragment extends TropesFragment {
	
	public static IndexFragment newInstance(Uri url) {
		IndexFragment f = new IndexFragment();
		Bundle bundle = new Bundle(2);
		bundle.putParcelable(PASSED_URL, url);
		bundle.putParcelable(TRUE_URL, url);
		f.setArguments(bundle);
		return f;
	}
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle bundle) {
		return inflater.inflate(R.layout.index_fragment, group, false);
	}
	
    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.menu.tropes_fragment_menu, menu);
        inflater.inflate(R.menu.index_fragment_menu, menu);

        MenuItem shareItem = menu.findItem(R.id.share_article);
        shareProvider = (ShareActionProvider) shareItem.getActionProvider();
    }
	
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(!loadingIsFinished()) {
            return true;
        }
        else if (item.getItemId() == R.id.index_as_article) {
            ((BaseActivity) getActivity()).loadArticle(trueUrl);