<commit_before>package com.github.takuji31.yapcasiaviewer;

import java.text.ParseException;
import java.util.ArrayList;

import com.github.takuji31.yapcasiaviewer.R;

import com.actionbarsherlock.view.MenuItem;
import com.github.takuji31.slidemenu.SlideMenu;
import com.github.takuji31.slidemenu.SlideMenuAdapter;
import com.github.takuji31.slidemenu.SlideMenuItem;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

public class TalkListActivity extends YAVActivity
        implements TalkListFragment.Callbacks {

    private boolean mTwoPane;
	private OnItemClickListener mMenuLisntener = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> list, View v, int id,
				long which) {
			int pos = (int) which;
	        TalkListFragment f = getTalkListFragment();
	        if (!mDates[pos].equals(f.getDateString())) {
				Bundle args = new Bundle();
				args.putInt(TalkListFragment.BUNDLE_DATE, pos);
				TalkListFragment newFragment = (TalkListFragment) Fragment.instantiate(TalkListActivity.this, TalkListFragment.class.getName(), args);
				getSupportFragmentManager().beginTransaction()
					.replace(R.id.container, newFragment)
					.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
					.addToBackStack(null)
					.commit();
			}
			mMenu.hide();
		}
	};
	private String[] mDates;

	SlideMenu mMenu;

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

        TalkListFragment f = getTalkListFragment();
        if (f == null) {
            FragmentManager fm = getSupportFragmentManager();
			f = (TalkListFragment) Fragment.instantiate(this, TalkListFragment.class.getName(), new Bundle());
			fm.beginTransaction().add(R.id.container, f).commit();
		}
        
        mMenu = new SlideMenu(this);
        SlideMenu.setAnimationDuration(200);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        ArrayList<SlideMenuItem> items = new ArrayList<SlideMenuItem>();
        mDates = getResources().getStringArray(R.array.dates);
        int i = 0;
        for (String date : mDates) {
			SlideMenuItem item = new SlideMenuItem();
			item.id = i;
			try {
				item.label = DateUtil.convertToDisplayDateString(date);
			} catch (ParseException e) {
				e.printStackTrace();
			}
			item.icon = -1;
			items.add(item);
			i++;
		}
        mMenu.setAdapter(new SlideMenuAdapter(this, items));
        mMenu.setOnItemClickListener(mMenuLisntener);
        mMenu.checkEnabled();
    }
    
    @Override
    protected void onStart() {
    	super.onStart();
        if (findViewById(R.id.talk_detail_container) != null) {
            mTwoPane = true;
            getTalkListFragment().setActivateOnItemClick(true);
        }
    	getSupportActionBar().setDisplayShowTitleEnabled(mTwoPane);
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	if (item.getItemId() == android.R.id.home) {
			mMenu.toggle();
		}
    	return super.onOptionsItemSelected(item);
    }
    
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    	if (keyCode == KeyEvent.KEYCODE_BACK && mMenu.isMenuShown()) {
			mMenu.hide();
    		return true;
		}
    	return super.onKeyDown(keyCode, event);
    }

    @Override
    public void onItemSelected(Talk talk) {
        if (mTwoPane) {
            Bundle arguments = new Bundle();
            arguments.putSerializable(TalkDetailFragment.ARG_TALK, talk);
            TalkDetailFragment fragment = new TalkDetailFragment();
            fragment.setArguments(arguments);
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.talk_detail_container, fragment)
                    .commit();

        } else {
            Intent detailIntent = new Intent(this, TalkDetailActivity.class);
            detailIntent.putExtra(TalkDetailFragment.ARG_TALK, talk);
            startActivity(detailIntent);
        }
    }
    
    public TalkListFragment getTalkListFragment() {<commit_msg>戻るボタンでトークの詳細を戻すようにした<commit_after>package com.github.takuji31.yapcasiaviewer;

import java.text.ParseException;
import java.util.ArrayList;

import com.github.takuji31.yapcasiaviewer.R;

import com.actionbarsherlock.view.MenuItem;
import com.github.takuji31.slidemenu.SlideMenu;
import com.github.takuji31.slidemenu.SlideMenuAdapter;
import com.github.takuji31.slidemenu.SlideMenuItem;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;

public class TalkListActivity extends YAVActivity
        implements TalkListFragment.Callbacks {

    private boolean mTwoPane;
	private OnItemClickListener mMenuLisntener = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> list, View v, int id,
				long which) {
			int pos = (int) which;
	        TalkListFragment f = getTalkListFragment();
	        if (!mDates[pos].equals(f.getDateString())) {
				Bundle args = new Bundle();
				args.putInt(TalkListFragment.BUNDLE_DATE, pos);
				TalkListFragment newFragment = (TalkListFragment) Fragment.instantiate(TalkListActivity.this, TalkListFragment.class.getName(), args);
				getSupportFragmentManager().beginTransaction()
					.replace(R.id.container, newFragment)
					.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
					.addToBackStack(null)
					.commit();
			}
			mMenu.hide();
		}
	};
	private String[] mDates;

	SlideMenu mMenu;

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

        TalkListFragment f = getTalkListFragment();
        if (f == null) {
            FragmentManager fm = getSupportFragmentManager();
			f = (TalkListFragment) Fragment.instantiate(this, TalkListFragment.class.getName(), new Bundle());
			fm.beginTransaction().add(R.id.container, f).commit();
		}
        
        mMenu = new SlideMenu(this);
        SlideMenu.setAnimationDuration(200);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        ArrayList<SlideMenuItem> items = new ArrayList<SlideMenuItem>();
        mDates = getResources().getStringArray(R.array.dates);
        int i = 0;
        for (String date : mDates) {
			SlideMenuItem item = new SlideMenuItem();
			item.id = i;
			try {
				item.label = DateUtil.convertToDisplayDateString(date);
			} catch (ParseException e) {
				e.printStackTrace();
			}
			item.icon = -1;
			items.add(item);
			i++;
		}
        mMenu.setAdapter(new SlideMenuAdapter(this, items));
        mMenu.setOnItemClickListener(mMenuLisntener);
        mMenu.checkEnabled();
    }
    
    @Override
    protected void onStart() {
    	super.onStart();
        if (findViewById(R.id.talk_detail_container) != null) {
            mTwoPane = true;
            getTalkListFragment().setActivateOnItemClick(true);
        }
    	getSupportActionBar().setDisplayShowTitleEnabled(mTwoPane);
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	if (item.getItemId() == android.R.id.home) {
			mMenu.toggle();
		}
    	return super.onOptionsItemSelected(item);
    }
    
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    	if (keyCode == KeyEvent.KEYCODE_BACK && mMenu.isMenuShown()) {
			mMenu.hide();
    		return true;
		}
    	return super.onKeyDown(keyCode, event);
    }

    @Override
    public void onItemSelected(Talk talk) {
        if (mTwoPane) {
            Bundle arguments = new Bundle();
            arguments.putSerializable(TalkDetailFragment.ARG_TALK, talk);
            TalkDetailFragment fragment = new TalkDetailFragment();
            fragment.setArguments(arguments);
            FragmentManager fm = getSupportFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            ft.replace(R.id.talk_detail_container, fragment);
            if (fm.findFragmentById(R.id.talk_detail_container) != null) {
                ft.addToBackStack(null);
			}
            ft.commit();

        } else {
            Intent detailIntent = new Intent(this, TalkDetailActivity.class);
            detailIntent.putExtra(TalkDetailFragment.ARG_TALK, talk);
            startActivity(detailIntent);
        }
    }
    
    public TalkListFragment getTalkListFragment() {
{'fraction_non_alphanumeric': 0.10484957341715312, 'fraction_numerical': 0.004041311180960934, 'mean_word_length': 3.2749520153550864, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6814510', 'n_tokens_mistral': 2859, 'n_tokens_neox': 2612, 'n_words': 471}