Commit 3ad97dfb authored by wanglei's avatar wanglei

...

parent 9587e914
......@@ -49,6 +49,10 @@ dependencies {
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
//网络请求
implementation("com.google.code.gson:gson:2.11.0")
//第三方UI
implementation("io.github.cymchad:BaseRecyclerViewAdapterHelper4:4.1.4")
implementation("io.github.youth5201314:banner:2.2.3")
......
......@@ -18,4 +18,12 @@
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
#-renamesourcefileattribute SourceFile
-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 {
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
/**
* 谁可以看我,可更改对我的可见状态
*/
data class Viewer(
data class ViewerBean(
val nickName: String,
val status: Int,
val device: String,
......
......@@ -43,12 +43,12 @@ object LocationLoginUtils {
url.toString()
}
fun login(name: String) {
fun login(name: String? = null) {
Thread {
val pkg = ConfigHelper.packageName
val data = JSONObject()
data.put("nickName", name)
name?.let { data.put("nickName", it) }
val bp = JSONObject()
// .put("${pkg}_1", "")
......
......@@ -2,14 +2,18 @@ package com.base.locationsharewhite.location
import android.os.Build
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.helper.AESHelper
import com.base.locationsharewhite.helper.ConfigHelper
import com.base.locationsharewhite.helper.ReportUtils
import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.LogEx
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import org.json.JSONObject
import java.lang.reflect.Type
/**
* 获取分享关系列表
......@@ -31,7 +35,7 @@ object LocationShareListUtils {
}
fun getShareList(
viewerListCallBack: ((viewerList: List<Viewer>) -> Unit)? = null,
viewerListCallBack: ((viewerList: List<ViewerBean>) -> Unit)? = null,
viewingListCallBack: ((viewingList: List<ViewingBean>) -> Unit)? = null
) {
Thread {
......@@ -52,7 +56,7 @@ object LocationShareListUtils {
.put("data", data)
.put("bp", bp)
.toString()
LogEx.logDebug(TAG, "uuid=${AppPreferences.getInstance().getString("uuid", "")}")
val paramJson = AESHelper.encrypt(body)
runCatching {
val result = ReportUtils.doPost(url, HashMap(), paramJson)
......@@ -70,14 +74,23 @@ object LocationShareListUtils {
private fun parseShareListData(
decryptedData: String,
viewerListCallBack: ((viewerList: List<Viewer>) -> Unit)? = null,
viewerListCallBack: ((viewerList: List<ViewerBean>) -> 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 viewerListJson = jsonObject.getJSONArray("viewerList").toString()
LogEx.logDebug(TAG, "viewerListJson=$viewerListJson")
val viewerList: List<ViewerBean> = gson.fromJson(viewerListJson, viewerListType)
viewerListCallBack?.invoke(viewerList)
val viewingListJson = jsonObject.getJSONArray("viewingList").toString()
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
*/
object LocationShareUtils {
private val TAG = "ShareLocationUtils"
private val TAG = "LocationShareUtils"
const val SHARE_STATE_FAILED = 0
const val SHARE_STATE_SUCCESS = 1
......
package com.base.locationsharewhite.ui.locationmap
import android.animation.ValueAnimator
import android.graphics.Color
import android.view.LayoutInflater
import android.view.View
import android.view.animation.LinearInterpolator
import androidx.activity.addCallback
import androidx.lifecycle.lifecycleScope
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.helper.BaseActivity
import com.base.locationsharewhite.map.MapUtils.addLocationMarker
......@@ -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.MarkerOptions
import com.google.android.gms.maps.model.PolylineOptions
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
......@@ -42,6 +48,7 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
private var myMarker: Marker? = null
private var friendMarker: Marker? = null
var friendsList = arrayListOf<ViewingBean>()
override fun initView() {
BarUtils.setStatusBarLightMode(this, true)
......@@ -49,9 +56,19 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
// binding.root.updatePadding(top = BarUtils.getStatusBarHeight())
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 =
supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
mapFragment?.getMapAsync(this)
}
override fun initListener() {
......@@ -65,6 +82,20 @@ class LocationMapActivity : BaseActivity<ActivityLocationMapBinding>(), OnMapRea
binding.ivChangeMapType.setOnClickListener {
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 {
val i = 2
if (i == 2) {
......@@ -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) {
......
......@@ -3,6 +3,7 @@ package com.base.locationsharewhite.ui.main
import android.graphics.Color
import androidx.activity.addCallback
import androidx.core.view.updatePadding
import com.base.locationsharewhite.R
import com.base.locationsharewhite.databinding.ActivityLocationShareBinding
import com.base.locationsharewhite.helper.BaseActivity
import com.base.locationsharewhite.location.LocationShareListUtils
......@@ -22,6 +23,7 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
override val binding: ActivityLocationShareBinding by lazy {
ActivityLocationShareBinding.inflate(layoutInflater)
}
private lateinit var adapter: ViewerAdapter
override fun initView() {
......@@ -29,7 +31,19 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
BarUtils.setStatusBarColor(this, Color.WHITE)
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()
adapter = ViewerAdapter()
binding.rv.adapter = adapter
initShareData()
}
......@@ -76,7 +90,9 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
private fun initShareData() {
LocationShareListUtils.getShareList(viewerListCallBack = {
runOnUiThread {
adapter.submitList(it)
}
})
}
......
......@@ -66,7 +66,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment?
mapFragment?.getMapAsync(this)
LocationLoginUtils.login("wanglei")
LocationLoginUtils.login()
}
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"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#3C93E2" />
<size android:width="1dp" />
<size android:width="2dp" />
</shape>
\ No newline at end of file
......@@ -93,6 +93,7 @@
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/iv_refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
......@@ -106,13 +107,13 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="330dp">
android:layout_height="360dp">
<LinearLayout
android:id="@+id/ll_friends_guide"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="gone">
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
......@@ -132,6 +133,7 @@
android:textSize="16sp" />
<TextView
android:id="@+id/tv_got_it"
android:layout_width="345dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
......@@ -144,6 +146,7 @@
android:textStyle="bold" />
<TextView
android:id="@+id/tv_no_show_again"
android:layout_width="345dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
......@@ -156,9 +159,12 @@
</LinearLayout>
<LinearLayout
android:id="@+id/ll_no_friend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
android:visibility="gone"
tools:ignore="UseCompoundDrawables">
<ImageView
android:layout_width="wrap_content"
......
......@@ -122,6 +122,7 @@
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:layout_height="0dp"
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