<commit_before>package com.grilledmonkey.grilledui;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;

import com.grilledmonkey.grilledui.abstracts.GrilledActivity;
import com.grilledmonkey.grilledui.adapters.SectionAdapter;
import com.grilledmonkey.grilledui.fragments.SectionListFragment;

/**
 * 
 * @author Aux
 *
 */
public class SectionActivity extends GrilledActivity {
	private static final String ARG_SECTION_ID = "sectionId";
	private static final String ARG_SECTION_FRAGMENT = "fragment";

	private boolean hasTwoPanes = false;
	private FragmentManager fm;
	private SectionAdapter sectionAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if(needsAutoInit()) {
			initSections();
		}
	}

	private void initSections() {
		initSections(R.layout.gui__activity_section_list);
	}

	private void initSections(int layout) {
		fm = getSupportFragmentManager();
		sectionAdapter = createSectionAdapter(fm);
		setContentView(layout);

		if(findViewById(R.id.section_detail_container) != null) {
			hasTwoPanes = true;
			// TODO Anything to do here?
			((SectionListFragment)fm.findFragmentById(R.id.section_list)).setActivateOnItemClick(true);
		}
	}

	public void onSectionSelected(int position) {
		Fragment fragment = sectionAdapter.getItem(position);
		if(hasTwoPanes) {
			// TODO R.id.section_detail_container should user changeable
			fm.beginTransaction().replace(R.id.section_detail_container, fragment).commit();
		}
		else {
			Intent intent = new Intent(this, SectionActivity.class);
			intent.putExtra(ARG_SECTION_ID, position);
			intent.putExtra(ARG_SECTION_FRAGMENT, fragment.getClass().getName());
			startActivity(intent);



			//			detailIntent.putE

			// In single-pane mode, simply start the detail activity
			// for the selected item ID.
			//			Intent detailIntent = new Intent(this, ItemDetailActivity.class);
			//			detailIntent.putExtra(ItemDetailFragment.ARG_ITEM_ID, id);
			//			startActivity(detailIntent);
		}
	}

	public boolean hasTwoPanes() {
		return(hasTwoPanes);
	}

	@Override
	public SectionAdapter getSectionAdapter() {
		return(sectionAdapter);<commit_msg>Some fixes<commit_after>package com.grilledmonkey.grilledui;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.text.TextUtils;
import android.util.Log;

import com.grilledmonkey.grilledui.abstracts.GrilledActivity;
import com.grilledmonkey.grilledui.adapters.SectionAdapter;
import com.grilledmonkey.grilledui.fragments.SectionListFragment;

/**
 * 
 * @author Aux
 *
 */
public class SectionActivity extends GrilledActivity {
	private static final String ARG_SECTION_ID = "sectionId";
	private static final String ARG_SECTION_FRAGMENT = "fragment";

	private static final int WRONG_SECTION_ID = -1;

	private boolean hasTwoPanes = false;
	private FragmentManager fm;
	private SectionAdapter sectionAdapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if(needsAutoInit()) {
			initSections();
		}
	}

	private void initSections() {
		initSections(R.layout.gui__activity_section_list);
	}

	private void initSections(int layout) {
		Intent intent = getIntent();
		Bundle extras = intent.getExtras();
		if(extras != null) {
			int sectionId = extras.getInt(ARG_SECTION_ID, WRONG_SECTION_ID);
			String fragment = extras.getString(ARG_SECTION_FRAGMENT);
			if(sectionId != WRONG_SECTION_ID && !TextUtils.isEmpty(fragment)) {
				// TODO Handle phone version here
				Log.w("SSS", "Section: " + sectionId + " | Fragment: " + fragment);
			}
		}

		fm = getSupportFragmentManager();
		sectionAdapter = createSectionAdapter(fm);
		setContentView(layout);

		if(findViewById(R.id.section_detail_container) != null) {
			hasTwoPanes = true;
			// TODO Anything to do here?
			((SectionListFragment)fm.findFragmentById(R.id.section_list)).setActivateOnItemClick(true);
		}
	}

	public void onSectionSelected(int position) {
		Fragment fragment = sectionAdapter.getItem(position);
		if(hasTwoPanes) {
			// TODO R.id.section_detail_container should user changeable
			fm.beginTransaction().replace(R.id.section_detail_container, fragment).commit();
		}
		else {
			Intent intent = new Intent(this, this.getClass());
			intent.putExtra(ARG_SECTION_ID, position);
			intent.putExtra(ARG_SECTION_FRAGMENT, fragment.getClass().getName());
			startActivity(intent);
		}
	}

	public boolean hasTwoPanes() {
		return(hasTwoPanes);
	}

	@Override
	public SectionAdapter getSectionAdapter() {
		return(sectionAdapter);
{'fraction_non_alphanumeric': 0.10542995985632792, 'fraction_numerical': 0.0010564124234100994, 'mean_word_length': 5.132124352331606, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2651010', 'n_tokens_mistral': 1593, 'n_tokens_neox': 1448, 'n_words': 282}