<commit_before>/**
 * Appcelerator Titanium Mobile
 * Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */

package ti.modules.titanium.ui.widget.picker;

import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.Date;

import kankan.wheel.widget.WheelView;

import org.appcelerator.titanium.TiDict;
import org.appcelerator.titanium.TiProxy;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.view.TiUIView;

import android.widget.LinearLayout;

public class TiUIDateSpinner extends TiUIView
		implements WheelView.OnItemSelectedListener
{
	private WheelView monthWheel;
	private WheelView dayWheel;
	private WheelView yearWheel;
	
	private boolean suppressChangeEvent = false;
	private boolean ignoreItemSelection = false;

	private int defaultMaxYear, defaultMinYear;
	private int maxYear, minYear;
	private Date maxDate, minDate;
	
	private Calendar calendar = Calendar.getInstance();
	
	public TiUIDateSpinner(TiViewProxy proxy)
	{
		super(proxy);
		createNativeView();
	}
	
	private void createNativeView()
	{
		defaultMaxYear = calendar.get(Calendar.YEAR) + 100;
		defaultMinYear = calendar.get(Calendar.YEAR) - 100; 
		DecimalFormat formatter = new DecimalFormat("00");
		// TODO minDate/maxDate
		FormatNumericWheelAdapter months = new FormatNumericWheelAdapter(1, 12, formatter, 2);
		FormatNumericWheelAdapter days = new FormatNumericWheelAdapter(1, 31, formatter, 2);
		FormatNumericWheelAdapter years = new FormatNumericWheelAdapter(
				defaultMinYear, defaultMaxYear,	new DecimalFormat("0000"), 4);
		monthWheel = new WheelView(proxy.getContext());
		dayWheel = new WheelView(proxy.getContext());
		yearWheel = new WheelView(proxy.getContext());
		monthWheel.setAdapter(months);
		dayWheel.setAdapter(days);
		yearWheel.setAdapter(years);
		
    	monthWheel.setItemSelectedListener(this);
    	dayWheel.setItemSelectedListener(this);
    	yearWheel.setItemSelectedListener(this);
        
		LinearLayout layout = new LinearLayout(proxy.getContext());
		layout.setOrientation(LinearLayout.HORIZONTAL);
		
		layout.addView(dayWheel);
		layout.addView(monthWheel);
		layout.addView(yearWheel);
		setNativeView(layout);
		
	}
	
	@Override
	public void processProperties(TiDict d) {<commit_msg>Widen the day and month columns of the date spinner (cherry picked from commit <PASSWORD>)<commit_after>/**
 * Appcelerator Titanium Mobile
 * Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Apache Public License
 * Please see the LICENSE included with this distribution for details.
 */

package ti.modules.titanium.ui.widget.picker;

import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.Date;

import kankan.wheel.widget.WheelView;

import org.appcelerator.titanium.TiDict;
import org.appcelerator.titanium.TiProxy;
import org.appcelerator.titanium.proxy.TiViewProxy;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.view.TiUIView;

import android.widget.LinearLayout;

public class TiUIDateSpinner extends TiUIView
		implements WheelView.OnItemSelectedListener
{
	private WheelView monthWheel;
	private WheelView dayWheel;
	private WheelView yearWheel;
	
	private boolean suppressChangeEvent = false;
	private boolean ignoreItemSelection = false;

	private int defaultMaxYear, defaultMinYear;
	private int maxYear, minYear;
	private Date maxDate, minDate;
	
	private Calendar calendar = Calendar.getInstance();
	
	public TiUIDateSpinner(TiViewProxy proxy)
	{
		super(proxy);
		createNativeView();
	}
	
	private void createNativeView()
	{
		defaultMaxYear = calendar.get(Calendar.YEAR) + 100;
		defaultMinYear = calendar.get(Calendar.YEAR) - 100; 
		DecimalFormat formatter = new DecimalFormat("00");
		// TODO minDate/maxDate
		FormatNumericWheelAdapter months = new FormatNumericWheelAdapter(1, 12, formatter, 4);
		FormatNumericWheelAdapter days = new FormatNumericWheelAdapter(1, 31, formatter, 4);
		FormatNumericWheelAdapter years = new FormatNumericWheelAdapter(
				defaultMinYear, defaultMaxYear,	new DecimalFormat("0000"), 4);
		monthWheel = new WheelView(proxy.getContext());
		dayWheel = new WheelView(proxy.getContext());
		yearWheel = new WheelView(proxy.getContext());
		monthWheel.setAdapter(months);
		dayWheel.setAdapter(days);
		yearWheel.setAdapter(years);
		
    	monthWheel.setItemSelectedListener(this);
    	dayWheel.setItemSelectedListener(this);
    	yearWheel.setItemSelectedListener(this);
        
		LinearLayout layout = new LinearLayout(proxy.getContext());
		layout.setOrientation(LinearLayout.HORIZONTAL);
		
		layout.addView(dayWheel);
		layout.addView(monthWheel);
		layout.addView(yearWheel);
		setNativeView(layout);
		
	}
	
	@Override
	public void processProperties(TiDict d) {
{'fraction_non_alphanumeric': 0.090014064697609, 'fraction_numerical': 0.011653606590315451, 'mean_word_length': 5.456549935149157, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '5939386', 'n_tokens_mistral': 1684, 'n_tokens_neox': 1507, 'n_words': 346}