Skip to content

Commit

Permalink
Add scrollview and add to cart button on the details page
Browse files Browse the repository at this point in the history
  • Loading branch information
anas-ambri committed Jan 25, 2016
1 parent 5258220 commit 32f04f7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 29 deletions.
Expand Up @@ -32,7 +32,9 @@ protected void onCreate(Bundle savedInstanceState) {
}

// Show the Up button in the action bar.
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}

if (savedInstanceState == null) {
Fragment fragment = new BookDetailsFragmentBuilder(book).build();
Expand Down
Expand Up @@ -4,6 +4,7 @@
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.hannesdorfmann.fragmentargs.annotation.Arg;
import com.hannesdorfmann.mosby.mvp.MvpFragment;
Expand All @@ -13,6 +14,7 @@
import com.verybadalloc.designlib.presenters.BookDetailsPresenter;

import butterknife.InjectView;
import butterknife.OnClick;
import icepick.Icicle;

/**
Expand All @@ -33,6 +35,10 @@ public class BookDetailsFragment extends MvpFragment<BookDetailsView, BookDetail
TextView bookName;
@InjectView(R.id.book_author)
TextView bookAuthor;
@OnClick(R.id.book_add_cart)
void addToCart (){
Toast.makeText(getActivity(), "Book added to cart!", Toast.LENGTH_LONG).show();
}

public static final String BOOK = "book";

Expand Down
71 changes: 44 additions & 27 deletions app/src/main/res/layout/book_details_fragment.xml
@@ -1,37 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:fillViewport="false"
android:layout_width="match_parent"
android:orientation="vertical"
android:padding="15dp"
android:gravity="center_horizontal"
android:layout_height="match_parent"
tools:context=".BookDetailsFragment">
>
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:padding="15dp"
android:gravity="center_horizontal"
android:layout_height="match_parent"
tools:context=".BookDetailsFragment">

<ImageView
android:layout_width="200dp"
android:paddingBottom="20dp"
android:layout_height="wrap_content"
android:id="@+id/book_image"
android:adjustViewBounds="true"
android:src="@mipmap/book_image_not_found" />
<ImageView
android:layout_width="200dp"
android:paddingBottom="20dp"
android:layout_height="wrap_content"
android:id="@+id/book_image"
android:adjustViewBounds="true"
android:src="@mipmap/book_image_not_found" />

<TextView
android:id="@+id/book_name"
android:paddingBottom="5dp"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Book Name"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/book_name"
android:paddingBottom="5dp"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Book Name"
android:layout_height="wrap_content" />

<TextView
android:id="@+id/book_author"
android:paddingBottom="15dp"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Address"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/book_author"
android:paddingBottom="15dp"
android:layout_width="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Address"
android:layout_height="wrap_content" />

</LinearLayout>
<Button
android:id="@+id/book_add_cart"
android:textAppearance="?android:attr/textAppearanceButton"
android:background="?attr/colorAccent"
android:text="Add to Cart"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:textColor="?attr/colorPrimary"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="50dp" />
</LinearLayout>
</ScrollView>
6 changes: 5 additions & 1 deletion app/src/main/res/values/styles.xml
@@ -1,8 +1,12 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="Base.AppTheme">
<!-- Customize your theme here. -->
</style>

<style name="Base.AppTheme" parent="Theme.AppCompat.Light.NoActionBar" >

</style>

</resources>

0 comments on commit 32f04f7

Please sign in to comment.