Commit 5d0b11ab by konghaorui

测评业务模块 UI 适配

parent d89b0bd5
......@@ -14,7 +14,6 @@ import com.ydl.webview.NewH5Activity
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.ydl.ydlcommon.router.YdlCommonRouterManager
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.URLUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
......@@ -332,7 +331,7 @@ class ExpertSearchAdapter(private val context: Context, private val expertSearch
itemView.tvChat.setOnClickListener {
if (adapterPosition != RecyclerView.NO_POSITION) {
//判断是否已登录
if(!YdlCommonRouterManager.getYdlCommonRoute().isLogin()){
if(!ConsultantIn.getUserImpl().isLogin()){
TempH5RouteUtils.tempH5Route(IYDLRouterConstant.ROUTER_MINE_LOGIN)
return@setOnClickListener
}
......
......@@ -4,7 +4,9 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.support.v7.app.AppCompatActivity
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.router.RouterManager
import com.yidianling.user.api.service.IUserService
/**
* author : Zhangwenchao
......@@ -26,4 +28,8 @@ object ConsultantIn {
return RouterManager.getAppRouter()?.mainIntent(activity)
}
fun getUserImpl(): IUserService {
return ModularServiceManager.provide(IUserService::class.java)
}
}
\ No newline at end of file
......@@ -76,9 +76,11 @@ dependencies {
api project(':ydl-webview')
api project(':ydl-platform')
implementation modularPublication('com.ydl:m-test-api')
implementation modularPublication('com.ydl:m-user-api')
}else {
//发布时使用
implementation modularPublication('com.ydl:m-test-api')
compileOnly modularPublication('com.ydl:m-test-api')
compileOnly rootProject.ext.dependencies["ydl-m-user-api"]
api rootProject.ext.dependencies["ydl-webview"]
api(rootProject.ext.dependencies["ydl-platform"]) {
transitive = true
......
......@@ -21,6 +21,8 @@
<!--测评首页-->
<activity
android:name=".home.TestHomeActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/tests_NoTitleTheme"
/>
</application>
</manifest>
package com.yidianling.tests.home
import android.os.Build
import android.support.v4.content.ContextCompat
import android.support.v4.widget.SwipeRefreshLayout
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.text.TextUtils
import android.view.View
import android.widget.LinearLayout
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.YDLAsyncUtils
import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.*
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.common.tools.RxImageTool
import com.yidianling.tests.R
import com.yidianling.tests.home.adapter.AdapterWrapper
import com.yidianling.tests.home.adapter.TestHomeAdapter
......@@ -97,8 +97,23 @@ class TestHomeActivity : BaseMvpActivity<ITestHomeContract.View,ITestHomeContrac
img_mine.setOnClickListener {
(testHomeEvent as TestHomeEventImpl).jumpMine()
}
initStatus()
}
/**
* 初始化状态栏位置
*/
private fun initStatus() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色
StatusBarUtils.setTransparentForImageView(this, null)
val statusBarHeight = StatusBarUtils.getStatusBarHeight(this)
val lp1 = rl_tests_title_layout.layoutParams as LinearLayout.LayoutParams
lp1.height = (RxImageTool.dp2px(48f) + statusBarHeight)
rl_tests_title_layout.setPadding(0, statusBarHeight, 0, 0)
}
}
//路由传递过来的参数
private fun getRouterParam() {
if (null != intent && intent.hasExtra("routerParam")) {
......@@ -112,7 +127,7 @@ class TestHomeActivity : BaseMvpActivity<ITestHomeContract.View,ITestHomeContrac
private fun initAdapter() {
swipe_refresh_layout.setOnRefreshListener(this)
swipe_refresh_layout.setColorSchemeColors(ContextCompat.getColor(this, R.color.platform_main_theme_blue))
swipe_refresh_layout.setColorSchemeColors(ContextCompat.getColor(this, R.color.tests_main_theme))
mLayoutManager = LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false)
recyclerview.layoutManager = mLayoutManager
if (null == mTestHomeAdapter) {
......
......@@ -10,7 +10,6 @@ import com.ydl.ydl_router.manager.YDLRouterParams
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.yidianling.router.RouterManager
import com.yidianling.tests.list.view.TestCategoryListActivity
import com.yidianling.tests.router.TestsIn
import com.yidianling.tests.search.TestSearchActivity
......@@ -122,7 +121,7 @@ class TestHomeEventImpl(mContext: Context) : ITestHomeEvent {
if ("ceshi" == uri.host) {
val id = uri.getQueryParameter("id")
// YDLRouterManager.router(IYDLRouterConstant.ROUTER_TEST_DETAIL, YDLRouterParams().putExtra(IYDLRouterConstant.EXTRA_ID, id))
RouterManager.getTestsRouter()?.testDetailH5(id)
TestsIn.getTestsImpl().testDetailH5(id)
}
} else if (linkUrl.startsWith("http")) {
YDLRouterManager.router(
......
......@@ -14,13 +14,11 @@ import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.DisplayUtils
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.utils.remind.HttpErrorUtils
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.ToastUtil
import com.yidianling.tests.R
import com.yidianling.tests.TestsBIConstants
import com.yidianling.tests.home.utils.TestHomeUtils
import com.yidianling.tests.list.model.bean.CategotyPopItem
import com.yidianling.tests.list.model.bean.TestCategory
......@@ -308,8 +306,8 @@ class TestCategoryListActivity : BaseMvpActivity<TestListActivityView, TestListA
tv.setTextColor(ContextCompat.getColor(this, R.color.platform_colorTextDefault))
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.platform_ic_arrow_drop_down_grey_500_18dp, 0)
} else {
tv.setTextColor(ContextCompat.getColor(this, R.color.platform_google_green))
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.platform_ic_arrow_drop_down_green_18dp, 0)
tv.setTextColor(ContextCompat.getColor(this, R.color.tests_main_theme))
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.tests_ic_arrow_drop_down, 0)
}
}
......
......@@ -17,16 +17,12 @@ import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.ydl.ydlcommon.router.YdlCommonOut
import com.ydl.ydlcommon.router.YdlCommonRouterManager
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.view.listener.EndlessRecyclerViewScrollListener
import com.yidianling.common.tools.ToastUtil
import com.yidianling.router.RouterManager
import com.yidianling.tests.R
import com.yidianling.tests.TestRetrofitApi
import com.yidianling.tests.TestsBIConstants
import com.yidianling.tests.home.event.UpdateCouponMoneyEvent
import com.yidianling.tests.home.utils.TestHomeUtils
import com.yidianling.tests.list.model.bean.Test
......@@ -110,7 +106,8 @@ class TestListFragment : BaseFragment(), MyBaseAdapter.OnItemClickListener<Test>
}
fun fetchTestList() {
val loginBean = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()
val loginBean = TestsIn.getYDLUserInfo()
var userId = loginBean?.userId ?: "";
disposable = TestRetrofitApi.getTestRetrofitApi()
......@@ -173,12 +170,12 @@ class TestListFragment : BaseFragment(), MyBaseAdapter.OnItemClickListener<Test>
}else{
when (listType) {
1 -> {
RouterManager.getTestsRouter()?.testDetailH5(data.id.toString())
TestsIn.getTestsImpl().testDetailH5(data.id.toString())
}
2 -> {
RouterManager.getTestsRouter()?.testH5Result(data.testResultId.toString());
TestsIn.getTestsImpl().testH5Result(data.testResultId.toString());
}
else -> RouterManager.getTestsRouter()?.testDetailH5(data.id.toString())
else -> TestsIn.getTestsImpl().testDetailH5(data.id.toString())
}
}
}
......
......@@ -34,7 +34,7 @@ class CategoryConditionRecyclerViewAdapter(private val context: Context,
holder.tvSort.text = item.value
holder.tvSort.setTextColor(ContextCompat.getColor(context, R.color.platform_color_242424))
if (!TextUtils.isEmpty(lastSelectText) && item.value.equals(lastSelectText) && position!=0){
holder.tvSort.setTextColor(ContextCompat.getColor(context, R.color.platform_google_green))
holder.tvSort.setTextColor(ContextCompat.getColor(context, R.color.tests_main_theme))
lastSelectView = holder.tvSort
}
}
......@@ -49,7 +49,7 @@ class CategoryConditionRecyclerViewAdapter(private val context: Context,
lastSelectView?.setTextColor(ContextCompat.getColor(context, R.color.platform_color_242424))
if (adapterPosition != 0){
tvSort.setTextColor(ContextCompat.getColor(context, R.color.platform_google_green))
tvSort.setTextColor(ContextCompat.getColor(context, R.color.tests_main_theme))
}
if (adapterPosition != RecyclerView.NO_POSITION){
......
......@@ -2,10 +2,10 @@ package com.yidianling.tests.modular
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydl_router.manager.YDLRouterParams
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.yidianling.tests.api.service.ITestsApiService
/**
......@@ -19,14 +19,12 @@ public class TestsApiServiceImp : ITestsApiService {
}
override fun testH5Result(testResultId: String) {
YDLRouterManager.router(
IYDLRouterConstant.ROUTER_H5_H5,
YDLRouterParams().putExtra(IYDLRouterConstant.EXTRA_URL, HttpConfig.MH5_URL+"ceshi/result/"+testResultId),"")
val h5Params = H5Params(HttpConfig.MH5_URL+"ceshi/result/"+testResultId, null)
NewH5Activity.start(BaseApp.getApp(),h5Params)
}
override fun testDetailH5(testId: String) {
YDLRouterManager.router(
IYDLRouterConstant.ROUTER_H5_H5,
YDLRouterParams().putExtra(IYDLRouterConstant.EXTRA_URL, HttpConfig.MH5_URL+"ceshi/"+testId),"")
val h5Params = H5Params(HttpConfig.MH5_URL+"ceshi/"+testId, null)
NewH5Activity.start(BaseApp.getApp(),h5Params)
}
}
\ No newline at end of file
......@@ -2,8 +2,13 @@ package com.yidianling.tests.router
import android.app.Activity
import android.content.Intent
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.router.YdlUserInfo
import com.yidianling.router.RouterManager
import com.yidianling.router.im.IMRequestCallback
import com.yidianling.tests.api.service.ITestsApiService
import com.yidianling.user.api.bean.UserResponseBean
import com.yidianling.user.api.service.IUserService
/**
* author : Zhangwenchao
......@@ -12,12 +17,23 @@ import com.yidianling.router.im.IMRequestCallback
*/
object TestsIn {
fun getTestsImpl(): ITestsApiService {
return ModularServiceManager.provide(ITestsApiService::class.java)
}
fun isLogin(): Boolean {
return RouterManager.getUserRouter()?.isLogin()?:false
return ModularServiceManager.provide(IUserService::class.java).isLogin()
}
fun getYDLUserInfo(): YdlUserInfo? {
return ModularServiceManager.getPlatformUserService()?.getUser()
}
fun getUserInfo(): UserResponseBean.UserInfo? {
return ModularServiceManager.provide(IUserService::class.java).getUserInfo()
}
fun loginWayIntent(activity: Activity): Intent? {
return RouterManager.getUserRouter()?.loginWayIntent(activity)
return ModularServiceManager.provide(IUserService::class.java).loginWayIntent(activity)
}
fun publishTrendIntent(activity: Activity, url: String, cover: String, title: String): Intent? {
......
......@@ -21,13 +21,13 @@ import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.view.listener.EndlessRecyclerViewScrollListener
import com.yidianling.common.tools.ToastUtil
import com.yidianling.router.RouterManager
import com.yidianling.tests.R
import com.yidianling.tests.home.event.UpdateCouponMoneyEvent
import com.yidianling.tests.home.utils.TestHomeUtils
import com.yidianling.tests.list.model.bean.RecommendSearchItemBean
import com.yidianling.tests.list.model.bean.Test
import com.yidianling.tests.list.view.adapter.TestListRecyclerAdapter
import com.yidianling.tests.router.TestsIn
import de.greenrobot.event.EventBus
import kotlinx.android.synthetic.main.tests_activity_test_search.*
import kotlinx.android.synthetic.main.tests_item_hot_search.view.*
......@@ -98,11 +98,11 @@ class TestSearchActivity : BaseMvpActivity<TestSearchView, TestSearchPresenter>(
hotSearchAdapter = TestListRecyclerAdapter(this, hotSearchedTestList, TestListRecyclerAdapter.PAGE_TYPE_SEARCH)
searchAdapter?.onItemClickListener = MyBaseAdapter.OnItemClickListener { _, _, data ->
RouterManager.getTestsRouter()?.testDetailH5(data.id.toString())
TestsIn.getTestsImpl().testDetailH5(data.id.toString())
}
hotSearchAdapter?.onItemClickListener = MyBaseAdapter.OnItemClickListener { _, _, data ->
RouterManager.getTestsRouter()?.testDetailH5(data.id.toString())
TestsIn.getTestsImpl().testDetailH5(data.id.toString())
}
headerHotSearch = View.inflate(this, R.layout.tests_header_hot_search, null) as LinearLayout?;
......
......@@ -2,7 +2,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:state_pressed="true">
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="@color/platform_google_green" />
<stroke android:width="1dp" android:color="@color/tests_main_theme" />
<corners android:radius="100dp"/>
<solid android:color="#cacaca"/>
</shape>
......@@ -10,7 +10,7 @@
<item android:state_enabled="true" android:state_pressed="false">
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="@color/platform_google_green" />
<stroke android:width="1dp" android:color="@color/tests_main_theme" />
<corners android:radius="100dp"/>
<solid android:color="@color/white"/>
</shape>
......
......@@ -3,14 +3,14 @@
<item android:state_enabled="true" android:state_pressed="true">
<shape android:shape="rectangle">
<corners android:radius="100dp"/>
<solid android:color="@color/platform_google_green_dark"/>
<solid android:color="@color/tests_main_theme"/>
</shape>
</item>
<item android:state_enabled="true" android:state_pressed="false">
<shape android:shape="rectangle">
<corners android:radius="100dp"/>
<solid android:color="@color/platform_google_green"/>
<solid android:color="@color/tests_main_theme"/>
</shape>
</item>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="true" android:state_pressed="true">
<color android:color="@color/platform_google_green_dark" />
<color android:color="@color/tests_main_theme" />
</item>
<item android:state_enabled="true" android:state_pressed="false">
<color android:color="@color/platform_google_green" />
<color android:color="@color/tests_main_theme" />
</item>
</selector>
\ No newline at end of file
......@@ -8,14 +8,14 @@
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<solid android:color="@color/platform_google_green" />
<solid android:color="@color/tests_main_theme" />
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="@color/platform_google_green" />
<solid android:color="@color/tests_main_theme" />
</shape>
</clip>
</item>
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#56CCF2"
android:endColor="#2F80ED"
android:startColor="@color/tests_main_theme_light"
android:endColor="@color/tests_main_theme"
android:angle="0" />
</shape>
\ No newline at end of file
......@@ -69,6 +69,7 @@
app:pa_tab_height="44dp"
app:pa_tab_indicator_margin="13dp"
app:pa_tab_mode="scrollable"
app:pa_indicator_color="@color/tests_main_theme"
/>
<LinearLayout
......
......@@ -45,9 +45,9 @@
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="40dp"
app:tabIndicatorColor="@color/platform_google_green"
app:tabIndicatorColor="@color/tests_main_theme"
app:tabMode="scrollable"
app:tabSelectedTextColor="@color/platform_google_green" />
app:tabSelectedTextColor="@color/tests_main_theme" />
<View
android:layout_width="match_parent"
......
......@@ -12,6 +12,6 @@
android:orientation="vertical"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:textColor="@color/platform_google_green"
android:textColor="@color/tests_main_theme"
tools:text="自闭症" />
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
android:orientation="vertical"
>
<include
layout="@layout/tests_testhome_bar"
android:layout_width="match_parent"
android:layout_height="48dp" />
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
......@@ -20,10 +26,6 @@
android:layout_height="match_parent"
android:visibility="gone" />
<include layout="@layout/tests_testhome_bar" />
</FrameLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>
</LinearLayout>
......@@ -3,14 +3,15 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="162dp"
android:layout_height="114dp"
android:background="@drawable/tests_testhome_bg" />
<android.support.v7.widget.CardView xmlns:app="http://schemas.android.com/apk/res-auto"
<android.support.v7.widget.CardView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="54dp"
android:layout_marginTop="6dp"
android:layout_marginRight="15dp"
app:cardCornerRadius="6dp"
app:cardElevation="2dp">
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal">
<View
android:id="@+id/v_bg"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@drawable/tests_testhome_bg" />
android:orientation="horizontal"
android:id="@+id/rl_tests_title_layout"
android:background="@drawable/tests_testhome_bg"
>
<LinearLayout
android:id="@+id/ll_bar_root"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
......@@ -55,4 +52,4 @@
android:padding="5dp"
android:src="@drawable/tests_testhome_mine" />
</LinearLayout>
</FrameLayout>
</RelativeLayout>
......@@ -3,16 +3,5 @@
<!--主题色-->
<color name="tests_main_theme">#fdbd00</color>
<!--主题浅色-->
<color name="tests_main_theme_light">#FFEC8C</color>
<!--主题亮色-->
<color name="tests_main_theme_bright">#fffae0</color>
<!--确认按钮背景颜色-->
<color name="tests_confirm_bg_color">#FFDD33</color>
<!--确认按钮字体颜色-->
<color name="tests_confirm_text_color">#242424</color>
<!--确认按钮提示字体颜色-->
<color name="tests_confirm_text_hint_color">#666666</color>
<!--筛选条件选择框字体颜色-->
<color name="tests_filter_content_text_color_en">#242424</color>
<color name="tests_filter_content_text_color_un">#555555</color>
<color name="tests_main_theme_light">#FCDA42</color>
</resources>
......@@ -3,16 +3,5 @@
<!--主题色-->
<color name="tests_main_theme">#1da1f2</color>
<!--主题浅色-->
<color name="tests_main_theme_light">#60BDF5</color>
<!--主题亮色-->
<color name="tests_main_theme_bright">#E8F6FF</color>
<!--确认按钮背景颜色-->
<color name="tests_confirm_bg_color">#1da1f2</color>
<!--确认按钮颜色-->
<color name="tests_confirm_text_color">#ffffff</color>
<!--确认提示颜色-->
<color name="tests_confirm_text_hint_color">#60ffffff</color>
<!--筛选条件选择框字体颜色-->
<color name="tests_filter_content_text_color_en">#1da1f2</color>
<color name="tests_filter_content_text_color_un">#242424</color>
<color name="tests_main_theme_light">#56CCF2</color>
</resources>
......@@ -14,7 +14,7 @@ import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.view.View
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.router.YdlCommonRouterManager
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.common.tools.LogUtil
import com.yidianling.user.LoginUtils
import com.yidianling.user.R
......@@ -111,7 +111,7 @@ class PrivacyDialog : Dialog {
if (UserHelper.getUserInfo() != null && !TextUtils.isEmpty(UserHelper.getUserInfo()!!.uid)) {
uid = UserHelper.getUserInfo()!!.uid!!
} else {
val loginBean = YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()
val loginBean = ModularServiceManager.getPlatformUserService()?.getUser()
if (loginBean != null) {
uid = loginBean.userId
}
......
......@@ -38,8 +38,6 @@ interface IYdlCommonRouter {
fun startP2PXiaoYi(context: Context)
fun isLogin(): Boolean
fun getUid(): Int
fun getAccessToken(): String?
......
package com.ydl.webview
import android.net.Uri
import android.text.TextUtils
import com.alibaba.android.arouter.launcher.ARouter
import com.ydl.ydl_router.manager.YDLRouterManager
import com.ydl.ydl_router.manager.YDLRouterParams
import com.ydl.ydl_router.util.YDLRouterUtils
import com.yidianling.common.tools.LogUtil
import java.io.UnsupportedEncodingException
import java.net.URLDecoder
/**
* Created by haorui on 2019-10-13.
* Des:使用接口返回的 router 链接打开H5页面
*/
object H5RouterUtils {
/**
* 完整的 router 链接
*/
fun tempH5Route(linkUrl: String?) {
if (TextUtils.isEmpty(linkUrl)) {
return
}
val linkUri = Uri.parse(linkUrl)
if (linkUri != null) {
val host = linkUri.host
if (!TextUtils.isEmpty(host) && host == "h5") {
//如果是h5,跳转至NewH5Activity
try {
var params = URLDecoder.decode(linkUri.getQueryParameter("params"),"UTF-8")
ARouter.getInstance().build("/new_h5/h5").withSerializable("routerParam", params).navigation()
return
}catch (e : NullPointerException){
LogUtil.e("params参数为空")
}catch (e : UnsupportedEncodingException){
LogUtil.e("解码错误")
}catch (e : UnsupportedOperationException){
LogUtil.e("这不是一个uri格式的地址")
}
return
}
}
YDLRouterManager.router(linkUrl)
}
fun tempH5Route(linkUrl: String?, params: YDLRouterParams?, callBack: String?) {
if (TextUtils.isEmpty(linkUrl)) {
return
}
val newUrl = linkUrl + YDLRouterUtils.ergodic(params) + "&callback=" + callBack
val linkUri = Uri.parse(newUrl)
if (linkUri != null) {
val host = linkUri.host
if (!TextUtils.isEmpty(host) && host == "h5") {
//如果是h5,跳转至NewH5Activity
try {
var params = URLDecoder.decode(linkUri.getQueryParameter("params"),"UTF-8")
ARouter.getInstance().build("/new_h5/h5").withSerializable("routerParam", params).navigation()
return
}catch (e : NullPointerException){
LogUtil.e("params参数为空")
}catch (e : UnsupportedEncodingException){
LogUtil.e("解码错误")
}catch (e : UnsupportedOperationException){
LogUtil.e("这不是一个uri格式的地址")
}
return
}
}
YDLRouterManager.router(linkUrl, params)
}
}
......@@ -28,9 +28,6 @@ class WebModularServiceUtils {
fun startMain(activity: Activity){
YdlCommonRouterManager.getYdlCommonRoute().startMain(activity,false)
// ARouter.getInstance().build("/main/main")
// .withFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
// .navigation()
}
}
}
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