Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
0b81449f
Commit
0b81449f
authored
Feb 25, 2022
by
sheteng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
取消点赞
parent
1fe0d2a8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
18 deletions
+24
-18
app/src/main/java/com/ccwangluo/accelerator/ui/news/NewsObjectFragment.kt
...a/com/ccwangluo/accelerator/ui/news/NewsObjectFragment.kt
+10
-8
app/src/main/java/com/ccwangluo/accelerator/ui/news/NewsObjectModel.kt
...java/com/ccwangluo/accelerator/ui/news/NewsObjectModel.kt
+12
-5
app/src/main/java/com/ccwangluo/accelerator/utils/http/HttpGo.kt
.../main/java/com/ccwangluo/accelerator/utils/http/HttpGo.kt
+2
-1
core/src/main/AndroidManifest.xml
core/src/main/AndroidManifest.xml
+0
-4
No files found.
app/src/main/java/com/ccwangluo/accelerator/ui/news/NewsObjectFragment.kt
View file @
0b81449f
...
...
@@ -124,7 +124,7 @@ class NewsObjectFragment : XPageFragment() {
}
itemData
.
isGreat
?.
let
{
if
(
it
)
{
itemView
.
findViewById
<
TextView
>(
R
.
id
.
great_num
).
setTextColor
(
Color
.
parseColor
(
"#
FF3B4FBE
"
))
itemView
.
findViewById
<
TextView
>(
R
.
id
.
great_num
).
setTextColor
(
Color
.
parseColor
(
"#
3CA4FD
"
))
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
great_img
)
.
setBackgroundResource
(
R
.
mipmap
.
icon_praise_bu
)
}
else
{
...
...
@@ -135,13 +135,15 @@ class NewsObjectFragment : XPageFragment() {
}
itemView
.
findViewById
<
ImageView
>(
R
.
id
.
great_img
).
setOnClickListener
{
itemData
.
isGreat
?.
let
{
if
(
it
)
{
return
@setOnClickListener
}
newsViewModel
?.
greate
(
itemData
.
type
,
gameId
,
itemData
.
id
)
{
ToastUtils
.
show
(
"点赞成功"
)
itemData
.
isGreat
=
true
itemData
.
greatNum
++
newsViewModel
?.
greate
(
this
@NewsObjectFragment
,
itemData
.
type
,
gameId
,
itemData
.
id
,
it
)
{
if
(!
it
)
{
ToastUtils
.
show
(
"点赞成功"
)
itemData
.
isGreat
=
true
itemData
.
greatNum
++
}
else
{
itemData
.
isGreat
=
false
itemData
.
greatNum--
}
recycle_view
?.
adapter
?.
notifyDataSetChanged
()
}
}
...
...
app/src/main/java/com/ccwangluo/accelerator/ui/news/NewsObjectModel.kt
View file @
0b81449f
...
...
@@ -4,7 +4,9 @@ import androidx.lifecycle.MutableLiveData
import
androidx.lifecycle.ViewModel
import
androidx.lifecycle.viewModelScope
import
com.ccwangluo.accelerator.model.NewsModel
import
com.ccwangluo.accelerator.utils.LoginUtils
import
com.ccwangluo.accelerator.utils.http.HttpGo
import
com.xuexiang.xpage.base.XPageFragment
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
...
...
@@ -37,12 +39,17 @@ class NewsObjectModel : ViewModel() {
/**
* 点赞
*/
fun
greate
(
type
:
Int
?,
gameId
:
Int
,
parentId
:
Int
,
callback
:
()
->
Unit
)
{
val
map
=
mutableMapOf
<
String
,
String
>()
map
.
put
(
"gameId"
,
gameId
.
toString
())
map
.
put
(
"parentId"
,
parentId
.
toString
())
fun
greate
(
xPageFragment
:
XPageFragment
,
type
:
Int
?,
gameId
:
Int
,
parentId
:
Int
,
isGreate
:
Boolean
,
callback
:
()
->
Unit
)
{
val
map
=
mutableMapOf
<
String
,
Any
>()
map
.
put
(
"gameId"
,
gameId
)
map
.
put
(
"parentId"
,
parentId
)
map
.
put
(
"isUnGreat"
,
isGreate
)
type
?.
let
{
map
.
put
(
"type"
,
it
.
toString
())
map
.
put
(
"type"
,
it
)
}
if
(
LoginUtils
.
token
==
null
)
{
LoginUtils
.
login
(
xPageFragment
,{})
return
}
viewModelScope
.
launch
(
Dispatchers
.
IO
)
{
val
res
=
...
...
app/src/main/java/com/ccwangluo/accelerator/utils/http/HttpGo.kt
View file @
0b81449f
...
...
@@ -6,6 +6,7 @@ import com.github.shadowsocks.http.HttpConfig
import
com.google.gson.Gson
import
com.google.gson.reflect.TypeToken
import
com.hjq.toast.ToastUtils
import
com.umeng.vt.diff.V
import
okhttp3.*
import
okhttp3.HttpUrl.Companion.toHttpUrl
import
okhttp3.MediaType.Companion.toMediaTypeOrNull
...
...
@@ -76,7 +77,7 @@ object HttpGo {
/**
* 同步请求
*/
inline
fun
<
reified
T
>
postSync
(
url
:
String
,
param
:
MutableMap
<
String
,
String
>):
BaseModel
<
T
>?
{
inline
fun
<
reified
T
>
postSync
(
url
:
String
,
param
:
MutableMap
<
String
,
out
Any
>):
BaseModel
<
T
>?
{
try
{
val
body
:
RequestBody
=
gson
.
toJson
(
param
).
toString
().
toRequestBody
(
jsonType
)
val
request
=
Request
.
Builder
()
...
...
core/src/main/AndroidManifest.xml
View file @
0b81449f
...
...
@@ -105,10 +105,6 @@
android:theme=
"@style/Theme.Shadowsocks.ActionBar"
/>
<activity
android:name=
"com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme=
"@style/Theme.Shadowsocks.ActionBar"
/>
<service
android:name=
"com.google.firebase.components.ComponentDiscoveryService"
android:directBootAware=
"true"
/>
<provider
android:name=
"com.google.firebase.provider.FirebaseInitProvider"
tools:node=
"remove"
/>
<service
android:name=
"androidx.room.MultiInstanceInvalidationService"
android:process=
":bg"
/>
</application>
...
...
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