Skip to content

Commit

Permalink
add new event detail activity
Browse files Browse the repository at this point in the history
  • Loading branch information
sandramngo committed Jul 5, 2014
1 parent 1b1664e commit e6c89e8
Show file tree
Hide file tree
Showing 11 changed files with 294 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
android:name=".activities.HomeActivity"
android:label="@string/title_activity_home" >
</activity>
<activity android:name=".activities.EventDetailActivity"
android:label="@string/event_details_title">
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.sms.partyview.activities;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

import com.sms.partyview.R;
import com.sms.partyview.models.Event;

public class EventDetailActivity extends Activity {
Event mEvent;
TextView tvEventName;
TextView tvEventOrganizer;
TextView tvEventDescription;
TextView tvEventTime;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_event_detail);
mEvent = (Event) getIntent().getSerializableExtra("event");
setupViews();
populateEventInfo();
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.event_detail, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}

public void setupViews() {
tvEventName = (TextView) findViewById(R.id.tvEventNameTitle);
tvEventOrganizer = (TextView) findViewById(R.id.tvEventOrganizerTitle);
tvEventDescription = (TextView) findViewById(R.id.tvEventDescTitle);
tvEventTime = (TextView) findViewById(R.id.tvEventTimeTitle);
}

public void populateEventInfo() {
tvEventName.setText(tvEventName.getText() + ": " + mEvent.getTitle());
tvEventOrganizer.setText(tvEventOrganizer.getText() + ": " + mEvent.getHost().getUserName());
tvEventDescription.setText(tvEventDescription.getText() + ": " + mEvent.getDescription());
tvEventTime.setText(tvEventTime.getText() + ": " + mEvent.getTime());
}
}
17 changes: 17 additions & 0 deletions app/src/main/java/com/sms/partyview/activities/HomeActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.sms.partyview.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
Expand All @@ -8,6 +9,8 @@
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;

import com.astuetz.PagerSlidingTabStrip;
Expand Down Expand Up @@ -70,15 +73,23 @@ public ArrayList<Event> getEvents() {
e1.setTitle("Independence Day BBQ");
e1.setHost(currentUser);
e1.setTime("4 July 2014, 4pm");
e1.setDescription("BBQ to celebrate 4th of July");
Event e2 = new Event();
e2.setTitle("End of CodePath Android Bootcamp");
e2.setHost(currentUser);
e2.setTime("24 July 2014, 7pm");
e2.setDescription("Party to celebrate the end of bootcamp!");
Event e3 = new Event();
e3.setTitle("Outsidelands");
e3.setHost(currentUser);
e3.setTime("8 Aug 2014, 7pm");
e3.setDescription("Music festival in SF!");

// Add the events to the event list.
ArrayList<Event> events = new ArrayList<Event>();
events.add(e1);
events.add(e2);
events.add(e3);

return events;
}
Expand Down Expand Up @@ -122,4 +133,10 @@ private List<Fragment> getFragments() {

return fragments;
}

public void onEventClick(Event event) {
Intent i = new Intent(this, EventDetailActivity.class);
i.putExtra("event", event);
startActivity(i);
}
}
134 changes: 134 additions & 0 deletions app/src/main/java/com/sms/partyview/activities/HomeActivity.java.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
package com.sms.partyview.activities;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;

import com.astuetz.PagerSlidingTabStrip;
import com.sms.partyview.R;
import com.sms.partyview.adapters.MyPagerAdapter;
import com.sms.partyview.fragments.AcceptedEventsFragment;
import com.sms.partyview.fragments.EventListFragment;
import com.sms.partyview.fragments.PendingEventsFragment;
import com.sms.partyview.models.Event;
import com.sms.partyview.models.User;

import java.util.ArrayList;
import java.util.List;

public class HomeActivity
extends FragmentActivity
implements EventListFragment.DummyEventProvider {

private FragmentPagerAdapter mAdapterViewPager;
private PagerSlidingTabStrip mTabs;

User currentUser;

// Keys for passing in data in an intent.
public static final String INTENT_USER_NAME = "user_name";
public static final String INTENT_EMAIL = "email";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);

setupViews();

setupTabs();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.home, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}

@Override
public ArrayList<Event> getEvents() {
Event e1 = new Event();
e1.setTitle("Independence Day BBQ");
e1.setHost(currentUser);
e1.setTime("4 July 2014, 4pm");
Event e2 = new Event();
e2.setTitle("End of CodePath Android Bootcamp");
e2.setHost(currentUser);
e2.setTime("24 July 2014, 7pm");

// Add the events to the event list.
ArrayList<Event> events = new ArrayList<Event>();
events.add(e1);
events.add(e2);

return events;
}

