-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathNetwork_Request.kt
More file actions
72 lines (66 loc) · 2.13 KB
/
Copy pathNetwork_Request.kt
File metadata and controls
72 lines (66 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Login (READ/GET)
private fun loginUser(username: String, password: String) {
ParseUser.logInInBackground(username, password, ({ user, e ->
if (user != null) {
Log.i(TAG, "Successfully logged in user")
goToMainActivity()
} else {
e.printStackTrace()
Toast.makeText(this, "Error logging in", Toast.LENGTH_SHORT).show()
}})
)
}
// User Request (READ/GET)
var currentUser: User = null
query.findInBackground(object: FindCallback<Post> {
override fun done(user: User, e: ParseException?) {
if (e != null) {
//Something went wrong
Log.e(TAG, "Error fetching user information")
} else {
if (user != null) {
for (user in posts) {
Log.i(TAG, "User: " + user.Info())
}
currentUser = user
adapter.notifyDataSetChanged()
}
}
}
})
// Cycle Request (READ/GET)
var allCycles: MutableList<Post> = mutableListOf()
query.findInBackground(object: FindCallback<Post> {
override fun done(cycles: MutableList<Cycle>?, e: ParseException?) {
if (e != null) {
//Something went wrong
Log.e(TAG, "Error fetching cycles")
} else {
if (cycles != null) {
for (cyle in posts) {
Log.i(TAG, "Cycle: " + cycle.getDescription())
}
allCycles.addAll(cycles)
adapter.notifyDataSetChanged()
}
}
}
})
// DailyInput (READ/GET)
var allDailyInputs: MutableList<DailyInput> = mutableListOf()
query.findInBackground(object: FindCallback<DailyInput> {
override fun done(dailyInputs: MutableList<DailyInput>?, e: ParseException?) {
if (e != null) {
//Something went wrong
Log.e(TAG, "Error fetching daily inputs")
} else {
if (posts != null) {
for (dailyInput in dailyInputs) {
Log.i(TAG, "Post: " + post.getDescription())
}
allDailyInputs.addAll(dailyInputs)
adapter.notifyDataSetChanged()
}
}
}
})