Skip to content

Commit

Permalink
Add: Bundle information from sublettee fragment, send to sublettee ma…
Browse files Browse the repository at this point in the history
…rketplace. Information is currently accessible within sublettee marketplace but additional search logic needs to be implemented.
  • Loading branch information
joemacd committed Jan 19, 2025
1 parent c200e28 commit 2293183
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,37 @@ class SubletteeFragment : Fragment() {
return@setOnClickListener
}

//Information to pass:
//Dates
val startDateMillis = startCalendar.timeInMillis
val endDateMillis = endCalendar.timeInMillis
//Price
val minPriceString = binding.subletteeMinPriceText.text.toString().trim()
val maxPriceString = binding.subletteeMaxPriceText.text.toString().trim()
val minPrice = minPriceString.toDouble()
val maxPrice = maxPriceString.toDouble()
//Location
val selectedLocation = binding.subletteeLocationAddressView.text.toString().removePrefix("Address: ").trim()

//Create the bundle:
val bundle = Bundle().apply {
putString("location", selectedLocation)
putDouble("minPrice", minPrice)
putDouble("maxPrice", maxPrice)
putLong("startDate", startDateMillis)
putLong("endDate", endDateMillis)
putBoolean("datesFlexible", areDatesFlexible)
putBoolean("locationFlexible", areLocationsFlexible)
}

//Pass the bundle:
val subletteeMarketplace = SubletteeMarketplace().apply {
arguments = bundle
}

// Load new fragment, which will hold the subletting marketplace in whole
mActivity.supportFragmentManager.beginTransaction()
.replace(((view as ViewGroup).parent as View).id, SubletteeMarketplace())
.replace(((view as ViewGroup).parent as View).id, subletteeMarketplace)
.addToBackStack(null)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.commit()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.ImageButton
import android.widget.Spinner
import android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import androidx.recyclerview.widget.GridLayoutManager
Expand Down Expand Up @@ -62,6 +63,18 @@ class SubletteeMarketplace : Fragment() {
dataModel = SublesseeViewModel(mActivity, mStudentLife)

val bundle = Bundle()

arguments?.let { bundle ->
val location = bundle.getString("location", "")
val minPrice = bundle.getDouble("minPrice", 0.0)
val maxPrice = bundle.getDouble("maxPrice", 0.0)
val startDateMillis = bundle.getLong("startDate", 0L)
val endDateMillis = bundle.getLong("endDate", 0L)
val datesFlexible = bundle.getBoolean("datesFlexible", false)
val locationFlexible = bundle.getBoolean("locationFlexible", false)

//Next Step: Add additional search logic now that the args have been retrieved
}
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
Expand Down

0 comments on commit 2293183

Please sign in to comment.