private void setupViews() {
retrieveUserInfo();
}

private void retrieveUserInfo() {
// Store user information.
currentUser = new User();
// Default user info fields.
currentUser.setEmail("foo@example.com");
currentUser.setUserName("AnonymousUser");
// Display the username and email.
String userName = getIntent().getStringExtra(INTENT_USER_NAME);
if (userName != null) {
currentUser.setUserName(userName);
}
String email = getIntent().getStringExtra(INTENT_EMAIL);
if (email != null) {
currentUser.setEmail(email);
}
}

private void setupTabs() {
// Initialize the ViewPager and set an adapter
ViewPager vpPager = (ViewPager) findViewById(R.id.vpPager);
mAdapterViewPager = new MyPagerAdapter(getSupportFragmentManager(), getFragments());
vpPager.setAdapter(mAdapterViewPager);

mTabs = (PagerSlidingTabStrip) findViewById(R.id.tabs);
mTabs.setViewPager(vpPager);
}

private List<Fragment> getFragments() {
List<Fragment> fragments = new ArrayList<Fragment>();

fragments.add(AcceptedEventsFragment.newInstance());
fragments.add(PendingEventsFragment.newInstance());

return fragments;
}

public void onEventClick(Event event) {
Intent i = new Intent(this, EventDetailActivity.class);
i.putExtra("event", event);
startActivity(i);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void onItemClick(AdapterView<?> parent, View view,
Event event = events.get(position);
System.err.println("Event: " + event.getTitle());
// TODO: pass it to listener.
dummyEventProvider.onEventClick(event);
}
});
eventsView.setOnScrollListener(new AbsListView.OnScrollListener() {
Expand All @@ -94,6 +95,7 @@ public void onScroll(AbsListView absListView, int i, int i2, int i3) {
public interface DummyEventProvider {
// Returns an array list of dummy events.
public ArrayList<Event> getEvents();
public void onEventClick(Event event);
}

// Add new events to list.
Expand Down
13 changes: 12 additions & 1 deletion app/src/main/java/com/sms/partyview/models/Event.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.sms.partyview.models;

import java.io.Serializable;

/**
* Created by sque on 7/4/14.
*/
public class Event {
public class Event implements Serializable {
String title;
String time;
User host;
String description;

public String getTitle() {
return title;
Expand All @@ -31,4 +34,12 @@ public User getHost() {
public void setHost(User host) {
this.host = host;
}

public String getDescription() { return description; }

public void setDescription(String desc) {
this.description = desc;
}

}

4 changes: 3 additions & 1 deletion app/src/main/java/com/sms/partyview/models/User.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.sms.partyview.models;

import java.io.Serializable;

/**
* Created by sque on 7/3/14.
*/
public class User {
public class User implements Serializable {
String userName;
String email;
String password; // TODO: consider security issues.
Expand Down
48 changes: 48 additions & 0 deletions app/src/main/res/layout/activity_event_detail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.sms.partyview.activities.EventDetailActivity">

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="@+id/linearLayout">
<TextView
android:id="@+id/tvEventDetailsTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/event_details_title"
android:padding="2dp"/>
<TextView
android:id="@+id/tvEventNameTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/event_name_title"
android:padding="2dp"/>
<TextView
android:id="@+id/tvEventTimeTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/event_time_title"
android:padding="2dp"/>
<TextView
android:id="@+id/tvEventOrganizerTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/event_organizer_title"
android:padding="2dp"/>
<TextView
android:id="@+id/tvEventDescTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/event_desc_title"
android:padding="2dp"/>
</LinearLayout>
</RelativeLayout>
8 changes: 8 additions & 0 deletions app/src/main/res/menu/event_detail.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.sms.partyview.activities.EventDetailActivity" >
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
android:showAsAction="never" />
</menu>
6 changes: 5 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@
<string name="home_event_title_label">Event title</string>
<string name="home_event_time_label">Event date / time</string>
<string name="home_event_host_label">Host name</string>

<string name="event_details_title">Event Details</string>
<string name="event_name_title">Name</string>
<string name="event_time_title">Time</string>
<string name="event_organizer_title">Organizer</string>
<string name="event_desc_title">Description</string>
</resources>

0 comments on commit e6c89e8

Please sign in to comment.