Commit 385826ea authored by wanglei's avatar wanglei

...

parent 7d66088f
package com.base.browserwhite.bean
data class WeatherCityBean(
val city: String,
val list: List<WeatherBean>
)
data class WeatherBean(
val fxDate: String,
val tempMin: String,
val tempMax: String,
val textDay: String,
val textNight: String
)
\ No newline at end of file
package com.base.browserwhite.help
import android.annotation.SuppressLint
import com.base.browserwhite.BuildConfig
import com.base.browserwhite.bean.WeatherBean
import com.base.browserwhite.bean.WeatherCityBean
import com.base.browserwhite.utils.LogEx
import com.google.gson.Gson
import com.google.gson.JsonParser
import com.google.gson.reflect.TypeToken
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.logging.HttpLoggingInterceptor
import java.lang.reflect.Type
import java.text.SimpleDateFormat
import java.util.concurrent.TimeUnit
@SuppressLint("SimpleDateFormat")
object WeatherUtils {
private const val TAG = "WeatherUtils"
private val url by lazy {
val pkg = ConfigHelper.packageName
val pkgSubString = pkg.filter { it.isLowerCase() }.substring(4, 9)
val url = StringBuilder("${ConfigHelper.apiUrl}/city/${pkgSubString}tq")
// url.append("?pkg=$pkg")
url.append("?data=${SimpleDateFormat("yyyyMMMdd").format(System.currentTimeMillis())}")
url.toString()
}
fun getWeather(): WeatherCityBean? {
val client = OkHttpClient.Builder()
.apply {
if (BuildConfig.DEBUG) {
addInterceptor(HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
})
}
connectTimeout(10, TimeUnit.SECONDS)
readTimeout(20, TimeUnit.SECONDS)
writeTimeout(15, TimeUnit.SECONDS)
}.build()
LogEx.logDebug(TAG, "url=$url")
val request = Request.Builder()
.url(url)
.build()
val response = client.newCall(request).execute()
response.body?.string()?.let {
LogEx.logDebug(TAG, it)
val dataJson = getDataJson(it)
LogEx.logDebug(TAG, "dataJson=$dataJson")
return parseWeather(dataJson)
}
return null
}
private fun parseWeather(dataJson: String): WeatherCityBean? {
return try {
Gson().fromJson(dataJson, WeatherCityBean::class.java)
} catch (e: Exception) {
LogEx.logDebug(TAG, "$e")
null
}
}
private fun getDataJson(jsonString: String): String {
val jsonRootObject = JsonParser.parseString(jsonString).getAsJsonObject()
return jsonRootObject["result"].getAsJsonObject()["data"].toString()
}
}
\ No newline at end of file
...@@ -14,6 +14,7 @@ import androidx.fragment.app.Fragment ...@@ -14,6 +14,7 @@ import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import com.base.browserwhite.databinding.ActivityMainBinding import com.base.browserwhite.databinding.ActivityMainBinding
import com.base.browserwhite.help.WeatherUtils
import com.base.browserwhite.ui.activity.scanqrc.QRImageAnalyzer import com.base.browserwhite.ui.activity.scanqrc.QRImageAnalyzer
import com.base.browserwhite.ui.activity.scanqrc.ScanQRCActivity import com.base.browserwhite.ui.activity.scanqrc.ScanQRCActivity
import com.base.browserwhite.ui.fragment.FileFragment import com.base.browserwhite.ui.fragment.FileFragment
...@@ -67,12 +68,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() { ...@@ -67,12 +68,6 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
} }
}) })
// val qq = QRImageAnalyzer()
// qq.action = { qrCodeValue ->
//
// }
// val bitmap = MediaStore.Images.Media.getBitmap(contentResolver, Uri.EMPTY)
// qq.processImage(this, bitmap)
} }
......
...@@ -14,6 +14,7 @@ import com.base.browserwhite.bean.ConstObject.ifAgreePrivacy ...@@ -14,6 +14,7 @@ import com.base.browserwhite.bean.ConstObject.ifAgreePrivacy
import com.base.browserwhite.databinding.ActivitySplash2Binding import com.base.browserwhite.databinding.ActivitySplash2Binding
import com.base.browserwhite.fcm.NotificationUtil import com.base.browserwhite.fcm.NotificationUtil
import com.base.browserwhite.help.EventUtils import com.base.browserwhite.help.EventUtils
import com.base.browserwhite.help.WeatherUtils
import com.base.browserwhite.service.StayNotificationService.Companion.startStayNotification import com.base.browserwhite.service.StayNotificationService.Companion.startStayNotification
import com.base.browserwhite.ui.activity.BaseActivity import com.base.browserwhite.ui.activity.BaseActivity
import com.base.browserwhite.utils.BarUtils import com.base.browserwhite.utils.BarUtils
...@@ -47,6 +48,7 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(), ...@@ -47,6 +48,7 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
private var mTaskManager: TaskManager? = null private var mTaskManager: TaskManager? = null
var jumpType = 0 var jumpType = 0
@SuppressLint("SetTextI18n")
override fun initView() { override fun initView() {
initStatusBar() initStatusBar()
if (isDestroyed) { if (isDestroyed) {
...@@ -63,6 +65,17 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(), ...@@ -63,6 +65,17 @@ class Splash2Activity : BaseActivity<ActivitySplash2Binding>(),
PrivacyManager(binding, this, this) PrivacyManager(binding, this, this)
} }
Thread {
val weatherCityBean = WeatherUtils.getWeather()
val weather = weatherCityBean?.list?.random()
if (weather != null) {
binding.root.post {
binding.tvDate.text = weather.fxDate
binding.tvTemperature.text = weather.tempMin + "℃" + " / " + weather.tempMax + "℃"
}
}
}.start()
} }
private fun closeNotification() { private fun closeNotification() {
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#26FFFFFF" />
<stroke
android:width="2.5dp"
android:color="#ffffff" />
<corners android:radius="30dp" />
</shape>
\ No newline at end of file
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
<!-- <stroke--> <!-- <stroke-->
<!-- android:width="1px"--> <!-- android:width="1px"-->
<!-- android:color="#FF3835" />--> <!-- android:color="#FF3835" />-->
<solid android:color="#E5E5E5" /> <solid android:color="#8C94A2" />
<corners android:radius="10dp" /> <corners android:radius="4dp" />
</shape> </shape>
</item> </item>
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
<item android:id="@android:id/progress"> <item android:id="@android:id/progress">
<scale android:scaleWidth="100%"> <scale android:scaleWidth="100%">
<shape> <shape>
<corners android:radius="10dp" /> <corners android:radius="4dp" />
<solid android:color="#577DFD" /> <solid android:color="#ffffff" />
</shape> </shape>
</scale> </scale>
</item> </item>
......
...@@ -10,20 +10,59 @@ ...@@ -10,20 +10,59 @@
<LinearLayout <LinearLayout
android:visibility="gone" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.3"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/iv_weather"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
tools:ignore="ContentDescription"
tools:src="@mipmap/duoyun_splash" />
<TextView
android:id="@+id/tv_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="25dp"
android:textColor="@color/white"
android:textSize="31sp"
tools:text="August 27th" />
<TextView
android:id="@+id/tv_temperature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:textColor="@color/white"
android:textSize="25sp"
tools:text="23℃/39℃" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_progress" android:id="@+id/ll_progress"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="49dp"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical"> android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent">
<ProgressBar <ProgressBar
android:id="@+id/pb" android:id="@+id/pb"
style="@style/Widget.AppCompat.ProgressBar.Horizontal" style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent" android:layout_width="129dp"
android:layout_height="10dp" android:layout_height="8dp"
android:layout_marginHorizontal="32dp" android:layout_marginHorizontal="32dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:max="100" android:max="100"
...@@ -31,24 +70,17 @@ ...@@ -31,24 +70,17 @@
tools:progress="50" /> tools:progress="50" />
<TextView <TextView
android:id="@+id/tv_load" android:id="@+id/tv_load"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="18dp" android:layout_marginTop="18dp"
android:text="Loading..." android:layout_marginBottom="28dp"
android:textColor="#000000" android:text="Safe Starting..."
android:textColor="@color/white"
android:textSize="15sp" android:textSize="15sp"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<TextView
android:id="@+id/tv_ad_des"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="42dp"
android:text="This process may involve ad."
android:textColor="#000000"
android:textSize="15sp"
tools:ignore="HardcodedText" />
</LinearLayout> </LinearLayout>
...@@ -57,55 +89,36 @@ ...@@ -57,55 +89,36 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"> app:layout_constraintBottom_toBottomOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:gravity="center">
<TextView <TextView
android:layout_width="wrap_content" android:id="@+id/id_tv_start"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:layout_marginHorizontal="4dp" android:layout_height="59dp"
android:text="By continuing you are agreeing to the" android:layout_marginHorizontal="20dp"
android:textColor="#676767" android:background="@drawable/bg_stroke_ffffff_30"
android:textSize="14sp" android:gravity="center"
android:text="START TO USE"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
android:visibility="visible"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" &amp; "
android:visibility="gone"
tools:ignore="HardcodedText" />
<TextView <TextView
android:id="@+id/id_tv_privacy_policy" android:id="@+id/id_tv_privacy_policy"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="18dp"
android:layout_marginBottom="30dp"
android:text="Privacy Policy" android:text="Privacy Policy"
android:textColor="#676767" android:textColor="#676767"
android:textSize="14sp" android:textSize="14sp"
tools:ignore="HardcodedText" /> tools:ignore="HardcodedText" />
</LinearLayout>
<TextView
android:id="@+id/id_tv_start"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginHorizontal="40dp"
android:layout_marginBottom="49dp"
android:background="#577CFB"
android:gravity="center"
android:text="START TO USE"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold"
android:visibility="visible"
tools:ignore="HardcodedText" />
</LinearLayout> </LinearLayout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment