Skip to content

Commit

Permalink
get all personal todos
Browse files Browse the repository at this point in the history
  • Loading branch information
YaseenOmar committed Apr 11, 2023
1 parent 02e3cf7 commit 25244b0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
package com.red_velvet_cake.dailytodo.data

import android.util.Log
import com.red_velvet_cake.dailytodo.domain.TodoService
import okhttp3.*
import java.io.IOException

class TodoServiceImpl: TodoService {
// token just test
val TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJodHRwczovL3RoZS1jaGFuY2Uub3JnLyIsInN1YiI6IjRmODg2NTIzLTUwNWItNDEzMy05NjEzLWYxZTA1ODVhMzFiOCIsInRlYW1JZCI6IjAxYThhOTg4LTQ0NjItNDNhNi1hOThhLTE2MjY4NzNmYTc4NyIsImlzcyI6Imh0dHBzOi8vdGhlLWNoYW5jZS5vcmcvIiwiZXhwIjoxNjgxMjM4Njc4fQ.D5DB1QmEo7ELXB8exmOSj9xYjEQi7fDCTti-__3BUuk"
val client = OkHttpClient()
override fun getAllPersonalTodos(){
Log.i("iii" , "make request")
val request = Request.Builder().url("https://team-todo-62dmq.ondigitalocean.app/todo/personal").header("Authorization","Bearer $TOKEN" ) .build()
client.newCall(request).enqueue(object :Callback{
override fun onFailure(call: Call, e: IOException) {
Log.i("iii" , "fail ${e.message}")

}
override fun onResponse(call: Call, response: Response) {
Log.i("iii" , response.body?.string().toString())
}
})
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.red_velvet_cake.dailytodo.domain

interface TodoService {
fun getAllPersonalTodos()
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ package com.red_velvet_cake.dailytodo.ui.activity

import android.view.LayoutInflater
import android.widget.Toast
import com.red_velvet_cake.dailytodo.data.TodoServiceImpl
import com.red_velvet_cake.dailytodo.databinding.ActivityDashboardBinding
import com.red_velvet_cake.dailytodo.ui.base.BaseActivity
import com.red_velvet_cake.dailytodo.utils.ConnectionStatus

class DashboardActivity : BaseActivity<ActivityDashboardBinding>() {
override val LOG_TAG: String = this::class.java.name
val todoServiceImpl = TodoServiceImpl()
override val bindingInflater: (LayoutInflater) -> ActivityDashboardBinding
get() = ActivityDashboardBinding::inflate

override fun setUp() {}
override fun setUp() {
// just test
todoServiceImpl.getAllPersonalTodos()
}

override fun addCallbacks() {}

Expand Down

0 comments on commit 25244b0

Please sign in to comment.