Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
scanqrwhite2copy1
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
scanqrwhite2copy1
Commits
cf46200a
Commit
cf46200a
authored
Feb 13, 2025
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
b3b3f240
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
40 deletions
+54
-40
EarthquakeBean.kt
...src/main/java/com/base/scanqrclear/bean/EarthquakeBean.kt
+2
-0
EarthquakeActivity.kt
.../com/base/scanqrclear/ui/earthquake/EarthquakeActivity.kt
+42
-26
activity_earthquake.xml
app/src/main/res/layout/activity_earthquake.xml
+10
-14
No files found.
app/src/main/java/com/base/scanqrclear/bean/EarthquakeBean.kt
View file @
cf46200a
...
...
@@ -14,6 +14,8 @@ data class EarthquakeProperties(
val
place
:
String
,
//地点
val
time
:
Long
,
//发生时间
val
mmi
:
Any
?,
//烈度(Intensity)通常用Modified Mercalli Intensity (MMI)
val
sig
:
Int
,
//地震的显著性(Significance)
val
types
:
String
,
//nearby-cities, origin, phase-data
)
data class
EarthquakeGeometry
(
...
...
app/src/main/java/com/base/scanqrclear/ui/earthquake/EarthquakeActivity.kt
View file @
cf46200a
package
com.base.scanqrclear.ui.earthquake
import
android.annotation.SuppressLint
import
android.location.LocationManager
import
android.view.View
import
androidx.activity.addCallback
import
androidx.core.view.updatePadding
import
com.base.scanqrclear.R
import
com.base.scanqrclear.ads.AdsMgr
import
com.base.scanqrclear.ads.AdsShowCallBack
import
com.base.scanqrclear.base.BaseActivity
import
com.base.scanqrclear.bean.EarthquakeData
import
com.base.scanqrclear.databinding.ActivityEarthquakeBinding
...
...
@@ -17,6 +16,7 @@ import com.google.gson.Gson
import
com.gyf.immersionbar.ktx.immersionBar
import
okhttp3.OkHttpClient
import
okhttp3.Request
import
java.text.DecimalFormat
class
EarthquakeActivity
:
BaseActivity
<
ActivityEarthquakeBinding
>(
ActivityEarthquakeBinding
::
inflate
)
{
...
...
@@ -26,47 +26,63 @@ class EarthquakeActivity : BaseActivity<ActivityEarthquakeBinding>(ActivityEarth
binding
.
clTop
.
updatePadding
(
top
=
BarUtils
.
getStatusBarHeight
())
AdsMgr
.
showNative
(
binding
.
flAd
,
R
.
layout
.
layout_admob_item
)
AdsMgr
.
showInsert
(
this
,
false
,
object
:
AdsShowCallBack
()
{
override
fun
close
(
where
:
Int
)
{
}
override
fun
failed
(
where
:
Int
)
{
}
override
fun
googleFailed
(
where
:
Int
)
{
}
})
Thread
{
val
data
=
fetchEarthquakeData
()
val
oneData
=
data
?.
features
?.
maxBy
{
it
.
properties
.
ma
g
}
val
oneData
=
data
?.
features
?.
maxBy
{
it
.
properties
.
si
g
}
oneData
?.
let
{
runOnUiThread
{
kotlin
.
runCatching
{
binding
.
tvWhere
.
text
=
it
.
properties
.
place
binding
.
tvTime
.
text
=
it
.
properties
.
time
.
toFormatTime3
()
binding
.
tvLevel
.
text
=
"Level "
+
"${it.properties.mag}"
binding
.
tvDepth
.
text
=
it
.
geometry
.
coordinates
[
2
].
toInt
().
toString
()
+
" Kilometers"
if
(
it
.
properties
.
mmi
!=
null
)
{
binding
.
tvIntensityTitle
.
visibility
=
View
.
VISIBLE
binding
.
tvIntensity
.
visibility
=
View
.
VISIBLE
binding
.
tvIntensity
.
text
=
it
.
properties
.
mmi
.
toString
()
val
ss
=
it
.
geometry
.
coordinates
[
2
]
LogEx
.
logDebug
(
TAG
,
"ss=$ss"
)
if
(
ss
<
0.01f
)
{
binding
.
tvDepth
.
text
=
"0.1 Kilometers"
}
else
{
val
df
=
DecimalFormat
(
"#.00"
)
val
depth
=
df
.
format
(
ss
)
binding
.
tvDepth
.
text
=
"$depth Kilometers"
}
// binding.tvWarningTime.text = "" + " S"
binding
.
tvLongitudeLatitude
.
text
=
"[ ${it.geometry.coordinates[0]},${it.geometry.coordinates[1]} ]"
binding
.
tvSignificance
.
text
=
it
.
properties
.
sig
.
toString
()
binding
.
tvTypes
.
text
=
it
.
properties
.
types
.
removePrefix
(
","
).
removeSuffix
(
","
)
}
}
}
}.
start
()
launcher
.
launch
(
arrayOf
(
android
.
Manifest
.
permission
.
ACCESS_COARSE_LOCATION
,
android
.
Manifest
.
permission
.
LOCATION_HARDWARE
,
)
)
{
val
locationManager
=
getSystemService
(
LOCATION_SERVICE
)
as
LocationManager
locationManager
.
requestLocationUpdates
(
LocationManager
.
NETWORK_PROVIDER
,
0L
,
0f
)
{
location
->
LogEx
.
logDebug
(
TAG
,
"${location.altitude} ${location.longitude}"
)
}
}
//
launcher.launch(
//
arrayOf(
//
android.Manifest.permission.ACCESS_COARSE_LOCATION,
//
android.Manifest.permission.LOCATION_HARDWARE,
//
)
//
) {
//
val locationManager = getSystemService(LOCATION_SERVICE) as LocationManager
//
//
locationManager.requestLocationUpdates(
//
LocationManager.NETWORK_PROVIDER,
//
0L,
//
0f
//
) { location ->
//
LogEx.logDebug(TAG, "${location.altitude} ${location.longitude}")
//
}
//
}
}
override
fun
initListener
()
{
...
...
app/src/main/res/layout/activity_earthquake.xml
View file @
cf46200a
...
...
@@ -151,7 +151,6 @@
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"16dp"
android:layout_marginVertical=
"6dp"
android:visibility=
"gone"
app:cardBackgroundColor=
"@color/white"
app:cardCornerRadius=
"10dp"
app:cardElevation=
"2dp"
>
...
...
@@ -163,41 +162,38 @@
android:paddingVertical=
"13dp"
>
<TextView
android:id=
"@+id/tvIntensityTitle"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"13dp"
android:text=
"
Estimated Intensity
"
android:text=
"
Latitude and Longitude
"
android:textColor=
"#999999"
android:textSize=
"15sp"
android:visibility=
"gone"
/>
android:textSize=
"15sp"
/>
<TextView
android:id=
"@+id/tv
Intensity
"
android:id=
"@+id/tv
LongitudeLatitude
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"13dp"
android:layout_marginBottom=
"8dp"
android:textSize=
"15sp"
android:visibility=
"gone"
tools:text=
"3 Degrees (strong vibration sensation)"
/>
tools:text=
"[ -120.568168640137, 36.009334564209 ]"
/>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"13dp"
android:text=
"
Warning tim
e"
android:text=
"
Significanc
e"
android:textColor=
"#999999"
android:textSize=
"15sp"
/>
<TextView
android:id=
"@+id/tv
WarningTim
e"
android:id=
"@+id/tv
Significanc
e"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"13dp"
android:textSize=
"15sp"
tools:text=
"6
1 S
"
/>
tools:text=
"6"
/>
<TextView
...
...
@@ -205,17 +201,17 @@
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"13dp"
android:layout_marginTop=
"8dp"
android:text=
"
Distance from the epicenter to you
"
android:text=
"
Types
"
android:textColor=
"#999999"
android:textSize=
"15sp"
/>
<TextView
android:id=
"@+id/tv
Distance
"
android:id=
"@+id/tv
Types
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"13dp"
android:textSize=
"15sp"
tools:text=
"
260 Kilometers
"
/>
tools:text=
"
nearby-cities, origin, phase-data
"
/>
</LinearLayout>
</androidx.cardview.widget.CardView>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment