<commit_before>/**
 * Copyright 2013 <NAME>, <NAME>, <NAME>, <NAME>, <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package ca.ualberta.cs.c301f13t13.gui;

import java.util.ArrayList;
import java.util.UUID;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import ca.ualberta.cmput301f13t13.storyhoard.R;
import ca.ualberta.cs.c301f13t13.backend.Chapter;
import ca.ualberta.cs.c301f13t13.backend.Choice;
import ca.ualberta.cs.c301f13t13.backend.GeneralController;

/**
 * Views the chapter provided through the intent. Does not allow going backwards
 * through the activity stack.
 * 
 * @author <NAME>
 * 
 */
public class ViewChapterActivity extends Activity {
	private UUID storyID;
	private UUID chapterID;
	private GeneralController gc;
	private Chapter chapter;
	private ArrayList<Choice> choices;

	private TextView chapterContent;
	private ListView chapterChoices;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_view_chapter);

		// Grab the necessary UUIDs and GC
		Bundle bundle = this.getIntent().getExtras();
		storyID = (UUID) bundle.get("storyID");
		chapterID = (UUID) bundle.get("chapterID");
		gc = GeneralController.getInstance();

		// Setup the activity fields
		chapterContent = (TextView) findViewById(R.id.chapterContent);
		chapterChoices = (ListView) findViewById(R.id.chapterChoices);
	}

	@Override
	public void onResume() {
		super.onResume();
		chapter = gc.getCompleteChapter(chapterID, this);
		// Check to make sure chapter story constraint not violated
		if (chapter.getStoryId() != storyID) {
			Toast.makeText(this, "Chapter not within story", Toast.LENGTH_SHORT)
					.show();
			//finish();
		}
		chapterContent.setText(chapter.getText());
		choices = chapter.getChoices();
	}
}
<commit_msg>Added hackish choice selection. No choices to test yet though<commit_after>/**
 * Copyright 2013 <NAME>, <NAME>, <NAME>, <NAME>, <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package ca.ualberta.cs.c301f13t13.gui;

import java.util.ArrayList;
import java.util.UUID;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import ca.ualberta.cmput301f13t13.storyhoard.R;
import ca.ualberta.cs.c301f13t13.backend.Chapter;
import ca.ualberta.cs.c301f13t13.backend.Choice;
import ca.ualberta.cs.c301f13t13.backend.GeneralController;

/**
 * Views the chapter provided through the intent. Does not allow going backwards
 * through the activity stack.
 * 
 * @author <NAME>
 * 
 */
public class ViewChapterActivity extends Activity {
	private UUID storyID;
	private UUID chapterID;
	private GeneralController gc;
	private Chapter chapter;
	private ArrayList<Choice> choices = new ArrayList<Choice>();
	private ArrayAdapter<Choice> choiceAdapter;

	private TextView chapterContent;
	private ListView chapterChoices;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_view_chapter);

		// Grab the necessary UUIDs and GC
		Bundle bundle = this.getIntent().getExtras();
		storyID = (UUID) bundle.get("storyID");
		chapterID = (UUID) bundle.get("chapterID");
		gc = GeneralController.getInstance();

		// Setup the activity fields
		chapterContent = (TextView) findViewById(R.id.chapterContent);
		chapterChoices = (ListView) findViewById(R.id.chapterChoices);

		// Setup the choices and choice adapters
		choiceAdapter = new ArrayAdapter<Choice>(this, android.R.id.text1,
				choices);
		chapterChoices.setAdapter(choiceAdapter);
	}

	@Override
	public void onResume() {
		super.onResume();
		chapter = gc.getCompleteChapter(chapterID, this);
		choices.clear();
		chapterContent.setText(chapter.getText());
		choices.addAll(chapter.getChoices());
		choiceAdapter.notifyDataSetChanged();
		// Check to make sure chapter story constraint not violated
		if (chapter.getStoryId() != storyID) {
			Toast.makeText(this, "Chapter not within story", Toast.LENGTH_SHORT)
					.show();
			// finish();
		}
	}
}

{'fraction_non_alphanumeric': 0.10383447228549735, 'fraction_numerical': 0.01651480637813212, 'mean_word_length': 4.647374062165059, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5710080', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1523, 'n_words': 467}