Skip to content

Commit

Permalink
Merge pull request #31 from cis3296f22/fedor-dev
Browse files Browse the repository at this point in the history
Created Book data class & Rec Fragment Functionality
  • Loading branch information
loganbee authored Nov 16, 2022
2 parents 9a566fc + 0d196c5 commit e316388
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 26 deletions.
1 change: 1 addition & 0 deletions .idea/misc.xml

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

1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies {
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/edu/temple/bookrecommendationsystem/Book.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package edu.temple.bookrecommendationsystem

import java.net.URL

data class Book(val title: String, val author: String, val coverURL: Int)
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package edu.temple.bookrecommendationsystem

import android.annotation.SuppressLint
import android.graphics.Color
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import org.w3c.dom.Text

/**
* A simple [Fragment] subclass.
Expand All @@ -21,8 +26,40 @@ class RecommendationFragment : Fragment() {
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val rootView = inflater.inflate(R.layout.fragment_recommendation, container, false)
rootView.findViewById<TextView>(R.id.testt).text = "Hey there!"
return rootView
return inflater.inflate(R.layout.fragment_recommendation, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
var count = 0
val dummyBooks = arrayOf(Book("Red Book", "Red Author", R.color.red),
Book("Blue Book", "Blue Author", R.color.blue),
Book("Green Book", "Green Author", R.color.green),
Book("Yellow Book", "Yellow Author", R.color.yellow),
Book("Cyan Book", "Cyan Author", R.color.cyan),
Book("Magenta Book", "Magenta Author", R.color.magenta))
val cover = requireView().findViewById<ImageView>(R.id.recommendationCover)
val title = requireView().findViewById<TextView>(R.id.recommendationTitle)
val author = requireView().findViewById<TextView>(R.id.recommendationAuthor)
cover.setImageResource(dummyBooks[0].coverURL)
title.text = dummyBooks[0].title
author.text = dummyBooks[0].author

requireView().findViewById<Button>(R.id.dislike_button).setOnClickListener {
count++
val index = count % dummyBooks.size
cover.setImageResource(dummyBooks[index].coverURL)
title.text = dummyBooks[index].title
author.text = dummyBooks[index].author
}

requireView().findViewById<Button>(R.id.like_button).setOnClickListener {
count++
val index = count % dummyBooks.size
cover.setImageResource(dummyBooks[index].coverURL)
title.text = dummyBooks[index].title
author.text = dummyBooks[index].author
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageButton

/**
* A simple [Fragment] subclass.
Expand All @@ -14,14 +15,15 @@ import android.view.ViewGroup
class SearchFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

}

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_search, container, false)
val rootview = inflater.inflate(R.layout.fragment_search, container, false)
return rootview
}

}
35 changes: 22 additions & 13 deletions app/src/main/res/layout/fragment_recommendation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,30 @@
<ImageView
android:layout_width="175dp"
android:layout_height="225dp"
android:id="@+id/bookCover"
android:id="@+id/recommendationCover"
android:layout_gravity="center"
android:src="@color/cardview_dark_background"
android:layout_marginBottom="50dp"/>
android:layout_marginBottom="15dp"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/recommendationTitle"
android:text="Book Title"
android:textSize="36sp"
android:layout_gravity="center"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/recommendationAuthor"
android:text="Book Author"
android:textStyle="italic"
android:textSize="20sp"
android:layout_gravity="center"
android:layout_marginBottom="25dp"
/>

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -36,15 +56,4 @@

</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/testt"
android:text="@string/book_recommendation_system"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#0000C1"
android:layout_gravity="center"
android:layout_marginBottom="50dp" />

</LinearLayout>
19 changes: 11 additions & 8 deletions app/src/main/res/layout/fragment_search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">

<Button
android:id="@+id/searchBooksButton"
android:layout_width="match_parent"
android:layout_height="75dp"
android:text="SEARCH"
tools:ignore="ImageContrastCheck,RedundantDescriptionCheck"
tools:layout_editor_absoluteX="129dp"
tools:layout_editor_absoluteY="0dp" />
<ImageButton
android:id="@+id/searchButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:src="@android:drawable/ic_menu_search"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</LinearLayout>
6 changes: 6 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
<color name="red">#FF0000</color>
<color name="blue">#0000FF</color>
<color name="green">#00FF00</color>
<color name="yellow">#FFFF00</color>
<color name="cyan">#00FFFF</color>
<color name="magenta">#FF00FF</color>
</resources>

0 comments on commit e316388

Please sign in to comment.