From 0360ff1f41786015f49acb073512f5cee7793656 Mon Sep 17 00:00:00 2001 From: vavali08 Date: Fri, 25 Oct 2024 17:53:22 -0400 Subject: [PATCH] Main in subletting!! --- .../Subletting/SubletDetailsHolderFragment.kt | 5 -- .../Subletting/SubletterHolderFragment.kt | 9 +-- .../pennmobile/adapters/MainPagerAdapter.kt | 3 +- .../adapters/PostedSubletsListAdapter.kt | 6 +- .../labs/pennmobile/api/StudentLife.java | 80 +++++++++++++++++++ build.gradle | 4 +- 6 files changed, 91 insertions(+), 16 deletions(-) diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/Subletting/SubletDetailsHolderFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/Subletting/SubletDetailsHolderFragment.kt index 1b7f9cb3..94342cdd 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/Subletting/SubletDetailsHolderFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/Subletting/SubletDetailsHolderFragment.kt @@ -15,7 +15,6 @@ import com.pennapps.labs.pennmobile.adapters.SubletDetailsPagerAdapter import com.pennapps.labs.pennmobile.api.StudentLife import com.pennapps.labs.pennmobile.classes.SublettingViewModel import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior -import kotlinx.android.synthetic.main.fragment_dining_holder.view.appbar_home_holder //Pulls existing datamodel from previous class SubletDetailsHolderFragment(private val dataModel: SublettingViewModel, private val subletNumber: Int) : Fragment() { @@ -57,8 +56,4 @@ class SubletDetailsHolderFragment(private val dataModel: SublettingViewModel, pr } - - private fun initAppBar(view: View) { - (view.appbar_home_holder.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() - } } \ No newline at end of file diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/Subletting/SubletterHolderFragment.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/Subletting/SubletterHolderFragment.kt index 2c5b262b..1927ca9c 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/Subletting/SubletterHolderFragment.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/Subletting/SubletterHolderFragment.kt @@ -13,7 +13,6 @@ import com.pennapps.labs.pennmobile.adapters.SubletterPagerAdapter import com.pennapps.labs.pennmobile.api.StudentLife import com.pennapps.labs.pennmobile.classes.SublettingViewModel import com.pennapps.labs.pennmobile.components.collapsingtoolbar.ToolbarBehavior -import kotlinx.android.synthetic.main.fragment_dining_holder.view.appbar_home_holder class SubletterHolderFragment : Fragment() { lateinit var subletterPagerAdapter: SubletterPagerAdapter @@ -46,8 +45,8 @@ class SubletterHolderFragment : Fragment() { } - - private fun initAppBar(view: View) { - (view.appbar_home_holder.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() - } +// +// private fun initAppBar(view: View) { +// (view.appbar_home_holder.layoutParams as CoordinatorLayout.LayoutParams).behavior = ToolbarBehavior() +// } } \ No newline at end of file diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/MainPagerAdapter.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/MainPagerAdapter.kt index d90d8bac..7d61231b 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/MainPagerAdapter.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/MainPagerAdapter.kt @@ -8,6 +8,7 @@ import com.pennapps.labs.pennmobile.DiningHolderFragment import com.pennapps.labs.pennmobile.GsrTabbedFragment import com.pennapps.labs.pennmobile.HomeFragment import com.pennapps.labs.pennmobile.LaundryFragment +import com.pennapps.labs.pennmobile.Subletting.SublettingFragment import com.pennapps.labs.pennmobile.morefragments.MoreFragment class MainPagerAdapter( @@ -19,7 +20,7 @@ class MainPagerAdapter( HOME_POSITION -> HomeFragment() DINING_POSITION -> DiningHolderFragment() GSR_POSITION -> GsrTabbedFragment() - LAUNDRY_POSITION -> LaundryFragment() + LAUNDRY_POSITION -> SublettingFragment() MORE_POSITION -> MoreFragment() else -> HomeFragment() } diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/PostedSubletsListAdapter.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/PostedSubletsListAdapter.kt index 6d98bcdd..0ce3290c 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/PostedSubletsListAdapter.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/PostedSubletsListAdapter.kt @@ -12,14 +12,14 @@ 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.SublesseeDetailsFragment +import com.pennapps.labs.pennmobile.Subletting.SublesseeDetailsFragment import com.pennapps.labs.pennmobile.Subletting.SubletDetailsFragment import com.pennapps.labs.pennmobile.Subletting.SubletDetailsHolderFragment import com.pennapps.labs.pennmobile.classes.Sublet import com.pennapps.labs.pennmobile.classes.SublettingModel import com.pennapps.labs.pennmobile.classes.SublettingViewModel -import kotlinx.android.synthetic.main.include_main.expandable_bottom_bar -import kotlinx.android.synthetic.main.include_main.toolbar +//import kotlinx.android.synthetic.main.include_main.expandable_bottom_bar +//import kotlinx.android.synthetic.main.include_main.toolbar class PostedSubletsListAdapter(private val dataModel: SublettingViewModel): RecyclerView.Adapter() { diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/api/StudentLife.java b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/api/StudentLife.java index aa344921..b2a3ee9f 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/api/StudentLife.java +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/api/StudentLife.java @@ -16,24 +16,30 @@ import com.pennapps.labs.pennmobile.classes.GSRLocation; import com.pennapps.labs.pennmobile.classes.GSRReservation; import com.pennapps.labs.pennmobile.classes.LaundryRoom; +import com.pennapps.labs.pennmobile.classes.Offer; import com.pennapps.labs.pennmobile.classes.Poll; import com.pennapps.labs.pennmobile.classes.Post; import com.pennapps.labs.pennmobile.classes.SaveAccountResponse; +import com.pennapps.labs.pennmobile.classes.Sublet; import com.pennapps.labs.pennmobile.classes.Venue; import com.pennapps.labs.pennmobile.classes.WhartonStatus; import java.util.ArrayList; import java.util.List; +import okhttp3.MultipartBody; import retrofit.Callback; import retrofit.client.Response; import retrofit.http.Body; +import retrofit.http.DELETE; import retrofit.http.Field; import retrofit.http.FormUrlEncoded; import retrofit.http.GET; import retrofit.http.Header; import retrofit.http.Headers; import retrofit.http.POST; +import retrofit.http.PUT; +import retrofit.http.Part; import retrofit.http.Path; import retrofit.http.Query; import rx.Observable; @@ -190,4 +196,78 @@ void sendFitnessPref( @Header("Authorization") String bearerToken, @Body FitnessRequest rooms, Callback callback); + + + @Headers({"Content-Type: application/json"}) + @POST("/sublet/properties/") + void createSublet( + @Header("Authorization") String bearerToken, + @Body Sublet sublet, + Callback callback); + + @Headers({"Content-Type: application/json"}) + @POST("/sublet/properties/{sublet_id}/images/") + void createImage( + @Header("Authorization") String bearerToken, + @Path("sublet_id") int id, + @Part("sublet") MultipartBody.Part sublet, + @Part("image") MultipartBody.Part partFile, + Callback callback + ); + + @Headers({"Content-Type: application/json"}) + @GET("/sublet/properties/") + Observable> getPostedSublets( + @Header("Authorization") String bearerToken, + @Query("subletter") boolean subletter); + + @Headers({"Content-Type: application/json"}) + @GET("/sublet/properties/{sublet_id}/offers/") + Observable> getSubletOffers( + @Header("Authorization") String bearerToken, + @Path("sublet_id") int id + ); + + @Headers({"Content-Type: application/json"}) + @DELETE("/sublet/properties/{sublet_id}") + void deleteSublet( + @Header("Authorization") String bearerToken, + @Path("sublet_id") int id, + Callback callback); + + @Headers({"Content-Type: application/json"}) + @PUT("/sublet/properties/{sublet_id}") + void editSublet( + @Header("Authorization") String bearerToken, + @Path("sublet_id") int id, + @Body Sublet sublet, + Callback callback + ); + + @Headers({"Content-Type: application/json"}) + @GET("/sublet/properties/") + Observable> getSublets( + @Header("Authorization") String bearerToken); + + @Headers({"Content-Type: application/json"}) + @POST("/sublet/properties/{sublet_id}/favorites/") + void addFavoriteSublet( + @Header("Authorization") String bearerToken, + @Path("sublet_id") int id, + @Body Sublet sublet, + Callback callback); + + @Headers({"Content-Type: application/json"}) + @GET("/sublet/favorites/") + Observable> getSubletFavorites( + @Header("Authorization") String bearerToken); + + @Headers({"Content-Type: application/json"}) + @POST("/sublet/properties/{sublet_id}/offers/") + void createOffer( + @Header("Authorization") String bearerToken, + @Path("sublet_id") int id, + @Body Offer offer, + Callback callback); } + diff --git a/build.gradle b/build.gradle index fc2b26d7..fcc3e50d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { - id 'com.android.application' version '8.6.1' apply false - id 'com.android.library' version '8.6.1' apply false + id 'com.android.application' version '8.0.2' apply false + id 'com.android.library' version '8.0.2' apply false id 'org.jetbrains.kotlin.android' version '1.9.24' apply false id 'com.google.gms.google-services' version "4.4.0" apply false id("com.google.firebase.crashlytics") version "2.9.9" apply false