[Android Q&A, Help & Troubleshooting] flagello79:
..and finally MONTH ACTIVITY.class

PLEASE GIVE ME HELP TO FIND THE PROBLEM AND TO SOLVE THE BUG,SO I CAN USE THE CALENDAR ALSO WHE LANGUAGE PHONE SETTING IS IN ITALIAN,OR FRENCH,OR ANY OTHER LANGUAGES!

package com.android.calendar;

import android.app.Activity;
import android.content.*;
import android.database.ContentObserver;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.text.format.*;
import android.view.*;
import android.view.animation.*;
import android.widget.*;
import com.android.iphoneview.iphoneUtils;
import java.util.*;

// Referenced classes of package com.android.calendar:
// Navigator, MonthView, Utils, AgendaActivity,
// DayActivity, CalendarPreferenceActivity, EditEvent, EventLoader,
// CalendarApplication

public class MonthActivity extends Activity
implements android.widget.ViewSwitcher.ViewFactory, Navigator, android.view.animation.Animation.AnimationListener, android.view.View.OnClickListener
{

public MonthActivity()
{
mUpdateTZ = new _cls1();
oldlines = 0;
mIntentReceiver = new _cls2();
mObserver = new _cls3(new Handler());
}

void eventsChanged()
{
((MonthView)mSwitcher.getCurrentView()).reloadEvents();
}

public boolean getAllDay()
{
return false;
}

public long getSelectedTime()
{
return ((MonthView)mSwitcher.getCurrentView()).getSelectedTimeInMillis();
}

int getStartDay()
{
return mStartDay;
}

protected ViewSwitcher getSwitcher()
{
return mSwitcher;
}

public void goTo(Time time, boolean flag)
{
updateTitle(time);
MonthView monthview = (MonthView)mSwitcher.getCurrentView();
monthview.dismissPopup();
Time time1 = monthview.getTime();
if(flag)
{
int i = time1.month + 12 * time1.year;
MonthView monthview1;
if(time.month + 12 * time.year < i)
{
mSwitcher.setInAnimation(mInAnimationPast);
mSwitcher.setOutAnimation(mOutAnimationPast);
} else
{
mSwitcher.setInAnimation(mInAnimationFuture);
mSwitcher.setOutAnimation(mOutAnimationFuture);
}
}
monthview1 = (MonthView)mSwitcher.getNextView();
monthview1.setSelectionMode(monthview.getSelectionMode());
monthview1.setSelectedTime(time);
monthview1.reloadEvents();
setListview(monthview1.minLines());
monthview1.animationStarted();
mSwitcher.showNext();
monthview1.requestFocus();
mTime = time;
}

public void goToToday()
{
Time time = new Time(Utils.getTimeZone(this, mUpdateTZ));
time.set(System.currentTimeMillis());
time.minute = 0;
time.second = 0;
time.normalize(false);
((TextView)findViewById(0x7f0d0013)).setText(iphoneUtils.formatMonthYear(time));
mTime = time;
MonthView monthview = (MonthView)mSwitcher.getCurrentView();
monthview.setSelectedTime(time);
monthview.reloadEvents();
}

public View makeView()
{
MonthView monthview = new MonthView(this, this);
monthview.setLayoutParams(new android.widget.FrameLayout.LayoutParams(-1, -1));
monthview.setSelectedTime(mTime);
return monthview;
}

public void onAnimationEnd(Animation animation)
{
((MonthView)mSwitcher.getCurrentView()).animationFinished();
}

public void onAnimationRepeat(Animation animation)
{
}

public void onAnimationStart(Animation animation)
{
}

public void onClick(View view)
{
if(!view.equals(mTabAgenda)) goto _L2; else goto _L1
_L1:
iphoneUtils.startActivity(this, com/android/calendar/AgendaActivity.getName(), getSelectedTime());
iphoneUtils.cancelAnimationAndFinishActivity(this);
_L4:
return;
_L2:
if(view.equals(mTabDay))
{
iphoneUtils.startActivity(this, com/android/calendar/DayActivity.getName(), getSelectedTime());
iphoneUtils.cancelAnimationAndFinishActivity(this);
} else
if(view.equals(mButtonSetting))
iphoneUtils.startActivity(this, com/android/calendar/CalendarPreferenceActivity.getName(), getSelectedTime());
else
if(view.equals(mButtonAddEvent))
{
long l = getSelectedTime();
long l1 = l + 0x36ee80L;
Intent intent = new Intent("android.intent.action.EDIT");
intent.setClassName(this, com/android/calendar/EditEvent.getName());
intent.putExtra("beginTime", l);
intent.putExtra("endTime", l1);
intent.putExtra("allDay", getAllDay());
startActivity(intent);
overridePendingTransition(0x7f040000, 0x7f04000d);
} else
if(view.equals(mButtonToday))
goToToday();
if(true) goto _L4; else goto _L3
_L3:
}

protected void onCreate(Bundle bundle)
{
super.onCreate(bundle);
setRequestedOrientation(1);
setContentView(0x7f030019);
mContentResolver = getContentResolver();
long l;
int i;
String s;
String s1;
String s2;
String s3;
String s4;
String s5;
String s6;
if(bundle != null)
l = bundle.getLong("beginTime");
else
l = iphoneUtils.timeFromIntentInMillis(getIntent());
mTime = new Time(Utils.getTimeZone(this, mUpdateTZ));
mTime.set(l);
mTime.normalize(true);
mStartDay = Calendar.getInstance().getFirstDayOfWeek();
i = mStartDay - 1 - 1;
s = DateUtils.getDayOfWeekString(1 + (i + 1) % 7, 20);
((TextView)findViewById(0x7f0d00a7)).setText(s);
s1 = DateUtils.getDayOfWeekString(1 + (i + 2) % 7, 20);
((TextView)findViewById(0x7f0d00a8)).setText(s1);
s2 = DateUtils.getDayOfWeekString(1 + (i + 3) % 7, 20);
((TextView)findViewById(0x7f0d00a9)).setText(s2);
s3 = DateUtils.getDayOfWeekString(1 + (i + 4) % 7, 20);
((TextView)findViewById(0x7f0d00aa)).setText(s3);
s4 = DateUtils.getDayOfWeekString(1 + (i + 5) % 7, 20);
((TextView)findViewById(0x7f0d00ab)).setText(s4);
s5 = DateUtils.getDayOfWeekString(1 + (i + 6) % 7, 20);
((TextView)findViewById(0x7f0d00ac)).setText(s5);
s6 = DateUtils.getDayOfWeekString(1 + (i + 7) % 7, 20);
((TextView)findViewById(0x7f0d00ad)).setText(s6);
((TextView)findViewById(0x7f0d0013)).setText(iphoneUtils.formatMonthYear(mTime));
mEventLoader = new EventLoader(this);
mProgressBar = (ProgressBar)findViewById(0x7f0d0033);
mSwitcher = (ViewSwitcher)findViewById(0x7f0d0034);
mSwitcher.setFactory(this);
mSwitcher.getCurrentView().requestFocus();
mInAnimationPast = AnimationUtils.loadAnimation(this, 0x7f040004);
mOutAnimationPast = AnimationUtils.loadAnimation(this, 0x7f040005);
mInAnimationFuture = AnimationUtils.loadAnimation(this, 0x7f04000a);
mOutAnimationFuture = AnimationUtils.loadAnimation(this, 0x7f04000b);
mInAnimationPast.setAnimationListener(this);
mInAnimationFuture.setAnimationListener(this);
ll = (LinearLayout)findViewById(0x7f0d00ae);
mTabAgenda = (TextView)findViewById(0x7f0d000d);
mTabAgenda.setOnClickListener(this);
mTabDay = (TextView)findViewById(0x7f0d000e);
mTabDay.setOnClickListener(this);
mButtonSetting = (Button)findViewById(0x7f0d0002);
mButtonSetting.setOnClickListener(this);
mButtonAddEvent = (Button)findViewById(0x7f0d0004);
mButtonAddEvent.setOnClickListener(this);
mButtonToday = (Button)findViewById(0x7f0d000c);
mButtonToday.setOnClickListener(this);
}

public boolean onCreateOptionsMenu(Menu menu)
{
return super.onCreateOptionsMenu(menu);
}

protected void onNewIntent(Intent intent)
{
long l = iphoneUtils.timeFromIntentInMillis(intent);
if(l > 0L)
{
Time time = new Time(Utils.getTimeZone(this, mUpdateTZ));
time.set(l);
goTo(time, false);
}
}

public boolean onOptionsItemSelected(MenuItem menuitem)
{
return super.onOptionsItemSelected(menuitem);
}

protected void onPause()
{
super.onPause();
if(isFinishing())
mEventLoader.stopBackgroundThread();
mContentResolver.unregisterContentObserver(mObserver);
unregisterReceiver(mIntentReceiver);
((MonthView)mSwitcher.getCurrentView()).dismissPopup();
((MonthView)mSwitcher.getNextView()).dismissPopup();
mEventLoader.stopBackgroundThread();
CalendarApplication.setDefaultView(this, 0);
}

public boolean onPrepareOptionsMenu(Menu menu)
{
return super.onPrepareOptionsMenu(menu);
}

protected void onResume()
{
super.onResume();
mUpdateTZ.run();
mEventLoader.startBackgroundThread();
eventsChanged();
MonthView monthview = (MonthView)mSwitcher.getCurrentView();
MonthView monthview1 = (MonthView)mSwitcher.getNextView();
String s = PreferenceManager.getDefaultSharedPreferences(this).getString("preferredDetailedView", CalendarPreferenceActivity.DEFAULT_DETAILED_VIEW);
monthview.updateView();
monthview1.updateView();
monthview.setDetailedView(s);
monthview1.setDetailedView(s);
IntentFilter intentfilter = new IntentFilter();
intentfilter.addAction("android.intent.action.TIME_SET");
intentfilter.addAction("android.intent.action.DATE_CHANGED");
intentfilter.addAction("android.intent.action.TIMEZONE_CHANGED");
registerReceiver(mIntentReceiver, intentfilter);
setListview(monthview.minLines());
mContentResolver.registerContentObserver(android.provider.Calendar.Events.CONTENT_URI, true, mObserver);
}

protected void onSaveInstanceState(Bundle bundle)
{
super.onSaveInstanceState(bundle);
bundle.putLong("beginTime", mTime.toMillis(true));
}

public void setListview(int i)
{
lp = (android.widget.RelativeLayout.LayoutParams)ll.getLayoutParams();
newHeight = 110;
if(oldlines == i) goto _L2; else goto _L1
_L1:
if(i != 4) goto _L4; else goto _L3
_L3:
newHeight = 290;
_L6:
lp.height = newHeight;
if(oldHeight != 0)
{
TranslateAnimation translateanimation = new TranslateAnimation(0.0F, 0.0F, newHeight - oldHeight, 0.0F);
translateanimation.setDuration(400L);
ll.startAnimation(translateanimation);
}
oldlines = i;
oldHeight = newHeight;
_L2:
return;
_L4:
if(i == 5)
newHeight = 200;
else
if(i == 6)
newHeight = 110;
if(true) goto _L6; else goto _L5
_L5:
}

protected void startProgressSpinner()
{
mProgressBar.setVisibility(0);
}

protected void stopProgressSpinner()
{
mProgressBar.setVisibility(8);
}

public void updateTitle(Time time)
{
TextView textview = (TextView)findViewById(0x7f0d0013);
StringBuffer stringbuffer = new StringBuffer(iphoneUtils.formatMonthYear(time));
if(!TextUtils.equals(Utils.getTimeZone(this, mUpdateTZ), Time.getCurrentTimezone()))
{
int i = 1;
if(DateFormat.is24HourFormat(this))
i |= 0x80;
long l = System.currentTimeMillis();
String s = Utils.getTimeZone(this, mUpdateTZ);
boolean flag;
TimeZone timezone;
if(time.isDst != 0)
flag = true;
else
flag = false;
timezone = TimeZone.getTimeZone(s);
stringbuffer.append(" (").append(Utils.formatDateRange(this, l, l, i)).append(" ").append(timezone.getDisplayName(flag, 0, Locale.getDefault())).append(")");
}
textview.setText(stringbuffer.toString());
}

private static final boolean DEBUG = true;
private static final int INITIAL_HEAP_SIZE = 0x400000;
private static final String TAG = "MonthActivity";
private LinearLayout ll;
private android.widget.RelativeLayout.LayoutParams lp;
private Button mButtonAddEvent;
private Button mButtonSetting;
private Button mButtonToday;
private ContentResolver mContentResolver;
EventLoader mEventLoader;
private Animation mInAnimationFuture;
private Animation mInAnimationPast;
private BroadcastReceiver mIntentReceiver;
private ContentObserver mObserver;
private Animation mOutAnimationFuture;
private Animation mOutAnimationPast;
private ProgressBar mProgressBar;
private int mStartDay;
private ViewSwitcher mSwitcher;
private TextView mTabAgenda;
private TextView mTabDay;
private Time mTime;
private Runnable mUpdateTZ;
private int newHeight;
private int oldHeight;
private int oldlines;

private class _cls1
implements Runnable
{

public void run()
{
mTime.timezone = Utils.getTimeZone(MonthActivity.this, this);
mTime.normalize(true);
updateTitle(mTime);
}

final MonthActivity this$0;

_cls1()
{
this$0 = MonthActivity.this;
super();
}
}

private class _cls2 extends BroadcastReceiver
{

public void onReceive(Context context, Intent intent)
{
String s = intent.getAction();
if(s.equals("android.intent.action.TIME_SET") || s.equals("android.intent.action.DATE_CHANGED") || s.equals("android.intent.action.TIMEZONE_CHANGED"))
eventsChanged();
}

final MonthActivity this$0;

_cls2()
{
this$0 = MonthActivity.this;
super();
}
}

private class _cls3 extends ContentObserver
{

public boolean deliverSelfNotifications()
{
return true;
}

public void onChange(boolean flag)
{
eventsChanged();
}

final MonthActivity this$0;

_cls3(Handler handler)
{
this$0 = MonthActivity.this;
super(handler);
}
}

}