Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/quanuw/WineApp
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-r-teng committed Mar 30, 2019
2 parents 84e7887 + 242a939 commit 55f41a5
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 13 deletions.
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:configChanges="orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
27 changes: 25 additions & 2 deletions app/src/main/java/com/example/wineapp/AddWineFragment.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.example.wineapp;

import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.InputType;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RatingBar;
import android.widget.Toast;


Expand All @@ -35,6 +38,7 @@ public class AddWineFragment extends Fragment {

private EditText nameEditText;
private EditText yearEditText;
private RatingBar ratingRatingBar;
private Button addWineButton;

public AddWineFragment() {
Expand Down Expand Up @@ -76,17 +80,22 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
nameEditText = rootView.findViewById(R.id.name);
yearEditText = rootView.findViewById(R.id.year);
yearEditText.setInputType(InputType.TYPE_CLASS_NUMBER);
ratingRatingBar = rootView.findViewById(R.id.rating);
addWineButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = nameEditText.getText().toString();
String year = yearEditText.getText().toString();
String rating = String.valueOf(ratingRatingBar.getRating());
Toast.makeText(
getActivity(),
"ADDING WINE: " + name + " " + year + " beep boop...",
"ADDING WINE: " + name + " " + year + " " + rating + " stars beep boop...",
Toast.LENGTH_SHORT
).show();

DataManager dataManager = new DataManager(getActivity());
dataManager.insert(name, "Secret Sauce");
showData(dataManager.selectAll());
getFragmentManager().popBackStack();
}
});
return rootView;
Expand Down Expand Up @@ -116,6 +125,12 @@ public void onDetach() {
mListener = null;
}

@Override
public void onDestroy() {
super.onDestroy();
setRetainInstance(true);
}

/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
Expand All @@ -130,4 +145,12 @@ public interface OnAddWineListener {
// TODO: Update argument type and name
void onAddWine();
}

public void showData (Cursor c) {
while (c.moveToNext()){

Log.i("LOLOLOLOL" + c.getString(0), c.getString(1) + ", " + c.getString(2) + ", "
+ c.getString(3) + ", " + c.getString(4) + ", " + c.getString(5));
}
}
}
5 changes: 5 additions & 0 deletions app/src/main/java/com/example/wineapp/WineDetailFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ public void onDetach() {
mListener = null;
}

@Override
public void onDestroy() {
super.onDestroy();
}

/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/anim/enter_from_bottom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<translate
android:fromXDelta="0%" android:toXDelta="0%"
android:fromYDelta="100%" android:toYDelta="0%"
android:duration="500" />
android:duration="400" />
</set>
2 changes: 1 addition & 1 deletion app/src/main/res/anim/exit_from_top.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<translate
android:fromXDelta="0%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="100%"
android:duration="500" />
android:duration="400" />
</set>
12 changes: 12 additions & 0 deletions app/src/main/res/layout/fragment_add_wine.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
android:hint="year"
android:textColor="@android:color/black" />

<RatingBar
android:id="@+id/rating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="143dp"
android:numStars="5"
android:stepSize="1"
android:progressTint="@color/gold"
android:secondaryProgressTint="@color/gold"/>

<Button
android:id="@+id/addWineButton"
android:layout_width="wrap_content"
Expand Down
29 changes: 21 additions & 8 deletions app/src/main/res/layout/wine_detail.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/wineDetailContents"
Expand All @@ -12,11 +12,24 @@

<TextView
android:id="@+id/info"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</android.support.constraint.ConstraintLayout>
<RatingBar
android:id="@+id/ratingDetail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="158dp"
android:layout_marginEnd="74dp"
android:layout_marginRight="74dp"
android:numStars="5"
android:progressTint="@color/gold"
android:secondaryProgressTint="@color/gold"
android:stepSize="1"
tools:layout_editor_absoluteX="72dp"
tools:layout_editor_absoluteY="101dp" />

</RelativeLayout>
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<color name="colorAccent">#D81B60</color>
<color name="colorWineListBackgroundLight">#E0E0E0</color>
<color name="colorWineListRowBackgroundDark">#CBCBCB</color>
<color name="gold">#FFD700</color>
</resources>

0 comments on commit 55f41a5

Please sign in to comment.