// Path: app/src/main/java/link/standen/michael/fatesheets/adapter/DeletableStringArrayAdapter.java
// public class DeletableStringArrayAdapter extends ArrayAdapter<String> {
// 
// 	private static final String TAG = DeletableStringArrayAdapter.class.getName();
// 
// 	private final Context context;
// 	private final int resourceId;
// 	private final List<String> items;
// 
// 	public DeletableStringArrayAdapter(@NonNull Context context, @LayoutRes int resourceId, @NonNull List<String> items) {
// 		super(context, resourceId, items);
// 
// 		this.context = context;
// 		this.resourceId = resourceId;
// 		this.items = items;
// 	}
// 
// 	public String getItem(int index){
// 		return items.get(index);
// 	}
// 
// 	@NonNull
// 	@Override
// 	public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
// 		View view = convertView;
// 		if (view == null){
// 			LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// 			view = inflater.inflate(resourceId, null);
// 		}
// 
// 		view.findViewById(R.id.delete).setOnClickListener(new View.OnClickListener() {
// 			@Override
// 			public void onClick(View v) {
// 				items.remove(position);
// 				DeletableStringArrayAdapter.this.notifyDataSetChanged();
// 			}
// 		});
// 
// 		// Description
// 		TextView descriptionView = (TextView) view.findViewById(R.id.description);
// 		// Update description field on focus lost
// 		descriptionView.addTextChangedListener(new TextWatcher() {
// 			@Override
// 			public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
// 
// 			@Override
// 			public void onTextChanged(CharSequence s, int start, int before, int count) {}
// 
// 			@Override
// 			public void afterTextChanged(Editable s) {
// 				items.set(position, s.toString());
// 			}
// 		});
// 		descriptionView.setText(getItem(position));
// 
// 		return view;
// 	}
// }
// 
// Path: app/src/main/java/link/standen/michael/fatesheets/view/AdapterLinearLayout.java
// public class AdapterLinearLayout extends LinearLayout {
// 
// 	private static final String TAG = AdapterLinearLayout.class.getName();
// 
// 	private Adapter adapter;
// 	private DataSetObserver dataSetObserver = new DataSetObserver() {
// 		@Override
// 		public void onChanged() {
// 			super.onChanged();
// 			reloadChildViews();
// 		}
// 	};
// 
// 	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
// 	public AdapterLinearLayout(Context context, AttributeSet attrs, int defStyle) {
// 		super(context, attrs, defStyle);
// 	}
// 
// 	public AdapterLinearLayout(Context context, AttributeSet attrs) {
// 		super(context, attrs);
// 	}
// 
// 	public AdapterLinearLayout(Context context) {
// 		super(context);
// 	}
// 
// 	public void setAdapter(Adapter adapter) {
// 		if (this.adapter == adapter){
// 			return;
// 		}
// 		this.adapter = adapter;
// 		if (adapter != null){
// 			adapter.registerDataSetObserver(dataSetObserver);
// 		}
// 		reloadChildViews();
// 	}
// 
// 	@Override
// 	protected void onDetachedFromWindow() {
// 		super.onDetachedFromWindow();
// 		if (adapter != null){
// 			try {
// 				adapter.unregisterDataSetObserver(dataSetObserver);
// 			} catch (IllegalStateException e){
// 				// Log error and ignore. I think it's fine.
// 				Log.e(TAG, "Observer was not registered.", e);
// 			}
// 		}
// 	}
// 
// 	private void reloadChildViews() {
// 		removeAllViewsInLayout();
// 
// 		if (adapter == null){
// 			return;
// 		}
// 
// 		int count = adapter.getCount();
// 		for (int position = 0; position < count; position++) {
// 			View v = adapter.getView(position, null, this);
// 			if (v != null){
// 				addView(v);
// 			}
// 		}
// 
// 		requestLayout();
// 	}
// }


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import link.standen.michael.fatesheets.R;
import link.standen.michael.fatesheets.adapter.DeletableStringArrayAdapter;
import link.standen.michael.fatesheets.view.AdapterLinearLayout;
package link.standen.michael.fatesheets.fragment;



/**
 * A fragment for managing a characters stunts.
 */
public class CoreCharacterEditStuntsFragment extends CharacterEditAbstractFragment {

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
							 Bundle savedInstanceState) {
		return inflater.inflate(R.layout.core_character_edit_stunts, container, false);
	}

	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		// Stunt
		Fragment childFragment = new StuntFragment();
		FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
		transaction.replace(R.id.stunt_container, childFragment).commit();
		// Extra
		childFragment = new ExtraFragment();
		transaction = getChildFragmentManager().beginTransaction();
		transaction.replace(R.id.extra_container, childFragment).commit();
	}

	/**
	 * Class for managing stunts.
	 */
	public static class StuntFragment extends CharacterEditAbstractFragment {

		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
								 Bundle savedInstanceState) {

			View rootView = inflater.inflate(R.layout.character_edit_stunts_stunt, container, false);

			// Stunts
// Path: app/src/main/java/link/standen/michael/fatesheets/adapter/DeletableStringArrayAdapter.java
// public class DeletableStringArrayAdapter extends ArrayAdapter<String> {
// 
// 	private static final String TAG = DeletableStringArrayAdapter.class.getName();
// 
// 	private final Context context;
// 	private final int resourceId;
// 	private final List<String> items;
// 
// 	public DeletableStringArrayAdapter(@NonNull Context context, @LayoutRes int resourceId, @NonNull List<String> items) {
// 		super(context, resourceId, items);
// 
// 		this.context = context;
// 		this.resourceId = resourceId;
// 		this.items = items;
// 	}
// 
// 	public String getItem(int index){
// 		return items.get(index);
// 	}
// 
// 	@NonNull
// 	@Override
// 	public View getView(final int position, @Nullable View convertView, @NonNull ViewGroup parent) {
// 		View view = convertView;
// 		if (view == null){
// 			LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// 			view = inflater.inflate(resourceId, null);
// 		}
// 
// 		view.findViewById(R.id.delete).setOnClickListener(new View.OnClickListener() {
// 			@Override
// 			public void onClick(View v) {
// 				items.remove(position);
// 				DeletableStringArrayAdapter.this.notifyDataSetChanged();
// 			}
// 		});
// 
// 		// Description
// 		TextView descriptionView = (TextView) view.findViewById(R.id.description);
// 		// Update description field on focus lost
// 		descriptionView.addTextChangedListener(new TextWatcher() {
// 			@Override
// 			public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
// 
// 			@Override
// 			public void onTextChanged(CharSequence s, int start, int before, int count) {}
// 
// 			@Override
// 			public void afterTextChanged(Editable s) {
// 				items.set(position, s.toString());
// 			}
// 		});
// 		descriptionView.setText(getItem(position));
// 
// 		return view;
// 	}
// }
// 
// Path: app/src/main/java/link/standen/michael/fatesheets/view/AdapterLinearLayout.java
// public class AdapterLinearLayout extends LinearLayout {
// 
// 	private static final String TAG = AdapterLinearLayout.class.getName();
// 
// 	private Adapter adapter;
// 	private DataSetObserver dataSetObserver = new DataSetObserver() {
// 		@Override
// 		public void onChanged() {
// 			super.onChanged();
// 			reloadChildViews();
// 		}
// 	};
// 
// 	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
// 	public AdapterLinearLayout(Context context, AttributeSet attrs, int defStyle) {
// 		super(context, attrs, defStyle);
// 	}
// 
// 	public AdapterLinearLayout(Context context, AttributeSet attrs) {
// 		super(context, attrs);
// 	}
// 
// 	public AdapterLinearLayout(Context context) {
// 		super(context);
// 	}
// 
// 	public void setAdapter(Adapter adapter) {
// 		if (this.adapter == adapter){
// 			return;
// 		}
// 		this.adapter = adapter;
// 		if (adapter != null){
// 			adapter.registerDataSetObserver(dataSetObserver);
// 		}
// 		reloadChildViews();
// 	}
// 
// 	@Override
// 	protected void onDetachedFromWindow() {
// 		super.onDetachedFromWindow();
// 		if (adapter != null){
// 			try {
// 				adapter.unregisterDataSetObserver(dataSetObserver);
// 			} catch (IllegalStateException e){
// 				// Log error and ignore. I think it's fine.
// 				Log.e(TAG, "Observer was not registered.", e);
// 			}
// 		}
// 	}
// 
// 	private void reloadChildViews() {
// 		removeAllViewsInLayout();
// 
// 		if (adapter == null){
// 			return;
// 		}
// 
// 		int count = adapter.getCount();
// 		for (int position = 0; position < count; position++) {
// 			View v = adapter.getView(position, null, this);
// 			if (v != null){
// 				addView(v);
// 			}
// 		}
// 
// 		requestLayout();
// 	}
// }


// Path: app/src/main/java/link/standen/michael/fatesheets/fragment/CoreCharacterEditStuntsFragment.java
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import link.standen.michael.fatesheets.R;
import link.standen.michael.fatesheets.adapter.DeletableStringArrayAdapter;
import link.standen.michael.fatesheets.view.AdapterLinearLayout;

package link.standen.michael.fatesheets.fragment;



/**
 * A fragment for managing a characters stunts.
 */
public class CoreCharacterEditStuntsFragment extends CharacterEditAbstractFragment {

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
							 Bundle savedInstanceState) {
		return inflater.inflate(R.layout.core_character_edit_stunts, container, false);
	}

	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		// Stunt
		Fragment childFragment = new StuntFragment();
		FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
		transaction.replace(R.id.stunt_container, childFragment).commit();
		// Extra
		childFragment = new ExtraFragment();
		transaction = getChildFragmentManager().beginTransaction();
		transaction.replace(R.id.extra_container, childFragment).commit();
	}

	/**
	 * Class for managing stunts.
	 */
	public static class StuntFragment extends CharacterEditAbstractFragment {

		@Override
		public View onCreateView(LayoutInflater inflater, ViewGroup container,
								 Bundle savedInstanceState) {

			View rootView = inflater.inflate(R.layout.character_edit_stunts_stunt, container, false);

			// Stunts
			final DeletableStringArrayAdapter stuntListAdapter = new DeletableStringArrayAdapter(getContext(),