<commit_before>package org.osb;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;


import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.ViewFlipper;


public class ScheduleActivity extends AbstractActivity {

	
	private static final Date JUN1 = new Date(110, 5, 1);
	private static final Date JUN2 = new Date(110, 5, 2);
	private static final Date JUN3 = new Date(110, 5, 3);
	private static final Date JUN4 = new Date(110, 5, 4);

	private static final int MENU_JUN1 = 1;
	private static final int MENU_JUN2 = 2;
	private static final int MENU_JUN3 = 3;
	private static final int MENU_JUN4 = 4;
	private static final int MENU_NEXT = 5;
	private static final int MENU_PREV = 6;
	private static final int MENU_ABOUT = 7;
	private static final int MENU_NOW = 8;
	private static final int MENU_REFRESH = 9;
	
	// state
	Date mCurrentDate;
	TextView mDate;
	boolean mDetail = false;
	Handler mHandler; 
	
	// general conference data
	Conference mConference;
	Date[] mDates;
	
	// session list
	EventAdapter mAdapter;
	ListView mEvents;
	
	// screen animation
	ViewFlipper mFlipper;
	Animation mInLeft;
    Animation mInRight;
    Animation mOutLeft;
    Animation mOutRight;
	
    // session details
    Event mEvent = null;
    HashMap<Integer, Speaker> mSpeakers;
    View mHeader;
    TextView mTitle;
    TextView mTime;
    TextView mLocation;
    View mTimeLocation;
    TextView mSpeaker;
    ScrollView mDescriptionScroller;
    TextView mDescription;
    ImageView mMapImage;
    LinearLayout mBio;
    
    // session detail actions
    Button mFoursquare;
    Button mShare;
    Button mMap;
    Button mShowDescription;
    Button mShowBio;
    
    /** Called when the activity is first created. */
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mHandler = new Handler();
        
        mSpeakers = new HashMap<Integer, Speaker>();
        
        mDate = (TextView) findViewById(R.id.date);
        mEvents = (ListView) findViewById(R.id.events);
        mFlipper = (ViewFlipper) findViewById(R.id.flipper);
        Context context = getApplicationContext();
        mInLeft = AnimationUtils.loadAnimation(context, R.anim.slide_in_left);
        mInRight = AnimationUtils.loadAnimation(context, R.anim.slide_in_right);
        mOutLeft = AnimationUtils.loadAnimation(context, R.anim.slide_out_left);
        mOutRight = AnimationUtils.loadAnimation(context, R.anim.slide_out_right);
        
        // grab views for details
        View detail = findViewById(R.id.detail);
        mHeader = findViewById(R.id.detail_header);
        mSpeaker = (TextView) findViewById(R.id.speaker);
        mTitle = (TextView) detail.findViewById(R.id.title);
        mTimeLocation = detail.findViewById(R.id.time_location);
        mTime = (TextView) detail.findViewById(R.id.time);
        mLocation = (TextView) detail.findViewById(R.id.location);
        mDescription = (TextView) detail.findViewById(R.id.description);
        mDescriptionScroller = (ScrollView) detail.findViewById(R.id.description_scroller);
        mMapImage = (ImageView) detail.findViewById(R.id.map_image);
        mBio = (LinearLayout) detail.findViewById(R.id.bio);
        
        // detail action buttons 
        mFoursquare = (Button) findViewById(R.id.foursquare);
        mShare = (Button) findViewById(R.id.share);
        mMap = (Button) findViewById(R.id.map);
        mShowDescription = (Button) findViewById(R.id.show_description);
        mShowBio = (Button) findViewById(R.id.show_bio);
        
