Skip to content

Commit

Permalink
Added basic "Snack Details" activity.
Browse files Browse the repository at this point in the history
  • Loading branch information
jfpiv committed Dec 8, 2015
1 parent 7f2e2ad commit 8c95831
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 5 deletions.
6 changes: 5 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<activity
android:name=".SplashScreen"
android:label="@string/app_name"
android:theme="@style/SplashTheme">
android:theme="@style/SplashTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down Expand Up @@ -58,6 +58,10 @@
android:label="@string/title_activity_welcome"
android:theme="@style/FullscreenTheme" >
</activity>
<activity
android:name=".SnackDetails"
android:label="@string/title_activity_snack_details" >
</activity>
</application>

</manifest>
9 changes: 5 additions & 4 deletions app/src/main/java/edu/sc/snacktrack/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,11 @@ public void onRDTPostExecute(final List<SnackEntry> snackList) {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
SnackEntry entry = snackList.get(position);

Log.d(TAG, "onItemClick, position " + position);
Log.d(TAG, "Snack detail coming up...");
Log.d(TAG, "Description: " + entry.getDescription());
Log.d(TAG, "Meal type: " + entry.getMealType());
Intent intent = new Intent(MainActivity.this, SnackDetails.class);
intent.putExtra(SnackDetails.DESCRIPTION_KEY, entry.getDescription());
intent.putExtra(SnackDetails.MEAL_TYPE_KEY, entry.getMealType());
intent.putExtra(SnackDetails.PHOTO_URL_KEY, entry.getPhoto().getUrl());
startActivity(intent);
}
});

Expand Down
66 changes: 66 additions & 0 deletions app/src/main/java/edu/sc/snacktrack/SnackDetails.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package edu.sc.snacktrack;

import android.content.Intent;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;

import org.w3c.dom.Text;

public class SnackDetails extends AppCompatActivity {

public static final String DESCRIPTION_KEY = "description";
public static final String MEAL_TYPE_KEY = "mealType";
public static final String PHOTO_URL_KEY = "photoURL";

private ImageView imageView;
private TextView descriptionTextView;
private TextView mealTypeTextView;

private ImageLoader imageLoader;

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

ActionBar actionBar = getSupportActionBar();
if(actionBar != null){
actionBar.setDisplayHomeAsUpEnabled(true);
}

Intent data = getIntent();

String photoURL = data.getStringExtra(PHOTO_URL_KEY);
String description = data.getStringExtra(DESCRIPTION_KEY);
String mealType = data.getStringExtra(MEAL_TYPE_KEY);

imageLoader = new ImageLoader(this);

imageView = (ImageView) findViewById(R.id.imageView);
descriptionTextView = (TextView) findViewById(R.id.descriptionTextView);
mealTypeTextView = (TextView) findViewById(R.id.mealTypeTextView);

imageLoader.DisplayImage(photoURL, imageView);
descriptionTextView.setText(description != null ? description : "No description");
mealTypeTextView.setText(mealType != null ? mealType : "No meal type");
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

int id = item.getItemId();

switch(id){
case android.R.id.home:
finish();
break;
}

return super.onOptionsItemSelected(item);
}
}
95 changes: 95 additions & 0 deletions app/src/main/res/layout/activity_snack_details.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/bg">

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin">


<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/imageView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="@drawable/ic_photo_camera_black_24dp"
android:scaleType="centerCrop"
android:layout_marginBottom="20dp" />

<LinearLayout
android:id="@+id/mealTypeWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/imageView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="#55ffffff"
android:padding="10dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="What is this?"
android:id="@+id/mealTypeLabel" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/mealTypeTextView"
android:textAppearance="?android:attr/textAppearanceMedium"
tools:text="Here's the meal type."
android:textColor="@android:color/black"/>

</LinearLayout>

<LinearLayout
android:id="@+id/descriptionWrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/mealTypeWrapper"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="20dp"
android:background="#55ffffff"
android:padding="10dp">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/description_label"
android:id="@+id/descriptionLabel" />


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:hint="@string/edit_description_hint"
android:id="@+id/descriptionTextView"
android:scrollbars="vertical"
android:minHeight="100dp"
android:textColor="#000000"/>

</LinearLayout>

</RelativeLayout>

</ScrollView>

</FrameLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@
<string name="title_activity_welcome">WelcomeActivity</string>
<string name="dummy_button">Dummy Button</string>
<string name="dummy_content">WELCOME TO \nSNACKTRACK</string>
<string name="title_activity_snack_details">Snack Details</string>
</resources>

0 comments on commit 8c95831

Please sign in to comment.