Commit d3175da6 authored by fengruiyu's avatar fengruiyu

自由世界

parent 61e0cac5
package com.mints.fiveworld;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
//@RunWith(AndroidJUnit4.class)
//public class ExampleInstrumentedTest {
// @Test
// public void useAppContext() {
// // Context of the app under test.
// Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
// assertEquals("com.mints.goodnews", appContext.getPackageName());
// }
//}
\ No newline at end of file
package com.mints.fiveworld
import android.content.Context
import android.os.StrictMode
import android.os.StrictMode.VmPolicy
import com.baidu.lbsapi.BMapManager
import com.baidu.mapapi.CoordType
import com.baidu.mapapi.SDKInitializer
import com.cuieney.rxpay_annotation.WX
import com.fry.base.base.BaseApp
import com.mints.fiveworld.ad.CsjGroMoreManager
import com.mints.fiveworld.main.vr.PanoramicActivity
import com.mints.fiveworld.manager.UmengManager
import com.orhanobut.logger.AndroidLogAdapter
import com.orhanobut.logger.FormatStrategy
import com.orhanobut.logger.Logger
import com.orhanobut.logger.PrettyFormatStrategy
import com.tencent.bugly.crashreport.CrashReport
import me.goldze.mvvmhabit.utils.KLog
/**
* Created by 冯瑞雨 on 2021/7/1.
*/
@WX(packageName = "com.mints.freeworld")
class AppApplication : BaseApp() {
override fun onCreate() {
super.onCreate()
mContext = this
thirdConfig()
val builder = VmPolicy.Builder()
StrictMode.setVmPolicy(builder.build())
builder.detectFileUriExposure()
// 解决java.util.concurrent.TimeoutException https://www.jianshu.com/p/844ef9c84f15
// val defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler()
// Thread.setDefaultUncaughtExceptionHandler { t, e ->
// if (t.name == "FinalizerWatchdogDaemon" && e is TimeoutException) {
// Log.e("ignore", "ignore")
// } else {
// defaultUncaughtExceptionHandler?.uncaughtException(t, e)
// }
// }
}
/*
* 三方配置
*/
private fun thirdConfig() {
// 友盟预初始化
UmengManager.preInit()
// bugly
CrashReport.initCrashReport(this, "df5783aab4", BuildConfig.DEBUG)
// GroMore
CsjGroMoreManager.init(this)
//百度地图
// 在使用 SDK 各组间之前初始化 context 信息,传入 ApplicationContext
// 默认本地个性化地图初始化方法
SDKInitializer.initialize(this)
//自4.3.0起,百度地图SDK所有接口均支持百度坐标和国测局坐标,用此方法设置您使用的坐标类型.
//包括BD09LL和GCJ02两种坐标,默认是BD09LL坐标。
SDKInitializer.setCoordType(CoordType.BD09LL)
//百度全景
initEngineManager(this)
bindLogger()
}
/**
* 初始化百度全景
*/
private fun initEngineManager(context: Context) {
if (mBMapManager == null) {
mBMapManager = BMapManager(context)
}
if (mBMapManager?.init(PanoramicActivity.MyGeneralListener())==false) {
KLog.e("BMapManager","BMapManager 初始化错误!")
}
}
/**
* 自定义logger
*/
private fun bindLogger() {
//自定义logger
val formatStrategy: FormatStrategy = PrettyFormatStrategy.newBuilder()
.showThreadInfo(false) //是否选择显示线程信息,默认为true
.methodCount(0) //方法数显示多少行,默认2行
.methodOffset(7) //隐藏方法内部调用到偏移量,默认5
// .logStrategy(customLog) //打印日志的策略,默认LogCat
.tag("mints---network") //自定义TAG全部标签,默认PRETTY_LOGGER
.build()
Logger.addLogAdapter(AndroidLogAdapter(formatStrategy))
}
companion object {
var mContext: AppApplication? = null
var mBMapManager: BMapManager? = null
fun getContext(): AppApplication? {
return mContext
}
}
}
\ No newline at end of file
package com.mints.fiveworld.ad
import android.content.Context
import com.bytedance.msdk.api.TTAdConfig
import com.bytedance.msdk.api.TTAdConstant
import com.bytedance.msdk.api.TTMediationAdSdk
import com.bytedance.msdk.api.UserInfoForSegment
import com.mints.fiveworld.BuildConfig
import com.mints.fiveworld.common.Constant
import com.mints.fiveworld.common.DeviceInfo
import java.util.*
/**
* 描述:GroMore (包含穿山甲,快手,优量汇初始化)
* 作者:孟崔广
* 时间:2021/7/12 17:51
*/
object CsjGroMoreManager {
const val TT_AD_APPID = "5198591"
private var sInit: Boolean = false
// gromore
var AD_UNIT_SPLASH_ID = "887523427" // 开屏
// 穿山甲id
var AD_CSJ_SPLASH_ID = "887523426" // 开屏
fun init(context: Context) {
if (!sInit) {
TTMediationAdSdk.initialize(context, buildConfig())
sInit = true
}
}
private fun buildConfig(): TTAdConfig {
val userInfo = UserInfoForSegment()
val customInfos: Map<String, String> = HashMap()
userInfo.customInfos = customInfos
return TTAdConfig.Builder()
.appId(TT_AD_APPID) //必填 ,不能为空
.appName(Constant.MINTS_APP_NAME) //必填,不能为空
.openAdnTest(false) //开启第三方ADN测试时需要设置为true,会每次重新拉去最新配置,release 包情况下必须关闭.默认false
.isPanglePaid(false) //是否为费用户
.setPublisherDid(DeviceInfo.instance.iMEI) //用户自定义device_id
.openDebugLog(BuildConfig.DEBUG) //测试阶段打开,可以通过日志排查问题,上线时去除该调用
.usePangleTextureView(true) //使用TextureView控件播放视频,默认为SurfaceView,当有SurfaceView冲突的场景,可以使用TextureView
.setPangleTitleBarTheme(TTAdConstant.TITLE_BAR_THEME_DARK)
.allowPangleShowNotify(true) //是否允许sdk展示通知栏提示
.allowPangleShowPageWhenScreenLock(true) //是否在锁屏场景支持展示广告落地页
.setPangleDirectDownloadNetworkType(TTAdConstant.NETWORK_STATE_WIFI, TTAdConstant.NETWORK_STATE_3G) //允许直接下载的网络状态集合
.needPangleClearTaskReset() //特殊机型过滤,部分机型出现包解析失败问题(大部分是三星)。参数取android.os.Build.MODEL
.setUserInfoForSegment(userInfo) // 设置流量分组的信息
.build()
}
}
\ No newline at end of file
package com.mints.fiveworld.adapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.fry.base.utils.DensityUtils;
import com.mints.fiveworld.adapter.listener.OnPageSelectListener;
import com.mints.fiveworld.widget.CoverFlowViewPager;
import java.util.List;
public class CoverFlowAdapter extends PagerAdapter implements ViewPager.OnPageChangeListener {
/**
* 默认缩小的padding值
*/
public static int sWidthPadding;
public static int sHeightPadding;
/**
* 子元素的集合
*/
private List<View> mViewList;
/**
* 滑动监听的回调接口
*/
private OnPageSelectListener listener;
/**
* 上下文对象
*/
private Context mContext;
public CoverFlowAdapter(List<View> mImageViewList, Context context) {
this.mViewList = mImageViewList;
mContext = context;
// 设置padding值
sWidthPadding = DensityUtils.dip2px(16);
sHeightPadding = DensityUtils.dip2px(28);
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView(mViewList.get(position));
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view = mViewList.get(position);
container.addView(view);
return view;
}
@Override
public int getCount() {
return mViewList == null ? 0 : mViewList.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
// 该方法回调ViewPager 的滑动偏移量
if (mViewList.size() > 0 && position < mViewList.size()) {
//当前手指触摸滑动的页面,从0页滑动到1页 offset越来越大,padding越来越大
int outHeightPadding = (int) (positionOffset * sHeightPadding);
int outWidthPadding = (int) (positionOffset * sWidthPadding);
// 从0滑动到一时,此时position = 0,其应该是缩小的,符合
mViewList.get(position).setPadding(outWidthPadding, outHeightPadding, outWidthPadding, outHeightPadding);
// position+1 为即将显示的页面,越来越大
if (position < mViewList.size() - 1) {
int inWidthPadding = (int) ((1 - positionOffset) * sWidthPadding);
int inHeightPadding = (int) ((1 - positionOffset) * sHeightPadding);
mViewList.get(position + 1).setPadding(inWidthPadding, inHeightPadding, inWidthPadding, inHeightPadding);
}
}
}
@Override
public void onPageSelected(int position) {
// 回调选择的接口
if (listener != null) {
listener.select(position);
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
/**
* 当将某一个作为最中央时的回调
*
* @param listener
*/
public void setOnPageSelectListener(CoverFlowViewPager listener) {
this.listener = listener;
}
}
package com.mints.fiveworld.adapter
import android.content.Context
import com.alibaba.android.vlayout.LayoutHelper
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.mints.fiveworld.R
import com.mints.fiveworld.databinding.DialogMapContentItemBinding
/**
* Created by 冯瑞雨 on 2021/8/9.
*/
class DialogMapContentAdapter(val context: Context, var list: List<String>?) :
AbstractVLayoutBaseAdapter<DialogMapContentItemBinding, List<String>>(context, list, 2) {
override fun onBindViewHolder(
holder: BindingViewHolder<DialogMapContentItemBinding>,
position: Int) {
// holder.binding.
}
override fun getItemCount() = list?.size?:0
override fun onCreateLayoutHelper(): LayoutHelper {
val helper = GridLayoutHelper(2)
helper.setAutoExpand(false)
return helper
}
override fun getLayoutId(viewType: Int) = R.layout.dialog_map_content_item
}
\ No newline at end of file
package com.mints.fiveworld.adapter
import android.content.Context
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.mints.fiveworld.R
import com.mints.fiveworld.databinding.DialogMapHearItemBinding
/**
* Created by 冯瑞雨 on 2021/8/9.
*/
class DialogMapHeadAdapter(val context: Context, var name: String?) :
AbstractVLayoutBaseAdapter<DialogMapHearItemBinding, String?>(context, name, 1) {
override fun onBindViewHolder(
holder: BindingViewHolder<DialogMapHearItemBinding>,
position: Int) {
holder.binding.title.text = name
}
override fun getItemCount() = 1
override fun onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.dialog_map_hear_item
}
\ No newline at end of file
package com.mints.fiveworld.adapter
import android.content.Context
import com.alibaba.android.vlayout.LayoutHelper
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.mints.fiveworld.R
import com.mints.fiveworld.databinding.ItemGridMapAdapterBinding
/**
* Created by 冯瑞雨 on 2021/8/9.
*/
class DialogMapTailAdapter(val context: Context) :
AbstractVLayoutBaseAdapter<ItemGridMapAdapterBinding, List<String>>(context, null, 3) {
override fun onBindViewHolder(
holder: BindingViewHolder<ItemGridMapAdapterBinding>,
position: Int
) {
}
override fun getItemCount() = 1
override fun onCreateLayoutHelper(): LayoutHelper {
return LinearLayoutHelper()
}
override fun getLayoutId(viewType: Int) = R.layout.dialog_map_tail_item
}
\ No newline at end of file
package com.mints.fiveworld.adapter
import android.content.Context
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.mints.fiveworld.R
import com.mints.fiveworld.bean.VreperienceBean
import com.mints.fiveworld.databinding.EnterDestinationAdapterBinding
/**
* Created by 冯瑞雨 on 2021/7/9.
*/
class EnterDestinationAdapter(val context: Context,val bean :List<VreperienceBean.Data>?):
AbstractVLayoutBaseAdapter<EnterDestinationAdapterBinding, List<VreperienceBean.Data>?>(context,bean,1) {
private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null
override fun onBindViewHolder(
holder: BindingViewHolder<EnterDestinationAdapterBinding>,
position: Int) {
vLayout = VirtualLayoutManager(context, VirtualLayoutManager.HORIZONTAL)
mAdapter = DelegateAdapter(vLayout,false)
holder.binding.listView.layoutManager = vLayout
holder.binding.listView.adapter = mAdapter
mAdapter?.addAdapter(ItemEnterDestinationAdapter(context,true,bean!!))
}
override fun getItemCount() = 1
override fun onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.enter_destination_adapter
}
\ No newline at end of file
package com.mints.fiveworld.adapter
import android.content.Context
import com.alibaba.android.vlayout.LayoutHelper
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.bumptech.glide.Glide
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.binding.setMargin
import com.mints.fiveworld.R
import com.mints.fiveworld.bean.Places
import com.mints.fiveworld.databinding.ItemGridBenfitAdpaterBinding
import com.mints.fiveworld.main.home.HomeViewModel
import me.goldze.mvvmhabit.utils.AppUtils
import me.goldze.mvvmhabit.utils.RxUtils
class GridBenfitAdapter(val context: Context, val viewMode: HomeViewModel?, places: List<Places>?) :
AbstractVLayoutBaseAdapter<ItemGridBenfitAdpaterBinding,
List<Places>>(context, places, 3) {
private var datalist: List<Places>? = places
private var mposition: Int = 0//设置首次进来默认选中第一个
override fun onBindViewHolder(holder: BindingViewHolder<ItemGridBenfitAdpaterBinding>, position: Int) {
//设置 view边距
if (position % 3 == 0) {
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 20F), AppUtils.dp2Px(context, 10F),
AppUtils.dp2Px(context, 10F), 0, null, null, null)
} else if (position % 3 == 1) {
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 10F), AppUtils.dp2Px(context, 10F),
AppUtils.dp2Px(context, 10F), 0, null, null, null)
} else {
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 10F), AppUtils.dp2Px(context, 10F),
AppUtils.dp2Px(context, 20F), 0, null, null, null)
}
datalist?.get(position)?.apply {
//设置图片
Glide.with(mContext).load(images?.get(0)).into(holder.binding.imageView3)
//设置标题
holder.binding.textView.text = name
//设置点击跳转
RxUtils.onMultiClick(holder.itemView) {
//页面跳转
// MintsWebViewActivity.startWebView(name, url = url)
viewMode?.authorized(name, latitude.toString(), longitude.toString(), true)
}
}
}
override fun getItemCount() = 6
override fun getLayoutId(viewType: Int) = R.layout.item_grid_benfit_adpater
fun getPosition() = mposition
override fun onCreateLayoutHelper(): LayoutHelper {
val hp: GridLayoutHelper = GridLayoutHelper(3)
hp.setAutoExpand(false)
return hp
}
}
package com.mints.fiveworld.adapter
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.google.gson.Gson
import com.mints.fiveworld.bean.AuthorizedBean
import com.mints.fiveworld.bean.BaseResponse
import com.mints.fiveworld.bean.MapBean
import com.mints.fiveworld.model.ApiModel
import com.mints.fiveworld.netwrok.base.HttpSubscribeImpl
import com.mints.fiveworld.webview.MintsWebViewActivity
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import java.io.BufferedReader
import java.io.InputStreamReader
class GridBenfitViewModel (application: Application) : BaseViewModel(application) {
val mapBean = MutableLiveData<MapBean>()
//0=境内 1=境外
val index = MutableLiveData(0)
fun getMapBean(){
val assets = AppManager.getAppManager().currentActivity.assets
val stringBuilder = StringBuilder()
try {
//通过管理器打开文件并读取
val bf = BufferedReader(
InputStreamReader(
assets.open("map.json"))
)
var line: String?
while (bf.readLine().also { line = it } != null) {
stringBuilder.append(line)
}
mapBean.value = Gson().fromJson(stringBuilder.toString(), MapBean::class.java)
} catch (e:Exception){
KLog.e("读取assets文件下的json出问题")
}
}
fun authorized(name:String?=null,lat:String?,lng:String?) {
ApiModel.authorized().safeSubscribe(object
: HttpSubscribeImpl<BaseResponse<AuthorizedBean>>(
this@GridBenfitViewModel,false
) {
override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) {
if(index.value == 0){
MintsWebViewActivity.startWebView(name,
MintsWebViewActivity.toBaduVR(lat,lng,response.result?.bk))
}else{
MintsWebViewActivity.startWebView(name,
MintsWebViewActivity.toGoogleVR(
response.result.u,
response.result.gk,
response.result.base,
lat,
lng,
response.result.ut
))
}
}
})
}
}
package com.mints.fiveworld.adapter
import android.content.Context
import com.alibaba.android.vlayout.LayoutHelper
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.bumptech.glide.Glide
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.binding.setMargin
import com.mints.fiveworld.R
import com.mints.fiveworld.bean.VrmapBean
import com.mints.fiveworld.databinding.ItemGridMapAdapterBinding
import com.mints.fiveworld.webview.MintsWebViewActivity
import me.goldze.mvvmhabit.utils.AppUtils
import me.goldze.mvvmhabit.utils.RxUtils
/**
* Created by 冯瑞雨 on 2021/7/9.
*/
class GridMapAdapter(val context: Context, var list: List<VrmapBean.Internal>?) :
AbstractVLayoutBaseAdapter<ItemGridMapAdapterBinding, List<VrmapBean.Internal>>(context, list, 2) {
override fun onBindViewHolder(
holder: BindingViewHolder<ItemGridMapAdapterBinding>,
position: Int
) {
var a = holder.binding.bg.layoutParams
if (position % 2 == 0) {
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 20F), AppUtils.dp2Px(context, 20F),
AppUtils.dp2Px(context, 15F), 0, null, null, null)
} else {
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 15F), AppUtils.dp2Px(context, 20F),
AppUtils.dp2Px(context, 20F), 0, null, null, null)
}
list?.get(position)?.apply {
//设置图片
Glide.with(mContext).load(img).into(holder.binding.image)
//设置标题
holder.binding.tvName.text = name
//设置点击跳转
RxUtils.onMultiClick(holder.itemView){
//页面跳转
MintsWebViewActivity.startWebView(name, url = url)
}
holder.binding.llstart.setNumber(stars?.toInt()?:5)
}
}
override fun getItemCount() = list!!.size
override fun onCreateLayoutHelper(): LayoutHelper {
val hp: GridLayoutHelper = GridLayoutHelper(2)
hp.setAutoExpand(false)
return hp
}
override fun getLayoutId(viewType: Int) = R.layout.item_grid_map_adapter
}
\ No newline at end of file
package com.mints.fiveworld.adapter
import android.content.Context
import android.graphics.Paint
import android.view.View
import com.alibaba.android.vlayout.LayoutHelper
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.binding.setMargin
import com.mints.fiveworld.R
import com.mints.fiveworld.bean.VipBean
import com.mints.fiveworld.databinding.ItemGridPaymentAdpaterBinding
import me.goldze.mvvmhabit.utils.AppUtils
class GridPaymentAdapter(val context: Context, val list: List<VipBean.ListBean>) :
AbstractVLayoutBaseAdapter<ItemGridPaymentAdpaterBinding,
List<VipBean.ListBean>>(context, list, 3) {
private var datalist: List<VipBean.ListBean>? = list
private var mposition: Int = 0//设置首次进来默认选中第一个
override fun onBindViewHolder(holder: BindingViewHolder<ItemGridPaymentAdpaterBinding>, position: Int) {
holder.binding.tvOldprice.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG
// var a = holder.binding.bg.layoutParams
//设置 view边距
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 10F), 0, AppUtils.dp2Px(context, 10F),
AppUtils.dp2Px(context, 10F), null, null, null)
//设置 view背景样式
if (mposition == position) {
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment_down)
} else {
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment)
}
//设置默认选中
if (holder.adapterPosition == mposition) {//如果当前的view是第一个设置默认背景,并且是第一次设置背景
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment_down)
}
//添加 套餐推荐内容
datalist?.let {
val databean = it[position]
// 设置点击事件
holder.itemView.setOnClickListener {
//设置当前段中view脚标
mposition = holder.adapterPosition
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment_down)
notifyDataSetChanged()
}
// holder.binding.tvDays.text = "${databean.days}天"
holder.binding.tvDays.text = databean.title
holder.binding.tvOldprice.text = "原价¥${databean.oldPrice}"
holder.binding.tvPrice.text = "¥${databean.price}"
holder.binding.ivHot.visibility = if (databean.activityType == 0) View.GONE else View.VISIBLE
}
}
override fun getItemCount(): Int {
return if (datalist == null) {
0
} else {
datalist!!.size
}
}
override fun getLayoutId(viewType: Int) = R.layout.item_grid_payment_adpater
fun getPosition() = mposition
override fun onCreateLayoutHelper(): LayoutHelper {
val hp: GridLayoutHelper = GridLayoutHelper(3)
hp.setAutoExpand(false)
return hp
}
}
package com.mints.fiveworld.adapter
import android.content.Context
import android.content.Intent
import com.alibaba.android.vlayout.LayoutHelper
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.binding.setMargin
import com.fry.base.utils.ImageLoader
import com.mints.fiveworld.R
import com.mints.fiveworld.bean.DetailedBean
import com.mints.fiveworld.databinding.ItemGridVrmapAdapterBinding
import com.mints.fiveworld.main.my.OpenvipActivity
import com.mints.fiveworld.main.vr.DetailedViewModel
import me.goldze.mvvmhabit.utils.AppUtils
import me.goldze.mvvmhabit.utils.RxUtils
class GridVrMapAdapter(val context: Context, var list: List<DetailedBean.DetailedItemBean>?, val viewModel: DetailedViewModel) :
AbstractVLayoutBaseAdapter<ItemGridVrmapAdapterBinding, List<DetailedBean.DetailedItemBean>>(context, list, 2) {
private val userManager by lazy { com.mints.fiveworld.manager.UserManager.INSTANCE }
override fun onBindViewHolder(
holder: BindingViewHolder<ItemGridVrmapAdapterBinding>,
position: Int
) {
var a = context.resources.displayMetrics;
val bgLayoutParams = holder.binding.bg.layoutParams
bgLayoutParams.height = (a.widthPixels * 0.5).toInt()
if (position % 2 == 0) {
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 10F), AppUtils.dp2Px(context, 10F),
AppUtils.dp2Px(context, 6F), 0, null, null, null)
} else {
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 6F), AppUtils.dp2Px(context, 10F), AppUtils.dp2Px(context, 10F),
0, null, null, null)
}
list?.let { it ->
holder.binding.tvName.text = it[position].name
ImageLoader.ImageBuilder.with(context)
.setUrl(it[position].img).setTargetView(holder.binding.image).start()
}
RxUtils.onMultiClick(holder.binding.bg) {
if (userManager.getVipFlag()) {//是会员
viewModel.authorized(list?.get(position)?.name, list?.get(position)?.lat, list?.get(position)?.lng)
}else{
context.startActivity(Intent(context, OpenvipActivity::class.java))
}
}
}
override fun getItemCount() = list?.size ?: 0
override fun onCreateLayoutHelper(): LayoutHelper {
val hp: GridLayoutHelper = GridLayoutHelper(2)
hp.setAutoExpand(false)
return hp
}
override fun getLayoutId(viewType: Int) = R.layout.item_grid_vrmap_adapter
}
\ No newline at end of file
package com.mints.fiveworld.adapter
import android.content.Intent
import android.text.TextUtils
import android.view.View
import androidx.databinding.ViewDataBinding
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.recycler_view.VHMAdapter
import com.fry.base.recycler_view.VHModel
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.mints.fiveworld.BR
import com.mints.fiveworld.R
import com.mints.fiveworld.bean.HistoryBean
import com.mints.fiveworld.databinding.ItemHistoryRecordAdapterBinding
import com.mints.fiveworld.main.home.SearchMapActivity
import com.mints.fiveworld.main.home.SearchMapViewModel
import me.goldze.mvvmhabit.binding.command.BindingAction
import me.goldze.mvvmhabit.binding.command.BindingCommand
import me.goldze.mvvmhabit.utils.RxUtils
import me.goldze.mvvmhabit.utils.SPUtils
import java.lang.reflect.Type
/**
* Created by 冯瑞雨 on 2021/7/14.
* 历史记录的adapter
*/
class HistoryRecordAdapter(val activity: SearchMapActivity,val viewModel: SearchMapViewModel
, var type: Int=0,var name: String? = null) :
AbstractVLayoutBaseAdapter<ItemHistoryRecordAdapterBinding, String>(activity, name, 1) {
var listName: MutableList<HistoryBean>?=null
var binding:ItemHistoryRecordAdapterBinding?= null
override fun onBindViewHolder(
holder: BindingViewHolder<ItemHistoryRecordAdapterBinding>,
position: Int
) {
binding = holder.binding
listName = getHistoryData()
if (listName!=null && listName!!.size>0){
binding?.historyBg?.visibility = View.VISIBLE
}else{
binding?.historyBg?.visibility = View.GONE
}
val adapter = VHMAdapter<HistoryRecordItemVHM>()
listName?.let {
for (index in it.size - 1 downTo 0) {
adapter.add(HistoryRecordItemVHM(activity,viewModel,it[index]))
}
}
holder.binding.listView.adapter = adapter
//清空
RxUtils.onMultiClick(binding?.tvClear){
listName?.clear()
SPUtils.getInstance(SearchMapActivity.HISTORY_NAME)
.removeKey(if (type==0){"Territory"}else{"Abroad"})
binding?.historyBg?.visibility = View.GONE
notifyDataSetChanged()
}
}
private fun getHistoryData(): MutableList<HistoryBean>? {
val instance = SPUtils.getInstance( SearchMapActivity.HISTORY_NAME)
val string = instance.decodeString(if (type==0){"Territory"}else{"Abroad"})
if (TextUtils.isEmpty(string)) {
return null
}
return try {
val listType: Type = object : TypeToken<List<HistoryBean?>?>() {}.type
Gson().fromJson(string, listType)
}catch (e:Exception){
null
}
}
fun addHistoryData(addName: HistoryBean) {
if (listName == null) {
listName = ArrayList<HistoryBean>()
}
if (listName?.size ?: 0 >= 15) {
val size = listName!!.size - 15
for (index in 0..size) {
listName?.removeAt(index)
}
}
for (index in listName!!.indices) {
if (listName!![index].name == addName.name) {
listName?.removeAt(index)
break
}
}
if (listName!=null && listName!!.size>0 && binding?.historyBg?.visibility == View.GONE){
binding?.historyBg?.visibility = View.VISIBLE
}
listName?.add(addName)
val instance = SPUtils.getInstance(SearchMapActivity.HISTORY_NAME)
instance?.encode(if (type==0){"Territory"}else{"Abroad"}, Gson().toJson(listName).toString())
}
override fun getItemCount() = 1
override fun onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.item_history_record_adapter
}
class HistoryRecordItemVHM(val activity: SearchMapActivity,val viewModel: SearchMapViewModel,
var historyBean: HistoryBean
) : VHModel() {
override fun getLayoutId() = R.layout.item_history_record_name
override fun getVariableId() = BR.vhm
override fun onBind(binding: ViewDataBinding) {
super.onBind(binding)
}
val onClick = BindingCommand<Any>(BindingAction {
viewModel.searchName.value = HistoryBean(name = historyBean.name,
latitude = historyBean.latitude,longitude = historyBean.longitude)
val intent = Intent()
intent.putExtra("latitude",historyBean.latitude)
intent.putExtra("longitude",historyBean.longitude)
intent.putExtra("inner",viewModel.index.value)
viewModel.finishData(SearchMapActivity.REQUEST_CODE,intent)
})
}
\ No newline at end of file
package com.mints.fiveworld.adapter
import android.content.Context
import android.content.Intent
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.utils.ImageLoader
import com.mints.fiveworld.R
import com.mints.fiveworld.bean.VreperienceBean
import com.mints.fiveworld.databinding.ItemEnterDestinationAdapterBinding
import com.mints.fiveworld.main.vr.DetailedActivity
import me.goldze.mvvmhabit.utils.RxUtils
/**
* Created by 冯瑞雨 on 2021/7/9.
* @param isMultipleLayout 是否是多布局
*/
class ItemEnterDestinationAdapter(
val context: Context,
private val isMultipleLayout: Boolean,
var list: List<VreperienceBean.Data>?
) : AbstractVLayoutBaseAdapter<ItemEnterDestinationAdapterBinding, List<VreperienceBean.Data>?>(
context,
list,
1
) {
override fun onBindViewHolder(
holder: BindingViewHolder<ItemEnterDestinationAdapterBinding>,
position: Int
) {
var a = context.resources.displayMetrics;
val bgLayoutParams = holder.binding.bg.layoutParams
if (isMultipleLayout) {
bgLayoutParams.width = (a.widthPixels * 0.9).toInt()
} else {
bgLayoutParams.width = a.widthPixels
}
RxUtils.onMultiClick(holder.itemView
){
var intent = Intent(context, DetailedActivity::class.java)
intent.putExtra("area",list?.get(position)?.area)
context.startActivity(intent)
}
list?.let { it ->
holder.binding.tvName.text = it[position].area
holder.binding.tvNumberPeople.text = "${it[position].activeNum}W人去过"
it[position].url?.let { url ->
val size = it[position].url?.size?:0
for (index in 0 until size) {
when (index) {
0 -> {
ImageLoader.ImageBuilder.with(context)
.setUrl(url[index]).setTargetView(holder.binding.image3).start()
}
1 -> {
ImageLoader.ImageBuilder.with(context)
.setUrl(url[index]).setTargetView(holder.binding.image2).start()
}
2 -> {
ImageLoader.ImageBuilder.with(context)
.setUrl(url[index]).setTargetView(holder.binding.image1).start()
}
}
}
}
}
}
override fun getItemCount() = list?.size ?: 0
override fun onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.item_enter_destination_adapter
}
package com.mints.fiveworld.adapter
import android.content.Context
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.baidu.mapapi.model.LatLng
import com.baidu.mapapi.utils.DistanceUtil.getDistance
import com.blankj.utilcode.util.ActivityUtils.startActivity
import com.bumptech.glide.Glide
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.mints.fiveworld.R
import com.mints.fiveworld.bean.HotViewBean
import com.mints.fiveworld.databinding.ItemHotViewAdapterBinding
import com.mints.fiveworld.main.home.HomeViewModel
import com.mints.fiveworld.main.my.OpenvipActivity
import com.mints.fiveworld.manager.UserManager
import com.mints.fiveworld.widget.dialog.HotViewDialog
import me.goldze.mvvmhabit.utils.RxUtils
import java.text.DecimalFormat
class ItemHotViewAdapter(val context: Context, val dialog: BottomSheetDialog?, var list: List<HotViewBean.Dataslist>?,
val viewModel: HomeViewModel, val mCurrentLat: Double,
val mCurrentLon: Double, val onHotItemClick: HotViewDialog.OnHotItemClick?=null) :
AbstractVLayoutBaseAdapter<ItemHotViewAdapterBinding, List<HotViewBean.Dataslist>?>(
context, list, 1
) {
override fun onBindViewHolder(holder: BindingViewHolder<ItemHotViewAdapterBinding>, position: Int) {
var a = context.resources.displayMetrics;
val bgLayoutParams = holder.binding.bg.layoutParams
bgLayoutParams.width = a.widthPixels
list?.get(position)?.apply {
//设置图片
Glide.with(mContext).load(img).into(holder.binding.image1)
//设置名称
holder.binding.viewname.text = name
//设置距离
var distance:Double=getDistance(LatLng(lat!!.toDouble(), lng!!.toDouble()),LatLng(mCurrentLat, mCurrentLon))
holder.binding.tvDistance.text = "距离${DecimalFormat("0.00").format(distance/1000).toString()}km"
//设置景点简介
holder.binding.tvDescribe.text = desc
//设置点击事件
RxUtils.onMultiClick(holder.itemView) {
//判断是否当前是否是会员,
if (!UserManager.INSTANCE.userIsLogin()) {
//否-跳转到开通vip界面
startActivity(OpenvipActivity::class.java)
} else {
dialog?.dismiss()
onHotItemClick?.onItemClick(position, list?.get(position))
}
}
}
}
override fun getItemCount() = list?.size ?: 0
override fun onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.item_hot_view_adapter
}
\ No newline at end of file
package com.mints.fiveworld.adapter
import android.content.Context
import android.content.Intent
import android.view.View
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.utils.ImageLoader
import com.mints.fiveworld.R
import com.mints.fiveworld.bean.Places
import com.mints.fiveworld.databinding.ItemPopularSceneAdapterBinding
import com.mints.fiveworld.main.home.SearchMapViewModel
import com.mints.fiveworld.main.my.OpenvipActivity
import com.mints.fiveworld.manager.UserManager
import me.goldze.mvvmhabit.utils.RxUtils
/**
* Created by 冯瑞雨 on 2021/7/14.
* 热门景区的adapter
*/
class PopularSceneAdapter(val context: Context, var list: List<Places>? = null,val viewMode: SearchMapViewModel) :
AbstractVLayoutBaseAdapter<ItemPopularSceneAdapterBinding, List<Places>>(context, list, 2) {
fun setData(list: List<Places>?){
this.list = list
notifyDataSetChanged()
}
override fun onBindViewHolder(
holder: BindingViewHolder<ItemPopularSceneAdapterBinding>,
position: Int
) {
RxUtils.onMultiClick(holder.binding.bg){
if (viewMode.index.value==0){
viewMode.authorized(list?.get(position)?.name
,list?.get(position)?.latitude.toString()
,list?.get(position)?.longitude.toString(),true)
}else{
if (UserManager.INSTANCE.userIsLogin()) {//是会员
viewMode.authorized(list?.get(position)?.name
,list?.get(position)?.latitude.toString()
,list?.get(position)?.longitude.toString(),false)
}else{
context.startActivity(Intent(context, OpenvipActivity::class.java))
}
}
}
holder.binding.tvName.text = list?.get(position)?.name
when(position){
0->{
holder.binding.sortIm.visibility = View.VISIBLE
holder.binding.sortTvName.text = ""
ImageLoader.ImageBuilder.with(context)
.setTargetView(holder.binding.sortIm)
.setDrawable(R.mipmap.sort_icon_1).start()
}
1->{
holder.binding.sortIm.visibility = View.VISIBLE
holder.binding.sortTvName.text = ""
ImageLoader.ImageBuilder.with(context)
.setTargetView(holder.binding.sortIm)
.setDrawable(R.mipmap.sort_icon_2).start()
}
2->{
holder.binding.sortIm.visibility = View.VISIBLE
holder.binding.sortTvName.text = ""
ImageLoader.ImageBuilder.with(context)
.setTargetView(holder.binding.sortIm)
.setDrawable(R.mipmap.sort_icon_3).start()
}
else->{
holder.binding.sortIm.visibility = View.GONE
holder.binding.sortTvName.text = "No.${position+1}"
}
}
if(list?.get(position)?.images!=null){
for ( index in list?.get(position)?.images!!.indices){
if (list?.get(position)?.images?.get(index)==null)return
when (index) {
0 -> {
ImageLoader.ImageBuilder.with(context)
.setUrl(list?.get(position)?.images?.get(index))
.setTargetView(holder.binding.image1)
.setCornerDp(4).start()
}
1 -> {
ImageLoader.ImageBuilder.with(context)
.setUrl(list?.get(position)?.images?.get(index))
.setTargetView(holder.binding.image2)
.setCornerDp(4).start()
}
else -> {
ImageLoader.ImageBuilder.with(context)
.setUrl(list?.get(position)?.images?.get(index))
.setTargetView(holder.binding.image3)
.setCornerDp(4).start()
}
}
}
}
}
override fun getItemCount() = if (list != null) {
list!!.size
} else {
0
}
override fun onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.item_popular_scene_adapter
}
package com.mints.fiveworld.adapter.listener;
public interface OnPageSelectListener {
void select(int position);
}
package com.mints.fiveworld.api
import com.mints.fiveworld.bean.BaseResponse
import com.mints.fiveworld.bean.PositionBean
import com.mints.fiveworld.netwrok.baidu.BaiduHttpManager
import io.reactivex.Observable
import retrofit2.Response
import retrofit2.http.*
interface BaiduApi {
companion object {
var BAIDU_IP = "http://api.map.baidu.com/"
fun newInstance(): BaiduApi {
return BaiduHttpManager.getInstance().defaultClient.create(BaiduApi::class.java)
}
}
/**
* 国内
*
* @return
*/
@GET("place/v2/suggestion")
fun suggestionPlace(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>>
/**
* 国外
* vo["region"] = "全球"
vo["output"] = "json"
vo["ak"] = "tnFhCM9cTeTDZqNjRPVHbfzOz6AUPoEq"@return
*/
@GET("place_abroad/v1/suggestion")
// fun suggestionPlaceAbroad(@Query vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>>
fun suggestionPlaceAbroad(@Query("query") vo: String,@Query("region") vo2: String,
@Query("output") vo3: String,@Query("ak") vo4: String):
Observable<Response<BaseResponse<PositionBean>>>
@GET("place/v2/suggestion")
fun suggestionPlaceDomestic(@Query("query") vo: String,@Query("region") vo2: String,
@Query("output") vo3: String,@Query("ak") vo4: String):
Observable<Response<BaseResponse<PositionBean>>>
}
\ No newline at end of file
package com.mints.fiveworld.api
import com.mints.fiveworld.bean.*
import com.mints.fiveworld.netwrok.common.HttpManager
import io.reactivex.Observable
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.POST
/**
* Created by 冯瑞雨 on 2021/7/2.
*/
interface MainApi {
companion object {
fun newInstance(): MainApi {
return HttpManager.getInstance().defaultClient.create(MainApi::class.java)
}
}
/**
* 打开激活
*
* @return
*/
@POST("na/saveTerminalInfo")
fun comSaveTerminalInfo(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>>
/**
* 获取验证码
*
* @return
*/
@POST("api/sendMobileCode")
fun sendMobileCode(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>>
/**
* 登录
*/
@POST("api/mobilelogin")
fun mobileLogin(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<UserBean>>>
/**
* 提交设备信息
*
* @return
*/
@POST("api/saveTerminalInfo")
fun saveTerminalInfo(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>>
/**
* 开通vip
*/
@POST("common/getVipProductsByType")
fun getVipProductsByType(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<VipBean>>>
/**
* 获取vip支付渠道
*/
@POST("common/getPayChannels")
fun getPayChannels(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<PaymentBean>>>
/**
* 获取支付参数
*/
@POST("api/getVipPayParams")
fun getVipPayParams(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<WxPayParamBean>>>
/**
* 支付成功
*/
@POST("api/queryVipOrder")
fun queryVipOrder(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<Any>>>
/**
* 获取用户登录信息
*/
@POST("api/baseMsg")
fun baseMsg():Observable<Response<BaseResponse<UserBean>>>
/**
* 获取VR街景数据
*/
@POST("na/vrPlaces")
fun vrPlaces():Observable<Response<BaseResponse<VrmapBean>>>
/**
* 绑定手机号接口
*/
@POST("api/bindingMobile")
fun bindingMobile(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<UserBean>>>
/**
* 获取绑定手机号验证码接口
*/
@POST("api/sendMobileBindingCode")
fun sendMobileBindingCode(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<Any>>>
/**
* 微信登录
*/
@POST("api/wechatlogin")
fun wechatlogin(@Body vo:@JvmSuppressWildcards Map<String,Any>): Observable<Response<BaseResponse<UserBean>>>
/**
* 更新版本
*
* @return
*/
@POST("common/checkUpgrade.do")
fun checkUpgrade(@Body vo: @JvmSuppressWildcards Map<String
, Any>):Observable<Response<BaseResponse<Version>>>
/**
* 授权
*
* @return
*/
@POST("api/mpgah")
fun authorized():Observable<Response<BaseResponse<AuthorizedBean>>>
/**
* 授权
* 国内免费用户查看
* @return
*/
@POST("na/mpgah")
fun authorizedA():Observable<Response<BaseResponse<AuthorizedBean>>>
/**
* 精选体验展示图
*/
@POST("na/getChooseExperienceHeadData")
fun getChooseExperienceHeadData(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<VreperienceBean>>>
/**
* 精选体验详情
*/
@POST("na/getChooseExperienceData")
fun getChooseExperienceData(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<DetailedBean>>>
/**
* 热门景点
*/
@POST("na/getAttractionsList")
fun getHotView(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<HotViewBean>>>
/**
* 景点推荐
*/
@POST("na/getAttractionsList")
fun getViewRecommed(@Body vo:@JvmSuppressWildcards Map<String,Any>):Observable<Response<BaseResponse<ViewRecommed>>>
}
\ No newline at end of file
package com.mints.fiveworld.bean
import android.annotation.SuppressLint
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
/**
* 最外层请求数据
*
* {
* "data":"SEebPNaIQqWTBAap3xfl21GzkIIVn/7W9S0Fwws6Mhl4mPb8ZjN+xEvQr5cy90px+ lUMt",
* "key":"ckPc1k8d07O5UbV5csWOT1jUsO7rXHvEgAoAVKZYP/8Kabh7HIdHL1wdZ0JHDc OKeNzoDMNo5LunUIW0hc1rLPSWtJblZSuzzN2+/2VJnj1=="
* }
*/
@SuppressLint("ParcelCreator")
@Parcelize
data class AppRequest(
var channel: String? = "",
var sign: String? = "",
// 新增1.1.9
var check: String? = "",
var data: String? = ""
) : Parcelable
package com.mints.fiveworld.bean
/**
* Created by 冯瑞雨 on 2021/7/29.
*/
class AuthorizedBean {
var u :String?=null
var gk :String?=null
var bk :String?=null
var ut :String?=null
var appInKey :String?=null
var appOutKey :String?=null
var base :String?=null
}
\ No newline at end of file
package com.mints.fiveworld.bean;
import java.util.List;
/**
* Created by goldze on 2017/5/10.
* 该类仅供参考,实际业务返回的固定字段, 根据需求来定义,
*/
public class BaseArrayResponse<T> extends BaseResponse<List<T>>{
@Override
public List<T> getResult() {
return result;
}
@Override
public void setResult(List<T> result) {
this.result = result;
}
}
package com.mints.fiveworld.bean;
import androidx.annotation.Nullable;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
/**
* Created by goldze on 2017/5/10.
* 该类仅供参考,实际业务返回的固定字段, 根据需求来定义,
*/
public class BaseResponse<T> implements Serializable {
private int status;
private String message="";
// @JsonAdapter(value = JsonAdapterGsonDeserializer.class)
@SerializedName("data")
protected @Nullable T result;
@SerializedName("result")
private @Nullable List<T> resultList;
public BaseResponse() {
}
public BaseResponse(int status, String message, T result) {
this.status = status;
this.message = message;
this.result = result;
}
public BaseResponse(int status) {
this.status = status;
}
public int getstatus() {
return status;
}
public void setstatus(int status) {
this.status = status;
}
public T getResult() {
return result;
}
public void setResult(T result) {
this.result = result;
}
public boolean isOk() {
return status == 200 || status == 0;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public void setResultList(@Nullable List<T> resultList) {
this.resultList = resultList;
}
@Nullable
public List<T> getResultList() {
return resultList;
}
@Override
public String toString() {
return "BaseResponse{" +
"status=" + status +
", message='" + message + '\'' +
", result=" + result +
'}';
}
}
package com.mints.fiveworld.bean
import java.io.Serializable
class DetailedBean : Serializable {
val desc: String?=null
val list: List<DetailedItemBean>?=null
inner class DetailedItemBean: Serializable {
val img: String?=null
val lat: Double=0.0
val lng: Double=0.0
val name: String?=null
}
}
package com.mints.fiveworld.bean;
import androidx.annotation.Nullable;
/**
* Created by 冯瑞雨 on 2021/7/30.
* 坐标对象,由经纬度构成
* Created by xfkang on 2018/3/28.
*/
public class GPS {
private @Nullable double lat;
private @Nullable double lng;
private @Nullable int inner=0;
public GPS() {
}
public GPS(double lat, double lng,int inner) {
this.lat = lat;
this.lng = lng;
this.inner = inner;
}
public GPS(double lat, double lng) {
this.lat = lat;
this.lng = lng;
}
public double getLat() {
return lat;
}
@Nullable
public void setLat(double lat) {
this.lat = lat;
}
public double getLng() {
return lng;
}
@Nullable
public void setLng(double lng) {
this.lng = lng;
}
public String toString() {
return "lat:" + lat + "," + "lng:" + lng+"," + "inner:" + inner;
}
}
\ No newline at end of file
package com.mints.fiveworld.bean
/**
* Created by 冯瑞雨 on 2021/7/21.
*/
class HistoryBean (
var name:String?=null,
var latitude:Double?=null,
var longitude:Double?=null
)
\ No newline at end of file
package com.mints.fiveworld.bean
import java.io.Serializable
class HotViewBean : Serializable {
public val list: List<Dataslist>? = null
inner class Dataslist : Serializable {
val desc: String? = null
val img: String? = null
val lat: String? = null
val lng: String? = null
val name: String? = null
val distance: Double? = null
}
}
package com.mints.fiveworld.bean
/**
* Created by 冯瑞雨 on 2021/7/17.
*/
class MapBean(){
//首页搜索-境内
var innerPlaces:Attractions?=null
//首页展示
var homePlaces:Attractions?=null
//首页搜索-境外
var outerPlaces:Attractions?=null
}
/**
* 景点
*/
class Attractions(){
var places:List<Places>?=null
var remark:String? = null
}
/**
* 景点的名称和图片
*/
class Places(){
var images :List<String>?=null
var name :String?=null
var latitude:Double?=0.0
var longitude:Double?=0.0
}
\ No newline at end of file
package com.mints.fiveworld.bean
/**
* Created by 冯瑞雨 on 2021/7/30.
*/
class MutualBean {
var title:String?=null
var d:String?=null
var lat:String?=null
var lng:String?=null
var inner:Int=0
}
\ No newline at end of file
package com.mints.fiveworld.bean
import java.io.Serializable
class PaymentBean:Serializable {
var list: List<String>?=null
}
\ No newline at end of file
package com.mints.fiveworld.bean
/**
* Created by 冯瑞雨 on 2021/7/15.
*/
data class PositionBean(
val address: String,
val business: String,
val city: String,
val cityid: String,
val district: String,
val location: Location,
val name: String,
val tag: String,
val uid: String
/**
* public String key;
public String city;
public String district;
public LatLng pt;
public String uid;
public String tag;
public String address;
*/
)
data class Location(
val lat: Double,
val lng: Double
)
\ No newline at end of file
package com.mints.fiveworld.bean
/**
* Created by 冯瑞雨 on 2021/7/15.
*/
class PositioningBean {
//纬度
var latitude:Double?=0.0
//经度
var longitude:Double?=0.0
// 国家码
var countryCode:String?=null
//国家名称
var country:String?=null
//获取省份
var province:String?=null
//获取城市
var city :String?=null
//获取区
var district :String?=null
//获取镇信息
var town :String?=null
//获取街道信息
var street :String?=null
// 地址信息
var addrStr :String?=null
}
\ No newline at end of file
package com.mints.fiveworld.bean
import java.io.Serializable
/**
* 描述:用户信息
* 作者:孟崔广
* 时间:2021/7/29 18:42
*/
class UserBean : Serializable {
val token: String = ""
val consumer: ConsumerBean? = null
inner class ConsumerBean : Serializable {
val openid: String = ""
val head: String = ""
val nickname: String = ""
val mobile: String = ""
val idcode: String = ""
val isForever: Boolean = false
val expireTime : Long = 0
val pk_id : Long = 0
}
}
package com.mints.fiveworld.bean;
import java.io.Serializable;
import java.util.LinkedList;
/**
* 描述:版本信息
* 作者:孟崔广
* 时间:2019/10/29 18:42
* 邮箱:mengcga@163.com
*/
public class Version implements Serializable {
private static final long serialVersionUID = -7241422035310338721L;
/**
* upgrades : [{"updateid":"583ab0df6b4744ae986afcff0d1e45a4","version":"1.0.1","updatemsg":"cj","script":null,"forceflag":1,"updatenum":1,"createtime":1483169915000,"updatetime":1483169918000}]
* forceUpgrade : true
*/
private boolean forceUpgrade;
private LinkedList<UpgradesBean> upgrades;
public boolean isForceUpgrade() {
return forceUpgrade;
}
public void setForceUpgrade(boolean forceUpgrade) {
this.forceUpgrade = forceUpgrade;
}
public LinkedList<UpgradesBean> getUpgrades() {
return upgrades;
}
public void setUpgrades(LinkedList<UpgradesBean> upgrades) {
this.upgrades = upgrades;
}
public class UpgradesBean implements Serializable {
/**
* updateid : 583ab0df6b4744ae986afcff0d1e45a4
* version : 1.0.1
* updatemsg : cj
* script : null
* forceflag : 1
* updatenum : 1
* createtime : 1483169915000
* updatetime : 1483169918000
*/
private String updateid;
private String version;
private String updatemsg;
private String url;
private int forceflag;
private int updatenum;
public String getUpdateid() {
return updateid;
}
public void setUpdateid(String updateid) {
this.updateid = updateid;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getUpdatemsg() {
return updatemsg;
}
public void setUpdatemsg(String updatemsg) {
this.updatemsg = updatemsg;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public int getForceflag() {
return forceflag;
}
public void setForceflag(int forceflag) {
this.forceflag = forceflag;
}
public int getUpdatenum() {
return updatenum;
}
public void setUpdatenum(int updatenum) {
this.updatenum = updatenum;
}
}
}
package com.mints.fiveworld.bean
import java.io.Serializable
class ViewRecommed : Serializable {
val list: List<dataslist>? = null
inner class dataslist : Serializable {
val desc: String? = null
val img: String? = null
val lat: String? = null
val lng: String? = null
val name: String? = null
}
}
package com.mints.fiveworld.bean
import java.io.Serializable
class VipBean : Serializable {
var list: List<ListBean>? = null
inner class ListBean : Serializable{
var id: Int = 0 // 1
var price: Double = 0.0// 78
var days: Int = 0 // 365
var remarks: String = "" // 看更多地图
var title: String = ""// 包年会员
var activityType: Int = 0 // 0
var oldPrice: Double = 0.0 // 138
var pid: String = ""// 1
}
}
package com.mints.fiveworld.bean
import java.io.Serializable
class VreperienceBean: Serializable {
val data: List<Data>?=null
inner class Data(
val activeNum: Double,
val area: String,
val url: List<String>?=null
)
}
package com.mints.fiveworld.bean
import java.io.Serializable
class VrmapBean : Serializable {
val abroad: List<Abroad>? = null//国外
val internal: List<Internal>? = null//国内
inner class Internal : Serializable {
val img: String? = null
val name: String? = null
val stars: String? = null
val url: String? = null
}
inner class Abroad : Serializable {
val group: Group? = null
val img: List<String>? = null
val name: String? = null
}
inner class Group : Serializable {
val brief: String? = null
val list: List<list>? = null
}
inner class list : Serializable {
val img: String? = null
val name: String? = null
}
}
\ No newline at end of file
package com.mints.fiveworld.bean;
import java.io.Serializable;
/**
* 第三方登录 微信
*/
public class WXInfo implements Serializable {
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column e_wxinfo.wid
*
* @mbggenerated
*/
private String wid;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column e_wxinfo.uid
*
* @mbggenerated
*/
private String uid;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column e_wxinfo.unionid
*
* @mbggenerated
*/
private String unionid;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column e_wxinfo.openid
*
* @mbggenerated
*/
private String openid;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column e_wxinfo.nickname
*
* @mbggenerated
*/
private String nickname;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column e_wxinfo.headimgurl
*
* @mbggenerated
*/
private String headimgurl;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column e_wxinfo.sex
*
* @mbggenerated
*/
private int sex;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column e_wxinfo.country
*
* @mbggenerated
*/
private String country;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column e_wxinfo.province
*
* @mbggenerated
*/
private String province;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database column e_wxinfo.city
*
* @mbggenerated
*/
private String city;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column e_wxinfo.wid
*
* @return the value of e_wxinfo.wid
* @mbggenerated
*/
public String getWid() {
return wid;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column e_wxinfo.wid
*
* @param wid the value for e_wxinfo.wid
* @mbggenerated
*/
public void setWid(String wid) {
this.wid = wid == null ? null : wid.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column e_wxinfo.uid
*
* @return the value of e_wxinfo.uid
* @mbggenerated
*/
public String getUid() {
return uid;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column e_wxinfo.uid
*
* @param uid the value for e_wxinfo.uid
* @mbggenerated
*/
public void setUid(String uid) {
this.uid = uid == null ? null : uid.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column e_wxinfo.unionid
*
* @return the value of e_wxinfo.unionid
* @mbggenerated
*/
public String getUnionid() {
return unionid;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column e_wxinfo.unionid
*
* @param unionid the value for e_wxinfo.unionid
* @mbggenerated
*/
public void setUnionid(String unionid) {
this.unionid = unionid == null ? null : unionid.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column e_wxinfo.openid
*
* @return the value of e_wxinfo.openid
* @mbggenerated
*/
public String getOpenid() {
return openid;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column e_wxinfo.openid
*
* @param openid the value for e_wxinfo.openid
* @mbggenerated
*/
public void setOpenid(String openid) {
this.openid = openid == null ? null : openid.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column e_wxinfo.nickname
*
* @return the value of e_wxinfo.nickname
* @mbggenerated
*/
public String getNickname() {
return nickname;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column e_wxinfo.nickname
*
* @param nickname the value for e_wxinfo.nickname
* @mbggenerated
*/
public void setNickname(String nickname) {
this.nickname = nickname == null ? null : nickname.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column e_wxinfo.headimgurl
*
* @return the value of e_wxinfo.headimgurl
* @mbggenerated
*/
public String getHeadimgurl() {
return headimgurl;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column e_wxinfo.headimgurl
*
* @param headimgurl the value for e_wxinfo.headimgurl
* @mbggenerated
*/
public void setHeadimgurl(String headimgurl) {
this.headimgurl = headimgurl == null ? null : headimgurl.trim();
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column e_wxinfo.country
*
* @return the value of e_wxinfo.country
* @mbggenerated
*/
public String getCountry() {
return country;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column e_wxinfo.country
*
* @param country the value for e_wxinfo.country
* @mbggenerated
*/
public void setCountry(String country) {
this.country = country == null ? null : country.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column e_wxinfo.province
*
* @return the value of e_wxinfo.province
* @mbggenerated
*/
public String getProvince() {
return province;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column e_wxinfo.province
*
* @param province the value for e_wxinfo.province
* @mbggenerated
*/
public void setProvince(String province) {
this.province = province == null ? null : province.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column e_wxinfo.city
*
* @return the value of e_wxinfo.city
* @mbggenerated
*/
public String getCity() {
return city;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column e_wxinfo.city
*
* @param city the value for e_wxinfo.city
* @mbggenerated
*/
public void setCity(String city) {
this.city = city == null ? null : city.trim();
}
}
\ No newline at end of file
package com.mints.fiveworld.bean;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
public class WxPayParamBean implements Serializable {
/**
* params : {"package":"Sign=WXPay","appid":"wx8f26539eabfb04f2","sign":"5012752C519C5EF177181F64514AF66C","partnerid":"1546641181","prepayid":"wx13145659084039f3fb9f073b1270898700","noncestr":"RAJD28WMYMT61N17FYOYGT73PNFC","timestamp":"1592031419"}
* tid : 2016514565805500001
*/
private ParamsBean appPayParams;
private long tid;
public ParamsBean getParams() {
return appPayParams;
}
public void setParams(ParamsBean params) {
this.appPayParams = params;
}
public long getTid() {
return tid;
}
public void setTid(long tid) {
this.tid = tid;
}
public class ParamsBean implements Serializable {
/**
* package : Sign=WXPay
* appid : wx8f26539eabfb04f2
* sign : 5012752C519C5EF177181F64514AF66C
* partnerid : 1546641181
* prepayid : wx13145659084039f3fb9f073b1270898700
* noncestr : RAJD28WMYMT61N17FYOYGT73PNFC
* timestamp : 1592031419
*/
@SerializedName("package")
private String packageX;
private String appid;
private String sign;
private String partnerid;
private String prepayid;
private String noncestr;
private String timestamp;
private String params;
public String getPackageX() {
return packageX;
}
public void setPackageX(String packageX) {
this.packageX = packageX;
}
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getPartnerid() {
return partnerid;
}
public void setPartnerid(String partnerid) {
this.partnerid = partnerid;
}
public String getPrepayid() {
return prepayid;
}
public void setPrepayid(String prepayid) {
this.prepayid = prepayid;
}
public String getNoncestr() {
return noncestr;
}
public void setNoncestr(String noncestr) {
this.noncestr = noncestr;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
}
}
package com.mints.fiveworld.common
import com.mints.fiveworld.BuildConfig
object Constant {
/**
* app名称
*/
const val MINTS_APP_NAME = "自由世界"
/**
* 应用包名
*/
const val MINTS_PKG_NAME = "com.mints.freeworld"
/**
* 第一次打开权限页面
*/
const val FIRST_OPEN_PERMISSIONS = "first_open_permissions"
// 协议地址
var REGISTER_URL = BuildConfig.MainIp + "map/register.html"//服务协议
var PRIVACY_URL = BuildConfig.MainIp + "map/privacy.html"//隐私协议
/**
* 第一次授权
*/
const val LOAN_PERMISSION_FLAG = "loan_permission_flag"
}
This diff is collapsed.
package com.mints.fiveworld.db
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import me.goldze.mvvmhabit.utils.Utils
/**
* Created by 冯瑞雨 on 2021/7/20.
*/
@Database(entities = [ScenicSpotBean::class], version = 1)
abstract class AppDatabase : RoomDatabase() {
abstract fun scenicSpotDao(): ScenicSpotDao
companion object {
private var _instance: AppDatabase? = null
@JvmStatic
fun instance(): AppDatabase {
if (_instance == null) {
synchronized(AppDatabase::class.java) {
if (_instance == null) {
_instance = Room.databaseBuilder(
Utils.getContext()
, AppDatabase::class.java
, "mints_room.com.mints.freeworld.db")
.allowMainThreadQueries()//设置是否允许在主线程做查询操作
//.fallbackToDestructiveMigration()//设置迁移数据库如果发生错误,将会重新创建数据库,而不是发生崩溃
.build()
}
}
}
return _instance!!
}
}
}
\ No newline at end of file
package com.mints.fiveworld.db
import androidx.room.*
/**
* Created by 冯瑞雨 on 2021/7/20.
*/
@Dao
interface ScenicSpotDao {
/**
* 添加 VR 免费专区
* OnConflictStrategy.REPLACE表如已有数据,就覆盖掉。
*/
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun addVRFreeZoneAll(list:List<ScenicSpotBean>)
/**
* 获取 VR 免费专区
*/
@Query("SELECT * FROM vr_scenic_spot")
fun getVRFreeZoneAll(): List<ScenicSpotBean>
//
// /**
// * 删除 VR 免费专区
// */
// @Delete
// fun deleteVRFreeZoneAll(list:List<ScenicSpotBean>)
//
// /**
// * 获取 国外的 免费专区
// */
// @Query("SELECT * FROM foreign_scenic_spots WHERE is_free = 1")
// fun getForeignFreeAll(list:List<ForeignScenicSpots>)
//
// /**
// * 获取 国外的 收费(精选体验)
// */
// @Query("SELECT * FROM foreign_scenic_spots WHERE is_free = 2")
// fun getForeignTollAll(list:List<ForeignScenicSpots>)
//
// /**
// * 添加 VR 国外
// */
// @Insert(onConflict = OnConflictStrategy.REPLACE)
// fun addForeignAll(list:List<ForeignScenicSpots>)
//
// /**
// * 删除 VR 国外免费
// */
// @Query("DELETE FROM foreign_scenic_spots WHERE is_free =1")
// fun deleteForeignFreeAll()
// /**
// * 删除 VR 国外收费
// */
// @Query("DELETE FROM foreign_scenic_spots WHERE is_free =2")
// fun deleteForeignTollAll()
}
\ No newline at end of file
package com.mints.fiveworld.db
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
/**
* Created by 冯瑞雨 on 2021/7/20.
* VR景区表
*/
@Entity(tableName = "vr_scenic_spot")
class ScenicSpotBean(
//主键 自增
@PrimaryKey(autoGenerate = true)
var id: Int = 0,
//景区 经度
var longitude :Double?=null,
//景区 纬度
var latitude :Double?=null,
//景区 名称
var name :String? = null,
//景区 图片
var images : String? = null,
//景区 url地址
var url : String? = null,
//景区 星级 默认0-5
@ColumnInfo(name="star_rating")
var starRating : String? = null
)
@Entity(tableName = "foreign_scenic_spots")
class ForeignScenicSpots(
//主键 自增
@PrimaryKey(autoGenerate = true)
var id: Int = 0,
//景区 免费还是收费的 1=免费 2=收费
@ColumnInfo(name="is_free")
var isFree:Int,
//景区 经度
var longitude :Double?=null,
//景区 纬度
var latitude :Double?=null,
//景区 目的地的ID
var did :Int?=null,
//景区 名称
var name :String? = null,
//景区 人数
@ColumnInfo(name = "number_people")
var numberPeople :Int? = null,
//景区 图片
var images : List<String>? = null
)
\ No newline at end of file
package com.mints.fiveworld.eventbean;
/**
* @author 冯瑞雨
* @date 2019/10/23 16:29
*/
public class DownloadEvent {
/**
* apk 的大小
*/
private long apkSize;
/**
* 下载的进度 百分比
*/
private int apkCurrentProgress;
/**
* 下载当前进度
*/
private long apkSchedule;
public long getApkSize() {
return apkSize;
}
public void setApkSize(long apkSize) {
this.apkSize = apkSize;
}
public int getApkCurrentProgress() {
return apkCurrentProgress;
}
public void setApkCurrentProgress(int apkCurrentProgress) {
this.apkCurrentProgress = apkCurrentProgress;
}
public long getApkSchedule() {
return apkSchedule;
}
public void setApkSchedule(long apkSchedule) {
this.apkSchedule = apkSchedule;
}
public DownloadEvent(long apkSize, int apkCurrentProgress, long apkSchedule) {
this.apkSize = apkSize;
this.apkCurrentProgress = apkCurrentProgress;
this.apkSchedule = apkSchedule;
}
}
package com.mints.fiveworld.login
import android.Manifest
import android.graphics.Color
import android.os.Bundle
import android.view.View
import androidx.lifecycle.Observer
import com.fry.base.base.BaseActivity
import com.mints.fiveworld.BR
import com.mints.fiveworld.R
import com.mints.fiveworld.databinding.ActivityLoginBinding
import com.mints.fiveworld.manager.UserManager
import com.mints.fiveworld.utils.BackInputUtil
import com.mints.fiveworld.widget.dialog.DialogUtils
import com.permissionx.guolindev.PermissionX
import com.permissionx.guolindev.callback.RequestCallback
import kotlinx.android.synthetic.main.activity_bindmobile.*
import kotlinx.android.synthetic.main.activity_login.*
import kotlinx.android.synthetic.main.include_header.*
import me.goldze.mvvmhabit.utils.AppUtils
import me.goldze.mvvmhabit.utils.ToastUtils
/**
* Created by 冯瑞雨 on 2021/7/2.
*/
class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View.OnClickListener {
private val userManager by lazy { UserManager.INSTANCE }
override fun getStatusBarHeightView(): View? {
return binding.tvName
}
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_login
override fun initVariableId() = BR.viewModel
override fun initData() {
super.initData()
initView()
initListener()
}
private fun initListener() {
binding.tvSendSms.setOnClickListener {
// ToastUtils.showLong("点击获取验证码")
var mobile = et_phone.text.toString().trim()
if (mobile.length < 13) {
ToastUtils.showLong("请输入手机号")
return@setOnClickListener
}
ToastUtils.showLong("验证码已发送")
sendCodeThread()
mobile = mobile.replace(" ".toRegex(), "")
viewModel.sendMobileCode(mobile)
}
binding.button.setOnClickListener {
var mobile = et_phone.text.toString().trim()
if (mobile.length < 13) {
ToastUtils.showLong("请输入手机号")
return@setOnClickListener
}
val code = et_sms.text.toString().trim()
if (code.length < 4) {
ToastUtils.showLong("请输入验证码")
return@setOnClickListener
}
PermissionX.init(this@LoginActivity)
.permissions(Manifest.permission.READ_PHONE_STATE)
.request(RequestCallback { allGranted, _, _ ->
if (allGranted) {
mobile = mobile.replace(" ".toRegex(), "")
// 登录
viewModel.mobilelogin(mobile, code)
} else {
DialogUtils.showPermissionDialog(this@LoginActivity, "设备")
}
})
}
iv_left_icon.setOnClickListener(this)
iv_left_icon.setOnClickListener(this)
}
private fun initView() {
tv_title.text = "手机号登录"
tv_title.setTextColor(Color.WHITE)
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back_white)
iv_left_icon.setPadding(
AppUtils.dp2Px(this, 15F),
AppUtils.dp2Px(this, 15F),
AppUtils.dp2Px(this, 15F),
AppUtils.dp2Px(this, 15F)
)
header_line.visibility = View.GONE
iv_left_icon.visibility = View.VISIBLE
//手机号设置格式
BackInputUtil.phoneNumAddSpace(et_phone)
/*mobile = UserManager.INSTANCE.getMobile()
if (!TextUtils.isEmpty(mobile)) {
et_sms.setText(mobile)
et_sms.setSelection(mobile!!.length + 2)
}*/
}
override fun initViewObservable() {
super.initViewObservable()
viewModel.data.observe(this, Observer<String> {
ToastUtils.showLong("登录成功")
finish()
})
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.iv_left_icon -> finish()
}
}
/**
* 发送手机验证码,按钮动态改变状态
*/
var num = 0
var run: Runnable? = null
fun sendCodeThread() {
num = 60
tv_send_sms?.let {
it.isEnabled = false
it.text = "($num)重新获取"
run = object : Runnable {
override fun run() {
num--
if (num == 0) {
it.text = "重新获取"
it.isEnabled = true
} else {
it.text = "($num)重新获取"
it.postDelayed(this, 1000)
}
}
}
it.postDelayed(run, 1000)
}
}
}
\ No newline at end of file
package com.mints.fiveworld.login
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.mints.fiveworld.bean.BaseResponse
import com.mints.fiveworld.bean.UserBean
import com.mints.fiveworld.common.DeviceInfo
import com.mints.fiveworld.manager.UserManager
import com.mints.fiveworld.manager.oaid.OaidManager
import com.mints.fiveworld.model.ApiModel
import com.mints.fiveworld.netwrok.base.HttpSubscribeImpl
import com.mints.fiveworld.utils.DeviceUuidFactory
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import java.util.HashMap
/**
* Created by mcg
*/
class LoginViewModel(application: Application) : BaseViewModel(application) {
val data :MutableLiveData<String> = MutableLiveData()
val deviceInfo: DeviceInfo
get() {
return DeviceInfo.instance
}
/**
* 获取手机验证码
*
* @param mobile
*/
fun sendMobileCode(mobile: String) {
val vo = HashMap<String, Any>()
vo["mobile"] = mobile
// vo["type"] = 1
ApiModel.sendMobileCode(lifecycleProvider,vo).subscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>(
this@LoginViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<Any>) {
// KLog.e("sendMobileCode", response.result.toString())
}
override fun onError(e: Throwable) {
KLog.e("sendMobileCode", "发送验证码错误")
}
})
}
/**
* 调用登录接口
*/
fun mobilelogin(mobile: String, smsCode: String) {
// showDialog()
val vo = HashMap<String, Any>()
vo["mobile"] = mobile
vo["smsCode"] = smsCode
// vo["device"] = DeviceUuidFactory().deviceUuid.toString()
ApiModel.login(lifecycleProvider,vo).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<UserBean>>(
this@LoginViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<UserBean>) {
//提交设备信息【注:这里海哥的意思是说在测试的环境下,进行当前的注册是利用手机号进行注册,由于开通了微信登录,就不需要再手机号登录的时候进行设备信息的提交】
this@LoginViewModel.saveTerminalInfo()
//保存用户信息到Usermanager
UserManager.INSTANCE.saveUserInfo(response.result)
data.value = response.message
KLog.e("login", response.result.toString())
// ToastUtils.showShort("登录信息="+response.result.consumer?.idcode)
}
override fun onError(e: Throwable) {
KLog.e("LoginViewModel", "登录错误")
}
})
}
/**
* 提交设备信息
*/
fun saveTerminalInfo() {
val vo = hashMapOf<String, Any>()
val macAddress: String = deviceInfo.getMacAddress()
val mac = macAddress.replace(":", "")
vo["mac"] = mac
vo["mac1"] = macAddress
vo["androidid"] = deviceInfo.getAndroidId(null)
vo["imei"] = deviceInfo.iMEI
vo["oaid"] =OaidManager.getOaid()
vo["os"] = "android"
vo["model"] = deviceInfo.newModel
vo["uuid"] = DeviceUuidFactory().deviceUuid
vo["osversion"] = deviceInfo.oSVersion
vo["appversion"] = deviceInfo.versionName
ApiModel.saveTerminalInfo(lifecycleProvider,vo).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>(
this@LoginViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<Any>) {
KLog.e("saveTerminalInfo", response.result.toString())
}
})
}
}
\ No newline at end of file
package com.mints.fiveworld.main
import android.Manifest
import android.os.Build
import android.os.Bundle
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2
import com.fry.base.base.BaseActivity
import com.fry.base.utils.ImageLoader
import com.ittianyu.bottomnavigationviewex.BottomNavigationViewEx
import com.mints.fiveworld.BR
import com.mints.fiveworld.R
import com.mints.fiveworld.databinding.ActivityMainBinding
import com.mints.fiveworld.main.googlemap.GoogleMapFragment
import com.mints.fiveworld.main.home.HomeFragment
import com.mints.fiveworld.main.my.MyFragment
import com.mints.fiveworld.main.vr.VRFragment
import com.mints.fiveworld.manager.UserManager
import com.mints.fiveworld.manager.oaid.OaidManager
import com.permissionx.guolindev.PermissionX
import com.permissionx.guolindev.callback.RequestCallback
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.ToastUtils
class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_main
override fun initVariableId() = BR.viewModel
override fun getStatusBarHeightView(): View? {
return null
}
private val homeFragment = HomeFragment()
override fun initData() {
super.initData()
OaidManager.init()
//初始化viewpager2
binding.mainViewpager.initMain(this,homeFragment)
//初始化 bottomBarF
binding.mainBottom.init {
when (it) {
R.id.menu_home -> {
if (UserManager.INSTANCE.userIsLogin() && UserManager.INSTANCE.getVipFlag()) {
binding.mainViewpager.setCurrentItem(3, false)
} else {
binding.mainViewpager.setCurrentItem(0, false)
}
}
R.id.menu_square -> binding.mainViewpager.setCurrentItem(1, false)
R.id.menu_my -> {
binding.mainViewpager.setCurrentItem(2, false)
// stopAnim()
}
}
}
//加载本地GIF动图
ImageLoader.ImageBuilder.with(this)
.setDrawable(R.mipmap.ic_earth_map)
.setTargetView(binding.ivTakephoto).start()
binding.mainBottom.interceptLongClick(
R.id.menu_home,
R.id.menu_square,
R.id.menu_my
)
PermissionX.init(this).permissions(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) Manifest.permission.ACCESS_BACKGROUND_LOCATION else "",
Manifest.permission.ACCESS_FINE_LOCATION
).request(RequestCallback { allGranted, grantedList, deniedList ->
})
viewModel.checkUpgrade()
}
override fun onResume() {
super.onResume()
if (binding.mainViewpager.currentItem == 0){
if (UserManager.INSTANCE.userIsLogin() && UserManager.INSTANCE.getVipFlag()) {
binding.mainViewpager.setCurrentItem(3, false)
}
}
}
var oldTime: Long = 0
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> {
// 设置为后台
val currentTime = System.currentTimeMillis()
if (currentTime - oldTime < 2 * 1000) {
AppManager.getAppManager().finishAllActivity()
} else {
ToastUtils.showLong("再次点击退出" + getString(R.string.app_name))
oldTime = currentTime
}
}
}
return true
}
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
if (ev.action == MotionEvent.ACTION_MOVE){
//触点的个数,就是有几个手指同时接触屏幕
if (ev.pointerCount==1){
homeFragment.updateGesture(true)
}else{
homeFragment.updateGesture(false)
}
}
return super.dispatchTouchEvent(ev)
}
}
private fun BottomNavigationViewEx.init(navigationItemSelectedAction: (Int) -> Unit): BottomNavigationViewEx {
enableAnimation(true)
enableShiftingMode(false)
enableItemShiftingMode(true)
setTextSize(12F)
setOnNavigationItemSelectedListener {
navigationItemSelectedAction.invoke(it.itemId)
true
}
return this
}
private fun ViewPager2.initMain(activity: MainActivity,homeFragment:HomeFragment): ViewPager2 {
//是否可滑动
this.isUserInputEnabled = false
//预加载
this.offscreenPageLimit = 4
//设置适配器
adapter = object : FragmentStateAdapter(activity) {
override fun createFragment(position: Int): Fragment {
return when (position) {
0 -> {
//首页
homeFragment
}
1 -> {
//广场
VRFragment()
}
2 -> {
//个人中心
MyFragment()
}
3 -> {
GoogleMapFragment()
}
else -> {
//首页
HomeFragment()
}
}
}
override fun getItemCount() = 4
}
if (UserManager.INSTANCE.userIsLogin() && UserManager.INSTANCE.getVipFlag()) {
this.setCurrentItem(3, false)
} else {
this.setCurrentItem(0, false)
}
return this
}
/**
* 拦截BottomNavigation长按事件 防止长按时出现Toast ---- 追求完美的大屌群友提的bug
* @receiver BottomNavigationViewEx
* @param ids IntArray
*/
private fun BottomNavigationViewEx.interceptLongClick(vararg ids: Int) {
val bottomNavigationMenuView: ViewGroup = (this.getChildAt(0) as ViewGroup)
for (index in ids.indices) {
bottomNavigationMenuView.getChildAt(index).findViewById<View>(ids[index])
.setOnLongClickListener {
true
}
}
}
package com.mints.fiveworld.main
import android.app.Application
import androidx.appcompat.app.AppCompatActivity
import com.google.gson.Gson
import com.mints.fiveworld.bean.BaseResponse
import com.mints.fiveworld.bean.MapBean
import com.mints.fiveworld.bean.Version
import com.mints.fiveworld.common.DeviceInfo
import com.mints.fiveworld.model.ApiModel
import com.mints.fiveworld.netwrok.base.HttpSubscribeImpl
import com.mints.fiveworld.utils.UpdateHelper
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import java.io.BufferedReader
import java.io.InputStreamReader
/**
* Created by 冯瑞雨 on 2021/7/1.
*/
class MainViewModel(application: Application) : BaseViewModel(application) {
fun getMapBean() {
val assets = AppManager.getAppManager().currentActivity.assets
val stringBuilder = StringBuilder()
try {
//通过管理器打开文件并读取
val bf = BufferedReader(
InputStreamReader(
assets.open("map.json")
)
)
var line: String?
while (bf.readLine().also { line = it } != null) {
stringBuilder.append(line)
}
KLog.e("json", stringBuilder.toString())
var mapBean = Gson().fromJson(stringBuilder.toString(), MapBean::class.java)
} catch (e: Exception) {
KLog.e("读取assets文件下的json出问题")
}
}
fun checkUpgrade() {
val vo = hashMapOf<String, Any>()
vo["platform"] = "android"
vo["version"] = DeviceInfo.instance.versionName
ApiModel.checkUpgrade(lifecycleProvider, vo)
.safeSubscribe(object
: HttpSubscribeImpl<BaseResponse<Version>>(
null, false
) {
override fun onBusinessSuccess(response: BaseResponse<Version>) {
response.result?.apply {
UpdateHelper.processUpdate(
AppManager.getAppManager().currentActivity as AppCompatActivity, this
)
}
}
})
}
}
\ No newline at end of file
package com.mints.fiveworld.main.home
import android.os.Build
import android.os.Bundle
import android.util.Log
import android.view.View.OnTouchListener
import android.view.ViewTreeObserver.OnGlobalLayoutListener
import android.view.animation.DecelerateInterpolator
import android.widget.AbsListView
import androidx.databinding.ViewDataBinding
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.fry.base.base.BaseActivity
import com.fry.base.recycler_view.VHMAdapter
import com.fry.base.recycler_view.VHModel
import com.fry.base.utils.DensityUtils
import com.mints.fiveworld.BR
import com.mints.fiveworld.R
import com.mints.fiveworld.databinding.ActivityHistoricalImageBinding
import java.util.*
/**
* 描述:历史影像
* 作者:孟崔广
* 时间:2021/7/12 17:51
*/
class HistoricalimageActivity :
BaseActivity<ActivityHistoricalImageBinding, HistoricalimageModel>() {
private var centerToLiftDistance = 0//RecyclerView款度的一半 ,也就是控件中间位置到左部的距离 ,
private var childViewHalfCount = 0 //当前RecyclerView一半最多可以存在几个Item
override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_historical_image
override fun initData() {
super.initData()
init()
}
private fun init() {
binding.recyclerView.layoutManager = LinearLayoutManager(
this,
LinearLayoutManager.HORIZONTAL,
false
)
binding.recyclerView.viewTreeObserver
.addOnGlobalLayoutListener(object : OnGlobalLayoutListener {
override fun onGlobalLayout() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
binding.recyclerView.viewTreeObserver.removeOnGlobalLayoutListener(this)
}
centerToLiftDistance = binding.recyclerView.width / 2
val childViewHeight: Int = DensityUtils.dip2px(
100F
) //是当前已知的 Item的高度
childViewHalfCount = (binding.recyclerView.width / childViewHeight +1 ) / 2
initRcData()
findView()
}
})
binding.recyclerView.postDelayed(Runnable { scrollToCenter(childViewHalfCount) }, 100L)
}
private var mDatas: MutableList<String?> = ArrayList<String?>()
private fun initRcData() {
if (mDatas == null) mDatas = ArrayList<String?>()
for (i in 0..9) {
mDatas?.add("条目$i")
}
for (j in 0 until childViewHalfCount) { //头部的空布局
mDatas?.add(0, null)
}
for (k in 0 until childViewHalfCount) { //尾部的空布局
mDatas?.add(null)
}
}
private var isTouch = false
private val centerViewItems: MutableList<CenterViewItem> = ArrayList()
var mAdapter: VHMAdapter<HistorytemVHM>? = null
private fun findView() {
mAdapter = VHMAdapter<HistorytemVHM>()
mDatas?.forEach {
mAdapter?.add(HistorytemVHM(it))
}
binding.recyclerView.adapter = mAdapter
binding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
if (newState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) {
val linearLayoutManager = recyclerView.layoutManager as LinearLayoutManager?
val fi = linearLayoutManager!!.findFirstVisibleItemPosition()
val la = linearLayoutManager.findLastVisibleItemPosition()
if (isTouch) {
isTouch = false
//获取最中间的Item View
val centerPositionDiffer = (la - fi) / 2
var centerChildViewPosition = fi + centerPositionDiffer //获取当前所有条目中中间的一个条目索引
centerViewItems.clear()
//遍历循环,获取到和中线相差最小的条目索引(精准查找最居中的条目)
if (centerChildViewPosition != 0) {
for (i in centerChildViewPosition - 1 until centerChildViewPosition + 2) {
val cView = recyclerView.layoutManager!!.findViewByPosition(i)
val viewLeft = cView!!.left + cView.width / 2
centerViewItems.add(
CenterViewItem(
i,
Math.abs(centerToLiftDistance - viewLeft)
)
)
}
val centerViewItem: CenterViewItem? =
getMinDifferItem(centerViewItems)
centerChildViewPosition = centerViewItem?.position ?: 0
}
scrollToCenter(centerChildViewPosition)
}
}
}
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
for (i in 0 until recyclerView.childCount) {
recyclerView.getChildAt(i).invalidate()
}
}
})
binding.recyclerView.setOnTouchListener(OnTouchListener { _, _ ->
isTouch = true
false
})
}
private val decelerateInterpolator = DecelerateInterpolator()
/**
* 移动指定索引到中心处 , 只可以移动可见区域的内容
* @param movePosition
*/
private fun scrollToCenter(movePosition: Int) {
var position =0
if(movePosition >= mDatas.size - childViewHalfCount ){
position =mDatas.size - childViewHalfCount -1
}else{
position = movePosition
}
position = if (position < childViewHalfCount) childViewHalfCount else position
position =
if (position < mAdapter?.itemCount ?: 0 - childViewHalfCount - 1) position else mAdapter?.itemCount
?: 0 - childViewHalfCount - 1
val linearLayoutManager = binding.recyclerView.layoutManager as LinearLayoutManager
val childView = linearLayoutManager.findViewByPosition(position)
Log.i("ccb", "滑动后中间View的索引: $position")
//把当前View移动到居中位置
if (childView == null) return
val childVhalf = childView.width / 2
val childViewLeft = childView.left
val viewCTop = centerToLiftDistance
val smoothDistance = childViewLeft - viewCTop + childVhalf
Log.i(
"ccb", """
居中位置距离左部距离: $viewCTop
当前居中控件距离左部距离: $childViewLeft
当前居中控件的一半高度: $childVhalf
滑动后再次移动距离: $smoothDistance
""".trimIndent()
)
binding.recyclerView.smoothScrollBy(smoothDistance, 0, decelerateInterpolator)
//mAdapter?.setSelectPosition(position)
//tv.setText("当前选中:" + mDatas!![position])
}
/**
* 计算距离中间最近的一个ItemView
* @param itemHeights
* @return
*/
fun getMinDifferItem(itemHeights: List<CenterViewItem>): CenterViewItem? {
var minItem = itemHeights[0] //默认第一个是最小差值
for (i in itemHeights.indices) {
//遍历获取最小差值
if (itemHeights[i].differ <= minItem.differ) {
minItem = itemHeights[i]
}
}
return minItem
}
}
class HistorytemVHM(
var string: String?
) : VHModel() {
override fun getLayoutId() = R.layout.item_history
override fun getVariableId() = BR.vhm
override fun onBind(binding: ViewDataBinding) {
super.onBind(binding)
}
}
class CenterViewItem //当前Item索引
//当前item和居中位置的差值
(var position: Int, var differ: Int)
package com.mints.fiveworld.main.home
import android.app.Application
import me.goldze.mvvmhabit.base.BaseViewModel
class HistoricalimageModel(application: Application): BaseViewModel(application) {
}
\ No newline at end of file
package com.mints.fiveworld.main.home
import me.goldze.mvvmhabit.base.ItemViewModel
import me.goldze.mvvmhabit.binding.command.BindingAction
import me.goldze.mvvmhabit.binding.command.BindingCommand
/**
* Created by 冯瑞雨 on 2021/7/9.
*/
class HomeButtonItemVM(viewModel: HomeViewModel,val name:String?,val image1:String,
val image2:String,val image3:String,
var latitude:String?,var longitude:String?,val isLook:Boolean?=false) : ItemViewModel<HomeViewModel?>(viewModel) {
val onItemClick = BindingCommand<Any?>(BindingAction {
viewModel.authorized(name,latitude,longitude,isLook?:false)
})
}
\ No newline at end of file
package com.mints.fiveworld.main.home
import android.content.Intent
import com.mints.fiveworld.bean.HistoryBean
import com.mints.fiveworld.bean.Location
import com.mints.fiveworld.main.my.OpenvipActivity
import com.mints.fiveworld.manager.UserManager
import me.goldze.mvvmhabit.base.ItemViewModel
import me.goldze.mvvmhabit.binding.command.BindingAction
import me.goldze.mvvmhabit.binding.command.BindingCommand
/**
* Created by 冯瑞雨 on 2021/7/15.
*
*/
class SearchAfterItem(viewModel: SearchMapViewModel,val name:String?
, val address:String?,val pt: Location?=null) :
ItemViewModel<SearchMapViewModel>(viewModel) {
/***
* 点击名称回调回调
*/
val onClick = BindingCommand<Any>(BindingAction {
if(viewModel.index.value==1&&( !UserManager.INSTANCE.userIsLogin() ||
!UserManager.INSTANCE.getVipFlag())){
viewModel.startActivity(OpenvipActivity::class.java)
return@BindingAction
}
viewModel.searchName.value = HistoryBean(name = this.name,
latitude = pt?.lat,longitude = pt?.lng)
val intent = Intent()
intent.putExtra("latitude",pt?.lat)
intent.putExtra("longitude",pt?.lng)
intent.putExtra("inner",viewModel.index.value)
viewModel.finishData(SearchMapActivity.REQUEST_CODE,intent)
})
}
package com.mints.fiveworld.main.home
import android.app.Application
import android.text.TextUtils
import androidx.databinding.ObservableArrayList
import androidx.lifecycle.MutableLiveData
import com.google.gson.Gson
import com.mints.fiveworld.BR
import com.mints.fiveworld.R
import com.mints.fiveworld.bean.*
import com.mints.fiveworld.model.ApiModel
import com.mints.fiveworld.model.BaiduModel
import com.mints.fiveworld.netwrok.base.HttpSubscribeImpl
import com.mints.fiveworld.webview.MintsWebViewActivity
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.SPUtils
import me.tatarka.bindingcollectionadapter2.ItemBinding
import java.io.BufferedReader
import java.io.InputStreamReader
/**
* Created by 冯瑞雨 on 2021/7/13.
*/
class SearchMapViewModel(application: Application) : BaseViewModel(application) {
//0=境内 1=境外
val index = MutableLiveData(0)
val positiondata: MutableLiveData<List<PositionBean>> = MutableLiveData()
//这里是走的一个点击回调,能够打开首页进行定位
val searchAfterItemBinding = ItemBinding.of<SearchAfterItem>(BR.viewModel, R.layout.item_search_after)
val searchAfterOneItems = ObservableArrayList<SearchAfterItem>()
//搜索的name
val searchName = MutableLiveData<HistoryBean>()
//定位位置
val positioningBean: PositioningBean? =getpositioningMap()
private fun getpositioningMap():PositioningBean?{
SPUtils.getInstance(SPUtils.POSITIONING_MAP)
.decodeString(SPUtils.POSITIONING_MAP)?.apply {
if (!TextUtils.isEmpty(this)){
return Gson().fromJson(this,PositioningBean::class.java)
}
}
return null
}
val mapBean = MutableLiveData<MapBean>()
fun getMapBean(){
val assets = AppManager.getAppManager().currentActivity.assets
val stringBuilder = StringBuilder()
try {
//通过管理器打开文件并读取
val bf = BufferedReader(
InputStreamReader(
assets.open("map.json"))
)
var line: String?
while (bf.readLine().also { line = it } != null) {
stringBuilder.append(line)
}
mapBean.value = Gson().fromJson(stringBuilder.toString(), MapBean::class.java)
} catch (e:Exception){
KLog.e("读取assets文件下的json出问题")
}
}
/**
* 获取国外搜索信息【通过搜索内容进行查找】
*/
fun searchabroad(position:String) {
BaiduModel.suggestionPlaceAbroad(lifecycleProvider
,position,"全球","json","tnFhCM9cTeTDZqNjRPVHbfzOz6AUPoEq")
.safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<PositionBean>>(
this@SearchMapViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<PositionBean>) {
positiondata.value = response.resultList
println("mcg __ "+response.resultList)
}
}
)
}
/**
* 获取国内搜索信息
* "query"" = "北京"
* "region"" = "中国"
* "output"" = "json"
* "ak"" = "C56Qdc560TQKtQaavS0NTPUYupsZHspI"
*/
fun searchdomestic(position:String) {
BaiduModel.suggestionPlaceDomestic(lifecycleProvider,position
,"中国","json","C56Qdc560TQKtQaavS0NTPUYupsZHspI")
.safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<PositionBean>>(
this@SearchMapViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<PositionBean>) {
positiondata.value = response.resultList
println("mcg __ "+response.result)
}
}
)
}
fun authorized(name:String?=null,lat:String?,lng:String?,isLook :Boolean) {
if (isLook) {
ApiModel.authorizedA().safeSubscribe(object
: HttpSubscribeImpl<BaseResponse<AuthorizedBean>>(
this@SearchMapViewModel, false
) {
override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) {
MintsWebViewActivity.startWebView(
name,
MintsWebViewActivity.toBaduVR(lat, lng, response.result?.bk)
)
}
})
} else {
ApiModel.authorized().safeSubscribe(object
: HttpSubscribeImpl<BaseResponse<AuthorizedBean>>(
this@SearchMapViewModel, false
) {
override fun onBusinessSuccess(response: BaseResponse<AuthorizedBean>) {
if (index.value == 0) {
MintsWebViewActivity.startWebView(
name,
MintsWebViewActivity.toBaduVR(lat, lng, response.result?.bk)
)
} else {
MintsWebViewActivity.startWebView(
name,
MintsWebViewActivity.toGoogleVR(
response.result.u,
response.result.gk,
response.result.base,
lat,
lng,
response.result.ut
)
)
}
}
})
}
}
}
\ No newline at end of file
package com.mints.fiveworld.main.home
import com.mints.fiveworld.bean.PositionBean
interface onGetSuggestionPositionsLister {
fun onGetSuggestionResult(var1: PositionBean?)
}
package com.mints.fiveworld.main.my
import android.app.Application
import me.goldze.mvvmhabit.base.BaseViewModel
class AboutusViewModel(application: Application): BaseViewModel(application) {
}
\ No newline at end of file
package com.mints.fiveworld.main.my
import android.app.Application
import me.goldze.mvvmhabit.base.BaseViewModel
class MoresettingsViewModel(application: Application): BaseViewModel(application) {
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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