Skip to content

Commit

Permalink
Update libraries
Browse files Browse the repository at this point in the history
Add rxjava1 to retrofit 2
Remove rxjava2
Update gradle version
Update agp
  • Loading branch information
meiron03 committed Jan 23, 2025
1 parent 7c69175 commit 59adafd
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 18 deletions.
4 changes: 2 additions & 2 deletions PennMobile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ dependencies {

debugImplementation libs.leakcanary.android

implementation libs.rxandroid
implementation libs.androidx.annotation
implementation (libs.androidx.lifecycle.extensions) {
transitive = true
Expand Down Expand Up @@ -88,9 +87,10 @@ dependencies {
implementation libs.logging.interceptor
implementation libs.okhttp
implementation libs.picasso
implementation libs.adapter.rxjava2
implementation libs.adapter.rxjava
implementation libs.squareup.retrofit
implementation libs.reactivex.rxandroid
implementation libs.rxjava
implementation libs.joda.time
implementation libs.commons.lang3
implementation libs.kotlinx.coroutines.core
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import retrofit.android.AndroidLog
import retrofit.client.OkClient
import retrofit.converter.GsonConverter
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory
import java.util.concurrent.TimeUnit
Expand Down Expand Up @@ -376,7 +376,7 @@ class MainActivity : AppCompatActivity() {
.client(okHttpClient)
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.build()
mStudentLifeRf2 = retrofit.create(StudentLifeRf2::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import com.pennapps.labs.pennmobile.api.classes.AccessTokenResponse
import com.pennapps.labs.pennmobile.fitness.classes.FitnessRoom
import com.pennapps.labs.pennmobile.fitness.classes.FitnessRoomUsage
import com.pennapps.labs.pennmobile.laundry.classes.LaundryPreferences
import com.pennapps.labs.pennmobile.laundry.classes.LaundryRequest
import com.pennapps.labs.pennmobile.laundry.classes.LaundryRoom
Expand All @@ -13,6 +15,8 @@ import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query
import rx.Observable

interface StudentLifeRf2 {
@FormUrlEncoded
Expand Down Expand Up @@ -56,4 +60,19 @@ interface StudentLifeRf2 {
@Header("Authorization") bearerToken: String,
@Body rooms: LaundryRequest,
): Response<ResponseBody>

@GET("penndata/fitness/rooms/")
fun getFitnessRooms(): Observable<List<FitnessRoom?>?>?

@GET("penndata/fitness/usage/{id}")
fun getFitnessRoomUsage(
@Path("id") id: Int,
@Query("num_samples") samples: Int,
@Query("group_by") groupBy: String?
): Observable<FitnessRoomUsage?>?

@GET("penndata/fitness/preferences")
fun getFitnessPreferences(
@retrofit.http.Header("Authorization") bearerToken: String?
): Observable<List<Int?>?>?
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.pennapps.labs.pennmobile.fitness.adapters

import StudentLifeRf2
import android.app.Activity
import android.content.Context
import android.graphics.Color
Expand Down Expand Up @@ -47,7 +48,7 @@ class FitnessAdapter(
) : RecyclerView.Adapter<FitnessAdapter.ViewHolder>() {
private lateinit var mActivity: Activity
private lateinit var mContext: Context
private lateinit var mStudentLife: StudentLife
private lateinit var mStudentLifeRf2: StudentLifeRf2

class ViewHolder(
val view: View,
Expand Down Expand Up @@ -75,15 +76,15 @@ class FitnessAdapter(
fun getExtraData(
context: Context,
activity: Activity,
studentLife: StudentLife,
studentLifeRf2: StudentLifeRf2,
room: FitnessRoom,
) {
if (hasExtraData) return
room.roomId?.let {
try {
studentLife.getFitnessRoomUsage(it, 3, "week").subscribe(
studentLifeRf2.getFitnessRoomUsage(it, 3, "week")?.subscribe(
{ roomUsage ->
createBarChart(context, roomUsage)
createBarChart(context, roomUsage!!)
activity.runOnUiThread {
hasExtraData = true
showExtra()
Expand Down Expand Up @@ -225,7 +226,7 @@ class FitnessAdapter(
): ViewHolder {
mContext = parent.context
mActivity = mContext as MainActivity
mStudentLife = MainActivity.studentLifeInstance
mStudentLifeRf2 = MainActivity.studentLifeInstanceRf2

val view =
LayoutInflater
Expand Down Expand Up @@ -396,7 +397,7 @@ class FitnessAdapter(
if (holder.hasExtraData) {
holder.showExtra()
} else {
holder.getExtraData(mContext, mActivity, mStudentLife, room)
holder.getExtraData(mContext, mActivity, mStudentLifeRf2, room)
}
}
}
Expand Down
13 changes: 6 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
adapterRxjava = "2.11.0"
activityCompose = "1.8.0"
adapterRxjava2 = "2.4.0"
agp = "8.6.1"
agp = "8.7.0"
androidRss = "master-SNAPSHOT"
annotation = "1.7.0"
blurview = "version-2.0.6"
Expand Down Expand Up @@ -53,12 +53,13 @@ preferenceKtx = "1.1.1"
recyclerview = "1.3.2"
retrofit = "2.9.0"
retrofitVersion = "1.9.0"
rxandroid = "2.0.2"
rxandroidVersion = "1.2.1"
rxjava1 = "1.3.8"
testng = "7.8.0"

[libraries]
adapter-rxjava2 = { module = "com.squareup.retrofit2:adapter-rxjava2", version.ref = "adapterRxjava2" }

adapter-rxjava = { module = "com.squareup.retrofit2:adapter-rxjava", version.ref = "adapterRxjava" }
android-rss = { module = "com.github.ahorn:android-rss", version.ref = "androidRss" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
androidx-annotation = { module = "androidx.annotation:annotation", version.ref = "annotation" }
Expand Down Expand Up @@ -87,7 +88,6 @@ androidx-percentlayout = { module = "androidx.percentlayout:percentlayout", vers
androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerview" }
androidx-runtime = { module = "androidx.compose.runtime:runtime" }
androidx-runtime-livedata = { module = "androidx.compose.runtime:runtime-livedata" }
androidx-runtime-rxjava2 = { module = "androidx.compose.runtime:runtime-rxjava2" }
androidx-ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" }
androidx-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" }
androidx-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
Expand Down Expand Up @@ -122,7 +122,7 @@ play-services-location = { module = "com.google.android.gms:play-services-locati
play-services-maps = { module = "com.google.android.gms:play-services-maps", version.ref = "playServicesMaps" }
reactivex-rxandroid = { module = "io.reactivex:rxandroid", version.ref = "rxandroidVersion" }
retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
rxandroid = { module = "io.reactivex.rxjava2:rxandroid", version.ref = "rxandroid" }
rxjava = { module = "io.reactivex:rxjava", version.ref = "rxjava1" }
squareup-retrofit = { module = "com.squareup.retrofit:retrofit", version.ref = "retrofitVersion" }
testng = { module = "org.testng:testng", version.ref = "testng" }

Expand Down Expand Up @@ -158,7 +158,6 @@ firebase = [
runtime = [
"androidx-runtime",
"androidx-runtime-livedata",
"androidx-runtime-rxjava2"
]

ui = [
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Dec 01 16:55:01 EST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 59adafd

Please sign in to comment.