Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/subletting' into subletting
Browse files Browse the repository at this point in the history
  • Loading branch information
trinif committed Apr 26, 2024
2 parents 19cf976 + d92cbac commit 2df9fbb
Show file tree
Hide file tree
Showing 15 changed files with 1,313 additions and 231 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.pennapps.labs.pennmobile
package com.pennapps.labs.pennmobile.Subletting

import android.graphics.BitmapFactory
import android.os.Bundle
Expand All @@ -15,20 +15,19 @@ import android.widget.Toast
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.fragment.app.Fragment
import com.pennapps.labs.pennmobile.MainActivity
import com.pennapps.labs.pennmobile.api.StudentLife
import com.pennapps.labs.pennmobile.classes.AmenitiesItem
import com.pennapps.labs.pennmobile.classes.MultipartUtil
import com.pennapps.labs.pennmobile.classes.Sublet
import com.pennapps.labs.pennmobile.classes.SublettingViewModel
import com.pennapps.labs.pennmobile.databinding.FragmentNewListingsBinding
import okhttp3.MediaType.Companion.toMediaType
import com.pennapps.labs.pennmobile.databinding.FragmentSubletterNewListingBinding
import okhttp3.MultipartBody
import okhttp3.RequestBody.Companion.toRequestBody
import java.io.IOException


class NewListingsFragment(private val dataModel: SublettingViewModel) : Fragment() {
private var _binding: FragmentNewListingsBinding? = null
private var _binding: FragmentSubletterNewListingBinding? = null
private val binding get() = _binding!!

private lateinit var mStudentLife: StudentLife
Expand Down Expand Up @@ -100,7 +99,7 @@ class NewListingsFragment(private val dataModel: SublettingViewModel) : Fragment

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?): View? {
_binding = FragmentNewListingsBinding.inflate(inflater, container, false)
_binding = FragmentSubletterNewListingBinding.inflate(inflater, container, false)
val view = binding.root
super.onViewCreated(view, savedInstanceState)

Expand Down Expand Up @@ -253,8 +252,10 @@ class NewListingsFragment(private val dataModel: SublettingViewModel) : Fragment
}
}

val subletPart = MultipartUtil.createSubletPart(subletId)

if (multipartImage != null) {
val subletPart = MultipartUtil.createSubletPart(subletId)
dataModel.postImage(mActivity, subletId, subletPart, multipartImage!!)
}



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import androidx.viewpager2.widget.ViewPager2
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.pennapps.labs.pennmobile.MainActivity
import com.pennapps.labs.pennmobile.R
import com.pennapps.labs.pennmobile.api.StudentLife
import com.pennapps.labs.pennmobile.classes.Sublet
import com.pennapps.labs.pennmobile.classes.SublettingViewModel
Expand All @@ -34,7 +36,7 @@ class SubletDetailsFragment(private val dataModel: SublettingViewModel, private

val sublet : Sublet = dataModel.getSublet(subletNumber)
binding.titleText.text = sublet.title
binding.priceText.text = sublet.price.toString()
binding.priceText.text = "$" + sublet.price.toString()
binding.addressText.text = sublet.address
binding.datesText.text = sublet.startDate + " to " + sublet.endDate
binding.descriptionText.text = sublet.description ?: "None"
Expand All @@ -51,9 +53,26 @@ class SubletDetailsFragment(private val dataModel: SublettingViewModel, private
dataModel.deleteSublet(mActivity, subletNumber)
}

binding.editText.setOnClickListener(){
navigateEditListing()
}




return binding.root
}

private fun navigateEditListing() {
val mainActivity = context as MainActivity

val fragment = SubletEditFragment(dataModel, subletNumber)

val fragmentManager = mainActivity.supportFragmentManager
fragmentManager.beginTransaction()
.replace(R.id.content_frame, fragment, "NEW_LISTING_FRAGMENT")
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.addToBackStack(null)
.commitAllowingStateLoss()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import android.view.ViewGroup
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayout
import com.google.android.material.tabs.TabLayoutMediator
import com.pennapps.labs.pennmobile.MainActivity
import com.pennapps.labs.pennmobile.R
import com.pennapps.labs.pennmobile.adapters.SubletDetailsPagerAdapter
Expand Down Expand Up @@ -41,6 +43,16 @@ class SubletDetailsHolderFragment(private val dataModel: SublettingViewModel, pr
subletDetailsPagerAdapter = SubletDetailsPagerAdapter(this, dataModel, subletNumber)
viewPager = view.findViewById(R.id.listing_view_pager)
viewPager.adapter = subletDetailsPagerAdapter
val tabLayout : TabLayout = view.findViewById(R.id.listing_tab_layout)
TabLayoutMediator(tabLayout, viewPager) { tab, position ->
if(position == 0) {
tab.text = "Details"
} else {
tab.text = "Candidates"
}
}.attach()




}
Expand Down
Loading

0 comments on commit 2df9fbb

Please sign in to comment.