        mEvents.setOnItemClickListener(new ListView.OnItemClickListener() {
			public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) {
				Object item = mAdapter.mFiltered.get(position);
				if (item instanceof Date) {
					return;// ignore clicks on the dates
				}
				Event event = (Event) item;
				Track track = mConference.tracks.get(event.track);
				Location location = mConference.locations.get(event.location);
				if (!event.details){
					// load detailed info for this session
					DataService service = getDataService();
					event = service.getEvent(event.id, false);
					mAdapter.mFiltered.add(position, event);
				}
				mHeader.setBackgroundColor(track.color);
				mTitle.setText(event.title);
				mLocation.setText(location.name);
				DateFormat startFormat = new SimpleDateFormat("E, h:mm");
				DateFormat endFormat = new SimpleDateFormat("h:mm a");
				String timeString = startFormat.format(event.start) + " - " + endFormat.format(event.end);
				mTime.setText(timeString);
				mSpeaker.setText(event.speakers);
				mTimeLocation.setBackgroundColor(track.color);
				mDescription.setText(event.description);
				show_description();
				mDescriptionScroller.scrollTo(0, 0);
				mFlipper.setInAnimation(mInRight);
                mFlipper.setOutAnimation(mOutLeft);
                mFlipper.showNext();
                mEvent = event;
                mDetail = true;
			}
		});
        
        mShowDescription.setOnClickListener(new OnClickListener() { 
			public void onClick(View v) {
				show_description();
			}
        });
        
        mMap.setOnClickListener(new OnClickListener() { 
			public void onClick(View v) {
				mMapImage.setImageResource(getMapResource(mLocation.getText()));
				mDescription.setVisibility(View.GONE);
				mBio.setVisibility(View.GONE);
				mMapImage.setVisibility(View.VISIBLE);
			}
			<commit_msg>speaker names now included in detail view, no more double listing after view session detail<commit_after>package org.osb;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;


import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.ViewFlipper;


public class ScheduleActivity extends AbstractActivity {

	
	private static final Date JUN1 = new Date(110, 5, 1);
	private static final Date JUN2 = new Date(110, 5, 2);
	private static final Date JUN3 = new Date(110, 5, 3);
	private static final Date JUN4 = new Date(110, 5, 4);

	private static final int MENU_JUN1 = 1;
	private static final int MENU_JUN2 = 2;
	private static final int MENU_JUN3 = 3;
	private static final int MENU_JUN4 = 4;
	private static final int MENU_NEXT = 5;
	private static final int MENU_PREV = 6;
	private static final int MENU_ABOUT = 7;
	private static final int MENU_NOW = 8;
	private static final int MENU_REFRESH = 9;
	
	// state
	Date mCurrentDate;
	TextView mDate;
	boolean mDetail = false;
	Handler mHandler; 
	
	// general conference data
	Conference mConference;
	Date[] mDates;
	
	// session list
	EventAdapter mAdapter;
	ListView mEvents;
	
	// screen animation
	ViewFlipper mFlipper;
	Animation mInLeft;
    Animation mInRight;
    Animation mOutLeft;
    Animation mOutRight;
	
    // session details
    Event mEvent = null;
    HashMap<Integer, Speaker> mSpeakers;
    View mHeader;
    TextView mTitle;
    TextView mTime;
    TextView mLocation;
    View mTimeLocation;
    TextView mSpeaker;
    ScrollView mDescriptionScroller;
    TextView mDescription;
    ImageView mMapImage;
    LinearLayout mBio;
    
    // session detail actions
    Button mFoursquare;
    Button mShare;
    Button mMap;
    Button mShowDescription;
    Button mShowBio;
    
    /** Called when the activity is first created. */
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mHandler = new Handler();
        
        mSpeakers = new HashMap<Integer, Speaker>();
        
        mDate = (TextView) findViewById(R.id.date);
        mEvents = (ListView) findViewById(R.id.events);
        mFlipper = (ViewFlipper) findViewById(R.id.flipper);
        Context context = getApplicationContext();
        mInLeft = AnimationUtils.loadAnimation(context, R.anim.slide_in_left);
        mInRight = AnimationUtils.loadAnimation(context, R.anim.slide_in_right);
        mOutLeft = AnimationUtils.loadAnimation(context, R.anim.slide_out_left);
        mOutRight = AnimationUtils.loadAnimation(context, R.anim.slide_out_right);
        
        // grab views for details
        View detail = findViewById(R.id.detail);
        mHeader = findViewById(R.id.detail_header);
        mSpeaker = (TextView) findViewById(R.id.speaker);
        mTitle = (TextView) detail.findViewById(R.id.title);
        mTimeLocation = detail.findViewById(R.id.time_location);
        mTime = (TextView) detail.findViewById(R.id.time);
        mLocation = (TextView) detail.findViewById(R.id.location);
        mDescription = (TextView) detail.findViewById(R.id.description);
        mDescriptionScroller = (ScrollView) detail.findViewById(R.id.description_scroller);
        mMapImage = (ImageView) detail.findViewById(R.id.map_image);
        mBio = (LinearLayout) detail.findViewById(R.id.bio);
        
        // detail action buttons 
        mFoursquare = (Button) findViewById(R.id.foursquare);
        mShare = (Button) findViewById(R.id.share);
        mMap = (Button) findViewById(R.id.map);
        mShowDescription = (Button) findViewById(R.id.show_description);
        mShowBio = (Button) findViewById(R.id.show_bio);
        
        mEvents.setOnItemClickListener(new ListView.OnItemClickListener() {
			public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) {
				Object item = mAdapter.mFiltered.get(position);
				if (item instanceof Date) {
					return;// ignore clicks on the dates
				}
				Event event = (Event) item;
				Track track = mConference.tracks.get(event.track);
				Location location = mConference.locations.get(event.location);
				if (!event.details){
					// load detailed info for this session
					DataService service = getDataService();
					event = service.getEvent(event.id, false);
					mAdapter.mFiltered.set(position, event);
				}
				
				String speaker_names = "";
				Speaker speaker;
				for(Integer sid: event.speaker_ids){
					if (mSpeakers.containsKey(sid)){
						speaker = mSpeakers.get(sid);
					} else {
						speaker = getDataService().getSpeaker(sid, false);
						mSpeakers.put(sid, speaker);
					}
					if (speaker_names == "") {
						speaker_names = speaker.name; 
					} else {
						speaker_names = speaker_names + ", " + speaker.name;
					}
				}
				mSpeaker.setText(speaker_names);
					
				mHeader.setBackgroundColor(track.color);
				mTitle.setText(event.title);
				mLocation.setText(location.name);
				DateFormat startFormat = new SimpleDateFormat("E, h:mm");
				DateFormat endFormat = new SimpleDateFormat("h:mm a");
				String timeString = startFormat.format(event.start) + " - " + endFormat.format(event.end);
				mTime.setText(timeString);
				mTimeLocation.setBackgroundColor(track.color);
				mDescription.setText(event.description);
				show_description();
				mDescriptionScroller.scrollTo(0, 0);
				mFlipper.setInAnimation(mInRight);
                mFlipper.setOutAnimation(mOutLeft);
                mFlipper.showNext();
                mEvent = event;
                mDetail = true;
			}
		});
        
        mShowDescription.setOnClickListener(new OnClickListener() { 
			public void onClick(View v) {
				show_description();
			}
        });
        
        mMap.setOnClickListener(new OnClickListener() { 
			public void onClick(View v) {
				mMapImage.setImageResource(getMapResource(mLocation.getText()));
				mDescription.setVisibility(View.GONE);
				mBio.setVisibility(View.GONE);
				mMapImage.setVisibility(View.VISIBLE);
			}
			
{'fraction_non_alphanumeric': 0.09947723312372149, 'fraction_numerical': 0.005909538601409197, 'mean_word_length': 3.4147157190635453, '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': '1191222', 'n_tokens_mistral': 4332, 'n_tokens_neox': 3836, 'n_words': 899}