Commit 3ad97dfb authored by wanglei's avatar wanglei

...

parent 9587e914
...@@ -49,6 +49,10 @@ dependencies { ...@@ -49,6 +49,10 @@ dependencies {
androidTestImplementation(libs.androidx.junit) androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core) androidTestImplementation(libs.androidx.espresso.core)
//网络请求
implementation("com.google.code.gson:gson:2.11.0")
//第三方UI //第三方UI
implementation("io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4") implementation("io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4")
implementation("io.github.youth5201314:banner:2.2.3") implementation("io.github.youth5201314:banner:2.2.3")
......
...@@ -18,4 +18,12 @@ ...@@ -18,4 +18,12 @@
# If you keep the line number information, uncomment this to # If you keep the line number information, uncomment this to
# hide the original source file name. # hide the original source file name.
#-renamesourcefileattribute SourceFile #-renamesourcefileattribute SourceFile
\ No newline at end of file -keep class com.base.locationsharewhite.bean.** { *; }
-keep class com.google.gson.reflect.** { *; }
-keep class com.google.gson.stream.** { *; }
-keepattributes *Annotation*
-keep class * extends com.google.gson.TypeAdapter
-keep class * extends com.google.gson.JsonSerializer
-keep class * extends com.google.gson.Deserializer
-keep class com.google.gson.TypeAdapters{*;}
\ No newline at end of file
...@@ -58,4 +58,12 @@ object ConstObject { ...@@ -58,4 +58,12 @@ object ConstObject {
AppPreferences.getInstance().put("topic_number", value, true) AppPreferences.getInstance().put("topic_number", value, true)
} }
var noShowFriendsShareGuide = false
get() {
return AppPreferences.getInstance().getBoolean("noShowFriendsShareGuide", field)
}
set(value) {
field = value
AppPreferences.getInstance().put("noShowFriendsShareGuide", value, true)
}
} }
\ No newline at end of file
...@@ -4,7 +4,7 @@ package com.base.locationsharewhite.bean ...@@ -4,7 +4,7 @@ package com.base.locationsharewhite.bean
/** /**
* 谁可以看我,可更改对我的可见状态 * 谁可以看我,可更改对我的可见状态
*/ */
data class Viewer( data class ViewerBean(
val nickName: String, val nickName: String,
val status: Int, val status: Int,
val device: String, val device: String,
......
...@@ -43,12 +43,12 @@ object LocationLoginUtils { ...@@ -43,12 +43,12 @@ object LocationLoginUtils {
url.toString() url.toString()
} }
fun login(name: String) { fun login(name: String? = null) {
Thread { Thread {
val pkg = ConfigHelper.packageName val pkg = ConfigHelper.packageName
val data = JSONObject() val data = JSONObject()
data.put("nickName", name) name?.let { data.put("nickName", it) }
val bp = JSONObject() val bp = JSONObject()
// .put("${pkg}_1", "") // .put("${pkg}_1", "")
......
...@@ -2,14 +2,18 @@ package com.base.locationsharewhite.location ...@@ -2,14 +2,18 @@ package com.base.locationsharewhite.location
import android.os.Build import android.os.Build
import com.base.locationsharewhite.BuildConfig import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.bean.Viewer import com.base.locationsharewhite.bean.ViewerBean
import com.base.locationsharewhite.bean.ViewingBean import com.base.locationsharewhite.bean.ViewingBean
import com.base.locationsharewhite.helper.AESHelper import com.base.locationsharewhite.helper.AESHelper
import com.base.locationsharewhite.helper.ConfigHelper import com.base.locationsharewhite.helper.ConfigHelper
import com.base.locationsharewhite.helper.ReportUtils import com.base.locationsharewhite.helper.ReportUtils
import com.base.locationsharewhite.utils.AppPreferences import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.LogEx import com.base.locationsharewhite.utils.LogEx
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import org.json.JSONObject import org.json.JSONObject
import java.lang.reflect.Type
/** /**
* 获取分享关系列表 * 获取分享关系列表
...@@ -31,7 +35,7 @@ object LocationShareListUtils { ...@@ -31,7 +35,7 @@ object LocationShareListUtils {
} }
fun getShareList( fun getShareList(
viewerListCallBack: ((viewerList: List<Viewer>) -> Unit)? = null, viewerListCallBack: ((viewerList: List<ViewerBean>) -> Unit)? = null,
viewingListCallBack: ((viewingList: List<ViewingBean>) -> Unit)? = null viewingListCallBack: ((viewingList: List<ViewingBean>) -> Unit)? = null
) { ) {
Thread { Thread {
...@@ -52,7 +56,7 @@ object LocationShareListUtils { ...@@ -52,7 +56,7 @@ object LocationShareListUtils {
.put("data", data) .put("data", data)
.put("bp", bp) .put("bp", bp)
.toString() .toString()
LogEx.logDebug(TAG, "uuid=${AppPreferences.getInstance().getString("uuid", "")}")
val paramJson = AESHelper.encrypt(body) val paramJson = AESHelper.encrypt(body)
runCatching { runCatching {
val result = ReportUtils.doPost(url, HashMap(), paramJson) val result = ReportUtils.doPost(url, HashMap(), paramJson)
...@@ -70,14 +74,23 @@ object LocationShareListUtils { ...@@ -70,14 +74,23 @@ object LocationShareListUtils {
private fun parseShareListData( private fun parseShareListData(
decryptedData: String, decryptedData: String,
viewerListCallBack: ((viewerList: List<Viewer>) -> Unit)? = null, viewerListCallBack: ((viewerList: List<ViewerBean>) -> Unit)? = null,
viewingListCallBack: ((viewingList: List<ViewingBean>) -> Unit)? = null viewingListCallBack: ((viewingList: List<ViewingBean>) -> Unit)? = null
) { ) {
val gson = Gson()
val viewerListType: Type = object : TypeToken<List<ViewerBean>>() {}.type
val viewingListType: Type = object : TypeToken<List<ViewingBean>>() {}.type
val jsonObject = JSONObject(decryptedData) val jsonObject = JSONObject(decryptedData)
val viewerListJson = jsonObject.getJSONArray("viewerList").toString() val viewerListJson = jsonObject.getJSONArray("viewerList").toString()
LogEx.logDebug(TAG, "viewerListJson=$viewerListJson") LogEx.logDebug(TAG, "viewerListJson=$viewerListJson")
val viewerList: List<ViewerBean> = gson.fromJson(viewerListJson, viewerListType)
viewerListCallBack?.invoke(viewerList)
val viewingListJson = jsonObject.getJSONArray("viewingList").toString() val viewingListJson = jsonObject.getJSONArray("viewingList").toString()
LogEx.logDebug(TAG, "viewingListJson=$viewingListJson") LogEx.logDebug(TAG, "viewingListJson=$viewingListJson")
val viewingList: List<ViewingBean> = gson.fromJson(viewingListJson, viewingListType)
viewingListCallBack?.invoke(viewingList)
} }
} }
\ No newline at end of file
...@@ -15,7 +15,7 @@ import org.json.JSONObject ...@@ -15,7 +15,7 @@ import org.json.JSONObject
*/ */
object LocationShareUtils { object LocationShareUtils {
private val TAG = "ShareLocationUtils" private val TAG = "LocationShareUtils"
const val SHARE_STATE_FAILED = 0 const val SHARE_STATE_FAILED = 0
const val SHARE_STATE_SUCCESS = 1 const val SHARE_STATE_SUCCESS = 1
......
package com.base.locationsharewhite.ui.locationmap package com.base.locationsharewhite.ui.locationmap
import android.animation.ValueAnimator
import android.graphics.Color import android.graphics.Color
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View
import android.view.animation.LinearInterpolator
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.base.locationsharewhite.R import com.base.locationsharewhite.R
import com.base.locationsharewhite.bean.ConstObject
import com.base.locationsharewhite.bean.ViewingBean
import com.base.locationsharewhite.databinding.ActivityLocationMapBinding import com.base.locationsharewhite.databinding.ActivityLocationMapBinding
import com.base.locationsharewhite.helper.BaseActivity import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.map.MapUtils.addLocationMarker import com.base.locationsharewhite.map.MapUtils.addLocationMarker
...@@ -23,6 +28,7 @@ import com.google.android.gms.maps.model.LatLng ...@@ -23,6 +28,7 @@ import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Marker import com.google.android.gms.maps.model.Marker
import com.google.android.gms.maps.model.MarkerOptions import com.google.android.gms.maps.model.MarkerOptions
import com.google.android.gms.maps.model.PolylineOptions import com.google.android.gms.maps.model.PolylineOptions
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive import kotlinx.coroutines.isActive
...@@ -42,6 +48,7 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea ...@@ -42,6 +48,7 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
private var myMarker: Marker? = null private var myMarker: Marker? = null
private var friendMarker: Marker? = null private var friendMarker: Marker? = null
var friendsList = arrayListOf<ViewingBean>()
override fun initView() { override fun initView() {
BarUtils.setStatusBarLightMode(this, true) BarUtils.setStatusBarLightMode(this, true)
...@@ -49,9 +56,19 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea ...@@ -49,9 +56,19 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
// binding.root.updatePadding(top = BarUtils.getStatusBarHeight()) // binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
locationPresenter = LocationPresenter(this, lifecycleScope) locationPresenter = LocationPresenter(this, lifecycleScope)
if (ConstObject.noShowFriendsShareGuide) {
binding.llFriendsGuide.visibility = View.GONE
binding.llNoFriend.visibility = View.VISIBLE
} else {
binding.llFriendsGuide.visibility = View.VISIBLE
binding.llNoFriend.visibility = View.GONE
}
val mapFragment = val mapFragment =
supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment? supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
mapFragment?.getMapAsync(this) mapFragment?.getMapAsync(this)
} }
override fun initListener() { override fun initListener() {
...@@ -65,6 +82,20 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea ...@@ -65,6 +82,20 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
binding.ivChangeMapType.setOnClickListener { binding.ivChangeMapType.setOnClickListener {
map?.let { showMapTypeDialog(it) } map?.let { showMapTypeDialog(it) }
} }
binding.tvGotIt.setOnClickListener {
binding.llFriendsGuide.visibility = View.GONE
if (friendsList.isEmpty()) {
binding.llNoFriend.visibility = View.VISIBLE
}
}
binding.tvNoShowAgain.setOnClickListener {
ConstObject.noShowFriendsShareGuide = true
binding.llFriendsGuide.visibility = View.GONE
if (friendsList.isEmpty()) {
binding.llNoFriend.visibility = View.VISIBLE
}
}
binding.ivLocation.setOnClickListener { binding.ivLocation.setOnClickListener {
val i = 2 val i = 2
if (i == 2) { if (i == 2) {
...@@ -75,6 +106,38 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea ...@@ -75,6 +106,38 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
} }
} }
binding.ivRefresh.setOnClickListener {
startRefreshAnimation()
lifecycleScope.launch(Dispatchers.Main) {
delay(2000)
stopRefreshAnimation()
}
}
}
private var valueAnimator: ValueAnimator? = null
private fun startRefreshAnimation() {
if (valueAnimator == null) {
valueAnimator = ValueAnimator.ofFloat(0f, 360f)
valueAnimator?.run {
duration = 1000
repeatMode = ValueAnimator.RESTART
repeatCount = ValueAnimator.INFINITE
interpolator = LinearInterpolator()
addUpdateListener {
binding.ivRefresh.rotation = it.animatedValue as Float
}
start()
}
}
}
private fun stopRefreshAnimation() {
valueAnimator?.cancel()
valueAnimator = null
binding.ivRefresh.rotation = 0f
} }
override fun onMapReady(googleMap: GoogleMap) { override fun onMapReady(googleMap: GoogleMap) {
......
...@@ -3,6 +3,7 @@ package com.base.locationsharewhite.ui.main ...@@ -3,6 +3,7 @@ package com.base.locationsharewhite.ui.main
import android.graphics.Color import android.graphics.Color
import androidx.activity.addCallback import androidx.activity.addCallback
import androidx.core.view.updatePadding import androidx.core.view.updatePadding
import com.base.locationsharewhite.R
import com.base.locationsharewhite.databinding.ActivityLocationShareBinding import com.base.locationsharewhite.databinding.ActivityLocationShareBinding
import com.base.locationsharewhite.helper.BaseActivity import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.location.LocationShareListUtils import com.base.locationsharewhite.location.LocationShareListUtils
...@@ -22,6 +23,7 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() { ...@@ -22,6 +23,7 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
override val binding: ActivityLocationShareBinding by lazy { override val binding: ActivityLocationShareBinding by lazy {
ActivityLocationShareBinding.inflate(layoutInflater) ActivityLocationShareBinding.inflate(layoutInflater)
} }
private lateinit var adapter: ViewerAdapter
override fun initView() { override fun initView() {
...@@ -29,7 +31,19 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() { ...@@ -29,7 +31,19 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
BarUtils.setStatusBarColor(this, Color.WHITE) BarUtils.setStatusBarColor(this, Color.WHITE)
binding.root.updatePadding(top = BarUtils.getStatusBarHeight()) binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
binding.editCode.setOnFocusChangeListener { v, hasFocus ->
if (hasFocus) {
binding.editCode.hint = ""
} else {
binding.editCode.hint = this.resources.getString(R.string.enter_others_location_code)
}
}
binding.shimmerLayout.startShimmerAnimation() binding.shimmerLayout.startShimmerAnimation()
adapter = ViewerAdapter()
binding.rv.adapter = adapter
initShareData() initShareData()
} }
...@@ -76,7 +90,9 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() { ...@@ -76,7 +90,9 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
private fun initShareData() { private fun initShareData() {
LocationShareListUtils.getShareList(viewerListCallBack = { LocationShareListUtils.getShareList(viewerListCallBack = {
runOnUiThread {
adapter.submitList(it)
}
}) })
} }
......
...@@ -66,7 +66,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback { ...@@ -66,7 +66,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment? supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
mapFragment?.getMapAsync(this) mapFragment?.getMapAsync(this)
LocationLoginUtils.login("wanglei") LocationLoginUtils.login()
} }
override fun initListener() { override fun initListener() {
......
package com.base.locationsharewhite.ui.main
import android.content.Context
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import com.base.locationsharewhite.R
import com.base.locationsharewhite.bean.ViewerBean
import com.base.locationsharewhite.databinding.ItemViewerBinding
import com.base.locationsharewhite.ui.views.XmlEx.inflate
import com.chad.library.adapter4.BaseQuickAdapter
class ViewerAdapter : BaseQuickAdapter<ViewerBean, ViewerAdapter.ViewerViewHolder>() {
inner class ViewerViewHolder(view: View) : ViewHolder(view)
override fun onBindViewHolder(holder: ViewerViewHolder, position: Int, item: ViewerBean?) {
item ?: return
val binding = ItemViewerBinding.bind(holder.itemView)
runCatching { binding.tvNameLetters.text = item.nickName.substring(0, 1) }
binding.tvNameCode.text = item.nickName
binding.tvTime.text = "time"
binding.tvSwitch.isChecked = item.status == 1
}
override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): ViewerViewHolder {
return ViewerViewHolder(R.layout.item_viewer.inflate(parent))
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#3C93E2" /> <solid android:color="#3C93E2" />
<size android:width="1dp" /> <size android:width="2dp" />
</shape> </shape>
\ No newline at end of file
...@@ -93,6 +93,7 @@ ...@@ -93,6 +93,7 @@
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageView
android:id="@+id/iv_refresh"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
...@@ -106,13 +107,13 @@ ...@@ -106,13 +107,13 @@
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="330dp"> android:layout_height="360dp">
<LinearLayout <LinearLayout
android:id="@+id/ll_friends_guide"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical">
android:visibility="gone">
<ImageView <ImageView
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -132,6 +133,7 @@ ...@@ -132,6 +133,7 @@
android:textSize="16sp" /> android:textSize="16sp" />
<TextView <TextView
android:id="@+id/tv_got_it"
android:layout_width="345dp" android:layout_width="345dp"
android:layout_height="50dp" android:layout_height="50dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
...@@ -144,6 +146,7 @@ ...@@ -144,6 +146,7 @@
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tv_no_show_again"
android:layout_width="345dp" android:layout_width="345dp"
android:layout_height="50dp" android:layout_height="50dp"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
...@@ -156,9 +159,12 @@ ...@@ -156,9 +159,12 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/ll_no_friend"
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"
tools:ignore="UseCompoundDrawables">
<ImageView <ImageView
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -122,6 +122,7 @@ ...@@ -122,6 +122,7 @@
</LinearLayout> </LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
......
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