// Path: app/src/main/java/fr/julienvermet/bugdroid/model/Account.java
// public class Account implements Serializable {
// 
//     private static final long serialVersionUID = -2274154012859845136L;
//     public int _id;
//     public int instances_id;
//     public String username;
//     public String password;
// 
//     public static Account toAccount(Cursor cursor) {
//         Account account = new Account();
//         account._id = cursor.getInt(cursor.getColumnIndexOrThrow(Columns.ID.getName()));
//         account.instances_id = cursor.getInt(cursor.getColumnIndexOrThrow(Columns.INSTANCES_ID.getName()));
//         account.username = cursor.getString(cursor.getColumnIndexOrThrow(Columns.EMAIL.getName()));
//         account.password = cursor.getString(cursor.getColumnIndexOrThrow(Columns.PASSWORD.getName()));
//         return account;
//     }
// }
// 
// Path: app/src/main/java/fr/julienvermet/bugdroid/model/Instance.java
// public class Instance implements Serializable {
// 
//     private static final long serialVersionUID = 6357426966223304678L;
//     public int _id;
//     public String name;
//     public String url;
//     public Account account;
// 
//     public ContentValues toContentValues() {
//         ContentValues contentValues = new ContentValues();
//         contentValues.put(Instances.Columns.ID.getName(), _id);
//         contentValues.put(Instances.Columns.NAME.getName(), name);
//         contentValues.put(Instances.Columns.URL.getName(), url);
//         return contentValues;
//     }
// 
//     public static Instance toInstance(Cursor cursor) {
//         Instance instance = new Instance();
//         instance._id = cursor.getInt(cursor.getColumnIndexOrThrow(Columns.ID.getName()));
//         instance.name = cursor.getString(cursor.getColumnIndexOrThrow(Columns.NAME.getName()));
//         instance.url = cursor.getString(cursor.getColumnIndexOrThrow(Columns.URL.getName()));
//         return instance;
//     }
// }


import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v4.widget.CursorAdapter;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.PasswordTransformationMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockListFragment;
import com.actionbarsherlock.internal.widget.IcsListPopupWindow;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import fr.julienvermet.bugdroid.R;
import fr.julienvermet.bugdroid.model.Account;
import fr.julienvermet.bugdroid.model.Instance;
import fr.julienvermet.bugdroid.provider.BugDroidContent.Accounts;
import fr.julienvermet.bugdroid.provider.BugDroidContent.Instances;
import fr.julienvermet.bugdroid.util.Patterns;
            holder.instanceName = (TextView) view.findViewById(R.id.instanceName);
            holder.instanceUrl = (TextView) view.findViewById(R.id.instanceUrl);
            holder.accountsList = (LinearLayout) view.findViewById(R.id.accountsList);
            holder.withoutAccount = view.findViewById(R.id.withoutAccount);
            holder.withoutAccountRadioButton = (RadioButton) holder.withoutAccount
                .findViewById(R.id.accountRadioButton);
            holder.position = cursor.getPosition();
            final View instanceMenu = view.findViewById(R.id.instanceMenu);
            instanceMenu.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    mInstancePosition = holder.position;
                    String[] listItems = { "Add account", "Edit", "Delete" };
                    mListPopupWindow = new IcsListPopupWindow(getActivity());
                    int popupWindowWidth = (int) getResources().getDimension(R.dimen.instances_menu_width);
                    mListPopupWindow.setContentWidth(popupWindowWidth);
                    mListPopupWindow.setAdapter(new ArrayAdapter(getActivity(),
                        android.R.layout.simple_list_item_1, listItems));
                    mListPopupWindow.setAnchorView(instanceMenu);
                    mListPopupWindow.setOnItemClickListener(InstanceAdapter.this);
                    mListPopupWindow.show();
                }
            });

            view.setTag(holder);
            return view;
        }

        private int mInstancePosition;

