pref(AccountUtil): 部分方法不再需要 context
This commit is contained in:
parent
d94d66eb1f
commit
5515e8f457
|
|
@ -238,17 +238,18 @@ open class MainActivity : BaseActivity(), NavigationBarView.OnItemSelectedListen
|
|||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
if (AccountUtil.isLoggedIn() && AccountUtil.getCookie(this) == null) {
|
||||
showDialog(DialogUtil.build(this)
|
||||
.setTitle(R.string.title_dialog_update_stoken)
|
||||
.setMessage(R.string.message_dialog_update_stoken)
|
||||
.setPositiveButton(R.string.button_sure_default) { _: DialogInterface?, _: Int ->
|
||||
startActivity(
|
||||
UpdateInfoActivity.newIntent(
|
||||
this,
|
||||
UpdateInfoActivity.ACTION_UPDATE_LOGIN_INFO
|
||||
if (AccountUtil.isLoggedIn() && AccountUtil.getCookie() == null) {
|
||||
showDialog(
|
||||
DialogUtil.build(this)
|
||||
.setTitle(R.string.title_dialog_update_stoken)
|
||||
.setMessage(R.string.message_dialog_update_stoken)
|
||||
.setPositiveButton(R.string.button_sure_default) { _: DialogInterface?, _: Int ->
|
||||
startActivity(
|
||||
UpdateInfoActivity.newIntent(
|
||||
this,
|
||||
UpdateInfoActivity.ACTION_UPDATE_LOGIN_INFO
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
.setCancelable(false)
|
||||
.create())
|
||||
|
|
|
|||
|
|
@ -928,7 +928,7 @@ class ThreadActivity : BaseActivity(), View.OnClickListener, IThreadMenuFragment
|
|||
}
|
||||
|
||||
private fun canDelete(): Boolean {
|
||||
return dataBean?.thread?.author?.id == AccountUtil.getUid(this)
|
||||
return dataBean?.thread?.author?.id == AccountUtil.getUid()
|
||||
}
|
||||
|
||||
override fun onDelete() {
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ class UserActivity : BaseActivity() {
|
|||
PhotoViewBean(StringUtil.getAvatarUrl(it.user.portrait), null)
|
||||
)
|
||||
}
|
||||
if (TextUtils.equals(AccountUtil.getUid(this), it.user.id)) {
|
||||
if (TextUtils.equals(AccountUtil.getUid(), it.user.id)) {
|
||||
actionBtn.setText(R.string.menu_edit_info)
|
||||
} else {
|
||||
if ("1" == it.user.hasConcerned) {
|
||||
|
|
@ -272,7 +272,7 @@ class UserActivity : BaseActivity() {
|
|||
|
||||
@OnClick(R.id.user_center_action_btn)
|
||||
fun onActionBtnClick(view: View?) {
|
||||
if (TextUtils.equals(profileBean!!.user!!.id, AccountUtil.getUid(this))) {
|
||||
if (TextUtils.equals(profileBean!!.user!!.id, AccountUtil.getUid())) {
|
||||
goToActivity<EditProfileActivity>()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ class ThreadReplyAdapter(context: Context) :
|
|||
}
|
||||
R.id.menu_delete -> {
|
||||
if (TextUtils.equals(
|
||||
AccountUtil.getUid(context),
|
||||
AccountUtil.getUid(),
|
||||
subPostListItemBean.authorId
|
||||
)
|
||||
) {
|
||||
|
|
@ -417,7 +417,7 @@ class ThreadReplyAdapter(context: Context) :
|
|||
.setInitMenuCallback { menu: Menu ->
|
||||
PluginManager.initPluginMenu(menu, PluginManager.MENU_SUB_POST_ITEM)
|
||||
menu.findItem(R.id.menu_report).isVisible = false
|
||||
if (TextUtils.equals(AccountUtil.getUid(context), subPostListItemBean.authorId)) {
|
||||
if (TextUtils.equals(AccountUtil.getUid(), subPostListItemBean.authorId)) {
|
||||
menu.findItem(R.id.menu_delete).isVisible = true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ fun buildCommonRequest(
|
|||
clientVersion: String,
|
||||
): CommonRequest {
|
||||
return CommonRequest(
|
||||
BDUSS = AccountUtil.getBduss(context),
|
||||
BDUSS = AccountUtil.getBduss(),
|
||||
_client_id = RetrofitTiebaApi.clientId,
|
||||
_client_type = 2,
|
||||
_client_version = clientVersion,
|
||||
|
|
@ -80,6 +80,6 @@ fun buildCommonRequest(
|
|||
net_type = "1",
|
||||
oaid = OAID(App.oaid).toJson(),
|
||||
pversion = "1.0.3",
|
||||
stoken = AccountUtil.getSToken(context),
|
||||
stoken = AccountUtil.getSToken(),
|
||||
)
|
||||
}
|
||||
|
|
@ -200,7 +200,7 @@ object MixedTiebaApiImpl : ITiebaApi {
|
|||
override fun userLikeForum(
|
||||
uid: String, page: Int
|
||||
): Call<UserLikeForumBean> {
|
||||
val myUid = AccountUtil.getUid(App.INSTANCE)
|
||||
val myUid = AccountUtil.getUid()
|
||||
return RetrofitTiebaApi.MINI_TIEBA_API.userLikeForum(
|
||||
page = page,
|
||||
uid = myUid,
|
||||
|
|
@ -355,7 +355,7 @@ object MixedTiebaApiImpl : ITiebaApi {
|
|||
RetrofitTiebaApi.NEW_TIEBA_API.threadStore(
|
||||
pageSize,
|
||||
pageSize * page,
|
||||
AccountUtil.getUid(App.INSTANCE)
|
||||
AccountUtil.getUid()
|
||||
)
|
||||
|
||||
override fun removeStore(threadId: String, tbs: String): Call<CommonResponse> =
|
||||
|
|
|
|||
|
|
@ -8,8 +8,20 @@ import com.huanchengfly.tieba.post.api.models.OAID
|
|||
import com.huanchengfly.tieba.post.api.retrofit.adapter.DeferredCallAdapterFactory
|
||||
import com.huanchengfly.tieba.post.api.retrofit.adapter.FlowCallAdapterFactory
|
||||
import com.huanchengfly.tieba.post.api.retrofit.converter.gson.GsonConverterFactory
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interceptors.*
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interfaces.*
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interceptors.AddCookieInterceptor
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interceptors.CommonHeaderInterceptor
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interceptors.CommonParamInterceptor
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interceptors.DropInterceptor
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interceptors.FailureResponseInterceptor
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interceptors.ForceLoginInterceptor
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interceptors.ProtoFailureResponseInterceptor
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interceptors.SortAndSignInterceptor
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interceptors.StParamInterceptor
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interfaces.MiniTiebaApi
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interfaces.NewTiebaApi
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interfaces.OfficialProtobufTiebaApi
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interfaces.OfficialTiebaApi
|
||||
import com.huanchengfly.tieba.post.api.retrofit.interfaces.WebTiebaApi
|
||||
import com.huanchengfly.tieba.post.toJson
|
||||
import com.huanchengfly.tieba.post.utils.AccountUtil
|
||||
import com.huanchengfly.tieba.post.utils.CuidUtils
|
||||
|
|
@ -35,7 +47,7 @@ object RetrofitTiebaApi {
|
|||
private val connectionPool = ConnectionPool(32, 5, TimeUnit.MINUTES)
|
||||
|
||||
private val defaultCommonParamInterceptor = CommonParamInterceptor(
|
||||
Param.BDUSS to { AccountUtil.getBduss(App.INSTANCE) },
|
||||
Param.BDUSS to { AccountUtil.getBduss() },
|
||||
Param.CLIENT_ID to { clientId },
|
||||
Param.CLIENT_TYPE to { "2" },
|
||||
Param.OS_VERSION to { Build.VERSION.SDK_INT.toString() },
|
||||
|
|
@ -127,7 +139,7 @@ object RetrofitTiebaApi {
|
|||
CommonHeaderInterceptor(
|
||||
Header.CHARSET to { "UTF-8" },
|
||||
Header.CLIENT_TYPE to { "2" },
|
||||
Header.CLIENT_USER_TOKEN to { AccountUtil.getUid(App.INSTANCE) },
|
||||
Header.CLIENT_USER_TOKEN to { AccountUtil.getUid() },
|
||||
Header.COOKIE to { "CUID=${CuidUtils.getNewCuid()};ka=open;TBBRAND=${Build.MODEL};" },
|
||||
Header.CUID to { CuidUtils.getNewCuid() },
|
||||
Header.CUID_GALAXY2 to { CuidUtils.getNewCuid() },
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.huanchengfly.tieba.post.api.retrofit.interceptors
|
||||
|
||||
import com.huanchengfly.tieba.post.App
|
||||
import com.huanchengfly.tieba.post.api.Header
|
||||
import com.huanchengfly.tieba.post.utils.AccountUtil
|
||||
import okhttp3.Interceptor
|
||||
|
|
@ -25,7 +24,7 @@ object AddCookieInterceptor : Interceptor {
|
|||
if (addCookie) {
|
||||
headers = headers.newBuilder()
|
||||
.removeAll(Header.COOKIE)
|
||||
.add(Header.COOKIE, AccountUtil.getCookie(App.INSTANCE) ?: "")
|
||||
.add(Header.COOKIE, AccountUtil.getCookie() ?: "")
|
||||
.build()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.api.retrofit.interfaces
|
||||
|
||||
import android.text.TextUtils
|
||||
import com.huanchengfly.tieba.post.App
|
||||
import com.huanchengfly.tieba.post.App.ScreenInfo
|
||||
import com.huanchengfly.tieba.post.api.Header
|
||||
import com.huanchengfly.tieba.post.api.getScreenHeight
|
||||
|
|
@ -21,9 +20,7 @@ interface MiniTiebaApi {
|
|||
fun personalized(
|
||||
@Field("load_type") load_type: Int,
|
||||
@Field("pn") page: Int = 1,
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(
|
||||
App.INSTANCE
|
||||
),
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(),
|
||||
@Field("_client_version") client_version: String = "8.0.8.0",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("cuid_gid") cuid_gid: String = "",
|
||||
|
|
@ -48,9 +45,7 @@ interface MiniTiebaApi {
|
|||
fun personalizedAsync(
|
||||
@Field("load_type") load_type: Int,
|
||||
@Field("pn") page: Int = 1,
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(
|
||||
App.INSTANCE
|
||||
),
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(),
|
||||
@Field("_client_version") client_version: String = "8.0.8.0",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("cuid_gid") cuid_gid: String = "",
|
||||
|
|
@ -75,9 +70,7 @@ interface MiniTiebaApi {
|
|||
fun personalizedFlow(
|
||||
@Field("load_type") load_type: Int,
|
||||
@Field("pn") page: Int = 1,
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(
|
||||
App.INSTANCE
|
||||
),
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(),
|
||||
@Field("_client_version") client_version: String = "8.0.8.0",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("cuid_gid") cuid_gid: String = "",
|
||||
|
|
@ -103,9 +96,7 @@ interface MiniTiebaApi {
|
|||
fun agree(
|
||||
@Field("post_id") postId: String,
|
||||
@Field("thread_id") threadId: String,
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(
|
||||
App.INSTANCE
|
||||
),
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(),
|
||||
@Field("_client_version") client_version: String = "8.0.8.0",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("cuid_gid") cuid_gid: String = "",
|
||||
|
|
@ -113,7 +104,7 @@ interface MiniTiebaApi {
|
|||
@Field("obj_type") obj_type: Int = 3,
|
||||
@Field("op_type") op_type: Int = 0,
|
||||
@Field("tbs") tbs: String = AccountUtil.getLoginInfo()!!.tbs,
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken(App.INSTANCE)!!
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken()!!
|
||||
): Call<AgreeBean>
|
||||
|
||||
@Headers("${Header.FORCE_LOGIN}: ${Header.FORCE_LOGIN_TRUE}")
|
||||
|
|
@ -122,9 +113,7 @@ interface MiniTiebaApi {
|
|||
fun agreeFlow(
|
||||
@Field("post_id") postId: String,
|
||||
@Field("thread_id") threadId: String,
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(
|
||||
App.INSTANCE
|
||||
),
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(),
|
||||
@Field("_client_version") client_version: String = "8.0.8.0",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("cuid_gid") cuid_gid: String = "",
|
||||
|
|
@ -132,7 +121,7 @@ interface MiniTiebaApi {
|
|||
@Field("obj_type") obj_type: Int = 3,
|
||||
@Field("op_type") op_type: Int = 0,
|
||||
@Field("tbs") tbs: String = AccountUtil.getLoginInfo()!!.tbs,
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken(App.INSTANCE)!!
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken()!!
|
||||
): Flow<AgreeBean>
|
||||
|
||||
@Headers("${Header.FORCE_LOGIN}: ${Header.FORCE_LOGIN_TRUE}")
|
||||
|
|
@ -141,9 +130,7 @@ interface MiniTiebaApi {
|
|||
fun disagree(
|
||||
@Field("post_id") postId: String,
|
||||
@Field("thread_id") threadId: String,
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(
|
||||
App.INSTANCE
|
||||
),
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(),
|
||||
@Field("_client_version") client_version: String = "8.0.8.0",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("cuid_gid") cuid_gid: String = "",
|
||||
|
|
@ -151,7 +138,7 @@ interface MiniTiebaApi {
|
|||
@Field("obj_type") obj_type: Int = 3,
|
||||
@Field("op_type") op_type: Int = 1,
|
||||
@Field("tbs") tbs: String = AccountUtil.getLoginInfo()!!.tbs,
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken(App.INSTANCE)!!
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken()!!
|
||||
): Call<AgreeBean>
|
||||
|
||||
@Headers("${Header.FORCE_LOGIN}: ${Header.FORCE_LOGIN_TRUE}")
|
||||
|
|
@ -160,9 +147,7 @@ interface MiniTiebaApi {
|
|||
fun disagreeFlow(
|
||||
@Field("post_id") postId: String,
|
||||
@Field("thread_id") threadId: String,
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(
|
||||
App.INSTANCE
|
||||
),
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(),
|
||||
@Field("_client_version") client_version: String = "8.0.8.0",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("cuid_gid") cuid_gid: String = "",
|
||||
|
|
@ -170,7 +155,7 @@ interface MiniTiebaApi {
|
|||
@Field("obj_type") obj_type: Int = 3,
|
||||
@Field("op_type") op_type: Int = 1,
|
||||
@Field("tbs") tbs: String = AccountUtil.getLoginInfo()!!.tbs,
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken(App.INSTANCE)!!
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken()!!
|
||||
): Flow<AgreeBean>
|
||||
|
||||
@Headers("${Header.FORCE_LOGIN}: ${Header.FORCE_LOGIN_TRUE}")
|
||||
|
|
@ -276,7 +261,7 @@ interface MiniTiebaApi {
|
|||
@Field("obj_type") objType: String,
|
||||
@Field("page_name") page_name: String = "PB",
|
||||
@Field("next") next: Int = 10,
|
||||
@Field("user_id") myUid: String? = AccountUtil.getUid(App.INSTANCE),
|
||||
@Field("user_id") myUid: String? = AccountUtil.getUid(),
|
||||
@Field("scr_h") scr_h: String = getScreenHeight().toString(),
|
||||
@Field("scr_w") scr_w: String = getScreenWidth().toString(),
|
||||
@Field("q_type") q_type: Int = 2,
|
||||
|
|
@ -295,7 +280,7 @@ interface MiniTiebaApi {
|
|||
@Field("obj_type") objType: String,
|
||||
@Field("page_name") page_name: String = "PB",
|
||||
@Field("next") next: Int = 10,
|
||||
@Field("user_id") myUid: String? = AccountUtil.getUid(App.INSTANCE),
|
||||
@Field("user_id") myUid: String? = AccountUtil.getUid(),
|
||||
@Field("scr_h") scr_h: String = getScreenHeight().toString(),
|
||||
@Field("scr_w") scr_w: String = getScreenWidth().toString(),
|
||||
@Field("q_type") q_type: Int = 2,
|
||||
|
|
@ -405,9 +390,7 @@ interface MiniTiebaApi {
|
|||
@GET("/mo/q/search/user")
|
||||
fun searchUser(
|
||||
@Query("word") keyword: String,
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(
|
||||
App.INSTANCE
|
||||
),
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(),
|
||||
@Query("_client_version") client_version: String = "8.0.8.0",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Query("cuid_gid") cuid_gid: String = ""
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.huanchengfly.tieba.post.api.retrofit.interfaces
|
||||
|
||||
import com.huanchengfly.tieba.post.App
|
||||
import com.huanchengfly.tieba.post.App.ScreenInfo
|
||||
import com.huanchengfly.tieba.post.api.Header
|
||||
import com.huanchengfly.tieba.post.api.Param
|
||||
|
|
@ -108,7 +107,7 @@ interface OfficialTiebaApi {
|
|||
fun submitDislike(
|
||||
@Field("dislike") dislike: String,
|
||||
@Field("dislike_from") dislike_from: String = "homepage",
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken(App.INSTANCE)!!
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken()!!
|
||||
): Call<CommonResponse>
|
||||
|
||||
@Headers("${Header.FORCE_LOGIN}: ${Header.FORCE_LOGIN_TRUE}")
|
||||
|
|
@ -117,7 +116,7 @@ interface OfficialTiebaApi {
|
|||
fun submitDislikeFlow(
|
||||
@Field("dislike") dislike: String,
|
||||
@Field("dislike_from") dislike_from: String = "homepage",
|
||||
@Field("stoken") stoken: String? = AccountUtil.getSToken(App.INSTANCE)
|
||||
@Field("stoken") stoken: String? = AccountUtil.getSToken()
|
||||
): Flow<CommonResponse>
|
||||
|
||||
@Headers("${Header.FORCE_LOGIN}: ${Header.FORCE_LOGIN_TRUE}")
|
||||
|
|
@ -129,7 +128,7 @@ interface OfficialTiebaApi {
|
|||
@Field("_client_version") client_version: String = "11.10.8.6",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("authsid") authsid: String = "null",
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken(App.INSTANCE)!!,
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken()!!,
|
||||
@Field("from_type") fromType: Int = 2,
|
||||
@Field("in_live") inLive: Int = 0,
|
||||
@Field("timestamp") timestamp: Long = System.currentTimeMillis()
|
||||
|
|
@ -144,7 +143,7 @@ interface OfficialTiebaApi {
|
|||
@Field("_client_version") client_version: String = "11.10.8.6",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("authsid") authsid: String = "null",
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken(App.INSTANCE)!!,
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken()!!,
|
||||
@Field("from_type") fromType: Int = 2,
|
||||
@Field("in_live") inLive: Int = 0
|
||||
): Flow<FollowBean>
|
||||
|
|
@ -156,9 +155,9 @@ interface OfficialTiebaApi {
|
|||
@POST("/c/f/forum/getforumlist")
|
||||
@FormUrlEncoded
|
||||
fun getForumListFlow(
|
||||
@Field("BDUSS") bduss: String = AccountUtil.getBduss(App.INSTANCE)!!,
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken(App.INSTANCE)!!,
|
||||
@Field("user_id") userId: String = AccountUtil.getUid(App.INSTANCE)!!,
|
||||
@Field("BDUSS") bduss: String = AccountUtil.getBduss()!!,
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken()!!,
|
||||
@Field("user_id") userId: String = AccountUtil.getUid()!!,
|
||||
@Field("_client_version") client_version: String = "11.10.8.6",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
): Flow<GetForumListBean>
|
||||
|
|
@ -172,8 +171,8 @@ interface OfficialTiebaApi {
|
|||
@Field("_client_version") client_version: String = "11.10.8.6",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("authsid") authsid: String = "null",
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken(App.INSTANCE)!!,
|
||||
@Field("user_id") userId: String = AccountUtil.getUid(App.INSTANCE)!!
|
||||
@Field("stoken") stoken: String = AccountUtil.getSToken()!!,
|
||||
@Field("user_id") userId: String = AccountUtil.getUid()!!
|
||||
): Flow<MSignBean>
|
||||
|
||||
@Headers(
|
||||
|
|
@ -184,8 +183,8 @@ interface OfficialTiebaApi {
|
|||
@POST("/c/s/initNickname")
|
||||
@FormUrlEncoded
|
||||
fun initNickNameFlow(
|
||||
@Field("BDUSS") bduss: String = AccountUtil.getBduss(App.INSTANCE)!!,
|
||||
@Field("stoken") sToken: String = AccountUtil.getSToken(App.INSTANCE)!!,
|
||||
@Field("BDUSS") bduss: String = AccountUtil.getBduss()!!,
|
||||
@Field("stoken") sToken: String = AccountUtil.getSToken()!!,
|
||||
@Field("_client_version") client_version: String = "11.10.8.6",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version"
|
||||
): Flow<InitNickNameBean>
|
||||
|
|
@ -198,9 +197,9 @@ interface OfficialTiebaApi {
|
|||
@POST("/c/s/login")
|
||||
@FormUrlEncoded
|
||||
fun loginFlow(
|
||||
@Field("bdusstoken") bdusstoken: String = "${AccountUtil.getBduss(App.INSTANCE)!!}|null",
|
||||
@Field("stoken") sToken: String = AccountUtil.getSToken(App.INSTANCE)!!,
|
||||
@Field("user_id") userId: String? = AccountUtil.getUid(App.INSTANCE),
|
||||
@Field("bdusstoken") bdusstoken: String = "${AccountUtil.getBduss()!!}|null",
|
||||
@Field("stoken") sToken: String = AccountUtil.getSToken()!!,
|
||||
@Field("user_id") userId: String? = AccountUtil.getUid(),
|
||||
@Field("channel_id") channelId: String = "",
|
||||
@Field("channel_uid") channelUid: String = "",
|
||||
@Field("_client_version") client_version: String = "11.10.8.6",
|
||||
|
|
@ -215,9 +214,9 @@ interface OfficialTiebaApi {
|
|||
@POST("/c/u/user/profile")
|
||||
@FormUrlEncoded
|
||||
fun profileFlow(
|
||||
@Field("stoken") sToken: String = AccountUtil.getSToken(App.INSTANCE)!!,
|
||||
@Field("stoken") sToken: String = AccountUtil.getSToken()!!,
|
||||
@Field("tbs") tbs: String = AccountUtil.getLoginInfo()!!.tbs,
|
||||
@Field("uid") userId: String? = AccountUtil.getUid(App.INSTANCE),
|
||||
@Field("uid") userId: String? = AccountUtil.getUid(),
|
||||
@Field("is_from_usercenter") isFromUserCenter: String = "1",
|
||||
@Field("need_post_count") needPostCount: String = "1",
|
||||
@Field("page") page: String = "1",
|
||||
|
|
@ -237,7 +236,7 @@ interface OfficialTiebaApi {
|
|||
@Field("birthday_time") birthdayTime: String,
|
||||
@Field("intro") intro: String,
|
||||
@Field("sex") sex: String,
|
||||
@Field("stoken") sToken: String = AccountUtil.getSToken(App.INSTANCE)!!,
|
||||
@Field("stoken") sToken: String = AccountUtil.getSToken()!!,
|
||||
@Field("_client_version") client_version: String = "11.10.8.6",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
): Flow<CommonResponse>
|
||||
|
|
@ -259,9 +258,7 @@ interface OfficialTiebaApi {
|
|||
fun personalizedFlow(
|
||||
@Field("load_type") load_type: Int,
|
||||
@Field("pn") page: Int = 1,
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(
|
||||
App.INSTANCE
|
||||
),
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(),
|
||||
@Field("_client_version") client_version: String = "11.10.8.6",
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android $client_version",
|
||||
@Field("cuid_gid") cuid_gid: String = "",
|
||||
|
|
@ -287,7 +284,7 @@ interface OfficialTiebaApi {
|
|||
@POST("/c/f/excellent/personalized?cmd=309264")
|
||||
fun personalizedProtoFlow(
|
||||
@Body body: MyMultipartBody,
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(App.INSTANCE),
|
||||
@retrofit2.http.Header("client_user_token") client_user_token: String? = AccountUtil.getUid(),
|
||||
@retrofit2.http.Header(Header.USER_AGENT) user_agent: String = "bdtb for Android 11.10.8.6",
|
||||
): Flow<PersonalizedResponse>
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ class DislikeDialog(
|
|||
clickTime,
|
||||
extras.joinToString(",")
|
||||
),
|
||||
AccountUtil.getSToken(context)!!
|
||||
AccountUtil.getSToken()!!
|
||||
).enqueue(object : Callback<CommonResponse> {
|
||||
override fun onFailure(call: Call<CommonResponse>, t: Throwable) {}
|
||||
override fun onResponse(
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ class MyInfoFragment : BaseFragment(), View.OnClickListener, CompoundButton.OnCh
|
|||
if (AccountUtil.isLoggedIn()) {
|
||||
launch {
|
||||
TiebaApi.getInstance()
|
||||
.profileFlow(AccountUtil.getUid(attachContext)!!)
|
||||
.profileFlow(AccountUtil.getUid()!!)
|
||||
.catch { e ->
|
||||
e.printStackTrace()
|
||||
mRefreshView.isRefreshing = false
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ public class WebViewFragment extends BaseFragment implements DownloadListener, B
|
|||
}
|
||||
if (enableSwipeRefresh) swipeRefreshLayout.setRefreshing(true);
|
||||
if (AccountUtil.isLoggedIn() && !activityName.startsWith("LoginActivity") && !activityName.startsWith("UpdateInfoActivity")) {
|
||||
String cookieStr = AccountUtil.getBdussCookie(getAttachContext());
|
||||
String cookieStr = AccountUtil.getBdussCookie();
|
||||
CookieManager.getInstance().setCookie(url, cookieStr);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ class EditProfileActivity : BaseActivity() {
|
|||
|
||||
private val intents by lazy {
|
||||
merge(
|
||||
flowOf(EditProfileIntent.Init(AccountUtil.getUid(this) ?: "0"))
|
||||
flowOf(EditProfileIntent.Init(AccountUtil.getUid() ?: "0"))
|
||||
)
|
||||
}
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.huanchengfly.tieba.post.ui.page.main.home
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.animateContentSize
|
||||
import androidx.compose.foundation.Image
|
||||
|
|
@ -61,14 +60,13 @@ import androidx.compose.ui.unit.sp
|
|||
import com.google.accompanist.drawablepainter.rememberDrawablePainter
|
||||
import com.google.accompanist.placeholder.placeholder
|
||||
import com.huanchengfly.tieba.post.R
|
||||
import com.huanchengfly.tieba.post.activities.ForumActivity
|
||||
import com.huanchengfly.tieba.post.activities.NewSearchActivity
|
||||
import com.huanchengfly.tieba.post.api.ForumSortType
|
||||
import com.huanchengfly.tieba.post.arch.collectPartialAsState
|
||||
import com.huanchengfly.tieba.post.arch.pageViewModel
|
||||
import com.huanchengfly.tieba.post.getInt
|
||||
import com.huanchengfly.tieba.post.goToActivity
|
||||
import com.huanchengfly.tieba.post.ui.common.theme.compose.ExtendedTheme
|
||||
import com.huanchengfly.tieba.post.ui.page.LocalNavigator
|
||||
import com.huanchengfly.tieba.post.ui.page.destinations.ForumPageDestination
|
||||
import com.huanchengfly.tieba.post.ui.widgets.Chip
|
||||
import com.huanchengfly.tieba.post.ui.widgets.compose.AccountNavIconIfCompact
|
||||
import com.huanchengfly.tieba.post.ui.widgets.compose.ActionItem
|
||||
|
|
@ -80,18 +78,8 @@ import com.huanchengfly.tieba.post.ui.widgets.compose.rememberDialogState
|
|||
import com.huanchengfly.tieba.post.ui.widgets.compose.rememberMenuState
|
||||
import com.huanchengfly.tieba.post.utils.AccountUtil.LocalAccount
|
||||
import com.huanchengfly.tieba.post.utils.ImageUtil
|
||||
import com.huanchengfly.tieba.post.utils.ThemeUtil
|
||||
import com.huanchengfly.tieba.post.utils.TiebaUtil
|
||||
import com.huanchengfly.tieba.post.utils.appPreferences
|
||||
import com.huanchengfly.tieba.post.utils.preload.PreloadUtil
|
||||
import com.huanchengfly.tieba.post.utils.preload.loaders.ForumLoader
|
||||
|
||||
private fun getSortType(context: Context, forumName: String): ForumSortType {
|
||||
val defaultSortType = context.appPreferences.defaultSortType!!.toInt()
|
||||
return ForumSortType.valueOf(
|
||||
ThemeUtil.dataStore.getInt(forumName + "_sort_type", defaultSortType)
|
||||
)
|
||||
}
|
||||
|
||||
private fun getGridCells(context: Context, listSingle: Boolean = context.appPreferences.listSingle): GridCells {
|
||||
return if (listSingle) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import androidx.compose.runtime.MutableState
|
|||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.staticCompositionLocalOf
|
||||
import com.huanchengfly.tieba.post.App
|
||||
import com.huanchengfly.tieba.post.R
|
||||
import com.huanchengfly.tieba.post.api.TiebaApi
|
||||
import com.huanchengfly.tieba.post.models.database.Account
|
||||
|
|
@ -200,34 +199,29 @@ object AccountUtil {
|
|||
Toast.makeText(context, R.string.toast_exit_account_success, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
fun getSToken(context: Context? = App.INSTANCE): String? {
|
||||
if (context == null) return null
|
||||
fun getSToken(): String? {
|
||||
val account = getLoginInfo()
|
||||
return account?.sToken
|
||||
}
|
||||
|
||||
fun getCookie(context: Context?): String? {
|
||||
if (context == null) return null
|
||||
fun getCookie(): String? {
|
||||
val account = getLoginInfo()
|
||||
return account?.cookie
|
||||
}
|
||||
|
||||
fun getUid(context: Context?): String? {
|
||||
if (context == null) return null
|
||||
fun getUid(): String? {
|
||||
val account = getLoginInfo()
|
||||
return account?.uid
|
||||
}
|
||||
|
||||
fun getBduss(context: Context?): String? {
|
||||
if (context == null) return null
|
||||
fun getBduss(): String? {
|
||||
val account = getLoginInfo()
|
||||
return account?.bduss
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getBdussCookie(context: Context?): String? {
|
||||
if (context == null) return null
|
||||
val bduss = getBduss(context)
|
||||
fun getBdussCookie(): String? {
|
||||
val bduss = getBduss()
|
||||
return if (bduss != null) {
|
||||
getBdussCookie(bduss)
|
||||
} else null
|
||||
|
|
|
|||
Loading…
Reference in New Issue