Moved adding to calender to it's own method in event view. No longer will it be invoked by long-clicking in event list.

This commit is contained in:
Robert Kolner committed 2012-01-16 22:50:52 +01:00
1 parent 2090cd222d
commit 3acf6bb8b7
3 files changed
+30 -32

No files matched your search

+1
View File
@@ -14,4 +14,5 @@
<string name="main_menu_opening_hours">ÅPNINGSTIDER I DAG</string>
<string name="main_menu_tickets">BILLETTER</string><string name="main_menu_join">BLI MED</string>
<string name="main_menu_news">NYHETER</string>
<string name="calendar_not_found">Kunne ikke finne kalender-app. Avbryter.</string>
</resources>
@@ -10,7 +10,6 @@ import java.text.SimpleDateFormat;
import org.w3c.dom.NodeList;
import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
@@ -22,9 +21,8 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListAdapter;
@@ -154,7 +152,6 @@ public class EventListActivity extends BaseDnsActivity {
/* Add onClickListeners: */
row.setOnClickListener(getShortClickListener(e));
row.setOnLongClickListener(getLongClickListener(e));
return row;
}
@@ -260,31 +257,4 @@ public class EventListActivity extends BaseDnsActivity {
}
};
}
protected OnLongClickListener getLongClickListener (final Event e) {
return new OnLongClickListener() {
public boolean onLongClick(View v) {
if (e.getDate() == null)
return false;
long startDate = e.getDate().getTime();
try {
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("title", e.title);
intent.putExtra("beginTime", startDate);
intent.putExtra("endTime", startDate + (2*60*60*1000)); // Two hours
intent.putExtra("allDay", false);
intent.putExtra("eventLocation", e.getLocation());
intent.putExtra("reminder", false);
startActivity(intent);
return true;
} catch (ActivityNotFoundException e) {
return false;
}
}
};
}
}
@@ -2,6 +2,7 @@ package com.studentersamfundet.app.ui;
import java.text.SimpleDateFormat;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
@@ -11,18 +12,22 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.studentersamfundet.app.Event;
import com.studentersamfundet.app.R;
public class EventViewActivity extends BaseDnsActivity {
Event event;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.event_view);
Intent intent = getIntent();
final Event e = (Event)intent.getSerializableExtra("event");
this.event = (Event)intent.getSerializableExtra("event");
final Event e = this.event;
if (e == null) {
throw new Error("This should NEVER happen");
@@ -67,4 +72,26 @@ public class EventViewActivity extends BaseDnsActivity {
});
}
}
public void addToCalender(View v) {
if (this.event.getDate() == null)
return;
long startDate = this.event.getDate().getTime();
try {
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("title", this.event.title);
intent.putExtra("beginTime", startDate);
intent.putExtra("endTime", startDate + (2*60*60*1000)); // Two hours
intent.putExtra("allDay", false);
intent.putExtra("eventLocation", this.event.getLocation());
intent.putExtra("reminder", false);
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, R.string.calendar_not_found, Toast.LENGTH_SHORT).show();
}
}
}