Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
L
location share white
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
location share white
Commits
f5d694de
Commit
f5d694de
authored
Oct 24, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
f69c5e44
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
4 deletions
+104
-4
ViewerBean.kt
.../main/java/com/base/locationsharewhite/bean/ViewerBean.kt
+1
-1
ReportUtils.java
.../java/com/base/locationsharewhite/helper/ReportUtils.java
+1
-1
LocationStatusUtils.kt
...m/base/locationsharewhite/location/LocationStatusUtils.kt
+73
-0
LocationShareActivity.kt
.../base/locationsharewhite/ui/main/LocationShareActivity.kt
+17
-1
ViewerAdapter.kt
...java/com/base/locationsharewhite/ui/main/ViewerAdapter.kt
+12
-1
No files found.
app/src/main/java/com/base/locationsharewhite/bean/ViewerBean.kt
View file @
f5d694de
...
@@ -6,6 +6,6 @@ package com.base.locationsharewhite.bean
...
@@ -6,6 +6,6 @@ package com.base.locationsharewhite.bean
*/
*/
data class
ViewerBean
(
data class
ViewerBean
(
val
nickName
:
String
,
val
nickName
:
String
,
va
l
status
:
Int
,
va
r
status
:
Int
,
//0不可以看 1可以看
val
device
:
String
,
val
device
:
String
,
)
)
app/src/main/java/com/base/locationsharewhite/helper/ReportUtils.java
View file @
f5d694de
...
@@ -18,7 +18,7 @@ public class ReportUtils {
...
@@ -18,7 +18,7 @@ public class ReportUtils {
HttpURLConnection
conn
=
(
HttpURLConnection
)
new
URL
(
urlPath
).
openConnection
();
HttpURLConnection
conn
=
(
HttpURLConnection
)
new
URL
(
urlPath
).
openConnection
();
conn
.
setRequestMethod
(
"POST"
);
conn
.
setRequestMethod
(
"POST"
);
conn
.
setDoOutput
(
true
);
conn
.
setDoOutput
(
true
);
conn
.
setConnectTimeout
(
600
000
);
conn
.
setConnectTimeout
(
5
000
);
if
(!
TextUtils
.
isEmpty
(
json
))
{
if
(!
TextUtils
.
isEmpty
(
json
))
{
conn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
conn
.
setRequestProperty
(
"Content-Type"
,
"application/json"
);
conn
.
setRequestProperty
(
"Content-Length"
,
Integer
.
toString
(
json
.
getBytes
().
length
));
conn
.
setRequestProperty
(
"Content-Length"
,
Integer
.
toString
(
json
.
getBytes
().
length
));
...
...
app/src/main/java/com/base/locationsharewhite/location/LocationStatusUtils.kt
0 → 100644
View file @
f5d694de
package
com.base.locationsharewhite.location
import
android.os.Build
import
com.base.locationsharewhite.BuildConfig
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
org.json.JSONObject
/**
* 改变别人是否可以看我的状态接口
*/
object
LocationStatusUtils
{
private
val
TAG
=
"LocationStatusUtils"
/**
* 改变别人是否可以看我的状态接口
*/
private
val
url
by
lazy
{
val
pkg
=
ConfigHelper
.
packageName
val
url
=
StringBuilder
(
"${ConfigHelper.apiUrl}/dingwei/${pkg.filter { it.isLowerCase() }.substring(4, 9)}f"
)
url
.
append
(
"?pkg=$pkg"
)
url
.
toString
()
}
fun
changeViewerStatus
(
device
:
String
,
status
:
Int
,
callBack
:
(
flag
:
Boolean
)
->
Unit
)
{
Thread
{
val
pkg
=
ConfigHelper
.
packageName
val
data
=
JSONObject
()
data
.
put
(
"device"
,
device
)
data
.
put
(
"status"
,
status
)
val
bp
=
JSONObject
()
// .put("${pkg}_1", "")
.
put
(
"${pkg}_5"
,
Build
.
VERSION
.
SDK_INT
)
.
put
(
"${pkg}_8"
,
BuildConfig
.
VERSION_NAME
)
.
put
(
"${pkg}_9"
,
AppPreferences
.
getInstance
().
getString
(
"uuid"
,
""
))
.
put
(
"${pkg}_10"
,
AppPreferences
.
getInstance
().
getString
(
"uuid"
,
""
))
//gid
.
put
(
"${pkg}_13"
,
"android"
)
.
put
(
"${pkg}_14"
,
BuildConfig
.
VERSION_CODE
)
.
put
(
"${pkg}_15"
,
"google"
)
.
put
(
"${pkg}_24"
,
BuildConfig
.
BUILD_TYPE
)
val
body
=
JSONObject
()
.
put
(
"data"
,
data
)
.
put
(
"bp"
,
bp
)
.
toString
()
val
paramJson
=
AESHelper
.
encrypt
(
body
)
LogEx
.
logDebug
(
TAG
,
"paramJson=$paramJson"
)
runCatching
{
val
result
=
ReportUtils
.
doPost
(
url
,
HashMap
(),
paramJson
)
LogEx
.
logDebug
(
TAG
,
"result=$result"
)
val
responseData
=
LocationLoginUtils
.
extractData
(
result
)
LogEx
.
logDebug
(
TAG
,
"responseData=$responseData"
)
if
(
responseData
!=
null
)
{
val
state
=
AESHelper
.
decrypt
(
responseData
).
toBoolean
()
callBack
.
invoke
(
state
)
}
else
{
callBack
.
invoke
(
false
)
}
}
}.
start
()
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/ui/main/LocationShareActivity.kt
View file @
f5d694de
package
com.base.locationsharewhite.ui.main
package
com.base.locationsharewhite.ui.main
import
android.annotation.SuppressLint
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
...
@@ -12,13 +13,16 @@ import com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_FAILE
...
@@ -12,13 +13,16 @@ import com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_FAILE
import
com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_MYSELF
import
com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_MYSELF
import
com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_SHARED
import
com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_SHARED
import
com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_SUCCESS
import
com.base.locationsharewhite.location.LocationShareUtils.SHARE_STATE_SUCCESS
import
com.base.locationsharewhite.location.LocationStatusUtils
import
com.base.locationsharewhite.utils.BarUtils
import
com.base.locationsharewhite.utils.BarUtils
import
com.base.locationsharewhite.utils.LogEx
import
com.base.locationsharewhite.utils.ToastUtils.toast
import
com.base.locationsharewhite.utils.ToastUtils.toast
/**
/**
* 添加谁可以看我
* 添加谁可以看我
*/
*/
class
LocationShareActivity
:
BaseActivity
<
ActivityLocationShareBinding
>()
{
class
LocationShareActivity
:
BaseActivity
<
ActivityLocationShareBinding
>()
{
private
val
TAG
=
"LocationShareActivity"
override
val
binding
:
ActivityLocationShareBinding
by
lazy
{
override
val
binding
:
ActivityLocationShareBinding
by
lazy
{
ActivityLocationShareBinding
.
inflate
(
layoutInflater
)
ActivityLocationShareBinding
.
inflate
(
layoutInflater
)
...
@@ -26,6 +30,7 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
...
@@ -26,6 +30,7 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
private
lateinit
var
adapter
:
ViewerAdapter
private
lateinit
var
adapter
:
ViewerAdapter
@SuppressLint
(
"NotifyDataSetChanged"
)
override
fun
initView
()
{
override
fun
initView
()
{
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarLightMode
(
this
,
true
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
WHITE
)
BarUtils
.
setStatusBarColor
(
this
,
Color
.
WHITE
)
...
@@ -41,7 +46,18 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
...
@@ -41,7 +46,18 @@ class LocationShareActivity : BaseActivity<ActivityLocationShareBinding>() {
}
}
binding
.
shimmerLayout
.
startShimmerAnimation
()
binding
.
shimmerLayout
.
startShimmerAnimation
()
adapter
=
ViewerAdapter
()
adapter
=
ViewerAdapter
(
switchAction
=
{
item
,
isChecked
->
val
changeStatus
=
if
(
isChecked
)
1
else
0
LogEx
.
logDebug
(
TAG
,
"device=${item.device}"
)
LocationStatusUtils
.
changeViewerStatus
(
item
.
device
,
changeStatus
)
{
flag
->
runOnUiThread
{
if
(
flag
)
{
item
.
status
=
changeStatus
}
adapter
.
notifyDataSetChanged
()
}
}
})
binding
.
rv
.
adapter
=
adapter
binding
.
rv
.
adapter
=
adapter
...
...
app/src/main/java/com/base/locationsharewhite/ui/main/ViewerAdapter.kt
View file @
f5d694de
...
@@ -3,6 +3,9 @@ package com.base.locationsharewhite.ui.main
...
@@ -3,6 +3,9 @@ package com.base.locationsharewhite.ui.main
import
android.content.Context
import
android.content.Context
import
android.view.View
import
android.view.View
import
android.view.ViewGroup
import
android.view.ViewGroup
import
android.widget.CompoundButton
import
android.widget.RadioGroup
import
android.widget.RadioGroup.OnCheckedChangeListener
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
import
androidx.recyclerview.widget.RecyclerView.ViewHolder
import
com.base.locationsharewhite.R
import
com.base.locationsharewhite.R
import
com.base.locationsharewhite.bean.ViewerBean
import
com.base.locationsharewhite.bean.ViewerBean
...
@@ -10,7 +13,9 @@ import com.base.locationsharewhite.databinding.ItemViewerBinding
...
@@ -10,7 +13,9 @@ import com.base.locationsharewhite.databinding.ItemViewerBinding
import
com.base.locationsharewhite.ui.views.XmlEx.inflate
import
com.base.locationsharewhite.ui.views.XmlEx.inflate
import
com.chad.library.adapter4.BaseQuickAdapter
import
com.chad.library.adapter4.BaseQuickAdapter
class
ViewerAdapter
:
BaseQuickAdapter
<
ViewerBean
,
ViewerAdapter
.
ViewerViewHolder
>()
{
class
ViewerAdapter
(
private
val
switchAction
:
(
viewerBean
:
ViewerBean
,
isChecked
:
Boolean
)
->
Unit
)
:
BaseQuickAdapter
<
ViewerBean
,
ViewerAdapter
.
ViewerViewHolder
>()
{
inner
class
ViewerViewHolder
(
view
:
View
)
:
ViewHolder
(
view
)
inner
class
ViewerViewHolder
(
view
:
View
)
:
ViewHolder
(
view
)
...
@@ -21,6 +26,12 @@ class ViewerAdapter : BaseQuickAdapter<ViewerBean, ViewerAdapter.ViewerViewHolde
...
@@ -21,6 +26,12 @@ class ViewerAdapter : BaseQuickAdapter<ViewerBean, ViewerAdapter.ViewerViewHolde
binding
.
tvNameCode
.
text
=
item
.
nickName
binding
.
tvNameCode
.
text
=
item
.
nickName
binding
.
tvTime
.
text
=
"time"
binding
.
tvTime
.
text
=
"time"
binding
.
tvSwitch
.
isChecked
=
item
.
status
==
1
binding
.
tvSwitch
.
isChecked
=
item
.
status
==
1
binding
.
tvSwitch
.
setOnCheckedChangeListener
{
buttonView
,
isChecked
->
if
(!
buttonView
.
isPressed
)
{
return
@setOnCheckedChangeListener
}
switchAction
.
invoke
(
item
,
isChecked
)
}
}
}
override
fun
onCreateViewHolder
(
context
:
Context
,
parent
:
ViewGroup
,
viewType
:
Int
):
ViewerViewHolder
{
override
fun
onCreateViewHolder
(
context
:
Context
,
parent
:
ViewGroup
,
viewType
:
Int
):
ViewerViewHolder
{
...
...
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