This repository has been archived by the owner on Jun 23, 2024. It is now read-only.
generated from caffeine-addictt/waku
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
16 changed files
with
187 additions
and
124 deletions.
There are no files selected for viewing
13 changes: 11 additions & 2 deletions
13
Mobile/app/src/main/java/com/example/studentmobileapp/Models/Api.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
package com.example.studentmobileapp.Models | ||
|
||
package com.example.studentmobileapp.Models | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
|
||
@Serializable | ||
public class ApiResponse<T> { | ||
var status: Int = 0 | ||
val message: String = "" | ||
val data: T = null!! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 71 additions & 7 deletions
78
Mobile/app/src/main/java/com/example/studentmobileapp/Utilities/WorkshopService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,71 @@ | ||
//package com.example.studentmobileapp.Utilities | ||
// | ||
//import com.example.studentmobileapp.WorkshopsFragment | ||
// | ||
//class WorkshopService(private var context: WorkshopsFragment, private var req: UserLoginReq): AsyncTask<Void, Void, Boolean>() { | ||
// | ||
//} | ||
package com.example.studentmobileapp.Utilities | ||
|
||
import android.os.AsyncTask | ||
import com.example.studentmobileapp.Models.ApiResponse | ||
import com.example.studentmobileapp.Models.CreateWorkshopRequestReq | ||
import com.example.studentmobileapp.Models.CreateWorkshopRequestResp | ||
import com.example.studentmobileapp.Models.Workshop | ||
import com.example.studentmobileapp.WorkshopRequestAddFragment | ||
import com.example.studentmobileapp.WorkshopRequestFragment | ||
import com.example.studentmobileapp.databinding.WorkshopRequestViewBinding | ||
|
||
class CreateWorkshopRequestHttpService(private var context: WorkshopRequestAddFragment, private var req: CreateWorkshopRequestReq): AsyncTask<Void, Void, String?>() { | ||
@Deprecated("Deprecated in Java") | ||
override fun doInBackground(vararg params: Void?): String? { | ||
val request = HttpPost<CreateWorkshopRequestResp, CreateWorkshopRequestReq>( | ||
"/api/workshop-request", | ||
req, | ||
listOf(201) | ||
) | ||
|
||
if (request == null) { | ||
return "Failed to create workshop request" | ||
} | ||
|
||
return null | ||
} | ||
|
||
@Deprecated("Deprecated in Java", ReplaceWith("super.onPreExecute()", "android.os.AsyncTask")) | ||
override fun onPreExecute() { | ||
super.onPreExecute() | ||
} | ||
|
||
@Deprecated("Deprecated in Java") | ||
override fun onPostExecute(result: String?) { | ||
super.onPostExecute(result) | ||
if(result == null) { | ||
context.onCreateSuccess() | ||
} | ||
else { | ||
context.onCreateError(result) | ||
} | ||
} | ||
} | ||
|
||
class GetWorkshopRequestHttpService(private var context: WorkshopRequestFragment, private var forRequest: Boolean): AsyncTask<Void, Void, List<Workshop>?>() { | ||
@Deprecated("Deprecated in Java") | ||
override fun doInBackground(vararg params: Void?): List<Workshop>? { | ||
val request = HttpGet<ApiResponse<List<Workshop>>>( | ||
"/api/workshop?userid=${Settings.user!!.userId}", | ||
listOf(200) | ||
) | ||
|
||
return request?.data | ||
} | ||
|
||
@Deprecated("Deprecated in Java", ReplaceWith("super.onPreExecute()", "android.os.AsyncTask")) | ||
override fun onPreExecute() { | ||
super.onPreExecute() | ||
} | ||
|
||
@Deprecated("Deprecated in Java") | ||
override fun onPostExecute(result: List<Workshop>?) { | ||
super.onPostExecute(result) | ||
if(result != null) { | ||
context.populateWorkshopRequests(result) | ||
} | ||
else { | ||
context.onFetchError() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.