-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic "Snack Details" activity.
- Loading branch information
Showing
5 changed files
with
172 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters