Commit 283fbbed authored by fengruiyu's avatar fengruiyu

Merge branch 'master' of http://39.97.65.143:81/android/android_street into fry_dev

 Conflicts:
	app/src/main/AndroidManifest.xml
parents cdb591b9 a6fac0d4
......@@ -135,6 +135,9 @@ android {
dependencies {
implementation fileTree(include:['*.jar'], dir:'libs')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation rootProject.ext.support["junit"]
//下拉刷新
......@@ -152,7 +155,9 @@ dependencies {
implementation 'com.github.iielse:switchbutton:1.0.4'
// BottomDialog
implementation 'com.google.android.material:material:1.0.0'
// 日志
implementation 'com.squareup.okhttp3:logging-interceptor:4.1.0'
implementation 'com.orhanobut:logger:2.2.0'
// 三方接入
// 移动安全联盟
......
......@@ -314,10 +314,6 @@
}
-keep class com.uc.crashsdk.** { *; }
-keep interface com.uc.crashsdk.** { *; }
......
......@@ -2,42 +2,21 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mints.street">
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="30" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="false"
android:resizeable="true"
android:smallScreens="true" />
<!-- 这个权限用于进行网络定位 -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- 这个权限用于访问GPS定位 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- 获取网络状态,根据网络状态切换进行数据请求网络转换 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- 写外置存储。如果开发者使用了离线地图,并且数据写在外置存储区域,则需要申请该权限 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- 读取外置存储。如果开发者使用了so动态加载功能并且把so文件放在了外置存储区域,则需要申请该权限,否则不需要 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- 访问网络,进行地图相关业务数据请求,包括地图数据,路线规划,POI检索等 -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 调用相机,用于实现扫描二维码,预览个性化地图编辑器生成的个性化地图样式(开发者实际开发中地图SDK不需要该权限)-->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <!-- 这个权限用于访问GPS定位 -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位 -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <!-- 获取网络状态,根据网络状态切换进行数据请求网络转换 -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <!-- 写外置存储。如果开发者使用了离线地图,并且数据写在外置存储区域,则需要申请该权限 -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <!-- 读取外置存储。如果开发者使用了so动态加载功能并且把so文件放在了外置存储区域,则需要申请该权限,否则不需要 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- 访问网络,进行地图相关业务数据请求,包括地图数据,路线规划,POI检索等 -->
<uses-permission android:name="android.permission.INTERNET" /> <!-- 调用相机,用于实现扫描二维码,预览个性化地图编辑器生成的个性化地图样式(开发者实际开发中地图SDK不需要该权限) -->
<uses-permission android:name="android.permission.CAMERA" /> <!-- 获取手机状态信息 -->
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<!-- android10以后 后台运行位置 -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<application
android:name="com.mints.street.AppApplication"
android:name=".AppApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher_main"
android:label="@string/app_name"
......@@ -73,43 +52,46 @@
<meta-data
android:name="Mob-AppSecret"
android:value="${SHARE_SECRET}" />
<!--百度地图开放平台 -->
<meta-data
android:name="com.baidu.lbsapi.API_KEY"
android:value="SD6luBGzUFSVEZ3n9Xjk3xTsvDFmuRCi" /><!--百度地图开放平台 -->
<!--百度地图开放平台 service-->
<service android:name="com.baidu.location.f"
android:value="SD6luBGzUFSVEZ3n9Xjk3xTsvDFmuRCi" />
<!-- 百度地图开放平台 service -->
<service
android:name="com.baidu.location.f"
android:enabled="true"
android:process=":remote"/>
android:process=":remote" />
<activity android:name="com.mints.street.splash.SplashActivity"
<activity
android:name=".splash.SplashActivity"
android:theme="@style/NormalSplash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="um.60e80209a6f90557b7b19aa7" />
</intent-filter>
</activity>
<activity android:name="com.mints.street.login.LoginActivity">
</activity>
<activity android:name="com.mints.street.main.MainActivity"
<activity android:name=".login.LoginActivity"></activity>
<activity
android:name=".main.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTask"
android:theme="@style/AppTheme.NoneTranslucent">
</activity>
<activity android:name=".main.my.MoresettingsActivity"/>
<activity android:name=".main.my.AboutusActivity"/>
<activity android:name=".main.my.PermissionsActivity"/>
<activity android:name=".main.home.HistoricalimageActivity"/>
android:theme="@style/AppTheme.NoneTranslucent"></activity>
<activity android:name=".main.my.MoresettingsActivity" />
<activity android:name=".main.my.AboutusActivity" />
<activity android:name=".main.my.PermissionsActivity" />
<activity android:name=".main.my.OpenvipActivity" />
<activity android:name=".main.home.HistoricalimageActivity" />
<activity android:name=".main.my.BindMobileActivity" />
<activity android:name=".splash.GuideActivity"/>
<!-- ShareSDK start -->
<activity
android:name="com.mob.tools.MobUIShell"
......@@ -147,8 +129,7 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths"
tools:replace="android:resource" />
</provider>
<!-- 广点通广告 -->
</provider> <!-- 广点通广告 -->
<uses-library
android:name="org.apache.http.legacy"
android:required="false" />
......@@ -168,19 +149,16 @@
android:name="com.qq.e.ads.LandscapeADActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:screenOrientation="landscape"
tools:replace="android:screenOrientation" />
<!-- WX_APPID必填项 -->
tools:replace="android:screenOrientation" /> <!-- WX_APPID必填项 -->
<meta-data
android:name="WX_APPID"
android:value="wx8f26539eabfb04f2" />
<activity
android:name=".wxapi.WXPayEntryActivity"
android:exported="true"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<!-- 支付宝 -->
android:windowSoftInputMode="adjustPan" /> <!-- 支付宝 -->
<activity
android:name="com.alipay.sdk.app.H5PayActivity"
android:configChanges="orientation|keyboardHidden|navigation|screenSize"
......@@ -193,11 +171,7 @@
android:exported="false"
android:screenOrientation="behind"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity android:name=".main.vr.PanoramicActivity"
android:screenOrientation="sensor"
android:configChanges="orientation|keyboardHidden"
/>
<activity android:name=".main.home.SearchMapActivity"/>
<activity android:name=".main.vr.PanoramicActivity" />
</application>
</manifest>
\ No newline at end of file
......@@ -3,8 +3,6 @@ package com.mints.street
import android.content.Context
import android.os.StrictMode
import android.os.StrictMode.VmPolicy
import android.util.Log
import android.widget.Toast
import com.baidu.lbsapi.BMapManager
import com.baidu.mapapi.CoordType
import com.baidu.mapapi.SDKInitializer
......@@ -13,8 +11,11 @@ import com.fry.base.base.BaseApp
import com.mints.street.main.vr.PanoramicActivity
import com.mints.street.manager.CsjGroMoreManager
import com.mints.street.manager.UmengManager
import com.orhanobut.logger.AndroidLogAdapter
import com.orhanobut.logger.FormatStrategy
import com.orhanobut.logger.Logger
import com.orhanobut.logger.PrettyFormatStrategy
import me.goldze.mvvmhabit.utils.KLog
import java.util.concurrent.TimeoutException
/**
* Created by 冯瑞雨 on 2021/7/1.
......@@ -61,6 +62,8 @@ class AppApplication : BaseApp() {
SDKInitializer.setCoordType(CoordType.BD09LL)
//百度全景
initEngineManager(this)
bindLogger()
}
/**
* 初始化百度全景
......@@ -74,6 +77,21 @@ class AppApplication : BaseApp() {
}
}
/**
* 自定义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
......
package com.mints.street.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.street.adapter.listener.OnPageSelectListener;
import com.mints.street.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.street.adapter
import android.content.Context
import android.graphics.Paint
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.street.R
import com.mints.street.databinding.ItemGridPaymentAdpaterBinding
import me.goldze.mvvmhabit.utils.AppUtils
class GridPaymentAdapter(val context: Context, val list: List<String>) : AbstractVLayoutBaseAdapter<ItemGridPaymentAdpaterBinding, List<String>>(context, list, 3) {
private var mposition: Int = -1
override fun onBindViewHolder(holder: BindingViewHolder<ItemGridPaymentAdpaterBinding>, position: Int) {
holder.binding.text1.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG
var a = holder.binding.bg.layoutParams
holder.binding.bg.setMargin(AppUtils.dp2Px(context, 10F), 0, AppUtils.dp2Px(context, 10F), 0, null, null, null)
holder.itemView.setOnClickListener {
mposition = holder.adapterPosition
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment_down)
notifyDataSetChanged()
}
if (mposition == position) {
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment_down)
} else {
holder.binding.bg.setBackgroundResource(R.drawable.shape_bg_payment)
}
}
override fun getItemCount() = list.size
override fun onCreateLayoutHelper() = GridLayoutHelper(3)
override fun getLayoutId(viewType: Int) = R.layout.item_grid_payment_adpater
}
\ No newline at end of file
package com.mints.street.adapter.listener;
public interface OnPageSelectListener {
void select(int position);
}
package com.mints.street.api
import com.mints.street.bean.AwardBean
import com.mints.street.bean.BaseResponse
import com.mints.street.bean.UserBean
import com.mints.street.bean.VipBean
import com.mints.street.netwrok.common.HttpManager
import io.reactivex.Observable
import me.goldze.mvvmhabit.http.BaseResponse
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.POST
......@@ -18,6 +18,15 @@ interface MainApi {
return HttpManager.getInstance().defaultClient.create(MainApi::class.java)
}
}
/**
* 获取验证码
*
* @return
*/
@POST("api/sendMobileCode")
fun sendMobileCode(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>>
/**
* 登录
*/
......@@ -25,9 +34,14 @@ interface MainApi {
fun mobileLogin(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<UserBean>>>
/**
* 获取用户配置信息
* 提交设备信息
*
* @return
*/
@POST("api/getCoinMsg")
fun getCoinMsg(): Observable<Response<BaseResponse<AwardBean>>>
@POST("api/saveTerminalInfo")
fun saveTerminalInfo(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<Any>>>
@POST("api/getVipProductsByType")
fun getVipProductsByType(@Body vo: @JvmSuppressWildcards Map<String, Any>): Observable<Response<BaseResponse<VipBean>>>
}
\ No newline at end of file
package com.fry.base.bean
package com.mints.street.bean
import android.annotation.SuppressLint
import android.os.Parcelable
......
package com.mints.street.bean
import android.annotation.SuppressLint
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
/**
*
* @author jyx
* @date 2021/4/7
* @des
*/
@SuppressLint("ParcelCreator")
@Parcelize
data class AwardBean(
var highCoin: Int = 0,
var showHigh: Boolean = false,
var coin: Int = 0,
var riskinfoRate: Boolean = false
) : Parcelable
\ No newline at end of file
package me.goldze.mvvmhabit.http;
package com.mints.street.bean;
import androidx.annotation.Nullable;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
/**
* Created by goldze on 2017/5/10.
* 该类仅供参考,实际业务返回的固定字段, 根据需求来定义,
*/
public class BaseResponse<T> {
public class BaseResponse<T> implements Serializable {
private int status;
private String message;
......@@ -43,7 +44,7 @@ public class BaseResponse<T> {
}
public boolean isOk() {
return status >= 200 && status < 300;
return status == 200 && status < 700;
}
public String getMessage() {
......
......@@ -5,31 +5,19 @@ import java.io.Serializable
/**
* 描述:用户信息
* 作者:孟崔广
* 时间:2019/10/29 18:42
* 邮箱:mengcga@163.com
* 时间:2021/7/29 18:42
*/
class UserBean : Serializable {
val token: String? = null
val toKeepAnAccount: String? = null
val token: String = ""
val consumer: ConsumerBean? = null
inner class ConsumerBean : Serializable {
val head: String? = null
val openid: String? = null
val nickname: String? = null
val mobile: String? = null
val real_name: String? = null
val alipay_account: String? = null
val idcode: String? = null
val gameInfo: String? = null
var sumCoin: String? = null
val surplus //余额
= 0.0
val coin // 积分
= 0
val pk_id // 用户id
: Long = 0
val isFirstSignInApp // 首次登录app true:首次
= false
val openid: 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.street.bean
class VipBean {
}
\ No newline at end of file
......@@ -12,4 +12,8 @@ object Constant {
*/
const val MINTS_PKG_NAME = "com.mints.street"
/**
* 第一次打开权限页面
*/
const val FIRST_OPEN_PERMISSIONS = "first_open_permissions"
}
package com.mints.street.login
import android.graphics.Color
import android.os.Bundle
import android.os.PersistableBundle
import android.text.TextUtils
import android.view.View
import androidx.lifecycle.Observer
import com.fry.base.base.BaseActivity
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ActivityLoginBinding
import com.mints.street.manager.UserManager
import com.mints.street.utils.BackInputUtil
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.ToastUtils
......@@ -14,37 +21,70 @@ import me.goldze.mvvmhabit.utils.ToastUtils
* Created by 冯瑞雨 on 2021/7/2.
*/
class LoginActivity : BaseActivity<ActivityLoginBinding, LoginViewModel>(), View.OnClickListener {
private var mobile: String? = null
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_login
override fun initVariableId() = BR.viewModel
override fun initData() {
super.initData()
initView()
initListener()
}
private fun initView() {
private fun initListener() {
binding.button.setOnClickListener {
viewModel.login()
viewModel.login("18311400069", "123456")
}
iv_left_icon.setImageResource(R.mipmap.iv_return_white)
// iv_left_icon.visibility = View.VISIBLE
binding.tvSendSms.setOnClickListener {
// ToastUtils.showLong("点击获取验证码")
var mobile = et_phone.text.toString().trim()
if (mobile.length < 13) {
ToastUtils.showLong("请输入手机号")
return@setOnClickListener
}
mobile = mobile.replace(" ".toRegex(), "")
viewModel.sendMobileCode(mobile)
}
iv_left_icon.setOnClickListener(this)
iv_left_icon.setOnClickListener(this)
}
private fun initView() {
iv_left_icon.setImageResource(R.mipmap.iv_return_white)
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>{
viewModel.data.observe(this, Observer<String> {
ToastUtils.showLong("初始化成功")
})
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.iv_left_icon -> {
finish()
}
R.id.iv_left_icon -> finish()
}
}
}
\ No newline at end of file
......@@ -2,36 +2,109 @@ package com.mints.street.login
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.mints.street.bean.AwardBean
import com.mints.street.bean.BaseResponse
import com.mints.street.bean.UserBean
import com.mints.street.common.DeviceInfo
import com.mints.street.manager.UserManager
import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import com.mints.street.utils.DeviceUuidFactory
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.http.BaseResponse
import me.goldze.mvvmhabit.utils.KLog
import me.goldze.mvvmhabit.utils.ToastUtils
import java.util.HashMap
/**
* Created by 冯瑞雨 on 2021/7/2.
* Created by mcg
*/
class LoginViewModel(application: Application) : BaseViewModel(application) {
val data :MutableLiveData<String> = MutableLiveData()
fun login() {
ApiModel.coinMsg(lifecycleProvider).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<AwardBean>>(
this@LoginViewModel, true
) {
override fun onBusinessSuccess(response: BaseResponse<AwardBean>) {
KLog.e("sfdsdf", response.result.toString())
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).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>(
this@LoginViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<Any>) {
KLog.e("sendMobileCode", response.result.toString())
}
override fun onError(e: Throwable) {
data.value = "失败"
KLog.e("sendMobileCode", "发送验证码错误")
}
})
}
fun login(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>) {
// dismissDialog()
this@LoginViewModel.saveTerminalInfo()
UserManager.INSTANCE.saveUserInfo(response.result)
KLog.e("login", response.result.toString())
ToastUtils.showShort("登录信息="+response.result.consumer?.idcode)
data.value = response.message
}
override fun onError(e: Throwable) {
data.value = "失败"
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
// if (!TextUtils.isEmpty(App.OAID)) {
// vo["oaid"] = App.OAID
// }
vo["os"] = "android"
vo["model"] = deviceInfo.newModel
vo["uuid"] = DeviceUuidFactory().deviceUuid
vo["osversion"] = deviceInfo.oSVersion
vo["appversion"] = deviceInfo.versionName
override fun onComplete() {
super.onComplete()
ApiModel.saveTerminalInfo(lifecycleProvider,vo).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>(
this@LoginViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<Any>) {
KLog.e("saveTerminalInfo", response.result.toString())
}
})
}
......
......@@ -61,10 +61,11 @@ class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {
// test
UmengManager.initUm()
val rxPermissions = RxPermissions(this )
rxPermissions.request(Manifest.permission.ACCESS_COARSE_LOCATION)
val rxPermissions = RxPermissions(this)
rxPermissions.request(Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_PHONE_STATE)
.subscribe {
}
}
......@@ -148,6 +149,7 @@ private fun ViewPager2.initMain(activity: FragmentActivity): ViewPager2 {
}
return this
}
/**
* 拦截BottomNavigation长按事件 防止长按时出现Toast ---- 追求完美的大屌群友提的bug
* @receiver BottomNavigationViewEx
......
......@@ -2,13 +2,11 @@ package com.mints.street.main.home
import android.os.Bundle
import android.view.View
import com.coorchice.library.utils.LogUtils
import com.fry.base.base.BaseActivity
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ActivityHistoricalImageBinding
import kotlinx.android.synthetic.main.activity_historical_image.*
import me.goldze.mvvmhabit.utils.ToastUtils
/**
* 描述:历史影像
......@@ -17,6 +15,8 @@ import me.goldze.mvvmhabit.utils.ToastUtils
*/
class HistoricalimageActivity :BaseActivity<ActivityHistoricalImageBinding, HistoricalimageModel>(), View.OnClickListener {
var strings= mutableListOf<String>()
override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?)= R.layout.activity_historical_image
override fun initData() {
......@@ -25,9 +25,23 @@ class HistoricalimageActivity :BaseActivity<ActivityHistoricalImageBinding, Hist
}
private fun initView() {
iv_left.setOnClickListener(this)
iv_right.setOnClickListener(this)
bt_main.setOnClickListener(this)
for (i in 0..19) {
strings.add(i.toString() + "00")
}
hsMain.setData(strings)
}
override fun onClick(v: View?) {
when (v?.getId()) {
R.id.iv_left -> hsMain.setAnLeftOffset()
R.id.iv_right -> hsMain.setAnRightOffset()
R.id.bt_main -> tvMain.setText("所选文本:" + hsMain.getSelectedString())
else -> {
}
}
}
}
......@@ -137,6 +137,10 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>(), SensorE
binding.imageOut.setOnClickListener {
mBaiduMap?.setMapStatus(MapStatusUpdateFactory.zoomOut())
}
//历史影像
binding.imageMapHistory.setOnClickListener {
startActivity(HistoricalimageActivity::class.java)
}
mRecommendStopSearch = RecommendStopSearch.newInstance()
mRecommendStopSearch?.setOnGetRecommendStopResultListener { result ->
if (result != null) {
......
......@@ -17,12 +17,17 @@ class AboutusActivity :BaseActivity<ActivityAboutusBinding, AboutusViewModel>(),
override fun initData() {
super.initData()
initView()
initListener()
}
private fun initListener() {
iv_left_icon.setOnClickListener(this)
}
private fun initView() {
tv_title.text="关于我们"
tv_title.setTextColor(Color.BLACK)
iv_left_icon.setImageResource(R.mipmap.iv_return)
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
iv_left_icon.visibility=View.VISIBLE
tv_user.setOnClickListener(this)
tv_privacy.setOnClickListener(this)
......@@ -30,6 +35,7 @@ class AboutusActivity :BaseActivity<ActivityAboutusBinding, AboutusViewModel>(),
override fun onClick(v: View?) {
when(v?.id){
R.id.iv_left_icon -> finish()
R.id.tv_user->{
// startActivity(UseragreementActivity::class.java)
}
......
package com.mints.street.main.my
import android.Manifest
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import com.fry.base.base.BaseActivity
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ActivityBindmobileBinding
import com.mints.street.utils.BackInputUtil
import com.tbruyelle.rxpermissions2.RxPermissions
import kotlinx.android.synthetic.main.activity_bindmobile.*
import kotlinx.android.synthetic.main.include_header.*
import me.goldze.mvvmhabit.utils.ToastUtils
class BindMobileActivity : BaseActivity<ActivityBindmobileBinding, BindMobileViewModel>(), View.OnClickListener {
private var mobile: String? = null
override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_bindmobile
override fun initData() {
super.initData()
initView()
initListener()
}
private fun initListener() {
iv_left_icon.setOnClickListener(this)
tvLoginSendcode.setOnClickListener(this)
tvLoginNext.setOnClickListener(this)
}
private fun initView() {
tv_title.text = "绑定手机号"
iv_left_icon.visibility = View.VISIBLE
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
BackInputUtil.phoneNumAddSpace(etLoginMobile)
// mobile = UserManager.getInstance().mobile
if (!TextUtils.isEmpty(mobile)) {
etLoginMobile.setText(mobile)
etLoginMobile.setSelection(mobile!!.length + 2)
}
}
override fun onClick(v: View?) {
when(v?.id){
R.id.iv_left_icon -> {
finish()
}
R.id.tvLoginSendcode -> {
var mobile = etLoginMobile.text.toString().trim()
if (mobile.length < 13) {
ToastUtils.showShortSafe("请输入手机号")
return
}
sendCodeThread()
mobile = mobile.replace(" ".toRegex(), "")
// loginPresenter.sendMobileBindingCode(mobile)
viewModel.sendMobileCode(mobile)
}
R.id.tvLoginNext -> {
var mobile = etLoginMobile.text.toString().trim()
if (mobile.length < 13) {
ToastUtils.showShortSafe("请输入手机号")
return
}
val code = etLoginCode.text.toString().trim()
if (code.length < 4) {
ToastUtils.showShortSafe("请输入验证码")
return
}
RxPermissions(this@BindMobileActivity)
.request(Manifest.permission.READ_PHONE_STATE)
.subscribe { granted: Boolean ->
if (granted) {
mobile = mobile.replace(" ".toRegex(), "")
// loginPresenter.bindingMobile(mobile, code)
} else {
// showMissingPermissionDialog("设备")
}
}
}
}
}
var num = 0
var run: Runnable? = null
fun sendCodeThread() {
num = 60
tvLoginSendcode?.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)
}
}
}
package com.mints.street.main.my
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.http.BaseResponse
import me.goldze.mvvmhabit.utils.KLog
import java.util.HashMap
class BindMobileViewModel (application: Application): BaseViewModel(application) {
val data : MutableLiveData<String> = MutableLiveData()
/**
* 手机验证码
*
* @param mobile
*/
fun sendMobileCode(mobile: String) {
val vo = HashMap<String, Any>()
vo["mobile"] = mobile
vo["type"] = 1
ApiModel.sendMobileCode(lifecycleProvider,vo).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>(
this@BindMobileViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<Any>) {
KLog.e("sendMobileCode", response.result.toString())
}
override fun onError(e: Throwable) {
data.value = "失败"
KLog.e("sendMobileCode", "发送验证码错误")
}
})
}
}
......@@ -3,26 +3,92 @@ package com.mints.street.main.my
import android.graphics.Color
import android.os.Bundle
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.fry.base.base.BaseActivity
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ActivityMoresettingsBinding
import kotlinx.android.synthetic.main.activity_moresettings.*
import kotlinx.android.synthetic.main.include_header.*
class MoresettingsActivity: BaseActivity<ActivityMoresettingsBinding, MoresettingsViewModel>() {
class MoresettingsActivity : BaseActivity<ActivityMoresettingsBinding, MoresettingsViewModel>(), View.OnClickListener {
override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?)= R.layout.activity_moresettings
override fun initContentView(savedInstanceState: Bundle?) = R.layout.activity_moresettings
override fun initData() {
super.initData()
initView()
initListener()
}
private fun initListener() {
item_phone.setOnClickListener(this)
iv_left_icon.setOnClickListener(this)
item_userAgree.setOnClickListener(this)
item_privacyAgree.setOnClickListener(this)
}
private fun initView() {
tv_title.text="更多设置"
tv_title.text = "更多设置"
tv_title.setTextColor(Color.BLACK)
iv_left_icon.setImageResource(R.mipmap.iv_return)
iv_left_icon.visibility= View.VISIBLE
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
iv_left_icon.visibility = View.VISIBLE
item_phone.findViewById<TextView>(R.id.tv_title).text = "手机号"
val phone = ContextCompat.getDrawable(this, R.mipmap.icon_settings_tel)
phone?.setBounds(0, 0, 56, 56)
item_phone.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(phone, null, null, null)
// item_phone.findViewById<TextView>(R.id.tv_right).visibility=View.VISIBLE
// item_phone.findViewById<TextView>(R.id.tv_right).text = "未绑定"
item_phone.findViewById<TextView>(R.id.tv_right).visibility = View.GONE
item_phone.findViewById<ImageView>(R.id.iv_right).visibility = View.VISIBLE
item_userAgree.findViewById<TextView>(R.id.tv_title).text = "用户协议"
val userAgree = ContextCompat.getDrawable(this, R.mipmap.icon_settings_user)
userAgree?.setBounds(0, 0, 56, 56)
item_userAgree.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(userAgree, null, null, null)
item_userAgree.findViewById<TextView>(R.id.tv_right).visibility = View.GONE
item_userAgree.findViewById<ImageView>(R.id.iv_right).visibility = View.VISIBLE
item_privacyAgree.findViewById<TextView>(R.id.tv_title).text = "隐私协议"
val privacyAgree = ContextCompat.getDrawable(this, R.mipmap.icon_settings_privacy)
privacyAgree?.setBounds(0, 0, 56, 56)
item_privacyAgree.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(privacyAgree, null, null, null)
item_privacyAgree.findViewById<TextView>(R.id.tv_right).visibility = View.GONE
item_privacyAgree.findViewById<ImageView>(R.id.iv_right).visibility = View.VISIBLE
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.iv_left_icon -> {
finish()
}
R.id.item_phone -> {
// if (!userManager.userIsLogin()) {
// readyGo(WxLoginActivity::class.java)
// return
// }
// if (userManager.mobile.isEmpty()) {
startActivity(BindMobileActivity::class.java)
// }
}
R.id.item_userAgree -> {
}
R.id.item_privacyAgree -> {
}
}
}
......
......@@ -8,8 +8,10 @@ import android.view.View
import android.view.ViewGroup
import android.widget.CheckBox
import android.widget.ImageView
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.widget.LinearLayoutCompat
import androidx.core.content.ContextCompat
import com.fry.base.base.BaseFragment
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.mints.street.BR
......@@ -17,6 +19,7 @@ import com.mints.street.R
import com.mints.street.databinding.FragmentMyBinding
import com.mints.street.login.LoginActivity
import com.mints.street.main.home.HistoricalimageActivity
import kotlinx.android.synthetic.main.activity_moresettings.*
import kotlinx.android.synthetic.main.fragment_my.*
......@@ -25,14 +28,13 @@ import kotlinx.android.synthetic.main.fragment_my.*
* 个人中心页面
*/
class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickListener {
//弹窗
private var mBottomSheetDialog: BottomSheetDialog? = null
private var iv_weixin: ImageView? = null
private var ly_phone: LinearLayoutCompat? = null
private var cb_checked: CheckBox? = null
//checkbox是否选中
private var ischecked = false
override fun initContentView(inflater: LayoutInflater?,
container: ViewGroup?,
savedInstanceState: Bundle?) = R.layout.fragment_my
......@@ -41,11 +43,10 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL
override fun initData() {
super.initData()
initView()
initListener()
}
private fun initView() {
private fun initListener() {
//设置登录点击事件
binding.llMyLogin.setOnClickListener {
//创建弹窗
......@@ -63,21 +64,38 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL
//设置立即领取点击事件
binding.btTry.setOnClickListener {
startActivity(PermissionsActivity::class.java)
// startActivity(PermissionsActivity::class.java)
startActivity(OpenvipActivity::class.java)
}
ly_aboutus.setOnClickListener(this)
ly_moresettings.setOnClickListener(this)
aboutus.setOnClickListener(this)
moresettings.setOnClickListener(this)
}
private fun initView() {
aboutus.findViewById<TextView>(R.id.tv_title).text = "关于我们"
val userAgree = ContextCompat.getDrawable(context!!, R.mipmap.iv_about_us)
userAgree?.setBounds(0, 0, 56, 56)
aboutus.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(userAgree, null, null, null)
aboutus.findViewById<TextView>(R.id.tv_right).visibility = View.GONE
aboutus.findViewById<ImageView>(R.id.iv_right).visibility = View.VISIBLE
moresettings.findViewById<TextView>(R.id.tv_title).text = "更多设置"
val privacyAgree = ContextCompat.getDrawable(context!!, R.mipmap.iv_more_settings)
privacyAgree?.setBounds(0, 0, 56, 56)
moresettings.findViewById<TextView>(R.id.tv_title).setCompoundDrawables(privacyAgree, null, null, null)
moresettings.findViewById<TextView>(R.id.tv_right).visibility = View.GONE
moresettings.findViewById<ImageView>(R.id.iv_right).visibility = View.VISIBLE
}
override fun onClick(v: View?) {
when (v?.id) {
R.id.ly_aboutus -> {
// startActivity(AboutusActivity::class.java)
startActivity(HistoricalimageActivity::class.java)
R.id.aboutus -> {
startActivity(AboutusActivity::class.java)
// startActivity(PermissionsActivity::class.java)
}
R.id.ly_moresettings -> {
R.id.moresettings -> {
startActivity(MoresettingsActivity::class.java)
}
R.id.ll_my_login -> {
......
package com.mints.street.main.my
import android.graphics.Color
import android.os.Bundle
import android.view.View
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager
import com.fry.base.base.BaseActivity
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.adapter.EnterDestinationAdapter
import com.mints.street.adapter.GridMapAdapter
import com.mints.street.adapter.GridPaymentAdapter
import com.mints.street.databinding.ActivityOpenvipBinding
import kotlinx.android.synthetic.main.activity_openvip.*
import kotlinx.android.synthetic.main.include_header.*
class OpenvipActivity: BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>(), View.OnClickListener {
// private var vLayout: VirtualLayoutManager? = null
// private var mAdapter: DelegateAdapter? = null
private var vLayout:VirtualLayoutManager?=null
private var mAdapter:DelegateAdapter?=null
override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?)= R.layout.activity_openvip
override fun initData() {
super.initData()
initView()
initListener()
}
private fun initListener() {
iv_left_icon.setOnClickListener(this)
}
private fun initView() {
val layoutInflater = layoutInflater
// 初始化数据
// 初始化数据
val list: MutableList<View> = ArrayList()
val page1 = layoutInflater.inflate(R.layout.view_data_page1, null)
val page2 = layoutInflater.inflate(R.layout.view_data_page2, null)
val page3 = layoutInflater.inflate(R.layout.view_data_page3, null)
list.add(page1)
list.add(page2)
list.add(page3)
//设置显示的数据
cfp_data_viewpager.setViewList(list)
tv_title.text="成为会员"
tv_title.setTextColor(Color.WHITE)
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
iv_left_icon.visibility= View.VISIBLE
//recycleView管理
vLayout= VirtualLayoutManager(this)
mAdapter= DelegateAdapter(vLayout,false)
binding.listview.adapter=mAdapter
binding.listview.layoutManager=vLayout
mAdapter?.addAdapter(GridPaymentAdapter(this, listOf("1","2","3")))
}
override fun onClick(v: View?) {
when(v?.id){
R.id.iv_left_icon->finish()
}
}
}
package com.mints.street.main.my
import android.app.Application
import androidx.lifecycle.MutableLiveData
import com.mints.street.model.ApiModel
import com.mints.street.netwrok.base.HttpSubscribeImpl
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.http.BaseResponse
import me.goldze.mvvmhabit.utils.KLog
import java.util.HashMap
class OpenvipViewModel (application: Application): BaseViewModel(application) {
val data : MutableLiveData<String> = MutableLiveData()
/**
* 手机验证码
*
* @param mobile
*/
fun sendMobileCode(mobile: String) {
val vo = HashMap<String, Any>()
vo["mobile"] = mobile
vo["type"] = 1
ApiModel.sendMobileCode(lifecycleProvider,vo).safeSubscribe(
object : HttpSubscribeImpl<BaseResponse<Any>>(
this@OpenvipViewModel, true) {
override fun onBusinessSuccess(response: BaseResponse<Any>) {
KLog.e("sendMobileCode", response.result.toString())
}
override fun onError(e: Throwable) {
data.value = "失败"
KLog.e("sendMobileCode", "发送验证码错误")
}
})
}
}
package com.mints.street.main.my
import android.Manifest
import android.os.Build
import android.os.Bundle
import android.view.View
import com.fry.base.base.BaseActivity
import com.github.iielse.switchbutton.SwitchView
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ActivityMoresettingsBinding
import com.mints.street.common.Constant
import com.mints.street.databinding.ActivityPermissionsBinding
import com.mints.street.main.MainActivity
import com.tbruyelle.rxpermissions2.RxPermissions
import com.tencent.mmkv.MMKV
import kotlinx.android.synthetic.main.activity_permissions.*
import me.goldze.mvvmhabit.utils.ToastUtils
/**
* 描述:权限授权
* 作者:孟崔广
* 时间:2021/7/14 15:51
*/
class PermissionsActivity : BaseActivity<ActivityPermissionsBinding, PermissionsViewModel>(), View.OnClickListener {
class PermissionsActivity : BaseActivity<ActivityPermissionsBinding, PermissionsViewModel>() {
override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?)= R.layout.activity_permissions
override fun initData() {
super.initData()
initView()
initListener()
}
private fun initListener() {
btnPermissionsDont.setOnClickListener(this)
btnPermissionsNext.setOnClickListener(this)
}
private fun initView() {
sv_positioning.setOnStateChangedListener(object : SwitchView.OnStateChangedListener {
svPosition.setOnStateChangedListener(object : SwitchView.OnStateChangedListener {
override fun toggleToOn(view: SwitchView?) {
svPosition?.isOpened = true
}
override fun toggleToOff(view: SwitchView?) {
svPosition?.isOpened = false
}
})
svStrong.setOnStateChangedListener(object : SwitchView.OnStateChangedListener {
override fun toggleToOn(view: SwitchView?) {
svStrong?.isOpened = true
}
override fun toggleToOff(view: SwitchView?) {
svStrong?.isOpened = false
}
})
svReadmsg.setOnStateChangedListener(object : SwitchView.OnStateChangedListener {
override fun toggleToOn(view: SwitchView?) {
sv_positioning?.isOpened = true
svReadmsg?.isOpened = true
}
override fun toggleToOff(view: SwitchView?) {
sv_positioning?.isOpened = false
svReadmsg?.isOpened = false
}
})
}
override fun onClick(v: View?) {
when(v?.id){
R.id.btnPermissionsDont -> ToastUtils.showLong("请您同意授权,否则将无法使用APP功能")
R.id.btnPermissionsNext->{
val rxPermissions = RxPermissions(this)
rxPermissions.request(
if(svPosition.isOpened&&Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) Manifest.permission.ACCESS_BACKGROUND_LOCATION else "",
if(svPosition.isOpened) Manifest.permission.ACCESS_FINE_LOCATION else "",
if(svStrong.isOpened) Manifest.permission.WRITE_EXTERNAL_STORAGE else "",
if(svReadmsg.isOpened) Manifest.permission.READ_PHONE_STATE else ""
)
.subscribe {
startActivityThenKill(MainActivity::class.java)
}
MMKV.mmkvWithID(Constant.FIRST_OPEN_PERMISSIONS).encode(Constant.FIRST_OPEN_PERMISSIONS, true)
}
}
}
}
\ No newline at end of file
package com.mints.street.main.my
class PrivacypolicyActivity {
}
package com.mints.street.main.my
class UseragreementActivity {
}
......@@ -13,11 +13,6 @@ class UserManager {
companion object {
/**
* 游客 or 登录用户
*/
private const val IS_TEMP_USER = "is_temp_user"
/**
* 用户ID
*/
......@@ -38,46 +33,6 @@ class UserManager {
*/
private const val MOBILE = "mobile"
/**
* 姓名
*/
private const val REAL_NAME = "realName"
/**
* 支付宝
*/
private const val ALIPAY_ACCOUNT = "alipay_account"
/**
* 用户金币
*/
private const val USER_GOLD = "user_gold"
/**
* 用户总金币
*/
private const val USER_SUM_GOLD = "user_sum_gold"
/**
* 用户零钱
*/
private const val USER_CASH = "user_cash"
/**
* 是否老用户 true-老用户
*/
private const val USER_OLD = "user_old"
/**
* 猎豹游戏info
*/
private const val GAME_INFO = "game_info"
/**
* 广告隐藏标识
*/
private const val AD_SHOW_FLAG = "ad_show_flag"
/**
* 微信名称
*/
......@@ -93,6 +48,16 @@ class UserManager {
*/
private const val WX_OPENID = "wx_openid"
/**
* 是否购买会员
*/
private const val IS_FOREVER = "is_forever"
/**
* 会员是否永久
*/
private const val EXPIRETIME = "expiretime"
val INSTANCE: UserManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
UserManager()
}
......@@ -117,26 +82,19 @@ class UserManager {
if (user != null) {
val mobile: String? = user.mobile
val openid: String? = user.openid
if (mobile == null && openid == null) {
MMKV.mmkvWithID(IS_TEMP_USER).remove(IS_TEMP_USER)
} else {
MMKV.mmkvWithID(IS_TEMP_USER).encode(IS_TEMP_USER, mobile + openid)
}
MMKV.mmkvWithID(USER_ID).encode(USER_ID, user.pk_id.toString())
MMKV.mmkvWithID(CODE_ID).encode(CODE_ID, user.idcode.toString())
MMKV.mmkvWithID(CODE_ID).encode(CODE_ID, user.idcode)
if (!TextUtils.isEmpty(mobile)) {
MMKV.mmkvWithID(MOBILE).encode(MOBILE, mobile)
MMKV.mmkvWithID(ALIPAY_ACCOUNT)
.encode(ALIPAY_ACCOUNT, user.alipay_account.toString())
MMKV.mmkvWithID(USER_GOLD).encode(USER_GOLD, user.coin.toString())
MMKV.mmkvWithID(USER_CASH)
.encode(USER_CASH, String.format("%.2f", user.surplus))
MMKV.mmkvWithID(USER_SUM_GOLD).encode(USER_SUM_GOLD, user.sumCoin.toString())
MMKV.mmkvWithID(USER_OLD).encode(USER_OLD, !user.isFirstSignInApp)
MMKV.mmkvWithID(WX_NAME).encode(WX_NAME, user.nickname.toString())
MMKV.mmkvWithID(WX_HEADER).encode(WX_HEADER, user.head)
}
if (!TextUtils.isEmpty(user.nickname)) {
MMKV.mmkvWithID(WX_NAME).encode(WX_NAME, user.nickname)
}
MMKV.mmkvWithID(IS_FOREVER).encode(IS_FOREVER, user.isForever)
MMKV.mmkvWithID(EXPIRETIME).encode(EXPIRETIME, user.expireTime)
if (!TextUtils.isEmpty(openid)) {
MMKV.mmkvWithID(WX_OPENID).encode(WX_OPENID, openid)
MMKV.mmkvWithID(GAME_INFO).encode(GAME_INFO, user.gameInfo)
MMKV.mmkvWithID(REAL_NAME).encode(REAL_NAME, user.real_name)
}
}
}
......@@ -154,7 +112,7 @@ class UserManager {
* @return true为已登录 false 为未登录
*/
fun userIsLogin(): Boolean {
val kv = MMKV.mmkvWithID(IS_TEMP_USER).decodeString(IS_TEMP_USER, "")
val kv = MMKV.mmkvWithID(WX_OPENID).decodeString(WX_OPENID, "")
return !TextUtils.isEmpty(kv)
}
......@@ -182,100 +140,6 @@ class UserManager {
return kv.decodeString(CODE_ID, "")
}
/**
* 获取真实姓名
*/
fun getRealName(): String {
val kv = MMKV.mmkvWithID(REAL_NAME)
return kv.decodeString(REAL_NAME, "")
}
/**
* 设置真实姓名
*
* @param name
*/
fun setRealName(name: String?) {
val kv = MMKV.mmkvWithID(REAL_NAME)
kv.encode(REAL_NAME, name)
}
/**
* 是否老用户 true-老用户
*/
fun getUserOld(): Boolean {
val kv = MMKV.mmkvWithID(USER_OLD)
return kv.decodeBool(USER_OLD, false)
}
fun getAdShowFlag(): Boolean {
val kv = MMKV.mmkvWithID(AD_SHOW_FLAG)
return kv.decodeBool(AD_SHOW_FLAG, false)
}
/**
* 设置真实姓名
*
* @param userOld
*/
fun setUserOld(userOld: Boolean) {
val kv = MMKV.mmkvWithID(USER_OLD)
kv.encode(USER_OLD, userOld)
}
/**
* 获取支付宝账户
*/
fun getAlipayAccount(): String {
val kv = MMKV.mmkvWithID(ALIPAY_ACCOUNT)
return kv.decodeString(ALIPAY_ACCOUNT, "")
}
/**
* 设置支付宝账户
*
* @param alipay
*/
fun setAlipayAccount(alipay: String?) {
val kv = MMKV.mmkvWithID(ALIPAY_ACCOUNT)
kv.encode(ALIPAY_ACCOUNT, alipay)
}
fun getUserSumGold(): String {
val kv = MMKV.mmkvWithID(USER_SUM_GOLD)
return kv.decodeString(USER_SUM_GOLD, "")
}
/**
* 获取用户金币/积分
*/
fun getUserGold(): String {
val kv = MMKV.mmkvWithID(USER_GOLD)
return kv.decodeString(USER_GOLD, "")
}
/**
* 设置用户金币/积分
*
* @param gold
*/
fun setUserGold(gold: String?) {
val kv = MMKV.mmkvWithID(USER_GOLD)
kv.encode(USER_GOLD, gold)
}
/**
* 获取用户零钱
*/
fun getUserCash(): String {
val kv = MMKV.mmkvWithID(USER_CASH)
return kv.decodeString(USER_CASH, "")
}
fun getGameInfo(): String {
val kv = MMKV.mmkvWithID(GAME_INFO)
return kv.decodeString(GAME_INFO, "")
}
fun getWxName(): String {
val kv = MMKV.mmkvWithID(WX_NAME)
......@@ -292,60 +156,26 @@ class UserManager {
return kv.decodeString(WX_OPENID, "")
}
/**
* 设置用户零钱
*
* @param cash
*/
fun setUserCash(cash: String?) {
val kv = MMKV.mmkvWithID(USER_CASH)
kv.encode(WX_OPENID, cash)
}
fun setGameInfo(gameInfo: String?) {
val kv = MMKV.mmkvWithID(GAME_INFO)
kv.encode(GAME_INFO, gameInfo)
}
fun setWxName(wxName: String?) {
val kv = MMKV.mmkvWithID(WX_NAME)
kv.encode(WX_NAME, wxName)
}
fun setWxHeader(wxHeader: String?) {
val kv = MMKV.mmkvWithID(WX_HEADER)
kv.encode(WX_HEADER, wxHeader)
fun getIsforever(): Boolean {
val kv = MMKV.mmkvWithID(IS_FOREVER)
return kv.decodeBool(IS_FOREVER, false)
}
/**
* mobile
*
* @param mobile
*/
fun setMobile(mobile: String?) {
val kv = MMKV.mmkvWithID(MOBILE)
kv.encode(MOBILE, mobile)
fun getExpiretime(): Long {
val kv = MMKV.mmkvWithID(EXPIRETIME)
return kv.decodeLong(EXPIRETIME, 0)
}
fun setAdShowFlag(adShowFlag: Boolean) {
val kv = MMKV.mmkvWithID(AD_SHOW_FLAG)
kv.encode(AD_SHOW_FLAG, adShowFlag)
}
fun userLogout() {
MMKV.mmkvWithID(USER_ID).remove(USER_ID)
MMKV.mmkvWithID(CODE_ID).remove(CODE_ID)
MMKV.mmkvWithID(TOKEN_ID).remove(TOKEN_ID)
MMKV.mmkvWithID(REAL_NAME).remove(REAL_NAME)
MMKV.mmkvWithID(IS_TEMP_USER).remove(IS_TEMP_USER)
MMKV.mmkvWithID(ALIPAY_ACCOUNT).remove(ALIPAY_ACCOUNT)
MMKV.mmkvWithID(USER_GOLD).remove(USER_GOLD)
MMKV.mmkvWithID(USER_CASH).remove(USER_CASH)
MMKV.mmkvWithID(USER_OLD).remove(USER_OLD)
MMKV.mmkvWithID(WX_OPENID).remove(WX_OPENID)
MMKV.mmkvWithID(WX_NAME).remove(WX_NAME)
MMKV.mmkvWithID(WX_HEADER).remove(WX_HEADER)
// MMKV.mmkvWithID(GAME_INFO).remove(GAME_INFO)
MMKV.mmkvWithID(IS_FOREVER).remove(IS_FOREVER)
MMKV.mmkvWithID(EXPIRETIME).remove(EXPIRETIME)
}
}
\ No newline at end of file
package com.mints.street.model
import com.mints.street.api.MainApi
import com.mints.street.bean.AwardBean
import com.mints.street.bean.BaseResponse
import com.mints.street.bean.UserBean
import com.mints.street.netwrok.common.HttpManager
import com.trello.rxlifecycle2.LifecycleProvider
import io.reactivex.Observable
import me.goldze.mvvmhabit.http.BaseResponse
import retrofit2.Response
/**
* Created by 冯瑞雨 on 2021/7/2.
*/
object ApiModel {
/**
* 发送验证码
*/
fun sendMobileCode(lifecycleProvider: LifecycleProvider<Any>?
,map: Map<String, Any>): Observable<Response<BaseResponse<Any>>> {
return HttpManager.getInstance()
.execute(lifecycleProvider,MainApi.newInstance().sendMobileCode(map))
}
/**
* 登录
*/
......@@ -21,13 +30,22 @@ object ApiModel {
return HttpManager.getInstance()
.execute(lifecycleProvider,MainApi.newInstance().mobileLogin(map))
}
/**
* 获取用户配置信息
*
* 设备信息
*/
fun saveTerminalInfo(lifecycleProvider: LifecycleProvider<Any>?
,map: Map<String, Any>): Observable<Response<BaseResponse<Any>>> {
return HttpManager.getInstance()
.execute(lifecycleProvider,MainApi.newInstance().saveTerminalInfo(map))
}
fun coinMsg(lifecycleProvider: LifecycleProvider<Any>?): Observable<Response<BaseResponse<AwardBean>>> {
/**
* 开通会员
*/
fun openvip(lifecycleProvider: LifecycleProvider<Any>?
,map: Map<String, Any>): Observable<Response<BaseResponse<Any>>> {
return HttpManager.getInstance()
.execute(lifecycleProvider,MainApi.newInstance().getCoinMsg())
.execute(lifecycleProvider,MainApi.newInstance().getVipProductsByType(map))
}
}
\ No newline at end of file
package com.mints.street.netwrok.base
import com.mints.street.bean.BaseResponse
import me.goldze.mvvmhabit._enum.ViewStatus
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.http.BaseResponse
import me.goldze.mvvmhabit.http.ExceptionHandle
import me.goldze.mvvmhabit.http.ResponseThrowable
import me.goldze.mvvmhabit.utils.ToastUtils
......
package com.mints.street.netwrok.base;
import com.mints.street.bean.BaseResponse;
import io.reactivex.disposables.Disposable;
import me.goldze.mvvmhabit.http.BaseResponse;
import me.goldze.mvvmhabit.http.ResponseThrowable;
import retrofit2.Response;
......
package com.mints.street.netwrok.base
import com.mints.street.bean.BaseResponse
import io.reactivex.Observer
import io.reactivex.disposables.Disposable
import me.goldze.mvvmhabit.base.BaseViewModel
import me.goldze.mvvmhabit.http.BaseResponse
import retrofit2.Response
/**
......
......@@ -7,6 +7,9 @@ import androidx.annotation.NonNull;
import com.fry.base.BuildConfig;
import com.mints.street.netwrok.common.GsonConverterFactory;
import com.mints.street.netwrok.common.OkHttpInterceptor;
import com.mints.street.utils.encry.AESUtils;
import com.orhanobut.logger.Logger;
import java.util.concurrent.TimeUnit;
......@@ -23,11 +26,12 @@ import okhttp3.ConnectionPool;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.internal.platform.Platform;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
/**
* Created by jeme on 2019/1/31
* Created by mcg
*/
public class RetrofitClient {
......@@ -46,38 +50,31 @@ public class RetrofitClient {
OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder()
.cookieJar(new CookieJarImpl(new PersistentCookieStore(mContext)))
// .cache(cache)
// .addInterceptor()
// .addInterceptor(new CacheInterceptor(mContext))
// .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
.connectTimeout(mHttpConfig.getTimeOut(), TimeUnit.SECONDS)
.writeTimeout(mHttpConfig.getTimeOut(), TimeUnit.SECONDS)
.readTimeout(mHttpConfig.getTimeOut(), TimeUnit.SECONDS)
.connectionPool(new ConnectionPool(8, 15, TimeUnit.SECONDS));
// 这里你可以根据自己的机型设置同时连接的个数和时间,我这里8个,和每个保持时间为10s
if (configuation.getInterceptors() != null) {
for (Interceptor interceptor : configuation.getInterceptors()) {
clientBuilder.addInterceptor(interceptor);
if (BuildConfig.DEBUG) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(message -> {
if (TextUtils.isEmpty(message)) return;
String s = message.substring(0, 1);
String request = message.substring(0, 4);
if ("{".equals(s) || "[".equals(s)) {
Logger.json(message);
} else if (request.contains("-->") || request.contains("<--")) {
Logger.d("Method" + message);
} else {
Logger.d("params:" + message);
}
});
logging.setLevel(HttpLoggingInterceptor.Level.BODY);
clientBuilder.interceptors().add(logging);
}
if(BuildConfig.IS_DEV) {
clientBuilder.addInterceptor(new LoggingInterceptor
.Builder()
//是否开启日志打印
.loggable(BuildConfig.DEBUG)
//打印的等级
.setLevel(Level.BASIC)
// 打印类型
.log(Platform.INFO)
// request的Tag
.request("Request")
// Response的Tag
.response("Request")
// .addHeader("log-header", "I am the log request header.") // 添加打印头, 注意 key 和 value 都不能是中文
.build()
);
}
OkHttpInterceptor okHttpInterceptor = new OkHttpInterceptor(AESUtils.getDefaultKey());
clientBuilder.interceptors().add(okHttpInterceptor);
mOkHttpClient = clientBuilder.build();
mRetrofit = new Retrofit.Builder()
.client(mOkHttpClient)
......@@ -97,25 +94,4 @@ public class RetrofitClient {
}
return mRetrofit.create(service);
}
/**
* /**
* execute your customer API
* For example:
* MyApiService service =
* RetrofitClient.getInstance(MainActivity.this).create(MyApiService.class);
* <p>
* RetrofitClient.getInstance(MainActivity.this)
* .execute(service.lgon("name", "password"), subscriber)
* * @param subscriber
*/
public static <T> T execute(Observable<T> observable, Observer<T> subscriber) {
observable.subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(subscriber);
return null;
}
}
package com.mints.street.netwrok.common;
import com.google.gson.Gson;
import com.mints.street.bean.BaseResponse;
import com.mints.street.manager.UserManager;
import java.io.IOException;
......@@ -12,7 +13,6 @@ import java.lang.reflect.Type;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import me.goldze.mvvmhabit.http.BaseResponse;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
......
package com.mints.street.netwrok.common;
import com.mints.street.bean.BaseResponse;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.ObservableTransformer;
import io.reactivex.functions.Function;
import me.goldze.mvvmhabit.http.BaseResponse;
import retrofit2.Response;
/**
......
......@@ -3,10 +3,10 @@ package com.mints.street.netwrok.common;
import android.annotation.SuppressLint;
import com.fry.base.global.Constants;
import com.mints.street.bean.BaseResponse;
import com.mints.street.netwrok.base.HttpConfiguation;
import com.mints.street.netwrok.base.IHttpResponseListener;
import com.mints.street.netwrok.base.RetrofitClient;
import com.mints.street.utils.encry.AESUtils;
import com.trello.rxlifecycle2.LifecycleProvider;
import io.reactivex.Observable;
......@@ -17,7 +17,6 @@ import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Function;
import io.reactivex.schedulers.Schedulers;
import me.goldze.mvvmhabit.http.BaseResponse;
import me.goldze.mvvmhabit.http.ResponseThrowable;
import me.goldze.mvvmhabit.utils.RxUtils;
import retrofit2.Response;
......@@ -42,7 +41,6 @@ public class HttpManager {
private HttpManager() {
mDefaultClient = new RetrofitClient(
HttpConfiguation.create(Constants.getBaseUrl())
.addInterceptor(new OkHttpInterceptor(AESUtils.getDefaultKey()))
);
}
......@@ -80,60 +78,4 @@ public class HttpManager {
.compose(RxUtils.exceptionTransformer())
.compose(HttpErrorProcess.businessExceptionTransformer());
}
@SuppressLint("CheckResult")
public <B extends BaseResponse, T extends Response<B>>
void execute(LifecycleProvider life, final Observable<T> observable, IHttpResponseListener<B> listener) {
Observable<T> newObservable = Observable.just(observable)
.observeOn(Schedulers.io())
.flatMap((Function<Observable<T>, ObservableSource<T>>) tObservable -> {
// ServerTimeHelper.requestServerTime();
return observable;
})
.observeOn(AndroidSchedulers.mainThread());
if (life != null) {
newObservable = newObservable.compose(RxUtils.bindToLifecycle(life));
}
newObservable
.compose(RxUtils.schedulersTransformer())
.compose(RxUtils.exceptionTransformer())
.compose(HttpErrorProcess.businessExceptionTransformer())
.doOnSubscribe(new Consumer<Disposable>() {
@Override
public void accept(Disposable disposable) throws Exception {
if (listener != null) {
listener.onStart(disposable);
}
}
})
.doFinally(new Action() {
@Override
public void run() throws Exception {
if (listener != null) {
listener.onCompleted();
}
}
})
.subscribe(t -> {
if (listener != null) {
// listener.onCompleted();
if (!listener.onParseResponse(t)) {
if (t.body() != null && t.body().isOk()) {
listener.onBusinessSuccess(t.body());
} else {
listener.onBusinessFail(t.body());
}
}
}
}, throwable -> {
if (listener != null && throwable instanceof ResponseThrowable) {
listener.onFailed((ResponseThrowable) throwable);
}
throwable.printStackTrace();
}, () -> {
});
}
}
......@@ -3,10 +3,10 @@ package com.mints.street.netwrok.common
import android.text.TextUtils
import android.util.Log
import com.bytedance.hume.readapk.HumeSDK
import com.fry.base.bean.AppRequest
import com.google.gson.Gson
import com.mints.street.AppApplication
import com.mints.street.BuildConfig
import com.mints.street.bean.AppRequest
import com.mints.street.manager.UserManager
import com.mints.street.utils.CommonUtils
import com.mints.street.utils.encry.AESUtils
......@@ -165,10 +165,6 @@ class OkHttpInterceptor(aesKey: String) : Interceptor {
// 解密
try {
val json = JSONObject(rspString)
// if(!json.isNull("status")&& TextUtils.equals(json["status"].toString(),"401")){
// return
// }
if (!json.isNull("data")) {
val data = json["data"]
rspString = AESUtils.detrypt(data.toString(), aesKey)
......
package com.mints.street.splash
import android.os.Bundle
import android.view.View
import com.bumptech.glide.Glide
import com.fry.base.BR
import com.fry.base.base.BaseActivity
import com.mints.street.R
import com.mints.street.databinding.ActivityGuideBinding
import com.mints.street.main.MainActivity
import kotlinx.android.synthetic.main.activity_guide.*
class GuideActivity : BaseActivity<ActivityGuideBinding,GuideBindingViewModel>(), View.OnClickListener {
override fun initContentView(savedInstanceState: Bundle?)=R.layout.activity_guide
override fun initVariableId()= BR.viewModel
override fun initData() {
super.initData()
initView()
initListener()
}
private fun initListener() {
bt_enter.setOnClickListener(this)
}
private fun initView() {
Glide.with(this).asGif().load(R.mipmap.earth).into(iv_earth);
}
override fun onClick(v: View?) {
when(v?.id){
R.id.bt_enter->{
startActivityThenKill(MainActivity::class.java)
}
}
}
}
\ No newline at end of file
package com.mints.street.splash
import android.app.Application
import me.goldze.mvvmhabit.base.BaseViewModel
class GuideBindingViewModel(application: Application) :BaseViewModel(application){
}
......@@ -12,10 +12,14 @@ import com.bytedance.msdk.api.splash.TTSplashAdLoadCallback
import com.fry.base.base.BaseActivity
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.common.Constant
import com.mints.street.common.DeviceInfo
import com.mints.street.databinding.ActivitySplashBinding
import com.mints.street.main.MainActivity
import com.mints.street.main.my.PermissionsActivity
import com.mints.street.manager.CsjGroMoreManager
import com.mints.street.manager.UserManager
import com.tencent.mmkv.MMKV
/**
* 描述:gromore开屏页
......@@ -45,6 +49,7 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
}
//校验App签名
checkAppSign()
}
......@@ -53,7 +58,7 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
if (mForceGoMain) {
goToMainActivity()
}
if (onPaused ) {
if (onPaused) {
// 这种情况下,百度开屏广告不能在onAdDismiss中跳转,需要自己在onResume中跳转主页。
goToMainActivity()
}
......@@ -68,7 +73,6 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
override fun onStop() {
super.onStop()
mForceGoMain = true
}
......@@ -163,6 +167,11 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
* 跳转到主页面
*/
private fun goToMainActivity() {
if(MMKV.mmkvWithID(Constant.FIRST_OPEN_PERMISSIONS).decodeBool(Constant.FIRST_OPEN_PERMISSIONS, false)){
// 非新用户
startActivityThenKill(MainActivity::class.java)
}else{
startActivityThenKill(PermissionsActivity::class.java)
}
}
}
\ No newline at end of file
package com.mints.street.utils;
import android.text.Editable;
import android.text.Selection;
import android.text.TextWatcher;
import android.widget.EditText;
/**
* 验卷,每四位自动跟横线
* Created by mengcuiguang on 2016/8/15.
*/
public class BackInputUtil {
public static void bankCardNumAddSpace(final EditText mEditText) {
mEditText.addTextChangedListener(new TextWatcher() {
private Editable etable;
int beforeTextLength = 0;
int onTextLength = 0;
boolean isChanged = false;
int location = 0;//记录光标的位置
private char[] tempChar;
private StringBuffer buffer = new StringBuffer();
int konggeNumberB = 0;
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
beforeTextLength = s.length();
if (buffer.length() > 0) {
buffer.delete(0, buffer.length());
}
konggeNumberB = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == ' ') {
konggeNumberB++;
}
}
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
onTextLength = s.length();
buffer.append(s.toString());
if (onTextLength == beforeTextLength || onTextLength <= 3 || isChanged) {
isChanged = false;
return;
}
isChanged = true;
}
@Override
public void afterTextChanged(Editable s) {
if (isChanged) {
location = mEditText.getSelectionEnd();
int index = 0;
while (index < buffer.length()) {
if (buffer.charAt(index) == ' ') {
buffer.deleteCharAt(index);
} else {
index++;
}
}
index = 0;
int konggeNumberC = 0;
while (index < buffer.length()) {
//银行卡号的话需要改这里
if ((index == 4 || index == 9 || index == 14 || index == 19)) {
buffer.insert(index, ' ');
konggeNumberC++;
}
index++;
}
if (konggeNumberC > konggeNumberB) {
location += (konggeNumberC - konggeNumberB);
}
tempChar = new char[buffer.length()];
buffer.getChars(0, buffer.length(), tempChar, 0);
String str = buffer.toString();
if (location > str.length()) {
location = str.length();
} else if (location < 0) {
location = 0;
}
mEditText.setText(str);
etable = mEditText.getText();
Selection.setSelection(etable, location);
isChanged = false;
}
}
});
}
//手机号码的格式
public static void phoneNumAddSpace(final EditText mEditText) {
mEditText.addTextChangedListener(new TextWatcher() {
int beforeTextLength = 0;
int onTextLength = 0;
boolean isChanged = false;
int location = 0;// 记录光标的位置
private char[] tempChar;
private StringBuffer buffer = new StringBuffer();
int konggeNumberB = 0;
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
beforeTextLength = s.length();
if (buffer.length() > 0) {
buffer.delete(0, buffer.length());
}
konggeNumberB = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == ' ') {
konggeNumberB++;
}
}
}
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
onTextLength = s.length();
buffer.append(s.toString());
if (onTextLength == beforeTextLength || onTextLength <= 3
|| isChanged) {
isChanged = false;
return;
}
isChanged = true;
}
@Override
public void afterTextChanged(Editable s) {
if (isChanged) {
location = mEditText.getSelectionEnd();
int index = 0;
while (index < buffer.length()) {
if (buffer.charAt(index) == ' ') {
buffer.deleteCharAt(index);
} else {
index++;
}
}
index = 0;
int konggeNumberC = 0;
while (index < buffer.length()) {
if ((index == 3 || index == 8)) {
buffer.insert(index, ' ');
konggeNumberC++;
}
index++;
}
if (konggeNumberC > konggeNumberB) {
location += (konggeNumberC - konggeNumberB);
}
tempChar = new char[buffer.length()];
buffer.getChars(0, buffer.length(), tempChar, 0);
String str = buffer.toString();
if (location > str.length()) {
location = str.length();
} else if (location < 0) {
location = 0;
}
mEditText.setText(str);
Editable etable = mEditText.getText();
Selection.setSelection(etable, location);
isChanged = false;
}
}
});
}
}
package com.mints.street.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.provider.Settings;
import android.telephony.TelephonyManager;
import com.mints.street.AppApplication;
import java.io.UnsupportedEncodingException;
import java.util.UUID;
/**
* 描述:google生成android设备UUID
* 作者:孟崔广
* 时间:2018/5/9 20:03
* 邮箱:mengcg@xiaojinqb.cn
*/
public class DeviceUuidFactory {
protected static final String PREFS_FILE = "device_id.xml";
protected static final String PREFS_DEVICE_ID = "device_id";
protected static UUID uuid;
public DeviceUuidFactory() {
Context context= AppApplication.Companion.getContext();
if (uuid == null) {
synchronized (DeviceUuidFactory.class) {
if (uuid == null) {
final SharedPreferences prefs = context.getSharedPreferences(PREFS_FILE, 0);
final String id = prefs.getString(PREFS_DEVICE_ID, null);
if (id != null) {
// Use the ids previously computed and stored in the prefs file
uuid = UUID.fromString(id);
} else {
final String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
// Use the Android ID unless it's broken, in which case fallback on deviceId,
// unless it's not available, then fallback on a random number which we store
// to a prefs file
try {
if (!"9774d56d682e549c".equals(androidId)) {
uuid = UUID.nameUUIDFromBytes(androidId.getBytes("utf8"));
} else {
final String deviceId = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
uuid = deviceId != null ? UUID.nameUUIDFromBytes(deviceId.getBytes("utf8")) : UUID.randomUUID();
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
// Write the value out to the prefs file
prefs.edit().putString(PREFS_DEVICE_ID, uuid.toString()).commit();
}
}
}
}
}
/**
* Returns a unique UUID for the current android device. As with all UUIDs, this unique ID is "very highly likely"
* to be unique across all Android devices. Much more so than ANDROID_ID is.
* <p>
* The UUID is generated by using ANDROID_ID as the base key if appropriate, falling back on
* TelephonyManager.getDeviceID() if ANDROID_ID is known to be incorrect, and finally falling back
* on a random UUID that's persisted to SharedPreferences if getDeviceID() does not return a
* usable value.
* <p>
* In some rare circumstances, this ID may change. In particular, if the device is factory reset a new device ID
* may be generated. In addition, if a user upgrades their phone from certain buggy implementations of Android 2.2
* to a newer, non-buggy version of Android, the device ID may change. Or, if a user uninstalls your app on
* a device that has neither a proper Android ID nor a Device ID, this ID may change on reinstallation.
* <p>
* Note that if the code falls back on using TelephonyManager.getDeviceId(), the resulting ID will NOT
* change after a factory reset. Something to be aware of.
* <p>
* Works around a bug in Android 2.2 for many devices when using ANDROID_ID directly.
*
* @return a UUID that may be used to uniquely identify your device for most purposes.
* @see //http://code.google.com/p/android/issues/detail?id=10603
*/
public UUID getDeviceUuid() {
return uuid;
}
}
package com.mints.street.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import androidx.viewpager.widget.ViewPager;
import com.fry.base.utils.DensityUtils;
import com.mints.street.R;
import com.mints.street.adapter.CoverFlowAdapter;
import com.mints.street.adapter.listener.OnPageSelectListener;
import java.util.ArrayList;
import java.util.List;
public class CoverFlowViewPager extends RelativeLayout implements OnPageSelectListener {
/**
* 适配器
*/
private CoverFlowAdapter mAdapter;
/**
* 用于左右滚动
*/
private ViewPager mViewPager;
/**
* 需要显示的视图集合
*/
private List<View> mViewList = new ArrayList<>();
private OnPageSelectListener listener;
public CoverFlowViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
inflate(context, R.layout.widget_cover_flow, this);
mViewPager = findViewById(R.id.vp_conver_flow);
// 365dp 380
int marginWidth = DensityUtils.dip2px(50);
int displayWidth = DensityUtils.getDisplayWidth(getContext());
int height = DensityUtils.dip2px( 150);
LayoutParams layoutParams = new LayoutParams(displayWidth - marginWidth, height);
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
mViewPager.setLayoutParams(layoutParams);
init();
}
/**
* 初始化方法
*/
private void init() {
// 构造适配器,传入数据源
mAdapter = new CoverFlowAdapter(mViewList, getContext());
// 设置选中的回调
mAdapter.setOnPageSelectListener(this);
// 设置适配器
mViewPager.setAdapter(mAdapter);
// 设置滑动的监听,因为adpter实现了滑动回调的接口,所以这里直接设置adpter
mViewPager.addOnPageChangeListener(mAdapter);
// 预加载个数
mViewPager.setOffscreenPageLimit(5);
// 设置触摸事件的分发
setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// 传递给ViewPager 进行滑动处理
return mViewPager.dispatchTouchEvent(event);
}
});
}
/**
* 设置显示的数据,进行一层封装
*
* @param lists
*/
public void setViewList(List<View> lists) {
if (lists == null) {
return;
}
mViewList.clear();
for (View view : lists) {
FrameLayout layout = new FrameLayout(getContext());
// 设置padding 值,默认缩小
layout.setPadding(CoverFlowAdapter.sWidthPadding, CoverFlowAdapter.sHeightPadding, CoverFlowAdapter.sWidthPadding, CoverFlowAdapter.sHeightPadding);
layout.addView(view);
mViewList.add(layout);
}
// 刷新数据
mAdapter.notifyDataSetChanged();
}
/**
* 当将某一个作为最中央时的回调
*
* @param listener
*/
public void setOnPageSelectListener(OnPageSelectListener listener) {
this.listener = listener;
}
// 显示的回调
@Override
public void select(int position) {
if (listener != null) {
listener.select(position);
}
}
}
package com.mints.street.widget;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.TranslateAnimation;
import androidx.core.widget.NestedScrollView;
/**
* 有弹性的ScrollView
* 实现下拉弹回和上拉弹回
*
* @author zhangjg
* @date Feb 13, 2014 6:11:33 PM
*/
public class ElasticScrollView extends NestedScrollView {
private static final String TAG = "ElasticScrollView";
//移动因子, 是一个百分比, 比如手指移动了100px, 那么View就只移动50px
//目的是达到一个延迟的效果
private static final float MOVE_FACTOR = 0.5f;
//松开手指后, 界面回到正常位置需要的动画时间
private static final int ANIM_TIME = 300;
//ScrollView的子View, 也是ScrollView的唯一一个子View
private View contentView;
//手指按下时的Y值, 用于在移动时计算移动距离
//如果按下时不能上拉和下拉, 会在手指移动时更新为当前手指的Y值
private float startY;
//用于记录正常的布局位置
private Rect originalRect = new Rect();
//手指按下时记录是否可以继续下拉
private boolean canPullDown = false;
//手指按下时记录是否可以继续上拉
private boolean canPullUp = false;
//在手指滑动的过程中记录是否移动了布局
private boolean isMoved = false;
public ElasticScrollView(Context context) {
super(context);
}
public ElasticScrollView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
if (getChildCount() > 0) {
contentView = getChildAt(0);
}
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
if (contentView == null) return;
//ScrollView中的唯一子控件的位置信息, 这个位置信息在整个控件的生命周期中保持不变
originalRect.set(contentView.getLeft(), contentView.getTop(), contentView
.getRight(), contentView.getBottom());
}
/**
* 在触摸事件中, 处理上拉和下拉的逻辑
*/
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (contentView == null) {
return super.dispatchTouchEvent(ev);
}
int action = ev.getAction();
switch (action) {
case MotionEvent.ACTION_DOWN:
//判断是否可以上拉和下拉
canPullDown = isCanPullDown();
canPullUp = isCanPullUp();
//记录按下时的Y值
startY = ev.getY();
break;
case MotionEvent.ACTION_UP:
if (!isMoved) break; //如果没有移动布局, 则跳过执行
// 开启动画
TranslateAnimation anim = new TranslateAnimation(0, 0, contentView.getTop(),
originalRect.top);
anim.setDuration(ANIM_TIME);
anim.setInterpolator(new AccelerateInterpolator());
contentView.startAnimation(anim);
// 设置回到正常的布局位置
contentView.layout(originalRect.left, originalRect.top,
originalRect.right, originalRect.bottom);
//将标志位设回false
canPullDown = false;
canPullUp = false;
isMoved = false;
break;
case MotionEvent.ACTION_MOVE:
//在移动的过程中, 既没有滚动到可以上拉的程度, 也没有滚动到可以下拉的程度
if (!canPullDown && !canPullUp) {
startY = ev.getY();
canPullDown = isCanPullDown();
canPullUp = isCanPullUp();
break;
}
//计算手指移动的距离
float nowY = ev.getY();
int deltaY = (int) (nowY - startY);
//是否应该移动布局
boolean shouldMove =
(canPullDown && deltaY > 0) //可以下拉, 并且手指向下移动
|| (canPullUp && deltaY < 0) //可以上拉, 并且手指向上移动
|| (canPullUp && canPullDown); //既可以上拉也可以下拉(这种情况出现在ScrollView包裹的控件比ScrollView还小)
if (shouldMove) {
//计算偏移量
int offset = (int) (deltaY * MOVE_FACTOR);
//随着手指的移动而移动布局
contentView.layout(originalRect.left, originalRect.top + offset,
originalRect.right, originalRect.bottom + offset);
isMoved = true; //记录移动了布局
}
break;
default:
break;
}
return super.dispatchTouchEvent(ev);
}
/**
* 判断是否滚动到顶部
*/
private boolean isCanPullDown() {
return getScrollY() == 0 ||
contentView.getHeight() < getHeight() + getScrollY();
}
/**
* 判断是否滚动到底部
*/
private boolean isCanPullUp() {
return contentView.getHeight() <= getHeight() + getScrollY();
}
}
\ No newline at end of file
package com.mints.street.widget;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.text.TextPaint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.TintTypedArray;
import com.mints.street.R;
import java.util.ArrayList;
import java.util.List;
/**
* Created by 孟崔广
*/
public class HorizontalselectedView extends View {
private Context context;
private List<String> strings = new ArrayList<String>();//数据源字符串数组
private int seeSize = 5;//可见个数
private int anInt;//每个字母所占的大小;
private TextPaint textPaint;
private boolean firstVisible = true;
private int width;//控件宽度
private int height;//控件高度
private Paint selectedPaint;//被选中文字的画笔
private int n;
private float downX;
private float anOffset;
private float selectedTextSize;
private int selectedColor;
private float textSize;
private int textColor;
private Rect rect = new Rect();
;
private int textWidth = 0;
private int textHeight = 0;
private int centerTextHeight = 0;
public HorizontalselectedView(Context context) {
this(context, null);
}
public HorizontalselectedView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public HorizontalselectedView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.context = context;
setWillNotDraw(false);
setClickable(true);
initAttrs(attrs);//初始化属性
initPaint();//初始化画笔
}
/**
* 初始化画笔
*/
private void initPaint() {
textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
textPaint.setTextSize(textSize);
textPaint.setColor(textColor);
selectedPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG);
selectedPaint.setColor(selectedColor);
selectedPaint.setTextSize(selectedTextSize);
}
/**
* 初始化属性
* @param attrs
*/
private void initAttrs(AttributeSet attrs) {
TintTypedArray tta = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
R.styleable.HorizontalselectedView);
//两种字体颜色和字体大小
seeSize = tta.getInteger(R.styleable.HorizontalselectedView_HorizontalselectedViewSeesize, 5);
selectedTextSize = tta.getFloat(R.styleable.HorizontalselectedView_HorizontalselectedViewSelectedTextSize, 50);
selectedColor = tta.getColor(R.styleable.HorizontalselectedView_HorizontalselectedViewSelectedTextColor, context.getResources().getColor(android.R.color.black));
textSize = tta.getFloat(R.styleable.HorizontalselectedView_HorizontalselectedViewTextSize, 40);
textColor = tta.getColor(R.styleable.HorizontalselectedView_HorizontalselectedViewTextColor, context.getResources().getColor(android.R.color.darker_gray));
}
@Override
public boolean onTouchEvent(MotionEvent event) {
Log.e("action", "onTouchEvent: " + event.getAction());
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
downX = event.getX();//获得点下去的x坐标
break;
case MotionEvent.ACTION_MOVE://复杂的是移动时的判断
float scrollX = event.getX();
if (n != 0 && n != strings.size() - 1)
anOffset = scrollX - downX;//滑动时的偏移量,用于计算每个是数据源文字的坐标值
else {
anOffset = (float) ((scrollX - downX) / 1.5);//当滑到两端的时候添加一点阻力
}
if (scrollX > downX) {
//向右滑动,当滑动距离大于每个单元的长度时,则改变被选中的文字。
if (scrollX - downX >= anInt) {
if (n > 0) {
anOffset = 0;
n = n - 1;
downX = scrollX;
}
}
} else {
//向左滑动,当滑动距离大于每个单元的长度时,则改变被选中的文字。
if (downX - scrollX >= anInt) {
if (n < strings.size() - 1) {
anOffset = 0;
n = n + 1;
downX = scrollX;
}
}
}
invalidate();
break;
case MotionEvent.ACTION_UP:
//抬起手指时,偏移量归零,相当于回弹。
anOffset = 0;
invalidate();
break;
default:
break;
}
return super.onTouchEvent(event);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (firstVisible) {//第一次绘制的时候得到控件 宽高;
width = getWidth();
height = getHeight();
anInt = width / seeSize;
firstVisible = false;
}
if (n >= 0 && n <= strings.size() - 1) {//加个保护;防止越界
String s = strings.get(n);//得到被选中的文字
/**
* 得到被选中文字 绘制时所需要的宽高
*/
selectedPaint.getTextBounds(s, 0, s.length(), rect);
//3从矩形区域中读出文本内容的宽高
int centerTextWidth = rect.width();
centerTextHeight = rect.height();
canvas.drawText(strings.get(n), getWidth() / 2 - centerTextWidth / 2 + anOffset, getHeight() / 2 + centerTextHeight / 2, selectedPaint);//绘制被选中文字,注意点是y坐标
for (int i = 0; i < strings.size(); i++) {//遍历strings,把每个地方都绘制出来,
if (n > 0 && n < strings.size() - 1) {//这里主要是因为strings数据源的文字长度不一样,为了让被选中两边文字距离中心宽度一样,我们取得左右两个文字长度的平均值
textPaint.getTextBounds(strings.get(n - 1), 0, strings.get(n - 1).length(), rect);
int width1 = rect.width();
textPaint.getTextBounds(strings.get(n + 1), 0, strings.get(n + 1).length(), rect);
int width2 = rect.width();
textWidth = (width1 + width2) / 2;
}
if (i == 0) {//得到高,高度是一样的,所以无所谓
textPaint.getTextBounds(strings.get(0), 0, strings.get(0).length(), rect);
textHeight = rect.height();
}
if (i != n)
canvas.drawText(strings.get(i), (i - n) * anInt + getWidth() / 2 - textWidth / 2 + anOffset, getHeight() / 2 + textHeight / 2, textPaint);//画出每组文字
}
}
}
/**
* 改变中间可见文字的数目
*
* @param seeSizes 可见数
*/
public void setSeeSize(int seeSizes) {
if (seeSize > 0) {
seeSize = seeSizes;
invalidate();
}
}
/**
* 向左移动一个单元
*/
public void setAnLeftOffset() {
if (n < strings.size() - 1) {
n = n + 1;
invalidate();
}
}
/**
* 向右移动一个单元
*/
public void setAnRightOffset() {
if (n > 0) {
n = n - 1;
invalidate();
}
}
/**
* 设置个数据源
*
* @param strings 数据源String集合
*/
public void setData(List<String> strings) {
this.strings = strings;
n = strings.size() / 2;
invalidate();
}
/**
* 获得被选中的文本
*
* @return 被选中的文本
*/
public String getSelectedString() {
if (strings.size() != 0) {
return strings.get(n);
}
return null;
}
}
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/shape_bg_payment" android:state_enabled="true"/>
<item android:drawable="@drawable/shape_bg_payment_down" android:state_enabled="false"/>
</selector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners
android:topLeftRadius="20dp"
android:bottomLeftRadius="20dp"/>
<gradient
android:startColor="#73FFFFFF"
android:endColor="#00FFFFFF"
android:angle="0"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<corners android:radius="8dp" />
<stroke android:color="#99FF9800" android:width="1dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#66EDA412"/>
<corners android:radius="8dp"/>
<stroke android:color="#99FF9800" android:width="1dp"/>
</shape>
\ No newline at end of file
......@@ -2,6 +2,6 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#2196F3" />
<corners android:radius="21dp" />
<corners android:radius="30dp" />
</shape>
\ No newline at end of file
......@@ -7,6 +7,6 @@
android:color="#74000000"
/>
<solid android:color="#ffffffff" />
<corners android:radius="21dp" />
<corners android:radius="30dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/color_FF9837" />
<solid android:color="#F1CA54" />
<corners android:radius="100dp" />
</shape>
\ No newline at end of file
......@@ -3,6 +3,6 @@
android:shape="rectangle">
<solid android:color="#ffffffff" />
<corners android:radius="4dp" />
<corners android:radius="10dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="viewModel"
type="com.mints.street.main.my.BindMobileViewModel" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<include layout="@layout/include_header" />
<com.mints.street.widget.ElasticScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="50dp"
android:src="@mipmap/ic_launcher_main" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="30dp"
android:layout_marginRight="30dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="手机号:" />
<com.mints.street.widget.ClearEditText
android:id="@+id/etLoginMobile"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="30dp"
android:background="@null"
android:gravity="center_vertical"
android:hint="请输入手机号"
android:inputType="number"
android:maxLength="13"
android:maxLines="1"
android:textColor="@color/color_172B54"
android:textColorHint="@color/color_BEC2CC"
android:textSize="12sp" />
</LinearLayout>
<View
style="@style/line_3"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="验证码:" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="30dp">
<com.mints.street.widget.ClearEditText
android:id="@+id/etLoginCode"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_marginRight="120dp"
android:background="@null"
android:hint="请输入验证码"
android:inputType="number"
android:maxLength="4"
android:maxLines="1"
android:textColor="@color/color_172B54"
android:textColorHint="@color/color_BEC2CC"
android:textSize="12sp" />
<TextView
android:id="@+id/tvLoginSendcode"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:gravity="center"
android:text="发送验证码"
android:textColor="@color/color_FF9837"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
<View
style="@style/line_3"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp" />
<TextView
android:id="@+id/tvLoginNext"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="40dp"
android:layout_marginTop="30dp"
android:layout_marginRight="40dp"
android:background="@drawable/shape_main"
android:gravity="center"
android:text="绑定手机号"
android:textColor="@color/white"
android:textSize="14sp" />
</LinearLayout>
</com.mints.street.widget.ElasticScrollView>
</LinearLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="com.mints.street.splash.GuideBindingViewModel" />
</data>
<LinearLayout
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_earth"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_marginTop="20dp"
android:id="@+id/tv1"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_bg_guide_tv"
android:text="国内外全覆盖街景"
android:drawableLeft="@mipmap/satellite"
android:paddingLeft="10dp"/>
<TextView
android:layout_marginTop="20dp"
android:id="@+id/tv2"
android:layout_below="@+id/tv1"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_bg_guide_tv"
android:text="VR沉浸式景点体验"
android:drawableLeft="@mipmap/satellite"
android:paddingLeft="10dp"/>
<TextView
android:layout_marginTop="20dp"
android:id="@+id/tv3"
android:layout_below="@+id/tv2"
android:textSize="20sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/shape_bg_guide_tv"
android:text="高清卫星地图/历史影像"
android:drawableLeft="@mipmap/satellite"
android:paddingLeft="10dp"/>
<Button
android:id="@+id/bt_enter"
android:layout_marginTop="70dp"
android:layout_below="@+id/tv3"
android:layout_width="250dp"
android:layout_height="40dp"
android:textSize="18sp"
android:text="立即体验"
android:gravity="center"
android:background="@drawable/shape_login_bg"/>
</RelativeLayout>
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -5,13 +5,95 @@
<data>
<variable
name="ViewModel"
name="viewModel"
type="com.mints.street.main.home.HistoricalimageModel" />
</data>
<LinearLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
android:layout_height="20dp"
android:gravity="center"
android:textColor="@color/black"
android:text="V" />
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@android:color/darker_gray"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal">
<TextView
android:id="@+id/iv_left"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_weight="1"
android:gravity="center"
android:text="<"
android:textSize="16sp" />
<com.mints.street.widget.HorizontalselectedView
android:id="@+id/hsMain"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_weight="30"
app:HorizontalselectedViewSeesize="5"
app:HorizontalselectedViewSelectedTextColor="@color/black"
app:HorizontalselectedViewSelectedTextSize="60"
app:HorizontalselectedViewTextColor="@color/gray"
app:HorizontalselectedViewTextSize="40" />
<TextView
android:id="@+id/iv_right"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:gravity="center"
android:text=">"
android:textSize="16sp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@android:color/darker_gray"></View>
<Button
android:id="@+id/bt_main"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="100dp"
android:text="点击获得被选文本" />
<TextView
android:padding="5dp"
android:gravity="center"
android:id="@+id/tvMain"
android:layout_gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:textSize="20sp"
android:layout_marginTop="20dp"
android:background="@color/gray" />
</LinearLayout>
</layout>
\ No newline at end of file
......@@ -14,7 +14,9 @@
android:background="#CC000000"
android:orientation="vertical">
<include layout="@layout/include_header"/>
<include
android:id="@+id/ic_q"
layout="@layout/include_header"/>
<TextView
android:layout_width="wrap_content"
......@@ -22,7 +24,8 @@
android:layout_gravity="center"
android:layout_marginTop="60dp"
android:text="在国内也能用的"
android:textSize="24dp" />
android:textSize="24dp"
/>
<TextView
android:layout_width="wrap_content"
......@@ -52,6 +55,7 @@
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="10dp"
android:paddingRight="20dp"
android:background="@null"
android:gravity="center_vertical"
android:hint="@string/str_input_phone"
......
......@@ -10,70 +10,49 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_gold_card"
android:elevation="5dp"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/include_header" />
<LinearLayout
android:id="@+id/ly_aboutus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:padding="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:text="用户协议"
android:textColor="@color/black"
android:textSize="18sp" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:src="@mipmap/bg_right" />
</LinearLayout>
<include layout="@layout/include_header" />
<View
<com.mints.street.widget.ElasticScrollView
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#979797" />
android:layout_height="match_parent"
android:overScrollMode="never">
<LinearLayout
android:id="@+id/ly_moresettings"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:padding="10dp">
android:layout_height="match_parent"
android:elevation="5dp"
android:orientation="vertical">
<include
android:id="@+id/item_phone"
layout="@layout/item_settings" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:text="隐私政策"
android:textColor="@color/black"
android:textSize="18sp" />
<include
android:id="@+id/item_userAgree"
layout="@layout/item_settings" />
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:src="@mipmap/bg_right" />
<include
android:id="@+id/item_privacyAgree"
layout="@layout/item_settings" />
<Button
android:id="@+id/btn_switch"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:background="@drawable/shape_btn_switch"
android:text="退出登录"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
</com.mints.street.widget.ElasticScrollView>
</LinearLayout>
</layout>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="viewModel"
type="com.mints.street.adapter.GridMapAdapter" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/bg"
android:layout_width="150dp"
android:layout_height="150dp"
android:background="@drawable/shape_gold_card_20"
>
android:background="@drawable/shape_gold_card_20">
<ImageView
android:id="@+id/image"
app:layout_constraintTop_toTopOf="parent"
......
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="viewModel"
type="com.mints.street.adapter.GridPaymentAdapter" />
</data>
<LinearLayout
android:id="@+id/bg"
android:layout_width="100dp"
android:layout_height="100dp"
android:orientation="vertical"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6个月"
android:textColor="@color/black"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="¥68.0"
android:textStyle="bold"
android:textSize="20dp"
android:textColor="#FF5722"/>
<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="原价¥108.0"
android:textSize="10dp"
android:textColor="#25000000"/>
</LinearLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:textColor="@color/color_121B32"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_right"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:src="@mipmap/ic_arrow_more"
android:visibility="gone" />
<TextView
android:id="@+id/tv_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:visibility="gone" />
<View
style="@style/view_line_E6E6E6"
android:layout_alignParentBottom="true" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:background="@drawable/shape_bt_disagree"
android:orientation="vertical">
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_bt_disagree"
android:gravity="center_horizontal"
android:orientation="vertical">
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_bt_disagree"
android:gravity="center_horizontal"
android:orientation="vertical">
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false">
<androidx.viewpager.widget.ViewPager
android:id="@+id/vp_conver_flow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:overScrollMode="never" />
</RelativeLayout>
\ No newline at end of file
This diff is collapsed.
......@@ -4,4 +4,16 @@
<attr name="border_width" format="dimension" />
<attr name="border_color" format="color" />
</declare-styleable>
<declare-styleable name="HorizontalselectedView">
<!--可见数目-->
<attr name="HorizontalselectedViewSeesize" format="integer"></attr>
<!--被选择文字的大小和颜色-->
<attr name="HorizontalselectedViewSelectedTextSize" format="float"></attr>
<attr name="HorizontalselectedViewSelectedTextColor" format="color|reference"></attr>
<!--未被被选择文字的大小和颜色-->
<attr name="HorizontalselectedViewTextSize" format="float"></attr>
<attr name="HorizontalselectedViewTextColor" format="color|reference"></attr>
</declare-styleable>
</resources>
\ No newline at end of file
......@@ -20,8 +20,9 @@ android.enableJetifier=true
isBuildModule=false
DEBUG_URL="http://test.mints-id.com/camera-api/"
RELEASE_URL="https://api.mints-id.com/gc-api/"
DEBUG_URL="http://test.mints-id.com/map-api/"
#RELEASE_URL="https://api.mints-id.com/map-api/"
RELEASE_URL="http://test.mints-id.com/map-api/"
RELEASE_KEY_PASSWORD=mints.street
RELEASE_KEY_ALIAS=mints_street
......
......@@ -2,6 +2,7 @@ package com.fry.base.utils;
import android.content.Context;
import android.graphics.Point;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
......@@ -10,6 +11,7 @@ import me.goldze.mvvmhabit.utils.Utils;
/**
* 2019-09-29 created
* dip、px转化.
*
* @author KOM
*/
public class DensityUtils {
......@@ -17,7 +19,7 @@ public class DensityUtils {
private static Point screenPoint;
public static Point getWindowWidthHeight() {
if(screenPoint == null){
if (screenPoint == null) {
screenPoint = new Point();
WindowManager wm = (WindowManager) Utils.getContext()
.getSystemService(Context.WINDOW_SERVICE);
......@@ -41,6 +43,22 @@ public class DensityUtils {
return new int[]{point.x, point.y};
}
private static DisplayMetrics sDisplayMetrics;
public static int getDisplayWidth(Context context) {
initDisplayMetrics(context);
return sDisplayMetrics.widthPixels;
}
public static int getDisplayHeight(Context context) {
initDisplayMetrics(context);
return sDisplayMetrics.heightPixels;
}
private static synchronized void initDisplayMetrics(Context context) {
sDisplayMetrics = context.getResources().getDisplayMetrics();
}
public static int dip2px(float dpValue) {
final float scale = Utils.getContext().getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
......
#Sat Jul 10 16:33:56 CST 2021
VERSION_BUILD=2754
\ No newline at end of file
#Mon Jul 12 16:02:26 CST 2021
VERSION_BUILD=2813
package me.goldze.mvvmhabit.http;
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 me.goldze.mvvmhabit.http;
//
//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;
// }
//
//}
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