Skip to content

Commit

Permalink
points shop without api logic
Browse files Browse the repository at this point in the history
  • Loading branch information
sneh-saraff committed Feb 13, 2025
1 parent 985b43c commit a637c06
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/org/hackillinois/android/API.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ interface API {
suspend fun buyShopItem(@Body body: ItemInstance): ShopItem

@POST("shop/cart/{itemId}")
fun addItemCart(@Path("itemId") itemId: String) : Call<ResponseBody>
fun addItemCart(@Path("itemId") itemId: String): Call<ResponseBody>

@GET("shop/cart/")
suspend fun getCart(): Cart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ import androidx.recyclerview.widget.RecyclerView
import org.hackillinois.android.R
import org.hackillinois.android.database.entity.ShopItem


class CartFragment : Fragment() {

private lateinit var recyclerView: RecyclerView
private lateinit var cartAdapter: CartAdapter
private var cartItems: List<Pair<ShopItem, Int>> = listOf()

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_point_shop_cart, container, false)

recyclerView = view.findViewById(R.id.recyclerview_point_shop)
Expand All @@ -45,9 +47,7 @@ class CartFragment : Fragment() {
.commit()
}


return view

}

private fun fetchCartData() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import org.hackillinois.android.R

class RedeemFragment : Fragment() {

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val view = inflater.inflate(R.layout.fragment_point_shop_redeem, container, false)

// Handle Back Button Click
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class ShopAdapter(private var itemList: List<ShopItem>) :
// populating views within ViewHolder with data from 'item'
// position is zero-indexed but we want the leaderboard to start at 1
bind(item, holder.itemView, position + 1)


}

private fun bind(item: ShopItem, itemView: View, position: Int) {
Expand All @@ -65,9 +63,7 @@ class ShopAdapter(private var itemList: List<ShopItem>) :
Log.d("CartDebug", "Plus button clicked!")
App.getAPI().addItemCart(item.itemId)
}

}

}

fun updateShop(shopItem: List<ShopItem>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.hackillinois.android.view.shop

import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -15,7 +16,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.fragment_point_shop.number_of_coins_textview
import kotlinx.android.synthetic.main.fragment_point_shop.view.recyclerview_point_shop
import android.util.Log
import org.hackillinois.android.R
import org.hackillinois.android.common.JWTUtilities
import org.hackillinois.android.database.entity.Profile
Expand Down

0 comments on commit a637c06

Please sign in to comment.