// Path: app/src/main/java/fr/julienvermet/bugdroid/model/Account.java
// public class Account implements Serializable {
// 
//     private static final long serialVersionUID = -2274154012859845136L;
//     public int _id;
//     public int instances_id;
//     public String username;
//     public String password;
// 
//     public static Account toAccount(Cursor cursor) {
//         Account account = new Account();
//         account._id = cursor.getInt(cursor.getColumnIndexOrThrow(Columns.ID.getName()));
//         account.instances_id = cursor.getInt(cursor.getColumnIndexOrThrow(Columns.INSTANCES_ID.getName()));
//         account.username = cursor.getString(cursor.getColumnIndexOrThrow(Columns.EMAIL.getName()));
//         account.password = cursor.getString(cursor.getColumnIndexOrThrow(Columns.PASSWORD.getName()));
//         return account;
//     }
// }
// 
// Path: app/src/main/java/fr/julienvermet/bugdroid/model/Instance.java
// public class Instance implements Serializable {
// 
//     private static final long serialVersionUID = 6357426966223304678L;
//     public int _id;
//     public String name;
//     public String url;
//     public Account account;
// 
//     public ContentValues toContentValues() {
//         ContentValues contentValues = new ContentValues();
//         contentValues.put(Instances.Columns.ID.getName(), _id);
//         contentValues.put(Instances.Columns.NAME.getName(), name);
//         contentValues.put(Instances.Columns.URL.getName(), url);
//         return contentValues;
//     }
// 
//     public static Instance toInstance(Cursor cursor) {
//         Instance instance = new Instance();
//         instance._id = cursor.getInt(cursor.getColumnIndexOrThrow(Columns.ID.getName()));
//         instance.name = cursor.getString(cursor.getColumnIndexOrThrow(Columns.NAME.getName()));
//         instance.url = cursor.getString(cursor.getColumnIndexOrThrow(Columns.URL.getName()));
//         return instance;
//     }
// }


// Path: app/src/main/java/fr/julienvermet/bugdroid/ui/InstancesListFragment.java
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.LoaderManager;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
import android.support.v4.widget.CursorAdapter;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.PasswordTransformationMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.TextView;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockListFragment;
import com.actionbarsherlock.internal.widget.IcsListPopupWindow;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import fr.julienvermet.bugdroid.R;
import fr.julienvermet.bugdroid.model.Account;
import fr.julienvermet.bugdroid.model.Instance;
import fr.julienvermet.bugdroid.provider.BugDroidContent.Accounts;
import fr.julienvermet.bugdroid.provider.BugDroidContent.Instances;
import fr.julienvermet.bugdroid.util.Patterns;

            holder.instanceName = (TextView) view.findViewById(R.id.instanceName);
            holder.instanceUrl = (TextView) view.findViewById(R.id.instanceUrl);
            holder.accountsList = (LinearLayout) view.findViewById(R.id.accountsList);
            holder.withoutAccount = view.findViewById(R.id.withoutAccount);
            holder.withoutAccountRadioButton = (RadioButton) holder.withoutAccount
                .findViewById(R.id.accountRadioButton);
            holder.position = cursor.getPosition();
            final View instanceMenu = view.findViewById(R.id.instanceMenu);
            instanceMenu.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    mInstancePosition = holder.position;
                    String[] listItems = { "Add account", "Edit", "Delete" };
                    mListPopupWindow = new IcsListPopupWindow(getActivity());
                    int popupWindowWidth = (int) getResources().getDimension(R.dimen.instances_menu_width);
                    mListPopupWindow.setContentWidth(popupWindowWidth);
                    mListPopupWindow.setAdapter(new ArrayAdapter(getActivity(),
                        android.R.layout.simple_list_item_1, listItems));
                    mListPopupWindow.setAnchorView(instanceMenu);
                    mListPopupWindow.setOnItemClickListener(InstanceAdapter.this);
                    mListPopupWindow.show();
                }
            });

            view.setTag(holder);
            return view;
        }

        private int mInstancePosition;

        @Override