Commit a7a59a7f by luofan

最新代码提交

parent a32d47e1
Showing with 2666 additions and 2235 deletions
......@@ -25,7 +25,6 @@
<option value="$PROJECT_DIR$/pickerview" />
<option value="$PROJECT_DIR$/provider" />
<option value="$PROJECT_DIR$/saleCenter" />
<option value="$PROJECT_DIR$/umeng" />
<option value="$PROJECT_DIR$/userCenter" />
<option value="$PROJECT_DIR$/wheelview" />
</set>
......@@ -34,5 +33,6 @@
<option name="useQualifiedModuleNames" value="true" />
</GradleProjectSettings>
</option>
<option name="offlineMode" value="true" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="baseSDK/src/main/res/drawable/bg_input_black_react.xml" value="0.265625" />
<entry key="baseSDK/src/main/res/drawable/blue_commom.xml" value="0.265625" />
<entry key="baseSDK/src/main/res/layout/dialog_register.xml" value="0.225" />
<entry key="baseSDK/src/main/res/layout/lrecycle_layout.xml" value="0.25052083333333336" />
<entry key="orderCenter/src/main/res/layout/fragment_commom_recycle.xml" value="0.25052083333333336" />
<entry key="orderCenter/src/main/res/layout/fragment_multi_detail.xml" value="0.24947916666666667" />
<entry key="saleCenter/src/main/res/layout/fragment_product_instruction.xml" value="0.24947916666666667" />
<entry key="saleCenter/src/main/res/layout/fragment_sale_instruction.xml" value="0.375" />
<entry key="saleCenter/src/main/res/layout/item_sale_product.xml" value="0.24947916666666667" />
<entry key="userCenter/src/main/res/drawable/personal_center_selector.xml" value="0.265625" />
<entry key="userCenter/src/main/res/layout/activity_register.xml" value="0.12760416666666666" />
<entry key="userCenter/src/main/res/layout/activity_register_verify.xml" value="0.375" />
<entry key="userCenter/src/main/res/layout/fragment_home_user.xml" value="0.5026232948583421" />
</map>
</option>
</component>
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables">
<value>
<list size="7">
<list size="14">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
......@@ -13,18 +32,33 @@
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
<item index="7" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
<item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
<item index="11" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" />
<item index="12" class="java.lang.String" itemvalue="io.reactivex.annotations.Nullable" />
<item index="13" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.Nullable" />
</list>
</value>
</option>
<option name="myNotNulls">
<value>
<list size="6">
<list size="14">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
<item index="6" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
<item index="10" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
<item index="11" class="java.lang.String" itemvalue="io.reactivex.annotations.NonNull" />
<item index="12" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.NonNull" />
<item index="13" class="java.lang.String" itemvalue="lombok.NonNull" />
</list>
</value>
</option>
......
......@@ -18,7 +18,6 @@
<module fileurl="file://$PROJECT_DIR$/.idea/modules/pickerview/dayu-saas-android.pickerview.iml" filepath="$PROJECT_DIR$/.idea/modules/pickerview/dayu-saas-android.pickerview.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/provider/dayu-saas-android.provider.iml" filepath="$PROJECT_DIR$/.idea/modules/provider/dayu-saas-android.provider.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/saleCenter/dayu-saas-android.saleCenter.iml" filepath="$PROJECT_DIR$/.idea/modules/saleCenter/dayu-saas-android.saleCenter.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/umeng/dayu-saas-android.umeng.iml" filepath="$PROJECT_DIR$/.idea/modules/umeng/dayu-saas-android.umeng.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/userCenter/dayu-saas-android.userCenter.iml" filepath="$PROJECT_DIR$/.idea/modules/userCenter/dayu-saas-android.userCenter.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/wheelview/dayu-saas-android.wheelview.iml" filepath="$PROJECT_DIR$/.idea/modules/wheelview/dayu-saas-android.wheelview.iml" />
</modules>
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
</set>
</option>
</component>
</project>
\ No newline at end of file
......@@ -19,7 +19,7 @@
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />-->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.access_network_state" />
<!-- 读取日志 -->
......
......@@ -70,7 +70,7 @@ public class MyApplication extends BaseApplication {
//初始化greendao
GreenDaoManager.getInstance();
//初始化高德地图
LocationUtils.init(getApplicationContext());
// LocationUtils.init(getApplicationContext());
//初始化环信
// HxManager.getInstance().init(mContext);
if ((boolean) SPUtils.get("privacy",false)){
......@@ -79,7 +79,7 @@ public class MyApplication extends BaseApplication {
//直播
LiveUtils.initLive(this);
// LiveUtils.initLive(this);
}
......
......@@ -49,9 +49,9 @@ public class MainPresenter extends MainContract.Presenter {
mUser = UserManager.getInstance().getUser();
mAccountId = Integer.parseInt(mUser.getAccountId());
mSiteId = mUser.getSiteId();
if (!TextUtils.isEmpty(mUser.getNewAccount())) {
mView.showInvateCodeView();
}
// if (!TextUtils.isEmpty(mUser.getNewAccount())) {
// mView.showInvateCodeView();
// }
request();
}
......
......@@ -5,6 +5,7 @@ import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.location.Address;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Environment;
......@@ -21,6 +22,7 @@ import android.widget.TextView;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.amap.api.location.AMapLocation;
import com.bigfish.salecenter.ui.fragment.HomeSaleFragment;
import com.dayu.base.api.Api;
import com.dayu.base.api.DownloadService;
......@@ -46,6 +48,7 @@ import com.dayu.learncenter.ui.fragment.HomeLearnFragment;
import com.dayu.livemodule.LiveUtils;
import com.dayu.livemodule.event.UserKickOutEvent;
import com.dayu.location.base.LocationUtils;
import com.dayu.location.base.LocationUtils1;
import com.dayu.order.common.TabNumEvent;
import com.dayu.order.ui.activity.OrderDetailsActivity;
import com.dayu.order.ui.activity.ReceivingActivity;
......@@ -622,7 +625,7 @@ public class MainActivity extends BaseActivity<MainPresenter, ActivityMainBindin
@Override
protected void onDestroy() {
LocationUtils.destroy();
// LocationUtils.destroy();
TimeUtils.onDestory();
handler = null;
super.onDestroy();
......
......@@ -4,6 +4,7 @@ import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.location.Address;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
......@@ -13,6 +14,8 @@ import android.support.annotation.Nullable;
import com.dayu.bigfish.api.ApiFactory;
import com.dayu.common.Constants;
import com.dayu.location.base.LocationUtils;
import com.dayu.location.base.LocationUtils1;
import com.dayu.utils.LogUtils;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -43,7 +46,7 @@ public class LocationService extends Service {
super.onCreate();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
try {
startForeground(1,new Notification());
startForeground(1, new Notification());
} catch (Exception e) {
e.printStackTrace();
}
......@@ -51,29 +54,61 @@ public class LocationService extends Service {
mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
if (mAccountId == 0 || mSiteId == 0 || mHandler == null) {
if (mAccountId == 0 || mSiteId == 0 || mHandler == null) {
return;
}
mHandler.post(() -> LocationUtils.getCurrentLocation(location -> {
if (location != null) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("accountId", mAccountId);
jsonObject.put("siteId", mSiteId);
jsonObject.put("longitude", location.getLongitude());
jsonObject.put("latitude", location.getLatitude());
jsonObject.put("provinceName", location.getProvince());
jsonObject.put("cityName", location.getCity());
jsonObject.put("districtName", location.getDistrict());
} catch (JSONException e) {
e.printStackTrace();
// mHandler.post(() -> LocationUtils.getCurrentLocation(location -> {
// if (location != null) {
// JSONObject jsonObject = new JSONObject();
// try {
// jsonObject.put("accountId", mAccountId);
// jsonObject.put("siteId", mSiteId);
// jsonObject.put("longitude", location.getLongitude());
// jsonObject.put("latitude", location.getLatitude());
// jsonObject.put("provinceName", location.getProvince());
// jsonObject.put("cityName", location.getCity());
// jsonObject.put("districtName", location.getDistrict());
// LogUtils.d("dayulocaiton: "+location.toString());
// } catch (JSONException e) {
// e.printStackTrace();
// }
// RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
// Disposable disposable = ApiFactory.commiteLocation(requestBody).subscribe(aBoolean -> {
// }, throwable -> {
// });
// }
// }));
mHandler.post(() -> {
LocationUtils1.getInstance(getApplicationContext()).setAddressCallback(new LocationUtils1.AddressCallback() {
@Override
public void onGetAddress(Address location) {
if (location != null) {
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("accountId", mAccountId);
jsonObject.put("siteId", mSiteId);
jsonObject.put("longitude", location.getLongitude());
jsonObject.put("latitude", location.getLatitude());
jsonObject.put("provinceName", location.getAdminArea());
jsonObject.put("cityName", location.getLocality());
jsonObject.put("districtName", location.getSubLocality());
} catch (JSONException e) {
e.printStackTrace();
}
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
Disposable disposable = ApiFactory.commiteLocation(requestBody).subscribe(aBoolean -> {
}, throwable -> {
});
}
}
@Override
public void onGetLocation(double lat, double lng) {
}
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());
Disposable disposable = ApiFactory.commiteLocation(requestBody).subscribe(aBoolean -> {
}, throwable -> {
});
}
}));
});
});
super.handleMessage(msg);
}
};
......@@ -84,7 +119,7 @@ public class LocationService extends Service {
sendMessage();
}
};
mTimer.schedule(mTask, 2000, 1000*60*10);
mTimer.schedule(mTask, 2000, 1000 * 10);
}
public void sendMessage() {
......
......@@ -100,7 +100,7 @@ public class AppManager {
ActivityManager activityMgr = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
// activityMgr.
activityMgr.restartPackage(context.getPackageName());
// activityMgr.restartPackage(context.getPackageName());
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
......
......@@ -3,7 +3,7 @@
<stroke
android:width="1dp"
android:color="#333"
android:color="@color/view_color"
/>
<corners android:radius="0.5dp"/>
</shape>
\ No newline at end of file
......@@ -5,8 +5,8 @@ buildscript {
ext.build_tools_version = "27.0.3"
ext.min_sdk_version = 19
ext.target_sdk_version = 26
ext.version_code = 300
ext.verson_name = "3.0.0"
ext.version_code = 301
ext.verson_name = "3.0.1"
ext.gradle_version = '3.1.4'
ext.isReleaseMinify = false
ext.isDebugMinify = false
......@@ -15,13 +15,13 @@ buildscript {
// ext.kotlin_version = '1.2.50'
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.google.com' }
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven { url 'https://dl.bintray.com/umsdk/release' }
google()
}
dependencies {
classpath "com.android.tools.build:gradle:$gradle_version"
......@@ -32,12 +32,13 @@ buildscript {
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url 'https://maven.google.com' }
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
maven { url 'https://dl.bintray.com/umsdk/release' }
google()
}
}
......
......@@ -15,6 +15,6 @@ isLearnModule=true
##maven依赖
mavenMode=false
BASE_URL=http://47.94.101.239:3112
IS_64_BIT=false
IS_64_BIT=true
Android.useDeprecatedNdk=true
\ No newline at end of file
......@@ -42,7 +42,7 @@ dependencies {
// MLVB 需要使用 gson 进行 json 解析
implementation 'com.google.code.gson:gson:2.3.1'
// MLVB 需要依赖腾讯云 IM 服务
api 'com.tencent.imsdk:imsdk:4.5.45'
// api 'com.tencent.imsdk:imsdk:4.5.45'
// 弹幕功能需要依赖此库
implementation 'com.github.ctiao:dfm:0.4.4'
// Demo 依赖的图片加载库
......
......@@ -12,7 +12,7 @@
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<!-- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />-->
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
......@@ -105,14 +105,14 @@
<!-- android:permission="android.permission.BIND_JOB_SERVICE"-->
<!-- android:process=":network" />-->
<receiver android:name="com.tencent.imsdk.session.SessionBroadcastReceiver" >
<intent-filter>
<action android:name="com.tencent.imsdk.session.boot" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="com.tencent.qcloud.qal.TASK_REMOVED" />
</intent-filter>
</receiver>
<!-- <receiver android:name="com.tencent.imsdk.session.SessionBroadcastReceiver" >-->
<!-- <intent-filter>-->
<!-- <action android:name="com.tencent.imsdk.session.boot" />-->
<!-- <action android:name="android.intent.action.BOOT_COMPLETED" />-->
<!-- <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />-->
<!-- <action android:name="com.tencent.qcloud.qal.TASK_REMOVED" />-->
<!-- </intent-filter>-->
<!-- </receiver>-->
</application>
</manifest>
......@@ -21,7 +21,7 @@ public class LiveUtils {
TXLiveBase.getInstance().setLicence(context, TCGlobalConfig.LICENCE_URL, TCGlobalConfig.LICENCE_KEY);
// 必须:初始化 MLVB 组件
MLVBLiveRoomImpl.sharedInstance(context);
// MLVBLiveRoomImpl.sharedInstance(context);
// 必须:初始化全局的 用户信息管理类,记录个人信息。
TCUserMgr.getInstance().initContext(context);
......
......@@ -54,7 +54,7 @@ public abstract class MLVBLiveRoom {
* @note 可以调用 {@link MLVBLiveRoom#destroySharedInstance()} 销毁单例对象
*/
public static MLVBLiveRoom sharedInstance(Context context) {
return MLVBLiveRoomImpl.sharedInstance(context);
return null;
}
/**
......@@ -63,7 +63,7 @@ public abstract class MLVBLiveRoom {
* @note 销毁实例后,外部缓存的 MLVBLiveRoom 实例不能再使用,需要重新调用 {@link MLVBLiveRoom#sharedInstance(Context)} 获取新实例
*/
public static void destroySharedInstance() {
MLVBLiveRoomImpl.destroySharedInstance();
// MLVBLiveRoomImpl.destroySharedInstance();
}
/**
......
This source diff could not be displayed because it is too large. You can view the blob instead.
package com.dayu.livemodule.roomutil.im;
import android.content.Context;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.util.Log;
import com.dayu.livemodule.event.UserKickOutEvent;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.google.gson.JsonSyntaxException;
import com.tencent.imsdk.TIMCallBack;
import com.tencent.imsdk.TIMConnListener;
import com.tencent.imsdk.TIMConversation;
import com.tencent.imsdk.TIMConversationType;
import com.tencent.imsdk.TIMCustomElem;
import com.tencent.imsdk.TIMElem;
import com.tencent.imsdk.TIMFriendshipManager;
import com.tencent.imsdk.TIMGroupManager;
import com.tencent.imsdk.TIMGroupMemberInfo;
import com.tencent.imsdk.TIMGroupSystemElem;
import com.tencent.imsdk.TIMGroupSystemElemType;
import com.tencent.imsdk.TIMGroupTipsElem;
import com.tencent.imsdk.TIMGroupTipsType;
import com.tencent.imsdk.TIMManager;
import com.tencent.imsdk.TIMMessage;
import com.tencent.imsdk.TIMMessageListener;
import com.tencent.imsdk.TIMSdkConfig;
import com.tencent.imsdk.TIMTextElem;
import com.tencent.imsdk.TIMUserConfig;
import com.tencent.imsdk.TIMUserProfile;
import com.tencent.imsdk.TIMUserStatusListener;
import com.tencent.imsdk.TIMValueCallBack;
import com.tencent.imsdk.ext.group.TIMGroupManagerExt;
import com.tencent.liteav.basic.log.TXCLog;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.FormatFlagsConversionMismatchException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by jac on 2017/11/4.
* Copyright © 2013-2017 Tencent Cloud. All Rights Reserved.
*/
public class IMMessageMgr implements TIMMessageListener {
private static final String TAG = IMMessageMgr.class.getSimpleName();
private Context mContext;
private Handler mHandler;
private static boolean mConnectSuccess = false;
private boolean mLoginSuccess = false;
private String mSelfUserID;
private String mSelfUserSig;
private String mGroupID;
private TIMSdkConfig mTIMSdkConfig;
private IMMessageConnCallback mIMConnListener;
private IMMessageLoginCallback mIMLoginListener;
private IMMessageCallback mMessageListener;
/**
* 函数级公共Callback定义
*/
public interface Callback{
void onError(int code, String errInfo);
void onSuccess(Object... args);
}
/**
* 模块回调Listener定义
*/
public interface IMMessageListener {
/**
* IM连接成功
*/
void onConnected();
/**
* IM断开连接
*/
void onDisconnected();
/**
* IM群组里推流者成员变化通知
*/
void onPusherChanged();
/**
* 收到群文本消息
*/
void onGroupTextMessage(String groupID, String senderID, String userName, String headPic, String message);
/**
* 收到自定义的群消息
*/
void onGroupCustomMessage(String groupID, String senderID, String message);
/**
* 收到自定义的C2C消息
*/
void onC2CCustomMessage(String sendID, String cmd, String message);
/**
* IM群组销毁回调
*/
void onGroupDestroyed(final String groupID);
/**
* 日志回调
*/
void onDebugLog(String log);
/**
* 用户进群通知
* @param groupID 群标识
* @param users 进群用户信息列表
*/
void onGroupMemberEnter(String groupID, ArrayList<TIMUserProfile> users);
/**
* 用户退群通知
* @param groupID 群标识
* @param users 退群用户信息列表
*/
void onGroupMemberExit(String groupID, ArrayList<TIMUserProfile> users);
/**
* 用户被强制下线通知
*
*/
void onForceOffline();
}
public IMMessageMgr(final Context context) {
this.mContext = context.getApplicationContext();
this.mHandler = new Handler(this.mContext.getMainLooper());
this.mMessageListener = new IMMessageCallback(null);
}
/**
* 设置回调
* @param listener
*/
public void setIMMessageListener(IMMessageListener listener){
this.mMessageListener.setListener(listener);
}
/**
* 初始化
* @param userID 用户ID
* @param userSig 签名
* @param appID appID
* @param callback
*/
public void initialize(final String userID, final String userSig, final int appID, final Callback callback){
if (userID == null || userSig == null) {
mMessageListener.onDebugLog("参数错误,请检查 UserID, userSig 是否为空!");
if (callback != null) {
callback.onError(-1, "参数错误");
}
return;
}
this.mSelfUserID = userID;
this.mSelfUserSig = userSig;
this.runOnHandlerThread(new Runnable() {
@Override
public void run() {
long initializeStartTS = System.currentTimeMillis();
mIMConnListener = new IMMessageConnCallback(initializeStartTS, callback);
mTIMSdkConfig = new TIMSdkConfig(appID);
TIMUserConfig userConfig = new TIMUserConfig();
userConfig.setConnectionListener(mIMConnListener);
userConfig.setUserStatusListener(new TIMUserStatusListener() {
@Override
public void onForceOffline() {
IMMessageListener listener = mMessageListener;
if (listener != null)
listener.onForceOffline();
}
@Override
public void onUserSigExpired() {
IMMessageListener listener = mMessageListener;
if (listener != null)
listener.onForceOffline();
}
});
TIMManager.getInstance().addMessageListener(IMMessageMgr.this);
if( TIMManager.getInstance().init(mContext, mTIMSdkConfig) ){
login(new Callback() {
@Override
public void onError(int code, String errInfo) {
printDebugLog("login failed: %s(%d)", errInfo, code);
mLoginSuccess = false;
callback.onError(code, "IM登录失败");
}
@Override
public void onSuccess(Object... args) {
printDebugLog("login success");
mLoginSuccess = true;
mConnectSuccess = true;
callback.onSuccess();
}
});
TIMManager.getInstance().setUserConfig(userConfig);
}
else {
printDebugLog("init failed");
callback.onError(-1, "IM初始化失败");
}
}
});
}
public void runOnHandlerThread(Runnable runnable) {
Handler handler = mHandler;
if (handler != null) {
handler.post(runnable);
} else {
Log.e(TAG, "runOnHandlerThread -> Handler == null");
}
}
/**
* 反初始化
*/
public void unInitialize(){
TIMManager.getInstance().removeMessageListener(IMMessageMgr.this);
mContext = null;
mHandler = null;
//
// TIMUserConfig userConfig = new TIMUserConfig();
// userConfig.setConnectionListener(null);
// TIMManager.getInstance().setUserConfig(userConfig);
if (mTIMSdkConfig != null) {
mTIMSdkConfig = null;
}
if (mIMConnListener != null) {
mIMConnListener.clean();
mIMConnListener = null;
}
if (mIMLoginListener != null) {
mIMLoginListener.clean();
mIMLoginListener = null;
}
if (mMessageListener != null) {
mMessageListener.setListener(null);
}
logout(null);
}
/**
* 加入IM群组
* @param groupId 群ID
* @param callback
*/
public void jionGroup(final String groupId, final Callback callback){
if (!mLoginSuccess){
mMessageListener.onDebugLog("[jionGroup] IM 没有初始化");
if (callback != null) {
callback.onError(-1, "IM 没有初始化");
}
return;
}
this.runOnHandlerThread(new Runnable() {
@Override
public void run() {
TIMGroupManager.getInstance().applyJoinGroup(groupId, "who care?", new TIMCallBack() {
@Override
public void onError(int i, String s) {
printDebugLog("加入群 {%s} 失败:%s(%d)", groupId, s, i);
if (i == 10010) {
s = "房间已解散";
}
callback.onError(i, s);
}
@Override
public void onSuccess() {
printDebugLog("加入群 {%s} 成功", groupId);
mGroupID = groupId;
callback.onSuccess();
}
});
}
});
}
/**
* 退出IM群组
* @param groupId 群ID
* @param callback
*/
public void quitGroup(final String groupId, final Callback callback){
if (!mLoginSuccess){
mMessageListener.onDebugLog("[quitGroup] IM 没有初始化");
if (callback != null) {
callback.onError(-1, "IM 没有初始化");
}
return;
}
this.runOnHandlerThread(new Runnable() {
@Override
public void run() {
TIMGroupManager.getInstance().quitGroup(groupId, new TIMCallBack() {
@Override
public void onError(int i, String s) {
if (i == 10010) {
printDebugLog("群 {%s} 已经解散了", groupId);
onSuccess();
}
else{
printDebugLog("退出群 {%s} 失败: %s(%d)", groupId, s, i);
callback.onError(i, s);
}
}
@Override
public void onSuccess() {
printDebugLog("退出群 {%s} 成功", groupId);
mGroupID = groupId;
callback.onSuccess();
}
});
}
});
}
public void createGroup(final String groupId, final String groupType, final String groupName, final Callback callback) {
if (!mLoginSuccess){
mMessageListener.onDebugLog("IM 没有初始化");
if (callback != null) {
callback.onError(-1, "IM 没有初始化");
}
return;
}
final TIMGroupManager.CreateGroupParam param = new TIMGroupManager.CreateGroupParam(groupType, groupName);
param.setGroupId(groupId);
this.runOnHandlerThread(new Runnable() {
@Override
public void run() {
TIMGroupManager.getInstance().createGroup(param, new TIMValueCallBack<String>() {
@Override
public void onError(int i, String s) {
printDebugLog("创建群 {%s} 失败:%s(%d)", groupId, s, i);
if (i == 10036) {
String createRoomErrorMsg = "您当前使用的云通讯账号未开通音视频聊天室功能,创建聊天室数量超过限额,请前往腾讯云官网开通【IM音视频聊天室】,地址:https://buy.cloud.tencent.com/avc";
TXCLog.e(TAG, createRoomErrorMsg);
printDebugLog(createRoomErrorMsg);
}
if (i == 10025) {
mGroupID = groupId;
}
callback.onError(i, s);
}
@Override
public void onSuccess(String s) {
printDebugLog("创建群 {%s} 成功", groupId);
mGroupID = groupId;
callback.onSuccess();
}
});
}
});
}
/**
* 销毁IM群组
* @param groupId 群ID
* @param callback
*/
public void destroyGroup(final String groupId, final Callback callback){
if (!mLoginSuccess){
mMessageListener.onDebugLog("IM 没有初始化");
if (callback != null) {
callback.onError(-1, "IM 没有初始化");
}
return;
}
this.runOnHandlerThread(new Runnable() {
@Override
public void run() {
TIMGroupManager.getInstance().deleteGroup(groupId, new TIMCallBack() {
@Override
public void onError(int i, String s) {
printDebugLog("解散群 {%s} 失败:%s(%d)", groupId, s, i);
callback.onError(i, s);
}
@Override
public void onSuccess() {
printDebugLog("解散群 {%s} 成功", groupId);
mGroupID = groupId;
callback.onSuccess();
}
});
}
});
}
/**
* 发送IM群文本消息
* @param userName 发送者用户名
* @param headPic 发送者头像
* @param text 文本内容
* @param callback
*/
public void sendGroupTextMessage(final @NonNull String userName, final @NonNull String headPic, final @NonNull String text, final Callback callback){
if (!mLoginSuccess){
mMessageListener.onDebugLog("[sendGroupTextMessage] IM 没有初始化");
if (callback != null)
callback.onError(-1, "IM 没有初始化");
return;
}
this.runOnHandlerThread(new Runnable() {
@Override
public void run() {
TIMMessage message = new TIMMessage();
try {
CommonJson<UserInfo> txtHeadMsg = new CommonJson<UserInfo>();
txtHeadMsg.cmd = "CustomTextMsg";
txtHeadMsg.data = new UserInfo();
txtHeadMsg.data.nickName = userName;
txtHeadMsg.data.headPic = headPic;
String strCmdMsg = new Gson().toJson(txtHeadMsg, new TypeToken<CommonJson<UserInfo>>(){}.getType());
TIMCustomElem customElem = new TIMCustomElem();
customElem.setData(strCmdMsg.getBytes("UTF-8"));
TIMTextElem textElem = new TIMTextElem();
textElem.setText(text);
message.addElement(customElem);
message.addElement(textElem);
}
catch (Exception e) {
printDebugLog("[sendGroupTextMessage] 发送群{%s}消息失败,组包异常", mGroupID);
if (callback != null) {
callback.onError(-1, "发送群消息失败");
}
return;
}
TIMConversation conversation = TIMManager.getInstance().getConversation(TIMConversationType.Group, mGroupID);
conversation.sendMessage(message, new TIMValueCallBack<TIMMessage>() {
@Override
public void onError(int i, String s) {
printDebugLog("[sendGroupTextMessage] 发送群{%s}消息失败: %s(%d)", mGroupID, s, i);
if (callback != null)
callback.onError(i, s);
}
@Override
public void onSuccess(TIMMessage timMessage) {
printDebugLog("[sendGroupTextMessage] 发送群消息成功");
if (callback != null)
callback.onSuccess();
}
});
}
});
}
/**
* 发送自定义群消息
* @param content 自定义消息的内容
* @param callback
*/
public void sendGroupCustomMessage(final @NonNull String content, final Callback callback) {
if (!mLoginSuccess){
mMessageListener.onDebugLog("[sendGroupCustomMessage] IM 没有初始化");
if (callback != null)
callback.onError(-1, "IM 没有初始化");
return;
}
this.runOnHandlerThread(new Runnable() {
@Override
public void run() {
TIMMessage message = new TIMMessage();
try {
TIMCustomElem customElem = new TIMCustomElem();
customElem.setData(content.getBytes("UTF-8"));
message.addElement(customElem);
}
catch (Exception e) {
printDebugLog("[sendGroupCustomMessage] 发送自定义群{%s}消息失败,组包异常", mGroupID);
if (callback != null) {
callback.onError(-1, "发送CC消息失败");
}
return;
}
TIMConversation conversation = TIMManager.getInstance().getConversation(TIMConversationType.Group, mGroupID);
conversation.sendMessage(message, new TIMValueCallBack<TIMMessage>() {
@Override
public void onError(int i, String s) {
printDebugLog("[sendGroupCustomMessage] 发送自定义群{%s}消息失败: %s(%d)", mGroupID, s, i);
if (callback != null)
callback.onError(i, s);
}
@Override
public void onSuccess(TIMMessage timMessage) {
printDebugLog("[sendGroupCustomMessage] 发送自定义群消息成功");
if (callback != null)
callback.onSuccess();
}
});
}
});
}
/**
* 发送CC(端到端)自定义消息
* @param toUserID 接收者userID
* @param content 自定义消息的内容
* @param callback
*/
public void sendC2CCustomMessage(final @NonNull String toUserID, final @NonNull String content, final Callback callback) {
if (!mLoginSuccess){
mMessageListener.onDebugLog("[sendCustomMessage] IM 没有初始化");
if (callback != null)
callback.onError(-1, "IM 没有初始化");
return;
}
this.runOnHandlerThread(new Runnable() {
@Override
public void run() {
TIMMessage message = new TIMMessage();
try {
TIMCustomElem customElem = new TIMCustomElem();
customElem.setData(content.getBytes("UTF-8"));
message.addElement(customElem);
}
catch (Exception e) {
printDebugLog("[sendCustomMessage] 发送CC{%s}消息失败,组包异常", toUserID);
if (callback != null) {
callback.onError(-1, "发送CC消息失败");
}
return;
}
TIMConversation conversation = TIMManager.getInstance().getConversation(TIMConversationType.C2C, toUserID);
conversation.sendMessage(message, new TIMValueCallBack<TIMMessage>() {
@Override
public void onError(int i, String s) {
printDebugLog("[sendCustomMessage] 发送CC{%s}消息失败: %s(%d)", toUserID, s, i);
if (callback != null)
callback.onError(i, s);
}
@Override
public void onSuccess(TIMMessage timMessage) {
printDebugLog("[sendCustomMessage] 发送CC消息成功");
if (callback != null)
callback.onSuccess();
}
});
}
});
}
public void getGroupMembers(final String groupId, final int maxSize, final TIMValueCallBack<List<TIMUserProfile>> cb) {
this.runOnHandlerThread(new Runnable() {
@Override
public void run() {
TIMGroupManagerExt.getInstance().getGroupMembers(groupId, new TIMValueCallBack<List<TIMGroupMemberInfo>>() {
@Override
public void onError(int i, String s) {
}
@Override
public void onSuccess(List<TIMGroupMemberInfo> timGroupMemberInfos) {
ArrayList<String> users = new ArrayList<>();
int count = 0;
for (TIMGroupMemberInfo memberInfo : timGroupMemberInfos) {
if (count < maxSize) {
users.add(memberInfo.getUser());
count++;
} else {
break;
}
}
TIMFriendshipManager.getInstance().getUsersProfile(users, false, cb);
}
});
}
});
}
public void setSelfProfile(final String nickname, final String faceURL) {
if (nickname == null && faceURL == null) {
return;
}
this.runOnHandlerThread(new Runnable() {
@Override
public void run() {
HashMap<String, Object> profileMap = new HashMap<>();
if (nickname != null) {
profileMap.put(TIMUserProfile.TIM_PROFILE_TYPE_KEY_NICK, nickname);
}
if (faceURL != null) {
profileMap.put(TIMUserProfile.TIM_PROFILE_TYPE_KEY_FACEURL, faceURL);
}
TIMFriendshipManager.getInstance().modifySelfProfile(profileMap, new TIMCallBack() {
@Override
public void onError(int code, String desc) {
Log.e(TAG, "modifySelfProfile failed: " + code + " desc" + desc);
if (code == 6014){
EventBus.getDefault().post(new UserKickOutEvent());
}
}
@Override
public void onSuccess() {
Log.e(TAG, "modifySelfProfile success");
}
});
}
});
}
public void getUserProfile(final ArrayList<String> userIDs, final TIMValueCallBack<List<TIMUserProfile>> cb) {
TIMFriendshipManager.getInstance().getUsersProfile(userIDs, false, cb);
}
@Override
public boolean onNewMessages(List<TIMMessage> list) {
for (TIMMessage message : list) {
for (int i = 0; i < message.getElementCount(); i++) {
TIMElem element = message.getElement(i);
printDebugLog("onNewMessage type = %s", element.getType());
switch (element.getType()){
case GroupSystem:{
TIMGroupSystemElemType systemElemType = ((TIMGroupSystemElem) element).getSubtype();
switch (systemElemType){
case TIM_GROUP_SYSTEM_DELETE_GROUP_TYPE:{
printDebugLog("onNewMessage subType = %s", systemElemType);
if (mMessageListener != null)
mMessageListener.onGroupDestroyed(((TIMGroupSystemElem) element).getGroupId());
break;
}
case TIM_GROUP_SYSTEM_CUSTOM_INFO:{
byte[] userData = ((TIMGroupSystemElem) element).getUserData();
if (userData == null || userData.length == 0){
printDebugLog("userData == null");
break;
}
String data = new String(userData);
printDebugLog("onNewMessage subType = %s content = %s", systemElemType, data);
try {
CommonJson<Object> commonJson = new Gson().fromJson(data, new TypeToken<CommonJson<Object>>(){}.getType());
if (commonJson.cmd.equals("notifyPusherChange")) {
mMessageListener.onPusherChanged();
}
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
break;
}
}
break;
}//case GroupSystem
case Custom: {
byte[] userData = ((TIMCustomElem) element).getData();
if (userData == null || userData.length == 0){
printDebugLog("userData == null");
break;
}
String data = new String(userData);
printDebugLog("onNewMessage subType = Custom content = %s", data);
try {
CommonJson<Object> commonJson = new Gson().fromJson(data, new TypeToken<CommonJson<Object>>(){}.getType());
if (commonJson.cmd != null) {
if (commonJson.cmd.equalsIgnoreCase("CustomTextMsg")) {
++i;
UserInfo userInfo = new Gson().fromJson(new Gson().toJson(commonJson.data), UserInfo.class);
if (userInfo != null && i < message.getElementCount()) {
TIMElem nextElement = message.getElement(i);
TIMTextElem textElem = (TIMTextElem) nextElement;
String text = textElem.getText();
if (text != null){
mMessageListener.onGroupTextMessage(mGroupID, message.getSender(), userInfo.nickName, userInfo.headPic, text);
}
}
}
else if (commonJson.cmd.equalsIgnoreCase("linkmic") || commonJson.cmd.equalsIgnoreCase("pk")) {
mMessageListener.onC2CCustomMessage(message.getSender(), commonJson.cmd, new Gson().toJson(commonJson.data));
}
else if (commonJson.cmd.equalsIgnoreCase("CustomCmdMsg")) {
mMessageListener.onGroupCustomMessage(mGroupID, message.getSender(), new Gson().toJson(commonJson.data));
} else if (commonJson.cmd.equalsIgnoreCase("notifyPusherChange")) {
mMessageListener.onPusherChanged();
}
}
} catch (JsonSyntaxException e) {
e.printStackTrace();
}
break;
}
case GroupTips:
{
TIMGroupTipsElem tipsElem = (TIMGroupTipsElem)element;
if (tipsElem.getTipsType() == TIMGroupTipsType.Join) {
Map<String, TIMUserProfile> changedUserInfos = tipsElem.getChangedUserInfo();
if (changedUserInfos != null && changedUserInfos.size() > 0) {
ArrayList<TIMUserProfile> users = new ArrayList<>();
for (Map.Entry<String, TIMUserProfile> entry : changedUserInfos.entrySet()) {
users.add(entry.getValue());
}
mMessageListener.onGroupMemberEnter(tipsElem.getGroupId(), users);
}
} else if (tipsElem.getTipsType() == TIMGroupTipsType.Quit) {
ArrayList<TIMUserProfile> users = new ArrayList<>();
users.add(tipsElem.getOpUserInfo());
mMessageListener.onGroupMemberExit(tipsElem.getGroupId(), users);
}
break;
}
}
}
}
return false;
}
private void login(final Callback cb){
if (mSelfUserID == null || mSelfUserSig == null ){
if (cb != null) {
cb.onError(-1, "没有 UserId");
}
return;
}
Log.i(TAG, "start login: userId = " + this.mSelfUserID);
final long loginStartTS = System.currentTimeMillis();
mIMLoginListener = new IMMessageLoginCallback(loginStartTS, cb);
TIMManager.getInstance().login(this.mSelfUserID, this.mSelfUserSig, mIMLoginListener);
}
private void logout(final Callback callback){
if (!mLoginSuccess){
return;
}
TIMManager.getInstance().logout(null);
}
private void printDebugLog(String format, Object ...args){
String log;
try {
log = String.format(format, args);
Log.e(TAG, log);
if (mMessageListener != null) {
mMessageListener.onDebugLog(log);
}
} catch (FormatFlagsConversionMismatchException e) {
e.printStackTrace();
}
}
/**
* 辅助类 IM Connect Listener
*/
private class IMMessageConnCallback implements TIMConnListener {
private long initializeStartTS = 0;
private Callback callback;
public IMMessageConnCallback(long ts, Callback cb) {
initializeStartTS = ts;
callback = cb;
}
public void clean() {
initializeStartTS = 0;
callback = null;
}
@Override
public void onConnected() {
printDebugLog("connect success,initialize() time cost %.2f secs", (System.currentTimeMillis() - initializeStartTS) / 1000.0);
mMessageListener.onConnected();
mConnectSuccess = true;
}
@Override
public void onDisconnected(int i, String s) {
printDebugLog("disconnect: %s(%d)", s, i);
if (mLoginSuccess) {
if (mMessageListener != null) {
mMessageListener.onDisconnected();
}
} else {
if (callback != null) {
callback.onError(i, s);
}
}
mConnectSuccess = false;
}
@Override
public void onWifiNeedAuth(String s) {
printDebugLog("onWifiNeedAuth(): %s", s);
if (mLoginSuccess){
mMessageListener.onDisconnected();
}
else {
if (callback != null) {
callback.onError(-1, s);
}
}
mConnectSuccess = false;
}
}
/**
* 辅助类 IM Login Listener
*/
private class IMMessageLoginCallback implements TIMCallBack {
private long loginStartTS ;
private Callback callback;
public IMMessageLoginCallback(long ts, Callback cb) {
loginStartTS = ts;
callback = cb;
}
public void clean() {
loginStartTS = 0;
callback = null;
}
@Override
public void onError(int i, String s) {
if (callback != null) {
callback.onError(i, s);
}
}
@Override
public void onSuccess() {
printDebugLog("login success, time cost %.2f secs", (System.currentTimeMillis()- loginStartTS) / 1000.0);
if (callback != null) {
callback.onSuccess();
}
}
};
/**
* 辅助类 IM Message Listener
*/
private class IMMessageCallback implements IMMessageListener {
private IMMessageListener listener;
public IMMessageCallback(IMMessageListener listener) {
this.listener = listener;
}
public void setListener(IMMessageListener listener) {
this.listener = listener;
}
@Override
public void onConnected() {
runOnHandlerThread(new Runnable() {
@Override
public void run() {
if (listener != null)
listener.onConnected();
}
});
}
@Override
public void onDisconnected() {
runOnHandlerThread(new Runnable() {
@Override
public void run() {
if (listener != null)
listener.onDisconnected();
}
});
}
@Override
public void onPusherChanged() {
runOnHandlerThread(new Runnable() {
@Override
public void run() {
if (listener != null)
listener.onPusherChanged();
}
});
}
@Override
public void onGroupDestroyed(final String groupID) {
runOnHandlerThread(new Runnable() {
@Override
public void run() {
if (listener != null)
listener.onGroupDestroyed(groupID);
}
});
}
@Override
public void onDebugLog(final String line) {
runOnHandlerThread(new Runnable() {
@Override
public void run() {
if (listener != null)
listener.onDebugLog("[IM] "+line);
}
});
}
@Override
public void onGroupMemberEnter(final String groupID, final ArrayList<TIMUserProfile> users) {
runOnHandlerThread(new Runnable() {
@Override
public void run() {
if (listener != null)
listener.onGroupMemberEnter(groupID, users);
}
});
}
@Override
public void onGroupMemberExit(final String groupID, final ArrayList<TIMUserProfile> users) {
runOnHandlerThread(new Runnable() {
@Override
public void run() {
if (listener != null)
listener.onGroupMemberExit(groupID, users);
}
});
}
@Override
public void onForceOffline() {
runOnHandlerThread(new Runnable() {
@Override
public void run() {
if (listener != null) {
listener.onForceOffline();
}
}
});
}
@Override
public void onGroupTextMessage(final String roomID, final String senderID, final String userName, final String headPic, final String message) {
runOnHandlerThread(new Runnable() {
@Override
public void run() {
if (listener != null)
listener.onGroupTextMessage(roomID, senderID, userName, headPic, message);
}
});
}
@Override
public void onGroupCustomMessage(final String groupID, final String senderID, final String message) {
runOnHandlerThread(new Runnable() {
@Override
public void run() {
if (listener != null)
listener.onGroupCustomMessage(groupID, senderID, message);
}
});
}
@Override
public void onC2CCustomMessage(final String senderID, final String cmd, final String message) {
runOnHandlerThread(new Runnable() {
@Override
public void run() {
if (listener != null)
listener.onC2CCustomMessage(senderID, cmd, message);
}
});
}
}
private static class CommonJson<T> {
String cmd;
T data;
}
private static final class UserInfo {
String nickName;
String headPic;
}
}
//package com.dayu.livemodule.roomutil.im;
//
//import android.content.Context;
//import android.os.Handler;
//import android.support.annotation.NonNull;
//import android.util.Log;
//
//import com.dayu.livemodule.event.UserKickOutEvent;
//import com.google.gson.Gson;
//import com.google.gson.reflect.TypeToken;
//import com.google.gson.JsonSyntaxException;
//import com.tencent.imsdk.TIMCallBack;
//import com.tencent.imsdk.TIMConnListener;
//import com.tencent.imsdk.TIMConversation;
//import com.tencent.imsdk.TIMConversationType;
//import com.tencent.imsdk.TIMCustomElem;
//import com.tencent.imsdk.TIMElem;
//import com.tencent.imsdk.TIMFriendshipManager;
//import com.tencent.imsdk.TIMGroupManager;
//import com.tencent.imsdk.TIMGroupMemberInfo;
//import com.tencent.imsdk.TIMGroupSystemElem;
//import com.tencent.imsdk.TIMGroupSystemElemType;
//import com.tencent.imsdk.TIMGroupTipsElem;
//import com.tencent.imsdk.TIMGroupTipsType;
//import com.tencent.imsdk.TIMManager;
//import com.tencent.imsdk.TIMMessage;
//import com.tencent.imsdk.TIMMessageListener;
//import com.tencent.imsdk.TIMSdkConfig;
//import com.tencent.imsdk.TIMTextElem;
//import com.tencent.imsdk.TIMUserConfig;
//import com.tencent.imsdk.TIMUserProfile;
//import com.tencent.imsdk.TIMUserStatusListener;
//import com.tencent.imsdk.TIMValueCallBack;
//import com.tencent.imsdk.ext.group.TIMGroupManagerExt;
//import com.tencent.liteav.basic.log.TXCLog;
//
//import org.greenrobot.eventbus.EventBus;
//
//import java.util.ArrayList;
//import java.util.FormatFlagsConversionMismatchException;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//
///**
// * Created by jac on 2017/11/4.
// * Copyright © 2013-2017 Tencent Cloud. All Rights Reserved.
// */
//
//public class IMMessageMgr implements TIMMessageListener {
// private static final String TAG = IMMessageMgr.class.getSimpleName();
//
// private Context mContext;
// private Handler mHandler;
//
// private static boolean mConnectSuccess = false;
// private boolean mLoginSuccess = false;
//
// private String mSelfUserID;
// private String mSelfUserSig;
// private String mGroupID;
//
// private TIMSdkConfig mTIMSdkConfig;
// private IMMessageConnCallback mIMConnListener;
// private IMMessageLoginCallback mIMLoginListener;
// private IMMessageCallback mMessageListener;
//
// /**
// * 函数级公共Callback定义
// */
// public interface Callback{
// void onError(int code, String errInfo);
// void onSuccess(Object... args);
// }
//
// /**
// * 模块回调Listener定义
// */
// public interface IMMessageListener {
// /**
// * IM连接成功
// */
// void onConnected();
//
// /**
// * IM断开连接
// */
// void onDisconnected();
//
// /**
// * IM群组里推流者成员变化通知
// */
// void onPusherChanged();
//
// /**
// * 收到群文本消息
// */
// void onGroupTextMessage(String groupID, String senderID, String userName, String headPic, String message);
//
// /**
// * 收到自定义的群消息
// */
// void onGroupCustomMessage(String groupID, String senderID, String message);
//
// /**
// * 收到自定义的C2C消息
// */
// void onC2CCustomMessage(String sendID, String cmd, String message);
//
// /**
// * IM群组销毁回调
// */
// void onGroupDestroyed(final String groupID);
//
// /**
// * 日志回调
// */
// void onDebugLog(String log);
//
// /**
// * 用户进群通知
// * @param groupID 群标识
// * @param users 进群用户信息列表
// */
// void onGroupMemberEnter(String groupID, ArrayList<TIMUserProfile> users);
//
// /**
// * 用户退群通知
// * @param groupID 群标识
// * @param users 退群用户信息列表
// */
// void onGroupMemberExit(String groupID, ArrayList<TIMUserProfile> users);
//
//
// /**
// * 用户被强制下线通知
// *
// */
// void onForceOffline();
// }
//
// public IMMessageMgr(final Context context) {
// this.mContext = context.getApplicationContext();
// this.mHandler = new Handler(this.mContext.getMainLooper());
// this.mMessageListener = new IMMessageCallback(null);
// }
//
// /**
// * 设置回调
// * @param listener
// */
// public void setIMMessageListener(IMMessageListener listener){
// this.mMessageListener.setListener(listener);
// }
//
// /**
// * 初始化
// * @param userID 用户ID
// * @param userSig 签名
// * @param appID appID
// * @param callback
// */
// public void initialize(final String userID, final String userSig, final int appID, final Callback callback){
// if (userID == null || userSig == null) {
// mMessageListener.onDebugLog("参数错误,请检查 UserID, userSig 是否为空!");
// if (callback != null) {
// callback.onError(-1, "参数错误");
// }
// return;
// }
//
// this.mSelfUserID = userID;
// this.mSelfUserSig = userSig;
//
// this.runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// long initializeStartTS = System.currentTimeMillis();
// mIMConnListener = new IMMessageConnCallback(initializeStartTS, callback);
//
// mTIMSdkConfig = new TIMSdkConfig(appID);
//
// TIMUserConfig userConfig = new TIMUserConfig();
// userConfig.setConnectionListener(mIMConnListener);
// userConfig.setUserStatusListener(new TIMUserStatusListener() {
// @Override
// public void onForceOffline() {
// IMMessageListener listener = mMessageListener;
// if (listener != null)
// listener.onForceOffline();
// }
//
// @Override
// public void onUserSigExpired() {
// IMMessageListener listener = mMessageListener;
// if (listener != null)
// listener.onForceOffline();
// }
// });
//
// TIMManager.getInstance().addMessageListener(IMMessageMgr.this);
// if( TIMManager.getInstance().init(mContext, mTIMSdkConfig) ){
// login(new Callback() {
// @Override
// public void onError(int code, String errInfo) {
// printDebugLog("login failed: %s(%d)", errInfo, code);
// mLoginSuccess = false;
// callback.onError(code, "IM登录失败");
// }
//
// @Override
// public void onSuccess(Object... args) {
// printDebugLog("login success");
// mLoginSuccess = true;
// mConnectSuccess = true;
// callback.onSuccess();
// }
// });
// TIMManager.getInstance().setUserConfig(userConfig);
// }
// else {
// printDebugLog("init failed");
// callback.onError(-1, "IM初始化失败");
// }
// }
// });
// }
//
// public void runOnHandlerThread(Runnable runnable) {
// Handler handler = mHandler;
// if (handler != null) {
// handler.post(runnable);
// } else {
// Log.e(TAG, "runOnHandlerThread -> Handler == null");
// }
// }
// /**
// * 反初始化
// */
// public void unInitialize(){
//
// TIMManager.getInstance().removeMessageListener(IMMessageMgr.this);
//
// mContext = null;
// mHandler = null;
////
//// TIMUserConfig userConfig = new TIMUserConfig();
//// userConfig.setConnectionListener(null);
//// TIMManager.getInstance().setUserConfig(userConfig);
//
// if (mTIMSdkConfig != null) {
// mTIMSdkConfig = null;
// }
//
// if (mIMConnListener != null) {
// mIMConnListener.clean();
// mIMConnListener = null;
// }
// if (mIMLoginListener != null) {
// mIMLoginListener.clean();
// mIMLoginListener = null;
// }
// if (mMessageListener != null) {
// mMessageListener.setListener(null);
// }
//
// logout(null);
// }
//
// /**
// * 加入IM群组
// * @param groupId 群ID
// * @param callback
// */
// public void jionGroup(final String groupId, final Callback callback){
// if (!mLoginSuccess){
// mMessageListener.onDebugLog("[jionGroup] IM 没有初始化");
// if (callback != null) {
// callback.onError(-1, "IM 没有初始化");
// }
// return;
// }
//
// this.runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// TIMGroupManager.getInstance().applyJoinGroup(groupId, "who care?", new TIMCallBack() {
// @Override
// public void onError(int i, String s) {
// printDebugLog("加入群 {%s} 失败:%s(%d)", groupId, s, i);
// if (i == 10010) {
// s = "房间已解散";
// }
// callback.onError(i, s);
// }
//
// @Override
// public void onSuccess() {
// printDebugLog("加入群 {%s} 成功", groupId);
// mGroupID = groupId;
// callback.onSuccess();
// }
// });
// }
// });
// }
//
// /**
// * 退出IM群组
// * @param groupId 群ID
// * @param callback
// */
// public void quitGroup(final String groupId, final Callback callback){
// if (!mLoginSuccess){
// mMessageListener.onDebugLog("[quitGroup] IM 没有初始化");
// if (callback != null) {
// callback.onError(-1, "IM 没有初始化");
// }
// return;
// }
//
// this.runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// TIMGroupManager.getInstance().quitGroup(groupId, new TIMCallBack() {
// @Override
// public void onError(int i, String s) {
// if (i == 10010) {
// printDebugLog("群 {%s} 已经解散了", groupId);
// onSuccess();
// }
// else{
// printDebugLog("退出群 {%s} 失败: %s(%d)", groupId, s, i);
// callback.onError(i, s);
// }
// }
//
// @Override
// public void onSuccess() {
// printDebugLog("退出群 {%s} 成功", groupId);
// mGroupID = groupId;
// callback.onSuccess();
// }
// });
// }
// });
// }
//
// public void createGroup(final String groupId, final String groupType, final String groupName, final Callback callback) {
// if (!mLoginSuccess){
// mMessageListener.onDebugLog("IM 没有初始化");
// if (callback != null) {
// callback.onError(-1, "IM 没有初始化");
// }
// return;
// }
// final TIMGroupManager.CreateGroupParam param = new TIMGroupManager.CreateGroupParam(groupType, groupName);
// param.setGroupId(groupId);
// this.runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// TIMGroupManager.getInstance().createGroup(param, new TIMValueCallBack<String>() {
// @Override
// public void onError(int i, String s) {
// printDebugLog("创建群 {%s} 失败:%s(%d)", groupId, s, i);
// if (i == 10036) {
// String createRoomErrorMsg = "您当前使用的云通讯账号未开通音视频聊天室功能,创建聊天室数量超过限额,请前往腾讯云官网开通【IM音视频聊天室】,地址:https://buy.cloud.tencent.com/avc";
// TXCLog.e(TAG, createRoomErrorMsg);
// printDebugLog(createRoomErrorMsg);
// }
// if (i == 10025) {
// mGroupID = groupId;
// }
// callback.onError(i, s);
// }
//
// @Override
// public void onSuccess(String s) {
// printDebugLog("创建群 {%s} 成功", groupId);
// mGroupID = groupId;
// callback.onSuccess();
// }
// });
// }
// });
// }
//
// /**
// * 销毁IM群组
// * @param groupId 群ID
// * @param callback
// */
// public void destroyGroup(final String groupId, final Callback callback){
// if (!mLoginSuccess){
// mMessageListener.onDebugLog("IM 没有初始化");
// if (callback != null) {
// callback.onError(-1, "IM 没有初始化");
// }
// return;
// }
//
// this.runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// TIMGroupManager.getInstance().deleteGroup(groupId, new TIMCallBack() {
// @Override
// public void onError(int i, String s) {
// printDebugLog("解散群 {%s} 失败:%s(%d)", groupId, s, i);
// callback.onError(i, s);
// }
//
// @Override
// public void onSuccess() {
// printDebugLog("解散群 {%s} 成功", groupId);
// mGroupID = groupId;
// callback.onSuccess();
// }
// });
// }
// });
// }
//
// /**
// * 发送IM群文本消息
// * @param userName 发送者用户名
// * @param headPic 发送者头像
// * @param text 文本内容
// * @param callback
// */
// public void sendGroupTextMessage(final @NonNull String userName, final @NonNull String headPic, final @NonNull String text, final Callback callback){
// if (!mLoginSuccess){
// mMessageListener.onDebugLog("[sendGroupTextMessage] IM 没有初始化");
// if (callback != null)
// callback.onError(-1, "IM 没有初始化");
// return;
// }
//
// this.runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// TIMMessage message = new TIMMessage();
// try {
// CommonJson<UserInfo> txtHeadMsg = new CommonJson<UserInfo>();
// txtHeadMsg.cmd = "CustomTextMsg";
// txtHeadMsg.data = new UserInfo();
// txtHeadMsg.data.nickName = userName;
// txtHeadMsg.data.headPic = headPic;
// String strCmdMsg = new Gson().toJson(txtHeadMsg, new TypeToken<CommonJson<UserInfo>>(){}.getType());
//
// TIMCustomElem customElem = new TIMCustomElem();
// customElem.setData(strCmdMsg.getBytes("UTF-8"));
//
// TIMTextElem textElem = new TIMTextElem();
// textElem.setText(text);
//
// message.addElement(customElem);
// message.addElement(textElem);
// }
// catch (Exception e) {
// printDebugLog("[sendGroupTextMessage] 发送群{%s}消息失败,组包异常", mGroupID);
// if (callback != null) {
// callback.onError(-1, "发送群消息失败");
// }
// return;
// }
//
// TIMConversation conversation = TIMManager.getInstance().getConversation(TIMConversationType.Group, mGroupID);
// conversation.sendMessage(message, new TIMValueCallBack<TIMMessage>() {
// @Override
// public void onError(int i, String s) {
// printDebugLog("[sendGroupTextMessage] 发送群{%s}消息失败: %s(%d)", mGroupID, s, i);
//
// if (callback != null)
// callback.onError(i, s);
// }
//
// @Override
// public void onSuccess(TIMMessage timMessage) {
// printDebugLog("[sendGroupTextMessage] 发送群消息成功");
//
// if (callback != null)
// callback.onSuccess();
// }
// });
// }
// });
// }
//
// /**
// * 发送自定义群消息
// * @param content 自定义消息的内容
// * @param callback
// */
// public void sendGroupCustomMessage(final @NonNull String content, final Callback callback) {
// if (!mLoginSuccess){
// mMessageListener.onDebugLog("[sendGroupCustomMessage] IM 没有初始化");
// if (callback != null)
// callback.onError(-1, "IM 没有初始化");
// return;
// }
//
// this.runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// TIMMessage message = new TIMMessage();
// try {
// TIMCustomElem customElem = new TIMCustomElem();
// customElem.setData(content.getBytes("UTF-8"));
// message.addElement(customElem);
// }
// catch (Exception e) {
// printDebugLog("[sendGroupCustomMessage] 发送自定义群{%s}消息失败,组包异常", mGroupID);
// if (callback != null) {
// callback.onError(-1, "发送CC消息失败");
// }
// return;
// }
//
// TIMConversation conversation = TIMManager.getInstance().getConversation(TIMConversationType.Group, mGroupID);
// conversation.sendMessage(message, new TIMValueCallBack<TIMMessage>() {
// @Override
// public void onError(int i, String s) {
// printDebugLog("[sendGroupCustomMessage] 发送自定义群{%s}消息失败: %s(%d)", mGroupID, s, i);
//
// if (callback != null)
// callback.onError(i, s);
// }
//
// @Override
// public void onSuccess(TIMMessage timMessage) {
// printDebugLog("[sendGroupCustomMessage] 发送自定义群消息成功");
//
// if (callback != null)
// callback.onSuccess();
// }
// });
// }
// });
// }
//
// /**
// * 发送CC(端到端)自定义消息
// * @param toUserID 接收者userID
// * @param content 自定义消息的内容
// * @param callback
// */
// public void sendC2CCustomMessage(final @NonNull String toUserID, final @NonNull String content, final Callback callback) {
// if (!mLoginSuccess){
// mMessageListener.onDebugLog("[sendCustomMessage] IM 没有初始化");
// if (callback != null)
// callback.onError(-1, "IM 没有初始化");
// return;
// }
//
// this.runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// TIMMessage message = new TIMMessage();
// try {
// TIMCustomElem customElem = new TIMCustomElem();
// customElem.setData(content.getBytes("UTF-8"));
// message.addElement(customElem);
// }
// catch (Exception e) {
// printDebugLog("[sendCustomMessage] 发送CC{%s}消息失败,组包异常", toUserID);
// if (callback != null) {
// callback.onError(-1, "发送CC消息失败");
// }
// return;
// }
//
// TIMConversation conversation = TIMManager.getInstance().getConversation(TIMConversationType.C2C, toUserID);
// conversation.sendMessage(message, new TIMValueCallBack<TIMMessage>() {
// @Override
// public void onError(int i, String s) {
// printDebugLog("[sendCustomMessage] 发送CC{%s}消息失败: %s(%d)", toUserID, s, i);
//
// if (callback != null)
// callback.onError(i, s);
// }
//
// @Override
// public void onSuccess(TIMMessage timMessage) {
// printDebugLog("[sendCustomMessage] 发送CC消息成功");
//
// if (callback != null)
// callback.onSuccess();
// }
// });
// }
// });
// }
//
// public void getGroupMembers(final String groupId, final int maxSize, final TIMValueCallBack<List<TIMUserProfile>> cb) {
// this.runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// TIMGroupManagerExt.getInstance().getGroupMembers(groupId, new TIMValueCallBack<List<TIMGroupMemberInfo>>() {
// @Override
// public void onError(int i, String s) {
//
// }
//
// @Override
// public void onSuccess(List<TIMGroupMemberInfo> timGroupMemberInfos) {
// ArrayList<String> users = new ArrayList<>();
// int count = 0;
// for (TIMGroupMemberInfo memberInfo : timGroupMemberInfos) {
// if (count < maxSize) {
// users.add(memberInfo.getUser());
// count++;
// } else {
// break;
// }
// }
// TIMFriendshipManager.getInstance().getUsersProfile(users, false, cb);
// }
// });
// }
// });
// }
//
// public void setSelfProfile(final String nickname, final String faceURL) {
// if (nickname == null && faceURL == null) {
// return;
// }
// this.runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// HashMap<String, Object> profileMap = new HashMap<>();
// if (nickname != null) {
// profileMap.put(TIMUserProfile.TIM_PROFILE_TYPE_KEY_NICK, nickname);
// }
// if (faceURL != null) {
// profileMap.put(TIMUserProfile.TIM_PROFILE_TYPE_KEY_FACEURL, faceURL);
// }
// TIMFriendshipManager.getInstance().modifySelfProfile(profileMap, new TIMCallBack() {
// @Override
// public void onError(int code, String desc) {
// Log.e(TAG, "modifySelfProfile failed: " + code + " desc" + desc);
// if (code == 6014){
// EventBus.getDefault().post(new UserKickOutEvent());
// }
// }
//
// @Override
// public void onSuccess() {
// Log.e(TAG, "modifySelfProfile success");
// }
// });
// }
// });
// }
//
// public void getUserProfile(final ArrayList<String> userIDs, final TIMValueCallBack<List<TIMUserProfile>> cb) {
// TIMFriendshipManager.getInstance().getUsersProfile(userIDs, false, cb);
// }
//
// @Override
// public boolean onNewMessages(List<TIMMessage> list) {
// for (TIMMessage message : list) {
//
// for (int i = 0; i < message.getElementCount(); i++) {
// TIMElem element = message.getElement(i);
//
// printDebugLog("onNewMessage type = %s", element.getType());
//
// switch (element.getType()){
//
// case GroupSystem:{
// TIMGroupSystemElemType systemElemType = ((TIMGroupSystemElem) element).getSubtype();
//
// switch (systemElemType){
//
// case TIM_GROUP_SYSTEM_DELETE_GROUP_TYPE:{
// printDebugLog("onNewMessage subType = %s", systemElemType);
// if (mMessageListener != null)
// mMessageListener.onGroupDestroyed(((TIMGroupSystemElem) element).getGroupId());
// break;
// }
//
// case TIM_GROUP_SYSTEM_CUSTOM_INFO:{
//
// byte[] userData = ((TIMGroupSystemElem) element).getUserData();
// if (userData == null || userData.length == 0){
// printDebugLog("userData == null");
// break;
// }
//
// String data = new String(userData);
// printDebugLog("onNewMessage subType = %s content = %s", systemElemType, data);
// try {
// CommonJson<Object> commonJson = new Gson().fromJson(data, new TypeToken<CommonJson<Object>>(){}.getType());
// if (commonJson.cmd.equals("notifyPusherChange")) {
// mMessageListener.onPusherChanged();
// }
// } catch (JsonSyntaxException e) {
// e.printStackTrace();
// }
// break;
// }
// }
//
// break;
// }//case GroupSystem
//
// case Custom: {
// byte[] userData = ((TIMCustomElem) element).getData();
// if (userData == null || userData.length == 0){
// printDebugLog("userData == null");
// break;
// }
//
// String data = new String(userData);
// printDebugLog("onNewMessage subType = Custom content = %s", data);
// try {
// CommonJson<Object> commonJson = new Gson().fromJson(data, new TypeToken<CommonJson<Object>>(){}.getType());
// if (commonJson.cmd != null) {
// if (commonJson.cmd.equalsIgnoreCase("CustomTextMsg")) {
// ++i;
// UserInfo userInfo = new Gson().fromJson(new Gson().toJson(commonJson.data), UserInfo.class);
// if (userInfo != null && i < message.getElementCount()) {
// TIMElem nextElement = message.getElement(i);
// TIMTextElem textElem = (TIMTextElem) nextElement;
// String text = textElem.getText();
// if (text != null){
// mMessageListener.onGroupTextMessage(mGroupID, message.getSender(), userInfo.nickName, userInfo.headPic, text);
// }
// }
// }
// else if (commonJson.cmd.equalsIgnoreCase("linkmic") || commonJson.cmd.equalsIgnoreCase("pk")) {
// mMessageListener.onC2CCustomMessage(message.getSender(), commonJson.cmd, new Gson().toJson(commonJson.data));
// }
// else if (commonJson.cmd.equalsIgnoreCase("CustomCmdMsg")) {
// mMessageListener.onGroupCustomMessage(mGroupID, message.getSender(), new Gson().toJson(commonJson.data));
// } else if (commonJson.cmd.equalsIgnoreCase("notifyPusherChange")) {
// mMessageListener.onPusherChanged();
// }
// }
// } catch (JsonSyntaxException e) {
// e.printStackTrace();
// }
// break;
// }
//
// case GroupTips:
// {
// TIMGroupTipsElem tipsElem = (TIMGroupTipsElem)element;
// if (tipsElem.getTipsType() == TIMGroupTipsType.Join) {
// Map<String, TIMUserProfile> changedUserInfos = tipsElem.getChangedUserInfo();
// if (changedUserInfos != null && changedUserInfos.size() > 0) {
// ArrayList<TIMUserProfile> users = new ArrayList<>();
// for (Map.Entry<String, TIMUserProfile> entry : changedUserInfos.entrySet()) {
// users.add(entry.getValue());
// }
// mMessageListener.onGroupMemberEnter(tipsElem.getGroupId(), users);
// }
// } else if (tipsElem.getTipsType() == TIMGroupTipsType.Quit) {
// ArrayList<TIMUserProfile> users = new ArrayList<>();
// users.add(tipsElem.getOpUserInfo());
// mMessageListener.onGroupMemberExit(tipsElem.getGroupId(), users);
// }
// break;
// }
// }
// }
// }
// return false;
// }
//
// private void login(final Callback cb){
// if (mSelfUserID == null || mSelfUserSig == null ){
// if (cb != null) {
// cb.onError(-1, "没有 UserId");
// }
// return;
// }
//
// Log.i(TAG, "start login: userId = " + this.mSelfUserID);
//
// final long loginStartTS = System.currentTimeMillis();
//
// mIMLoginListener = new IMMessageLoginCallback(loginStartTS, cb);
//
// TIMManager.getInstance().login(this.mSelfUserID, this.mSelfUserSig, mIMLoginListener);
// }
//
// private void logout(final Callback callback){
// if (!mLoginSuccess){
// return;
// }
//
// TIMManager.getInstance().logout(null);
// }
//
// private void printDebugLog(String format, Object ...args){
// String log;
// try {
// log = String.format(format, args);
// Log.e(TAG, log);
// if (mMessageListener != null) {
// mMessageListener.onDebugLog(log);
// }
// } catch (FormatFlagsConversionMismatchException e) {
// e.printStackTrace();
// }
// }
//
// /**
// * 辅助类 IM Connect Listener
// */
// private class IMMessageConnCallback implements TIMConnListener {
// private long initializeStartTS = 0;
// private Callback callback;
//
// public IMMessageConnCallback(long ts, Callback cb) {
// initializeStartTS = ts;
// callback = cb;
// }
//
// public void clean() {
// initializeStartTS = 0;
// callback = null;
// }
//
// @Override
// public void onConnected() {
// printDebugLog("connect success,initialize() time cost %.2f secs", (System.currentTimeMillis() - initializeStartTS) / 1000.0);
// mMessageListener.onConnected();
// mConnectSuccess = true;
// }
//
// @Override
// public void onDisconnected(int i, String s) {
// printDebugLog("disconnect: %s(%d)", s, i);
// if (mLoginSuccess) {
// if (mMessageListener != null) {
// mMessageListener.onDisconnected();
// }
// } else {
// if (callback != null) {
// callback.onError(i, s);
// }
// }
// mConnectSuccess = false;
// }
//
// @Override
// public void onWifiNeedAuth(String s) {
// printDebugLog("onWifiNeedAuth(): %s", s);
// if (mLoginSuccess){
// mMessageListener.onDisconnected();
// }
// else {
// if (callback != null) {
// callback.onError(-1, s);
// }
// }
// mConnectSuccess = false;
// }
// }
//
// /**
// * 辅助类 IM Login Listener
// */
// private class IMMessageLoginCallback implements TIMCallBack {
// private long loginStartTS ;
// private Callback callback;
//
// public IMMessageLoginCallback(long ts, Callback cb) {
// loginStartTS = ts;
// callback = cb;
// }
//
// public void clean() {
// loginStartTS = 0;
// callback = null;
// }
//
// @Override
// public void onError(int i, String s) {
// if (callback != null) {
// callback.onError(i, s);
// }
// }
//
// @Override
// public void onSuccess() {
// printDebugLog("login success, time cost %.2f secs", (System.currentTimeMillis()- loginStartTS) / 1000.0);
// if (callback != null) {
// callback.onSuccess();
// }
// }
// };
//
// /**
// * 辅助类 IM Message Listener
// */
// private class IMMessageCallback implements IMMessageListener {
// private IMMessageListener listener;
//
// public IMMessageCallback(IMMessageListener listener) {
// this.listener = listener;
// }
//
// public void setListener(IMMessageListener listener) {
// this.listener = listener;
// }
//
// @Override
// public void onConnected() {
// runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// if (listener != null)
// listener.onConnected();
// }
// });
// }
//
// @Override
// public void onDisconnected() {
// runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// if (listener != null)
// listener.onDisconnected();
// }
// });
// }
// @Override
// public void onPusherChanged() {
// runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// if (listener != null)
// listener.onPusherChanged();
// }
// });
// }
//
// @Override
// public void onGroupDestroyed(final String groupID) {
// runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// if (listener != null)
// listener.onGroupDestroyed(groupID);
// }
// });
// }
//
// @Override
// public void onDebugLog(final String line) {
// runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// if (listener != null)
// listener.onDebugLog("[IM] "+line);
// }
// });
// }
//
// @Override
// public void onGroupMemberEnter(final String groupID, final ArrayList<TIMUserProfile> users) {
// runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// if (listener != null)
// listener.onGroupMemberEnter(groupID, users);
// }
// });
// }
//
// @Override
// public void onGroupMemberExit(final String groupID, final ArrayList<TIMUserProfile> users) {
// runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// if (listener != null)
// listener.onGroupMemberExit(groupID, users);
// }
// });
// }
//
// @Override
// public void onForceOffline() {
// runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// if (listener != null) {
// listener.onForceOffline();
// }
// }
// });
// }
//
// @Override
// public void onGroupTextMessage(final String roomID, final String senderID, final String userName, final String headPic, final String message) {
// runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// if (listener != null)
// listener.onGroupTextMessage(roomID, senderID, userName, headPic, message);
// }
// });
// }
//
// @Override
// public void onGroupCustomMessage(final String groupID, final String senderID, final String message) {
// runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// if (listener != null)
// listener.onGroupCustomMessage(groupID, senderID, message);
// }
// });
// }
//
// @Override
// public void onC2CCustomMessage(final String senderID, final String cmd, final String message) {
// runOnHandlerThread(new Runnable() {
// @Override
// public void run() {
// if (listener != null)
// listener.onC2CCustomMessage(senderID, cmd, message);
// }
// });
// }
// }
//
// private static class CommonJson<T> {
// String cmd;
// T data;
// }
//
// private static final class UserInfo {
// String nickName;
// String headPic;
// }
//}
......@@ -43,65 +43,65 @@ public class TCVideoListMgr {
* @param listener
*/
public void fetchLiveList(Context context, final Listener listener) {
MLVBLiveRoom liveRoom = MLVBLiveRoom.sharedInstance(context);
liveRoom.getRoomList(0, PAGE_SIZE, new IMLVBLiveRoomListener.GetRoomListCallback() {
@Override
public void onError(int errCode, String errInfo) {
if (listener != null) {
listener.onVideoList(errCode, null, false);
}
}
@Override
public void onSuccess(ArrayList<RoomInfo> data) {
ArrayList<TCVideoInfo> infos = new ArrayList();
if (data != null && data.size() > 0) {
for (RoomInfo value : data) {
List<AnchorInfo> pushers = value.pushers;
String envStr = "";
TCVideoInfo info = new TCVideoInfo();
info.playUrl = value.mixedPlayURL;
info.title = value.roomName;
info.userId = value.roomCreator;
info.groupId = value.roomID;
info.viewerCount = value.audienceCount;
info.livePlay = true;
info.roomInfo = value.roomInfo;
if (pushers != null && !pushers.isEmpty()) {
AnchorInfo pusher = pushers.get(0);
info.nickname = pusher.userName;
info.avatar = pusher.userAvatar;
}
try {
JSONObject jsonRoomInfo = new JSONObject(value.roomInfo);
info.title = jsonRoomInfo.optString("title");
info.frontCover = jsonRoomInfo.optString("frontcover");
info.location = jsonRoomInfo.optString("location");
envStr = jsonRoomInfo.optString(TCGlobalConfig.LIVE_ENVIRONMENT);
} catch (Exception e) {
e.printStackTrace();
if (!TextUtils.isEmpty(value.roomInfo)) {
info.title = value.roomInfo;
}
}
try {
JSONObject jsonCunstomInfo = new JSONObject(value.custom);
info.likeCount = jsonCunstomInfo.optInt("praise");
} catch (Exception e) {
e.printStackTrace();
}
if (envStr.equals(TCGlobalConfig.ENVIRONMENT))
infos.add(info);
}
}
if (listener != null) {
listener.onVideoList(0, infos, true);
}
}
});
// MLVBLiveRoom liveRoom = MLVBLiveRoom.sharedInstance(context);
// liveRoom.getRoomList(0, PAGE_SIZE, new IMLVBLiveRoomListener.GetRoomListCallback() {
// @Override
// public void onError(int errCode, String errInfo) {
// if (listener != null) {
// listener.onVideoList(errCode, null, false);
// }
// }
//
// @Override
// public void onSuccess(ArrayList<RoomInfo> data) {
// ArrayList<TCVideoInfo> infos = new ArrayList();
// if (data != null && data.size() > 0) {
// for (RoomInfo value : data) {
// List<AnchorInfo> pushers = value.pushers;
//
// String envStr = "";
// TCVideoInfo info = new TCVideoInfo();
// info.playUrl = value.mixedPlayURL;
// info.title = value.roomName;
// info.userId = value.roomCreator;
// info.groupId = value.roomID;
// info.viewerCount = value.audienceCount;
// info.livePlay = true;
// info.roomInfo = value.roomInfo;
// if (pushers != null && !pushers.isEmpty()) {
// AnchorInfo pusher = pushers.get(0);
// info.nickname = pusher.userName;
// info.avatar = pusher.userAvatar;
// }
//
// try {
// JSONObject jsonRoomInfo = new JSONObject(value.roomInfo);
// info.title = jsonRoomInfo.optString("title");
// info.frontCover = jsonRoomInfo.optString("frontcover");
// info.location = jsonRoomInfo.optString("location");
// envStr = jsonRoomInfo.optString(TCGlobalConfig.LIVE_ENVIRONMENT);
// } catch (Exception e) {
// e.printStackTrace();
// if (!TextUtils.isEmpty(value.roomInfo)) {
// info.title = value.roomInfo;
// }
// }
//
// try {
// JSONObject jsonCunstomInfo = new JSONObject(value.custom);
// info.likeCount = jsonCunstomInfo.optInt("praise");
// } catch (Exception e) {
// e.printStackTrace();
// }
// if (envStr.equals(TCGlobalConfig.ENVIRONMENT))
// infos.add(info);
// }
// }
// if (listener != null) {
// listener.onVideoList(0, infos, true);
// }
// }
// });
}
/**
......
......@@ -29,6 +29,6 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
api files('libs/Amap_2DMap_V5.2.0_20170627.jar')
api files('libs/AMap_Search_V7.3.0_20200331.jar')
// api files('libs/Amap_2DMap_V5.2.0_20170627.jar')
// api files('libs/AMap_Search_V7.3.0_20200331.jar')
}
......@@ -4,9 +4,18 @@ import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.location.Address;
import android.location.Criteria;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
......@@ -16,6 +25,8 @@ import com.amap.api.location.CoordinateConverter;
import com.amap.api.location.DPoint;
import java.io.File;
import java.util.List;
import java.util.Locale;
/**
......@@ -24,124 +35,124 @@ import java.io.File;
*/
public class LocationUtils {
@SuppressLint("StaticFieldLeak")
private static AMapLocationClient mlocationClient;
private static AMapLocation sLocation = null;
private static boolean flag = true;
private static MyLocationListener mListener;
private static Handler mHandler;
private static Context mContext;
/**
* @param context
* @Title: init
* @Description: 初始化地图导航,在Application onCreate中调用,只需调用一次
*/
public static void init(Context context) {
mContext = context;
AMapLocationClient.setApiKey("05936ed54259770e56ffd1e67ac77958");
mlocationClient = new AMapLocationClient(context);
AMapLocationClientOption mOption = new AMapLocationClientOption();
mOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);//可选,设置定位模式,可选的模式有高精度、仅设备、仅网络。默认为高精度模式
mOption.setGpsFirst(false);//可选,设置是否gps优先,只在高精度模式下有效。默认关闭
mOption.setHttpTimeOut(30000);//可选,设置网络请求超时时间。默认为30秒。在仅设备模式下无效
mOption.setInterval(2000);//可选,设置定位间隔。默认为2秒
mOption.setNeedAddress(true);//可选,设置是否返回逆地理地址信息。默认是true
mOption.setOnceLocation(false);//可选,设置是否单次定位。默认是false
mOption.setOnceLocationLatest(false);//可选,设置是否等待wifi刷新,默认为false.如果设置为true,会自动变为单次定位,持续定位时不要使用
AMapLocationClientOption.setLocationProtocol(AMapLocationClientOption.AMapLocationProtocol.HTTP);//可选, 设置网络请求的协议。可选HTTP或者HTTPS。默认为HTTP
mOption.setSensorEnable(false);//可选,设置是否使用传感器。默认是false
mOption.setWifiScan(true); //可选,设置是否开启wifi扫描。默认为true,如果设置为false会同时停止主动刷新,停止以后完全依赖于系统刷新,定位位置可能存在误差
mOption.setLocationCacheEnable(true); //可选,设置是否使用缓存定位,默认为true
mlocationClient.setLocationOption(mOption);
}
/**
* @Description: 定位结果回调
*/
public interface MyLocationListener {
void result(AMapLocation location);
}
/**
* @param listener
* @Title: getLocation
* @Description: 获取位置,如果之前获取过定位结果,则不会重复获取
*/
public static void getLocation(MyLocationListener listener) {
Log.e("luofan ", "开始获取地址.");
if (sLocation == null) {
getCurrentLocation(listener);
} else {
listener.result(sLocation);
}
}
/**
* @param listener
* @Title: getCurrentLocation
* @Description: 获取位置,重新发起获取位置请求
*/
public static void getCurrentLocation(MyLocationListener listener) {
mListener = listener;
if (mlocationClient == null) {
return;
}
flag = true;
mHandler = new Handler();
//刷新有时不回调.
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
if (flag) {
if (mListener != null) {
mListener.result(sLocation);
flag = false;
mlocationClient.stopLocation();
}
}
}
}, 5000);
mlocationClient.setLocationListener(new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation location) {
if (mListener != null && location != null && location.getErrorCode() == 0 && flag) {
flag = false;
mlocationClient.stopLocation();
sLocation = location;
mListener.result(location);
mHandler = null;
}
}
});
// 启动定位
mlocationClient.startLocation();
}
/**
* @Title: destroy
* @Description: 销毁定位,必须在退出程序时调用,否则定位会发生异常
*/
public static void destroy() {
mHandler = null;
if (mlocationClient != null) {
mlocationClient.onDestroy();
}
mListener = null;
}
/**
* @Title: destroy
* @Description: 销毁定位,必须在退出程序时调用,否则定位会发生异常
*/
public static void stop() {
mlocationClient.stopLocation();
}
// @SuppressLint("StaticFieldLeak")
// private static AMapLocationClient mlocationClient;
// private static AMapLocation sLocation = null;
// private static boolean flag = true;
// private static MyLocationListener mListener;
// private static Handler mHandler;
// private static Context mContext;
//
// /**
// * @param context
// * @Title: init
// * @Description: 初始化地图导航,在Application onCreate中调用,只需调用一次
// */
// public static void init(Context context) {
// mContext = context;
// AMapLocationClient.setApiKey("05936ed54259770e56ffd1e67ac77958");
// mlocationClient = new AMapLocationClient(context);
// AMapLocationClientOption mOption = new AMapLocationClientOption();
// mOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);//可选,设置定位模式,可选的模式有高精度、仅设备、仅网络。默认为高精度模式
// mOption.setGpsFirst(false);//可选,设置是否gps优先,只在高精度模式下有效。默认关闭
// mOption.setHttpTimeOut(30000);//可选,设置网络请求超时时间。默认为30秒。在仅设备模式下无效
// mOption.setInterval(2000);//可选,设置定位间隔。默认为2秒
// mOption.setNeedAddress(true);//可选,设置是否返回逆地理地址信息。默认是true
// mOption.setOnceLocation(false);//可选,设置是否单次定位。默认是false
// mOption.setOnceLocationLatest(false);//可选,设置是否等待wifi刷新,默认为false.如果设置为true,会自动变为单次定位,持续定位时不要使用
// AMapLocationClientOption.setLocationProtocol(AMapLocationClientOption.AMapLocationProtocol.HTTP);//可选, 设置网络请求的协议。可选HTTP或者HTTPS。默认为HTTP
// mOption.setSensorEnable(false);//可选,设置是否使用传感器。默认是false
// mOption.setWifiScan(true); //可选,设置是否开启wifi扫描。默认为true,如果设置为false会同时停止主动刷新,停止以后完全依赖于系统刷新,定位位置可能存在误差
// mOption.setLocationCacheEnable(true); //可选,设置是否使用缓存定位,默认为true
//
// mlocationClient.setLocationOption(mOption);
// }
//
// /**
// * @Description: 定位结果回调
// */
// public interface MyLocationListener {
// void result(AMapLocation location);
// }
//
// /**
// * @param listener
// * @Title: getLocation
// * @Description: 获取位置,如果之前获取过定位结果,则不会重复获取
// */
// public static void getLocation(MyLocationListener listener) {
// Log.e("luofan ", "开始获取地址.");
// if (sLocation == null) {
// getCurrentLocation(listener);
// } else {
// listener.result(sLocation);
// }
// }
//
// /**
// * @param listener
// * @Title: getCurrentLocation
// * @Description: 获取位置,重新发起获取位置请求
// */
// public static void getCurrentLocation(MyLocationListener listener) {
// mListener = listener;
// if (mlocationClient == null) {
// return;
// }
// flag = true;
// mHandler = new Handler();
// //刷新有时不回调.
// mHandler.postDelayed(new Runnable() {
// @Override
// public void run() {
// if (flag) {
// if (mListener != null) {
// mListener.result(sLocation);
// flag = false;
// mlocationClient.stopLocation();
// }
// }
// }
// }, 5000);
//
// mlocationClient.setLocationListener(new AMapLocationListener() {
//
// @Override
// public void onLocationChanged(AMapLocation location) {
// if (mListener != null && location != null && location.getErrorCode() == 0 && flag) {
// flag = false;
// mlocationClient.stopLocation();
// sLocation = location;
// mListener.result(location);
// mHandler = null;
// }
// }
// });
// // 启动定位
// mlocationClient.startLocation();
// }
//
// /**
// * @Title: destroy
// * @Description: 销毁定位,必须在退出程序时调用,否则定位会发生异常
// */
// public static void destroy() {
// mHandler = null;
// if (mlocationClient != null) {
// mlocationClient.onDestroy();
// }
// mListener = null;
// }
//
// /**
// * @Title: destroy
// * @Description: 销毁定位,必须在退出程序时调用,否则定位会发生异常
// */
// public static void stop() {
// mlocationClient.stopLocation();
// }
//
//
private static boolean isInstallPackage() {
return new File("/data/data/" + "com.autonavi.minimap").exists();
}
......@@ -171,39 +182,22 @@ public class LocationUtils {
public interface OpenMarketListener {
void openMarket();
}
private static final double EARTH_RADIUS = 6378137.0;
/**
* 根据经纬度计算两地距离
*
* @param longitude
* @param latitue
* @param longitude2
* @param latitue2
* @return
*/
public static double getDistance(double latitue, double longitude, double latitue2, double longitude2) {
DPoint point1 = new DPoint(latitue, longitude);
DPoint point2 = new DPoint(latitue2, longitude2);
return CoordinateConverter.calculateLineDistance(point1, point2);
// // 纬度
// double lat1 = Math.toRadians(latitue);
// double lat2 = Math.toRadians(latitue2);
// // 经度
// double lng1 = Math.toRadians(longitude);
// double lng2 = Math.toRadians(longitude2);
// // 纬度之差
// double a = lat1 - lat2;
// // 经度之差
// double b = lng1 - lng2;
// // 计算两点距离的公式
// double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
// Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(b / 2), 2)));
// // 弧长乘地球半径, 返回单位: 米
// s = s * EARTH_RADIUS;
// return s;
}
//
// private static final double EARTH_RADIUS = 6378137.0;
//
// /**
// * 根据经纬度计算两地距离
// *
// * @param longitude
// * @param latitue
// * @param longitude2
// * @param latitue2
// * @return
// */
// public static double getDistance(double latitue, double longitude, double latitue2, double longitude2) {
// DPoint point1 = new DPoint(latitue, longitude);
// DPoint point2 = new DPoint(latitue2, longitude2);
// return CoordinateConverter.calculateLineDistance(point1, point2);
//
// }
}
package com.dayu.location.base;
import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.provider.Settings;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class LocationUtils1 {
private volatile static LocationUtils1 uniqueInstance;
private LocationManager locationManager;
private Context mContext;
private static ArrayList<AddressCallback> addressCallbacks;
private AddressCallback addressCallback;
public AddressCallback getAddressCallback() {
return addressCallback;
}
public void setAddressCallback(AddressCallback addressCallback) {
this.addressCallback = addressCallback;
if(isInit){
showLocation();
}else {
isInit = true;
}
}
private static Location location;
private boolean isInit = false;//是否加载过
private LocationUtils1(Context context) {
mContext = context;
getLocation();
}
//采用Double CheckLock(DCL)实现单例
public static LocationUtils1 getInstance(Context context) {
if (uniqueInstance == null) {
synchronized (LocationUtils1.class) {
if (uniqueInstance == null) {
addressCallbacks = new ArrayList<>();
uniqueInstance = new LocationUtils1(context);
}
}
}
return uniqueInstance;
}
/**
* 添加回调事件
* @param addressCallback
*/
private void addAddressCallback(AddressCallback addressCallback){
addressCallbacks.add(addressCallback);
if(isInit){
showLocation();
}
}
/**
* 移除回调事件
* @param addressCallback
*/
public void removeAddressCallback(AddressCallback addressCallback){
if(addressCallbacks.contains(addressCallback)){
addressCallbacks.remove(addressCallback);
}
}
/**
* 清空回调事件
*/
public void cleareAddressCallback(){
removeLocationUpdatesListener();
addressCallbacks.clear();
}
private void getLocation() {
//1.获取位置管理器
locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
//添加用户权限申请判断
//2.获取位置提供器,GPS或是NetWork
// 获取所有可用的位置提供器
List<String> providerList = locationManager.getProviders(true);
String locationProvider;
if (providerList.contains(LocationManager.GPS_PROVIDER)) {
//GPS 定位的精准度比较高,但是非常耗电。
// System.out.println("=====GPS_PROVIDER=====");
locationProvider = LocationManager.GPS_PROVIDER;
} else if (providerList.contains(LocationManager.NETWORK_PROVIDER)) {//Google服务被墙不可用
//网络定位的精准度稍差,但耗电量比较少。
// System.out.println("=====NETWORK_PROVIDER=====");
locationProvider = LocationManager.NETWORK_PROVIDER;
} else {
// System.out.println("=====NO_PROVIDER=====");
// 当没有可用的位置提供器时,弹出Toast提示用户
Intent intent = new Intent();
intent.setAction(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mContext.startActivity(intent);
return;
}
//3.获取上次的位置,一般第一次运行,此值为null
location = locationManager.getLastKnownLocation(locationProvider);
if (location != null) {
// 显示当前设备的位置信息
// System.out.println("==显示当前设备的位置信息==");
showLocation();
} else {//当GPS信号弱没获取到位置的时候可从网络获取
// System.out.println("==Google服务被墙的解决办法==");
getLngAndLatWithNetwork();//Google服务被墙的解决办法
}
// 监视地理位置变化,第二个和第三个参数分别为更新的最短时间minTime和最短距离minDistace
//LocationManager 每隔 5 秒钟会检测一下位置的变化情况,当移动距离超过 10 米的时候,
// 就会调用 LocationListener 的 onLocationChanged() 方法,并把新的位置信息作为参数传入。
// locationManager.requestLocationUpdates(locationProvider, 5000, 10, locationListener);
}
//获取经纬度
private void showLocation() {
if(location == null){
getLocation();
}else {
double latitude = location.getLatitude();//纬度
double longitude = location.getLongitude();//经度
// for(AddressCallback addressCallback:addressCallbacks){
// addressCallback.onGetLocation(latitude,longitude);
// }
if(addressCallback != null){
addressCallback.onGetLocation(latitude,longitude);
}
getAddress(latitude, longitude);
}
}
private void getAddress(double latitude, double longitude) {
//Geocoder通过经纬度获取具体信息
Geocoder gc = new Geocoder(mContext, Locale.getDefault());
try {
List<Address> locationList = gc.getFromLocation(latitude, longitude, 1);
if (locationList != null) {
Address address = locationList.get(0);
String countryName = address.getCountryName();//国家
String countryCode = address.getCountryCode();
String adminArea = address.getAdminArea();//省
String locality = address.getLocality();//市
String subLocality = address.getSubLocality();//区
String featureName = address.getFeatureName();//街道
for (int i = 0; address.getAddressLine(i) != null; i++) {
String addressLine = address.getAddressLine(i);
//街道名称:广东省深圳市罗湖区蔡屋围一街深圳瑞吉酒店
// System.out.println("addressLine=====" + addressLine);
}
if(addressCallback != null){
addressCallback.onGetAddress(address);
}
// for(AddressCallback addressCallback:addressCallbacks){
// addressCallback.onGetAddress(address);
// }
}
} catch (IOException e) {
e.printStackTrace();
}
}
private void removeLocationUpdatesListener() {
if (locationManager != null) {
uniqueInstance = null;
locationManager.removeUpdates(locationListener);
}
}
private LocationListener locationListener = new LocationListener() {
// Provider的状态在可用、暂时不可用和无服务三个状态直接切换时触发此函数
@Override
public void onStatusChanged(String provider, int status, Bundle arg2) {
}
// Provider被enable时触发此函数,比如GPS被打开
@Override
public void onProviderEnabled(String provider) {
}
// Provider被disable时触发此函数,比如GPS被关闭
@Override
public void onProviderDisabled(String provider) {
}
//当坐标改变时触发此函数,如果Provider传进相同的坐标,它就不会被触发
@Override
public void onLocationChanged(Location loc) {
// System.out.println("==onLocationChanged==");
// location = loc;
// showLocation();
}
};
//从网络获取经纬度
private void getLngAndLatWithNetwork() {
//添加用户权限申请判断
LocationManager locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 5000, 10, locationListener);
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
showLocation();
}
public interface AddressCallback{
void onGetAddress(Address address);
void onGetLocation(double lat,double lng);
}
}
......@@ -88,6 +88,15 @@ public class OrderDetail implements Serializable {
private String showPrice;
private String needShortVideo;
private String teamName;
private String referenceTime;
public String getReferenceTime() {
return referenceTime;
}
public void setReferenceTime(String referenceTime) {
this.referenceTime = referenceTime;
}
public String getTeamName() {
return teamName;
......
......@@ -7,6 +7,7 @@ import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Paint;
import android.location.Address;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
......@@ -30,6 +31,7 @@ import com.dayu.base.ui.adapter.SpacesItemDecoration;
import com.dayu.base.ui.presenter.SImplePresenter;
import com.dayu.common.Constants;
import com.dayu.location.base.LocationUtils;
import com.dayu.location.base.LocationUtils1;
import com.dayu.order.R;
import com.dayu.order.api.OrderService;
import com.dayu.order.api.protocol.Spu;
......@@ -433,24 +435,50 @@ public class SopLocalActivity extends BaseActivity<SImplePresenter, ActivitySopL
}
private void getLocation() {
LocationUtils.getLocation(location -> {
hideDialog();
if (location == null) return;
SopAddress bean = new SopAddress();
bean.setId(currentSop.getId());
bean.setEngineerName(mUserInfo.getAccountName());
bean.setMobile(mUserInfo.getMobile());
bean.setOrderId(orderDetailId);
bean.setLatitude(location.getLatitude());
bean.setLongitude(location.getLongitude());
bean.setProvince(location.getProvince());
bean.setCity(location.getCity());
bean.setDistrict(location.getDistrict());
bean.setAoiName(location.getAoiName());
bean.setPoiName(location.getPoiName());
bean.setAddress(location.getAddress());
waterMark(bean);
LocationUtils1.getInstance(mActivity).setAddressCallback(new LocationUtils1.AddressCallback() {
@Override
public void onGetAddress(Address address) {
hideDialog();
if (address == null) return;
SopAddress bean = new SopAddress();
bean.setId(currentSop.getId());
bean.setEngineerName(mUserInfo.getAccountName());
bean.setMobile(mUserInfo.getMobile());
bean.setOrderId(orderDetailId);
bean.setLatitude(address.getLatitude());
bean.setLongitude(address.getLongitude());
bean.setProvince(address.getAdminArea());
bean.setCity(address.getLocality());
bean.setDistrict(address.getSubLocality());
bean.setAoiName(address.getFeatureName());
bean.setPoiName(address.getFeatureName());
bean.setAddress(address.getAddressLine(0));
waterMark(bean);
}
@Override
public void onGetLocation(double lat, double lng) {
}
});
// LocationUtils.getLocation(location -> {
// hideDialog();
// if (location == null) return;
// SopAddress bean = new SopAddress();
// bean.setId(currentSop.getId());
// bean.setEngineerName(mUserInfo.getAccountName());
// bean.setMobile(mUserInfo.getMobile());
// bean.setOrderId(orderDetailId);
// bean.setLatitude(location.getLatitude());
// bean.setLongitude(location.getLongitude());
// bean.setProvince(location.getProvince());
// bean.setCity(location.getCity());
// bean.setDistrict(location.getDistrict());
// bean.setAoiName(location.getAoiName());
// bean.setPoiName(location.getPoiName());
// bean.setAddress(location.getAddress());
// waterMark(bean);
// });
}
private void toNext() {
......
......@@ -7,6 +7,7 @@ import android.Manifest;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.location.Address;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
......@@ -20,6 +21,7 @@ import com.dayu.base.ui.adapter.CoreAdapter;
import com.dayu.common.Constants;
import com.dayu.event.UserInfo;
import com.dayu.location.base.LocationUtils;
import com.dayu.location.base.LocationUtils1;
import com.dayu.order.R;
import com.dayu.order.api.protocol.Order;
import com.dayu.order.api.protocol.Spu;
......@@ -479,16 +481,17 @@ public class OrderAdapter extends CoreAdapter<Order, FragmentOrderdoingItemBindi
}
private void getLocation(FragmentOrderdoingItemBinding h, int posiiton) {
LocationUtils.getLocation(new LocationUtils.MyLocationListener() {
LocationUtils1.getInstance(mContext).setAddressCallback(new LocationUtils1.AddressCallback() {
@Override
public void result(AMapLocation location) {
double latitude = 0;
double longitude = 0;
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
public void onGetAddress(Address address) {
}
@Override
public void onGetLocation(double lat, double lng) {
if (lat != 0) {
startFirstServe(lat, lng);
}
startFirstServe(latitude, longitude);
}
private void startFirstServe(double latitude, double longitude) {
......@@ -496,7 +499,6 @@ public class OrderAdapter extends CoreAdapter<Order, FragmentOrderdoingItemBindi
mPresenter.startServer(mItem.getId(), latitude, longitude)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(mPresenter.baseObserver(integer -> {
LocationUtils.stop();
ProgressUtil.stopLoad();
mItem.setStatus(4);
mItem.setSubStatus(integer);
......@@ -513,6 +515,40 @@ public class OrderAdapter extends CoreAdapter<Order, FragmentOrderdoingItemBindi
}
}
});
// LocationUtils.getLocation(new LocationUtils.MyLocationListener() {
// @Override
// public void result(AMapLocation location) {
// double latitude = 0;
// double longitude = 0;
// if (location != null) {
// latitude = location.getLatitude();
// longitude = location.getLongitude();
// }
// startFirstServe(latitude, longitude);
// }
//
// private void startFirstServe(double latitude, double longitude) {
// if (mItem.getSubStatus() == 1 || mItem.getSubStatus() == 2) {
// mPresenter.startServer(mItem.getId(), latitude, longitude)
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe(mPresenter.baseObserver(integer -> {
// LocationUtils.stop();
// ProgressUtil.stopLoad();
// mItem.setStatus(4);
// mItem.setSubStatus(integer);
// processClick(mItem, h, posiiton);
// mBind.tvItemProcess.setText(mContext.getString(R.string.process_order));
// mBind.itemUpdataTime.setText(mContext.getString(R.string.need_again_door));
// }, responeThrowable -> {
// if ("ORDER0006".equals(responeThrowable.subCode)) {
// EventBus.getDefault().post(new RefreshTab(3));
// EventBus.getDefault().post(new RefreshServe(1));
// }
// }));
//// MobclickAgent.onEvent(mContext, "start_server");
// }
// }
// });
}
private void dumpSubcribeTimeActivity(int id, int adapterPosition, int state, String time) {
......
......@@ -634,7 +634,6 @@
android:layout_height="wrap_content"
android:layout_below="@+id/tv_address"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginBottom="10dp"
android:text="@string/lookforword_time"
android:textColor="@color/tv_cl"
android:textSize="14sp" />
......@@ -646,11 +645,34 @@
android:layout_below="@+id/tv_address"
android:layout_marginLeft="19dp"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginBottom="10dp"
android:layout_toRightOf="@+id/tv_end_time"
android:text='@{!TextUtils.isEmpty(item.appointmentTime)?item.appointmentTime:@string/no_data}'
android:textColor="@color/cl_home_title_text_color"
android:textSize="14sp" />
<TextView
android:id="@+id/workTimeTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_end_time"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginBottom="10dp"
android:text="预计工时"
android:textColor="@color/tv_cl"
android:textSize="14sp" />
<TextView
android:id="@+id/workTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_end_time"
android:layout_marginLeft="19dp"
android:layout_marginTop="@dimen/dp_15"
android:layout_marginBottom="10dp"
android:layout_toRightOf="@+id/workTimeTv"
android:text='@{!TextUtils.isEmpty(item.referenceTime)?item.referenceTime:@string/no_data}'
android:textColor="@color/cl_home_title_text_color"
android:textSize="14sp" />
</RelativeLayout>
<TextView
......
......@@ -30,6 +30,7 @@ public class RouterPath {
public final static String PATH_WEBVIEW = "/user/webView";
public final static String PATH_REDEPLOY = "/user/redeploy";
public final static String PATH_REGISTER = "/user/register";
public final static String PATH_SERVER_REGISTER = "/user/server_register";
public final static String PATH_BUSINESS_TYPE = "/user/businessType";
/**
* 学习模块.
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.umeng.message.lib"
android:versionCode="1"
android:versionName="1.0">
<!-- <uses-permission android:name="android.permission.INTERNET" />-->
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />-->
<!-- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />-->
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />-->
<!-- <uses-permission android:name="android.permission.WAKE_LOCK" />-->
<!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" />-->
<!-- <uses-permission android:name="android.permission.BROADCAST_PACKAGE_ADDED" />-->
<!-- <uses-permission android:name="android.permission.BROADCAST_PACKAGE_CHANGED" />-->
<!-- <uses-permission android:name="android.permission.BROADCAST_PACKAGE_INSTALL" />-->
<!-- <uses-permission android:name="android.permission.BROADCAST_PACKAGE_REPLACED" />-->
<!-- <uses-permission android:name="android.permission.RESTART_PACKAGES" />-->
<!-- <uses-permission android:name="android.permission.GET_TASKS" />-->
<!-- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />-->
<!-- <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />-->
<!-- <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />-->
<application>
<!-- <meta-data-->
<!-- android:name="com.vivo.push.api_key"-->
<!-- android:value="6444f965-8da8-40ba-9852-c06c10cb33e6" />-->
<!-- <meta-data-->
<!-- android:name="com.vivo.push.app_id"-->
<!-- android:value="19962" />-->
<!-- <service-->
<!-- android:name="com.taobao.accs.ChannelService"-->
<!-- android:exported="true"-->
<!-- android:process=":channel">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.taobao.accs.intent.action.SERVICE" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="com.taobao.accs.intent.action.ELECTION" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- <service-->
<!-- android:name="com.taobao.accs.data.MsgDistributeService"-->
<!-- android:exported="true">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.taobao.accs.intent.action.RECEIVE" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- <receiver-->
<!-- android:name="com.taobao.accs.EventReceiver"-->
<!-- android:process=":channel">-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.BOOT_COMPLETED" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.PACKAGE_REMOVED" />-->
<!-- <data android:scheme="package" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.USER_PRESENT" />-->
<!-- </intent-filter>-->
<!-- </receiver>-->
<!-- <receiver-->
<!-- android:name="com.taobao.accs.ServiceReceiver"-->
<!-- android:process=":channel">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.taobao.accs.intent.action.COMMAND" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="com.taobao.accs.intent.action.START_FROM_AGOO" />-->
<!-- </intent-filter>-->
<!-- </receiver>-->
<!-- <service-->
<!-- android:name="com.taobao.accs.internal.AccsJobService"-->
<!-- android:permission="android.permission.BIND_JOB_SERVICE"-->
<!-- android:process=":channel"/>-->
<!-- <service-->
<!-- android:name="com.taobao.accs.ChannelService$KernelService"-->
<!-- android:process=":channel" />-->
<!-- <service-->
<!-- android:name="org.android.agoo.accs.AgooService"-->
<!-- android:exported="true">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.taobao.accs.intent.action.RECEIVE" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- <service-->
<!-- android:name="com.umeng.message.UmengIntentService"-->
<!-- android:exported="true"-->
<!-- android:process=":channel">-->
<!-- <intent-filter>-->
<!-- <action android:name="org.agoo.android.intent.action.RECEIVE" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- <service-->
<!-- android:name="com.umeng.message.XiaomiIntentService"-->
<!-- android:exported="true"-->
<!-- android:process=":channel">-->
<!-- <intent-filter>-->
<!-- <action android:name="org.agoo.android.intent.action.RECEIVE" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- <receiver-->
<!-- android:name="com.taobao.agoo.AgooCommondReceiver"-->
<!-- android:exported="true"-->
<!-- android:process=":channel">-->
<!-- <intent-filter>-->
<!-- <action android:name="${applicationId}.intent.action.COMMAND" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.PACKAGE_REMOVED" />-->
<!-- <data android:scheme="package" />-->
<!-- </intent-filter>-->
<!-- </receiver>-->
<!-- <service-->
<!-- android:name="com.umeng.message.UmengMessageIntentReceiverService"-->
<!-- android:exported="true"-->
<!-- android:process=":channel">-->
<!-- <intent-filter>-->
<!-- <action android:name="org.android.agoo.client.MessageReceiverService" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- <receiver-->
<!-- android:name="com.umeng.message.NotificationProxyBroadcastReceiver"-->
<!-- android:exported="false" />-->
<!-- <service-->
<!-- android:name="com.umeng.message.UmengMessageCallbackHandlerService"-->
<!-- android:permission="android.permission.BIND_JOB_SERVICE"-->
<!-- android:exported="false">-->
<!-- <intent-filter>-->
<!-- <action android:name="com.umeng.messge.registercallback.action" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="com.umeng.message.enablecallback.action" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="com.umeng.message.disablecallback.action" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="com.umeng.message.message.handler.action" />-->
<!-- </intent-filter>-->
<!-- <intent-filter>-->
<!-- <action android:name="com.umeng.message.message.sendmessage.action" />-->
<!-- </intent-filter>-->
<!-- </service>-->
<!-- <service-->
<!-- android:name="com.umeng.message.UmengDownloadResourceService"-->
<!-- android:permission="android.permission.BIND_JOB_SERVICE"-->
<!-- android:exported="false" />-->
<!-- <provider-->
<!-- android:name="com.umeng.message.provider.MessageProvider"-->
<!-- android:authorities="${applicationId}.umeng.message"-->
<!-- android:exported="false">-->
<!-- <grant-uri-permission android:pathPattern=".*" />-->
<!-- </provider>-->
</application>
</manifest>
\ No newline at end of file
apply plugin: 'com.android.library'
android {
compileSdkVersion compile_sdk_version
buildToolsVersion build_tools_version
defaultConfig {
minSdkVersion min_sdk_version
targetSdkVersion target_sdk_version
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
android {
lintOptions {
abortOnError false
}
}
}
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
//小米Push通道
api 'com.umeng.umsdk:xiaomi-push:3.6.17'
api 'com.umeng.umsdk:xiaomi-umengaccs:1.1.0'
//华为Push通道
api 'com.umeng.umsdk:huawei-basetb:2.6.3.305'
api 'com.umeng.umsdk:huawei-pushtb:2.6.3.305'
api 'com.umeng.umsdk:huawei-umengaccs:1.2.1'
//Oppo Push通道
api 'com.umeng.umsdk:oppo-push:1.0.1'
api 'com.umeng.umsdk:oppo-umengaccs:1.0.3'
//vivo Push通道
api 'com.umeng.umsdk:vivo-push:2.3.1'
api 'com.umeng.umsdk:vivo-umengaccs:1.0.4'
}
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-19
android.library=true
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="64dp">
<ImageView
android:id="@+id/notification_bar_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitCenter"/>
</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:background="#ffffff"
android:layout_height="64dp">
<RelativeLayout
android:id="@+id/upush_notification1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="10dp">
<ImageView
android:id="@+id/notification_large_icon1"
android:layout_width="48dp"
android:layout_height="48dp"
android:scaleType="fitXY" />
<TextView
android:id="@+id/notification_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="@+id/notification_large_icon1"
android:maxLines="1"
android:text="Title"
android:textColor="#000000"
android:textSize="16sp" />
<TextView
android:id="@+id/notification_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/notification_title"
android:layout_marginLeft="10dp"
android:layout_marginTop="3dp"
android:layout_toRightOf="@+id/notification_large_icon1"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="false"
android:fadingEdge="horizontal"
android:singleLine="true"
android:text="Message"
android:textColor="#000000" />
<requestFocus />
</RelativeLayout>
<RelativeLayout
android:id="@+id/upush_notification2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<ImageView
android:id="@+id/notification_large_icon2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" />
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
......@@ -22,6 +22,7 @@ import com.dayu.usercenter.model.bean.SaleRecordListBean;
import com.dayu.usercenter.model.bean.SelfLicenceBean;
import com.dayu.usercenter.model.bean.ServiceBean;
import com.dayu.usercenter.model.bean.ServiceSaveBean;
import com.dayu.usercenter.model.bean.ServiceSaveBean1;
import com.dayu.usercenter.model.bean.ServiceTypeBean;
import com.dayu.usercenter.model.bean.StarRatioBean;
import com.dayu.usercenter.model.bean.TeamInfo;
......@@ -385,6 +386,17 @@ public interface UserService2 {
Observable<BaseResponse<Boolean>> commitData(@Body ServiceSaveBean saveBean, @Path("accountId") int accountId);
/**
* 提交注册信息.
*/
@POST(Constants.API_7100 + "/engineerRelationCategory/registerInfo/batch/accountId/{accountId}")
Observable<BaseResponse<Boolean>> commitData1(@Body ServiceSaveBean1 saveBean, @Path("accountId") int accountId);
/**
* 提交注册信息.
*/
@POST(Constants.API_7100 + "/engineerRelationCategory/labelAndPrice/batch/accountId/{accountId}")
Observable<BaseResponse<Boolean>> commitServerData(@Body ServiceSaveBean saveBean, @Path("accountId") int accountId);
/**
* 获取服务地址.
*/
@GET(Constants.API_7100 + "/engineerAddress/default/accountId/{accountId}")
......
......@@ -24,6 +24,10 @@ public class ServiceSaveBean {
this.accountUrl = accountUrl;
this.identityUrl = identityUrl;
}
public AccountExt(String realName) {
this.realName = realName;
}
}
public ServiceSaveBean(String lowestPriceDay, int provinceId, String provinceName, int cityId, String cityName, int districtId,
......@@ -51,4 +55,8 @@ public class ServiceSaveBean {
this.address = address;
this.accountExt = accountExt;
}
public ServiceSaveBean(AccountExt accountExt){
this.accountExt = accountExt;
}
}
package com.dayu.usercenter.model.bean;
import java.util.List;
public class ServiceSaveBean1 {
private String lowestPriceDay;
private List<Long> labelIds;
private String cityName;
private String districtName;
private String provinceName;
private String address;
private AccountExt accountExt;
public static class AccountExt {
private String realName;
private String accountUrl;
private String identityUrl;
public AccountExt(String realName, String accountUrl, String identityUrl) {
this.realName = realName;
this.accountUrl = accountUrl;
this.identityUrl = identityUrl;
}
public AccountExt(String realName) {
this.realName = realName;
}
}
public ServiceSaveBean1(String lowestPriceDay, int provinceId, String provinceName, int cityId, String cityName, int districtId,
String districtName, List<Long> labelIds) {
this.lowestPriceDay = lowestPriceDay;
this.labelIds = labelIds;
this.cityName = cityName;
this.districtName = districtName;
this.provinceName = provinceName;
}
public ServiceSaveBean1(String lowestPriceDay, int provinceId, String provinceName, int cityId, String cityName, int districtId,
String districtName, List<Long> labelIds, String address, AccountExt accountExt) {
this.lowestPriceDay = lowestPriceDay;
this.labelIds = labelIds;
this.cityName = cityName;
this.districtName = districtName;
this.provinceName = provinceName;
this.address = address;
this.accountExt = accountExt;
}
public ServiceSaveBean1(AccountExt accountExt){
this.accountExt = accountExt;
}
}
......@@ -148,7 +148,12 @@ public class SmsLoginPresenter extends SmsLoginContract.Presenter {
info.setSiteId(-1);
info.setMobile(phoneNume.get());
UserManager.getInstance().saveUser(info);
ARouter.getInstance().build(RouterPath.PATH_MAIN).navigation();
if ("1".equals(info.getNewAccount())) {
ARouter.getInstance().build(RouterPath.PATH_SERVER_REGISTER).navigation();
}else {
ARouter.getInstance().build(RouterPath.PATH_MAIN).navigation();
}
} else {
ToastUtils.showShortToast(UIUtils.getString(R.string.login_faile_by_role));
}
......
......@@ -277,7 +277,7 @@ public class SmsLoginActivity extends BaseActivity<SmsLoginPresenter, ActivitySm
SPUtils.put("privacy", true);
dialog.dismiss();
//初始化高德地图
LocationUtils.init(getApplicationContext());
// LocationUtils.init(getApplicationContext());
initUM();
} else {
System.exit(0);
......
......@@ -90,16 +90,11 @@ public class BusinessTypeActivity extends BaseActivity<SImplePresenter, Activity
private void showDaySelect(String select) {
list = new ArrayMap<>();
list.put("200元/天", "200");
list.put("300元/天", "300");
list.put("350元/天", "350");
list.put("400元/天", "400");
list.put("450元/天", "450");
list.put("500元/天", "500");
list.put("600元/天", "600");
list.put("700元/天", "700");
list.put("800元/天", "800");
list.put("900元/天", "900");
list.put("1000元/天", "1000");
ArrayList<String> arrayList = new ArrayList<>();
arrayList.addAll(list.keySet());
ArrayList<String> values = new ArrayList<>();
......
package com.dayu.usercenter.ui.activity2;
import android.Manifest;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.widget.GridLayoutManager;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dayu.base.api.APIService;
import com.dayu.base.api.Api;
import com.dayu.base.api.BaseApiFactory;
import com.dayu.base.api.protocol.TreeAddressBean;
import com.dayu.base.ui.activity.BaseActivity;
import com.dayu.base.ui.presenter.SImplePresenter;
import com.dayu.common.Constants;
import com.dayu.location.base.LocationUtils;
import com.dayu.provider.event.CertificationEvent;
import com.dayu.provider.event.RefreshEvent;
import com.dayu.provider.router.RouterPath;
import com.dayu.usercenter.R;
import com.dayu.usercenter.api.UserService2;
import com.dayu.usercenter.databinding.ActivityRegisterVerifyBinding;
import com.dayu.usercenter.model.SaveSceneData;
import com.dayu.usercenter.model.bean.BusinessSceneBean;
import com.dayu.usercenter.model.bean.ServiceBean;
import com.dayu.usercenter.model.bean.ServiceSaveBean;
import com.dayu.usercenter.model.bean.ServiceSaveBean1;
import com.dayu.usercenter.model.bean.ServiceTypeBean;
import com.dayu.utils.CommonUtils;
import com.dayu.utils.GlideImageLoader;
import com.dayu.utils.SelectPicUtils;
import com.dayu.utils.ToastUtils;
import com.dayu.widgets.CustomDialog;
import com.dayu.widgets.WheelDialog;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.entity.LocalMedia;
import com.tbruyelle.rxpermissions2.RxPermissions;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
import io.reactivex.disposables.Disposable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created by mReturn
......@@ -56,24 +40,8 @@ import io.reactivex.disposables.Disposable;
**/
@Route(path = RouterPath.PATH_REGISTER)
public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegisterVerifyBinding> {
List<BusinessSceneBean> sceneDatas = new ArrayList<>();
List<SaveSceneData> savedSceneDatas = new ArrayList<>();
List<ServiceTypeBean> typeDatas = new ArrayList<>();
List<ServiceTypeBean> savedTypeDatas = new ArrayList<>();
BaseQuickAdapter<BusinessSceneBean, BaseViewHolder> sceneAdapter;
BaseQuickAdapter<ServiceTypeBean, BaseViewHolder> typeAdapter;
private List<TreeAddressBean> provinceList = new ArrayList<>();
private List<TreeAddressBean> cityList = new ArrayList<>();
private List<TreeAddressBean> areaList = new ArrayList<>();
private int provinceId;
private int cityId;
private int areaId;
private String provinceName;
private String cityName;
private String areaName;
private String dayPrice;
private String detailAddress;
private ArrayMap<String, String> list;
private String accountUrl;
private String accountPath;
private String identityUrl;
......@@ -102,7 +70,6 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
mBind.tvSubmit.setOnClickListener(v -> saveData());
initData();
initRefresh();
initAddrListener();
setListener();
}
......@@ -124,35 +91,6 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
mBind.refreshLayout.setOnRefreshListener(refreshLayout -> initData());
}
private void showDaySelect(String select) {
list = new ArrayMap<>();
list.put("200元/天", "200");
list.put("300元/天", "300");
list.put("400元/天", "400");
list.put("500元/天", "500");
list.put("600元/天", "600");
ArrayList<String> arrayList = new ArrayList<>();
arrayList.addAll(list.keySet());
ArrayList<String> values = new ArrayList<>();
values.addAll(list.values());
ArrayAdapter<String> adapter = new ArrayAdapter<>(mActivity, android.R.layout.simple_spinner_item, arrayList);
mBind.dayPrice.setAdapter(adapter);
int pos = values.indexOf(select);
mBind.dayPrice.setSelection(pos);
mBind.dayPrice.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mBind.dayPrice.setSelection(position);
dayPrice = values.get(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
private void initData() {
showDialog();
......@@ -160,19 +98,8 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
Api.getService(UserService2.class).getEngineerInfo(mUserId).compose(Api.applySchedulers())
.subscribe(mPresenter.baseObserver(data -> {
savedTypeDatas = data.getLabels();
setTypeAdapter();
showDaySelect(data.getLowestPriceDay());
mBind.province.setText(provinceName = data.getProvinceName());
mBind.city.setText(cityName = data.getCityName());
mBind.area.setText(areaName = data.getDistrictName());
getTreeAddrData(data.getProvinceId(), 2, false);
getTreeAddrData(data.getCityId(), 3, false);
provinceId = data.getProvinceId();
cityId = data.getCityId();
areaId = data.getDistrictId();
ServiceBean.AccountExt account = data.getAccountExt();
mBind.etName.setText(account.getRealName());
mBind.addressDetail.setText(data.getAddress());
identityUrl = account.getIdentityUrl();
accountUrl = account.getAccountUrl();
if (!TextUtils.isEmpty(accountUrl)) {
......@@ -188,87 +115,31 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
.subscribe(mPresenter.baseObserver(datas -> {
mBind.refreshLayout.finishRefresh();
typeDatas = datas;
setTypeAdapter();
}, responeThrowable -> {
mBind.refreshLayout.finishRefresh();
}));
}
//服务产品类型
private void setTypeAdapter() {
for (int i = 0; i < savedTypeDatas.size(); i++) {
for (int j = 0; j < typeDatas.size(); j++) {
if (typeDatas.get(j).getId() == savedTypeDatas.get(i).getLabelId())
typeDatas.get(j).setSelected(true);
}
}
// if (typeAdapter == null){
typeAdapter = new BaseQuickAdapter<ServiceTypeBean, BaseViewHolder>(R.layout.item_business_type, typeDatas) {
@Override
protected void convert(BaseViewHolder helper, ServiceTypeBean item) {
CheckBox cbItem = helper.getView(R.id.cb_item);
cbItem.setText(item.getName());
cbItem.setChecked(item.isSelected());
cbItem.setOnCheckedChangeListener((compoundButton, b) -> {
item.setSelected(b);
});
}
};
mBind.rvType.setLayoutManager(new GridLayoutManager(this, 2));
mBind.rvType.setAdapter(typeAdapter);
// }else {
// typeAdapter.notifyDataSetChanged();
// }
if (isForce) {
for (ServiceTypeBean bean : typeDatas) {
bean.setSelected(true);
}
typeAdapter.notifyDataSetChanged();
}
}
//保存数据
//保存服务类型数据
private void saveData() {
//业务场景
List<SaveSceneData> sceneList = new ArrayList<>();
List<Long> typeList = new ArrayList<>();
for (BusinessSceneBean sceneBean : sceneDatas) {
if (sceneBean.isSelected())
sceneList.add(new SaveSceneData(mUserId, sceneBean.getId(), sceneBean.getName(), sceneBean.getId()));
}
//服务类型
for (ServiceTypeBean typeBean : typeDatas) {
if (typeBean.isSelected())
typeList.add(typeBean.getId());
}
saveType(typeList);
}
//保存服务类型数据
private void saveType(List<Long> ids) {
if (ids.size() == 0) {
ToastUtils.showShortToast("请先选择服务技能");
if (TextUtils.isEmpty(mBind.etName.getText())) {
ToastUtils.showShortToast("请先填写姓名");
return;
}
if (TextUtils.isEmpty(provinceName) || TextUtils.isEmpty(cityName) || TextUtils.isEmpty(areaName)) {
ToastUtils.showShortToast("请先选择城市");
return;
boolean isChinese = true;
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
char[] nickchar = mBind.etName.getText().toString().toCharArray();
for (char c : nickchar) {
Matcher m = p.matcher(String.valueOf(c));
if (!m.matches()) {
isChinese = false;
}
}
if (TextUtils.isEmpty(mBind.etName.getText())) {
ToastUtils.showShortToast("请先填写姓名");
if (!isChinese) {
ToastUtils.showShortToast("姓名请输入汉字");
return;
}
// if (TextUtils.isEmpty(mBind.addressDetail.getText())) {
// ToastUtils.showShortToast("请先填写详细地址");
// return;
//
// }
if (TextUtils.isEmpty(accountUrl) && TextUtils.isEmpty(accountPath)) {
ToastUtils.showShortToast("请先上传头像");
return;
......@@ -277,7 +148,6 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
if (TextUtils.isEmpty(identityUrl) && TextUtils.isEmpty(identityPath)) {
ToastUtils.showShortToast("请先上传身份证照片");
return;
}
showDialog();
if (TextUtils.isEmpty(accountUrl) || TextUtils.isEmpty(identityUrl)) {
......@@ -289,34 +159,28 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
BaseApiFactory.uploadPhotoNew(BaseApiFactory.packPhoto(identityPath), Constants.PHOTO + "/privacy/idcard", "yyMM")
.subscribe(mPresenter.baseObserver(data -> {
identityUrl = data.get(0);
save(ids);
save();
}));
} else {
save(ids);
save();
}
}));
} else if (TextUtils.isEmpty(identityUrl)) {
BaseApiFactory.uploadPhotoNew(BaseApiFactory.packPhoto(identityPath), Constants.PHOTO + "/privacy/idcard", "yyMM")
.subscribe(mPresenter.baseObserver(imgs -> {
identityUrl = imgs.get(0);
save(ids);
save();
}));
}
} else {
save(ids);
save();
}
}
private void save(List<Long> ids) {
ServiceSaveBean.AccountExt accountExt = new ServiceSaveBean.AccountExt(mBind.etName.getText().toString().trim(), accountUrl, identityUrl);
ServiceSaveBean saveBean = new ServiceSaveBean(
dayPrice,
provinceId, provinceName,
cityId, cityName,
areaId, areaName,
ids, mBind.addressDetail.getText().toString(), accountExt
);
Api.getService(UserService2.class).commitData(saveBean, mUserId).compose(Api.applySchedulers())
private void save() {
ServiceSaveBean1.AccountExt accountExt = new ServiceSaveBean1.AccountExt(mBind.etName.getText().toString().trim(), accountUrl, identityUrl);
ServiceSaveBean1 saveBean = new ServiceSaveBean1(accountExt);
Api.getService(UserService2.class).commitData1(saveBean, mUserId).compose(Api.applySchedulers())
.subscribe(mPresenter.baseObserver(bool -> {
ToastUtils.showShortToast(bool ? R.string.save_success : R.string.save_fail);
CommonUtils.hideSoftInput(mActivity);
......@@ -326,180 +190,6 @@ public class RegisterActivity extends BaseActivity<SImplePresenter, ActivityRegi
}));
}
private void initAddrListener() {
mBind.province.setOnClickListener(view -> {
if (provinceList.size() > 0) {
showAddrDialog(1, provinceList);
} else {
getTreeAddrData(-1, 1, true);
}
});
mBind.city.setOnClickListener(view -> {
if (cityList.size() > 0) {
showAddrDialog(2, cityList);
} else {
getTreeAddrData(provinceId, 2, true);
}
});
mBind.area.setOnClickListener(view -> {
if (areaList.size() > 0) {
showAddrDialog(3, areaList);
} else {
getTreeAddrData(cityId, 3, true);
}
});
mBind.navigation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showDialog();
RxPermissions permissions = new RxPermissions(mActivity);
if (permissions.isGranted(Manifest.permission.ACCESS_COARSE_LOCATION)) {
getLocation();
} else {
CustomDialog mDialog = new CustomDialog(mActivity, R.style.CustomDialog, "大鱼需要你的定位权限,用于填入当前的位置信息"
, (dialog, confirm) -> {
if (confirm) {
Disposable observable = permissions.request(Manifest.permission.ACCESS_COARSE_LOCATION)
.subscribe(aBoolean -> {
if (aBoolean) {
getLocation();
} else {
ToastUtils.showShortToast("权限申请失败!");
}
});
}
dialog.dismiss();
});
mDialog.setTitle(getString(com.dayu.baselibrary.R.string.notice))
.setPositiveButton("去开启")
.setNegativeButton("取消");
mDialog.show();
}
}
});
}
private void getLocation() {
LocationUtils.getLocation(location -> {
hideDialog();
if (location == null) return;
Api.getService(UserService2.class).getAddress(location.getAdCode()).compose(Api.applySchedulers())
.subscribe(mPresenter.baseObserver(data -> {
mBind.province.setText(provinceName = data.getProvinceName());
mBind.city.setText(cityName = data.getCityName());
mBind.area.setText(areaName = data.getDistrictName());
getTreeAddrData(data.getProvinceId(), 2, false);
getTreeAddrData(data.getCityId(), 3, false);
provinceId = data.getProvinceId();
cityId = data.getCityId();
areaId = data.getDistrictId();
}));
});
}
/**
* 地址选择弹框
*
* @param type
* @param addressList
*/
private void showAddrDialog(int type, List<TreeAddressBean> addressList) {
List<String> addrs = new ArrayList<>();
for (int i = 0; i < addressList.size(); i++) {
addrs.add(addressList.get(i).getText());
}
WheelDialog.getInstance().show(this, addrs, pos -> {
onAddrChoosed(type, pos);
});
}
//选择弹框内的地址后
private void onAddrChoosed(int type, int index) {
switch (type) {
case 1:
if (provinceList.get(index).getText().equals(provinceName))
return;
provinceId = Integer.parseInt(provinceList.get(index).getId());
provinceName = provinceList.get(index).getText();
getTreeAddrData(provinceId, 2, false);
cityList.clear();
areaList.clear();
// mBind.city.setVisibility(View.VISIBLE);
// mBind.area.setVisibility(View.GONE);
updateAddressView();
break;
case 2:
if (cityList.get(index).getText().equals(cityName))
return;
cityId = Integer.parseInt(cityList.get(index).getId());
cityName = cityList.get(index).getText();
getTreeAddrData(cityId, 3, false);
areaList.clear();
// mBind.area.setVisibility(View.VISIBLE);
updateAddressView();
break;
case 3:
if (areaList.get(index).getText().equals(areaName))
return;
areaId = Integer.parseInt(areaList.get(index).getId());
areaName = areaList.get(index).getText();
mBind.area.setText(areaName);
// updateAddressView();
break;
}
}
//更新选择地址布局显示
private void updateAddressView() {
cityId = cityList.size() > 0 ? cityId : 0;
cityName = cityList.size() > 0 ? cityName : "";
areaId = areaList.size() > 0 ? areaId : 0;
areaName = areaList.size() > 0 ? areaName : "";
mBind.province.setText(provinceName);
mBind.city.setText(cityName);
mBind.area.setText(areaName);
}
/**
* 获取地址信息
*
* @param pId
* @param type 1.省 2.市 3.区
* @param showDialog 是否显示选择框
*/
private void getTreeAddrData(int pId, int type, boolean showDialog) {
if (Constants.treeAddressMap.containsKey(pId) && Constants.treeAddressMap.get(pId).size() > 0) {
dealAddrData(type, showDialog, Constants.treeAddressMap.get(pId));
} else {
if (showDialog)
showDialog();
Api.getService(APIService.class).getTreeAddress(pId).compose(Api.applySchedulers())
.safeSubscribe(mPresenter.baseObserver(datas -> {
dealAddrData(type, showDialog, datas);
Constants.treeAddressMap.put(pId, datas);
}));
}
}
//处理获取到地址信息数据
private void dealAddrData(int type, boolean showDialog, List<TreeAddressBean> datas) {
switch (type) {
case 1:
provinceList = datas;
break;
case 2:
cityList = datas;
mBind.city.setVisibility(View.VISIBLE);
break;
case 3:
areaList = datas;
mBind.area.setVisibility(View.VISIBLE);
break;
}
if (showDialog)
showAddrDialog(type, datas);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
......
package com.dayu.usercenter.ui.activity2;
import android.Manifest;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.widget.GridLayoutManager;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dayu.base.api.APIService;
import com.dayu.base.api.Api;
import com.dayu.base.api.BaseApiFactory;
import com.dayu.base.api.protocol.TreeAddressBean;
import com.dayu.base.ui.activity.BaseActivity;
import com.dayu.base.ui.presenter.SImplePresenter;
import com.dayu.common.Constants;
import com.dayu.provider.event.CertificationEvent;
import com.dayu.provider.event.RefreshEvent;
import com.dayu.provider.router.RouterPath;
import com.dayu.usercenter.R;
import com.dayu.usercenter.api.UserService2;
import com.dayu.usercenter.databinding.ActivityRegisterVerifyBinding;
import com.dayu.usercenter.databinding.ActivityServerRegisterVerifyBinding;
import com.dayu.usercenter.model.SaveSceneData;
import com.dayu.usercenter.model.bean.BusinessSceneBean;
import com.dayu.usercenter.model.bean.ServiceBean;
import com.dayu.usercenter.model.bean.ServiceSaveBean;
import com.dayu.usercenter.model.bean.ServiceTypeBean;
import com.dayu.utils.CommonUtils;
import com.dayu.utils.GlideImageLoader;
import com.dayu.utils.SelectPicUtils;
import com.dayu.utils.ToastUtils;
import com.dayu.widgets.CustomDialog;
import com.dayu.widgets.WheelDialog;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.entity.LocalMedia;
import com.tbruyelle.rxpermissions2.RxPermissions;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import io.reactivex.disposables.Disposable;
/**
* Created by mReturn
* on 2020/2/15
**/
@Route(path = RouterPath.PATH_SERVER_REGISTER)
public class ServerRegisterActivity extends BaseActivity<SImplePresenter, ActivityServerRegisterVerifyBinding> {
List<BusinessSceneBean> sceneDatas = new ArrayList<>();
List<SaveSceneData> savedSceneDatas = new ArrayList<>();
List<ServiceTypeBean> typeDatas = new ArrayList<>();
List<ServiceTypeBean> savedTypeDatas = new ArrayList<>();
BaseQuickAdapter<BusinessSceneBean, BaseViewHolder> sceneAdapter;
BaseQuickAdapter<ServiceTypeBean, BaseViewHolder> typeAdapter;
private List<TreeAddressBean> provinceList = new ArrayList<>();
private List<TreeAddressBean> cityList = new ArrayList<>();
private List<TreeAddressBean> areaList = new ArrayList<>();
private int provinceId;
private int cityId;
private int areaId;
private String provinceName;
private String cityName;
private String areaName;
private String dayPrice;
private ArrayMap<String, String> list;
boolean isForce; //是否强制用户选择服务场景
@Override
public void setPresenter() {
}
@Override
public int getLayoutId() {
return R.layout.activity_server_register_verify;
}
@Override
public void initView() {
if (getIntent().hasExtra(Constants.IS_FORCE)) {
isForce = getIntent().getBooleanExtra(Constants.IS_FORCE, false);
}
initUser();
mBind.receivingBack.setOnClickListener(v -> onBackPressed());
mBind.tvSubmit.setOnClickListener(v -> saveData());
initData();
initRefresh();
initAddrListener();
}
private void initRefresh() {
mBind.refreshLayout.setEnableLoadMore(false);
mBind.refreshLayout.setOnRefreshListener(refreshLayout -> initData());
}
private void showDaySelect(String select) {
list = new ArrayMap<>();
list.put("200元/天", "200");
list.put("300元/天", "300");
list.put("400元/天", "400");
list.put("500元/天", "500");
list.put("600元/天", "600");
ArrayList<String> arrayList = new ArrayList<>();
arrayList.addAll(list.keySet());
ArrayList<String> values = new ArrayList<>();
values.addAll(list.values());
ArrayAdapter<String> adapter = new ArrayAdapter<>(mActivity, android.R.layout.simple_spinner_item, arrayList);
mBind.dayPrice.setAdapter(adapter);
int pos = values.indexOf(select);
mBind.dayPrice.setSelection(pos);
mBind.dayPrice.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mBind.dayPrice.setSelection(position);
dayPrice = values.get(position);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
private void initData() {
showDialog();
//已保存服务类型数据
Api.getService(UserService2.class).getEngineerInfo(mUserId).compose(Api.applySchedulers())
.subscribe(mPresenter.baseObserver(data -> {
savedTypeDatas = data.getLabels();
setTypeAdapter();
showDaySelect(data.getLowestPriceDay());
mBind.province.setText(provinceName = data.getProvinceName());
mBind.city.setText(cityName = data.getCityName());
mBind.area.setText(areaName = data.getDistrictName());
getTreeAddrData(data.getProvinceId(), 2, false);
getTreeAddrData(data.getCityId(), 3, false);
provinceId = data.getProvinceId();
cityId = data.getCityId();
areaId = data.getDistrictId();
ServiceBean.AccountExt account = data.getAccountExt();
mBind.etName.setText(account.getRealName());
mBind.addressDetail.setText(data.getAddress());
}));
//服务类型数据
Api.getService(UserService2.class).getServiceType(1).compose(Api.applySchedulers())
.subscribe(mPresenter.baseObserver(datas -> {
mBind.refreshLayout.finishRefresh();
typeDatas = datas;
setTypeAdapter();
}, responeThrowable -> {
mBind.refreshLayout.finishRefresh();
}));
}
//服务产品类型
private void setTypeAdapter() {
for (int i = 0; i < savedTypeDatas.size(); i++) {
for (int j = 0; j < typeDatas.size(); j++) {
if (typeDatas.get(j).getId() == savedTypeDatas.get(i).getLabelId())
typeDatas.get(j).setSelected(true);
}
}
// if (typeAdapter == null){
typeAdapter = new BaseQuickAdapter<ServiceTypeBean, BaseViewHolder>(R.layout.item_business_type, typeDatas) {
@Override
protected void convert(BaseViewHolder helper, ServiceTypeBean item) {
CheckBox cbItem = helper.getView(R.id.cb_item);
cbItem.setText(item.getName());
cbItem.setChecked(item.isSelected());
cbItem.setOnCheckedChangeListener((compoundButton, b) -> {
item.setSelected(b);
});
}
};
mBind.rvType.setLayoutManager(new GridLayoutManager(this, 2));
mBind.rvType.setAdapter(typeAdapter);
// }else {
// typeAdapter.notifyDataSetChanged();
// }
if (isForce) {
for (ServiceTypeBean bean : typeDatas) {
bean.setSelected(true);
}
typeAdapter.notifyDataSetChanged();
}
}
//保存数据
private void saveData() {
//业务场景
List<SaveSceneData> sceneList = new ArrayList<>();
List<Long> typeList = new ArrayList<>();
for (BusinessSceneBean sceneBean : sceneDatas) {
if (sceneBean.isSelected())
sceneList.add(new SaveSceneData(mUserId, sceneBean.getId(), sceneBean.getName(), sceneBean.getId()));
}
//服务类型
for (ServiceTypeBean typeBean : typeDatas) {
if (typeBean.isSelected())
typeList.add(typeBean.getId());
}
saveType(typeList);
}
//保存服务类型数据
private void saveType(List<Long> ids) {
if (ids.size() == 0) {
ToastUtils.showShortToast("请先选择服务技能");
return;
}
if (TextUtils.isEmpty(provinceName) || TextUtils.isEmpty(cityName) || TextUtils.isEmpty(areaName)) {
ToastUtils.showShortToast("请先选择城市");
return;
}
if (TextUtils.isEmpty(mBind.etName.getText())) {
ToastUtils.showShortToast("请先填写姓名");
return;
}
boolean isChinese = true;
Pattern p = Pattern.compile("[\u4e00-\u9fa5]");
char[] nickchar = mBind.etName.getText().toString().toCharArray();
for (char c : nickchar) {
Matcher m = p.matcher(String.valueOf(c));
if (!m.matches()) {
isChinese = false;
}
}
if (!isChinese) {
ToastUtils.showShortToast("姓名请输入汉字");
return;
}
showDialog();
save(ids);
}
private boolean isChinese(char c) {
Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
|| ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
|| ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
|| ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
|| ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
return true;
}
return false;
}
private void save(List<Long> ids) {
ServiceSaveBean.AccountExt accountExt = new ServiceSaveBean.AccountExt(mBind.etName.getText().toString().trim());
ServiceSaveBean saveBean = new ServiceSaveBean(
dayPrice,
provinceId, provinceName,
cityId, cityName,
areaId, areaName,
ids, mBind.addressDetail.getText().toString(), accountExt
);
Api.getService(UserService2.class).commitServerData(saveBean, mUserId).compose(Api.applySchedulers())
.subscribe(mPresenter.baseObserver(bool -> {
ToastUtils.showShortToast(bool ? R.string.save_success : R.string.save_fail);
CommonUtils.hideSoftInput(mActivity);
ARouter.getInstance().build(RouterPath.PATH_MAIN).navigation();
finish();
}));
}
private void initAddrListener() {
mBind.province.setOnClickListener(view -> {
if (provinceList.size() > 0) {
showAddrDialog(1, provinceList);
} else {
getTreeAddrData(-1, 1, true);
}
});
mBind.city.setOnClickListener(view -> {
if (cityList.size() > 0) {
showAddrDialog(2, cityList);
} else {
getTreeAddrData(provinceId, 2, true);
}
});
mBind.area.setOnClickListener(view -> {
if (areaList.size() > 0) {
showAddrDialog(3, areaList);
} else {
getTreeAddrData(cityId, 3, true);
}
});
mBind.navigation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showDialog();
RxPermissions permissions = new RxPermissions(mActivity);
if (permissions.isGranted(Manifest.permission.ACCESS_COARSE_LOCATION)) {
// getLocation();
} else {
CustomDialog mDialog = new CustomDialog(mActivity, R.style.CustomDialog, "大鱼需要你的定位权限,用于填入当前的位置信息"
, (dialog, confirm) -> {
if (confirm) {
Disposable observable = permissions.request(Manifest.permission.ACCESS_COARSE_LOCATION)
.subscribe(aBoolean -> {
if (aBoolean) {
// getLocation();
} else {
ToastUtils.showShortToast("权限申请失败!");
}
});
}
dialog.dismiss();
});
mDialog.setTitle(getString(com.dayu.baselibrary.R.string.notice))
.setPositiveButton("去开启")
.setNegativeButton("取消");
mDialog.show();
}
}
});
}
// private void getLocation() {
// LocationUtils.getLocation(location -> {
// hideDialog();
// if (location == null) return;
// Api.getService(UserService2.class).getAddress(location.getAdCode()).compose(Api.applySchedulers())
// .subscribe(mPresenter.baseObserver(data -> {
// mBind.province.setText(provinceName = data.getProvinceName());
// mBind.city.setText(cityName = data.getCityName());
// mBind.area.setText(areaName = data.getDistrictName());
// getTreeAddrData(data.getProvinceId(), 2, false);
// getTreeAddrData(data.getCityId(), 3, false);
// provinceId = data.getProvinceId();
// cityId = data.getCityId();
// areaId = data.getDistrictId();
// }));
// });
// }
/**
* 地址选择弹框
*
* @param type
* @param addressList
*/
private void showAddrDialog(int type, List<TreeAddressBean> addressList) {
List<String> addrs = new ArrayList<>();
for (int i = 0; i < addressList.size(); i++) {
addrs.add(addressList.get(i).getText());
}
WheelDialog.getInstance().show(this, addrs, pos -> {
onAddrChoosed(type, pos);
});
}
//选择弹框内的地址后
private void onAddrChoosed(int type, int index) {
switch (type) {
case 1:
if (provinceList.get(index).getText().equals(provinceName))
return;
provinceId = Integer.parseInt(provinceList.get(index).getId());
provinceName = provinceList.get(index).getText();
getTreeAddrData(provinceId, 2, false);
cityList.clear();
areaList.clear();
// mBind.city.setVisibility(View.VISIBLE);
// mBind.area.setVisibility(View.GONE);
updateAddressView();
break;
case 2:
if (cityList.get(index).getText().equals(cityName))
return;
cityId = Integer.parseInt(cityList.get(index).getId());
cityName = cityList.get(index).getText();
getTreeAddrData(cityId, 3, false);
areaList.clear();
// mBind.area.setVisibility(View.VISIBLE);
updateAddressView();
break;
case 3:
if (areaList.get(index).getText().equals(areaName))
return;
areaId = Integer.parseInt(areaList.get(index).getId());
areaName = areaList.get(index).getText();
mBind.area.setText(areaName);
// updateAddressView();
break;
}
}
//更新选择地址布局显示
private void updateAddressView() {
cityId = cityList.size() > 0 ? cityId : 0;
cityName = cityList.size() > 0 ? cityName : "";
areaId = areaList.size() > 0 ? areaId : 0;
areaName = areaList.size() > 0 ? areaName : "";
mBind.province.setText(provinceName);
mBind.city.setText(cityName);
mBind.area.setText(areaName);
}
/**
* 获取地址信息
*
* @param pId
* @param type 1.省 2.市 3.区
* @param showDialog 是否显示选择框
*/
private void getTreeAddrData(int pId, int type, boolean showDialog) {
if (Constants.treeAddressMap.containsKey(pId) && Constants.treeAddressMap.get(pId).size() > 0) {
dealAddrData(type, showDialog, Constants.treeAddressMap.get(pId));
} else {
if (showDialog)
showDialog();
Api.getService(APIService.class).getTreeAddress(pId).compose(Api.applySchedulers())
.safeSubscribe(mPresenter.baseObserver(datas -> {
dealAddrData(type, showDialog, datas);
Constants.treeAddressMap.put(pId, datas);
}));
}
}
//处理获取到地址信息数据
private void dealAddrData(int type, boolean showDialog, List<TreeAddressBean> datas) {
switch (type) {
case 1:
provinceList = datas;
break;
case 2:
cityList = datas;
mBind.city.setVisibility(View.VISIBLE);
break;
case 3:
areaList = datas;
mBind.area.setVisibility(View.VISIBLE);
break;
}
if (showDialog)
showAddrDialog(type, datas);
}
@Override
public void onBackPressed() {
if (!isForce) {
super.onBackPressed();
} else {
ToastUtils.showShortToast(R.string.pls_set_business_choose_type);
}
}
}
......@@ -120,6 +120,10 @@
<activity
android:name=".ui.activity2.RegisterActivity"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activity2.ServerRegisterActivity"
android:screenOrientation="portrait" />
</application>
</manifest>
......@@ -21,7 +21,7 @@
<TextView
android:id="@+id/tv_title"
style="@style/text_title"
android:text="注册申请" />
android:text="实名注册身份申请" />
<ImageView
android:id="@+id/receiving_back"
......@@ -48,249 +48,91 @@
android:orientation="vertical"
android:paddingTop="10dp">
<TextView
style="@style/sale_item_text"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@color/top_tab_selected_bg"
android:gravity="center"
android:text="请设置您的可接单服务区域"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="center_vertical"
android:paddingStart="15dp"
android:paddingEnd="15dp">
<TextView
android:id="@+id/province"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:background="@drawable/bg_input_black_react"
android:drawableEnd="@drawable/icon_arrow_down_gray32"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:paddingTop="1dp"
android:hint="请选择省"
android:textColorHint="@color/default_text_color"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
<TextView
android:id="@+id/city"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:background="@drawable/bg_input_black_react"
android:drawableEnd="@drawable/icon_arrow_down_gray32"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:hint="@string/setlect_ciy_hint"
android:textColorHint="@color/default_text_color"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
<TextView
android:id="@+id/area"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_gravity="right"
android:layout_weight="1"
android:background="@drawable/bg_input_black_react"
android:drawableEnd="@drawable/icon_arrow_down_gray32"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:hint="请选择区"
android:textColorHint="@color/default_text_color"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:paddingTop="10dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
style="@style/sale_item_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="所在地区:"
android:textColor="@color/default_text_color"
android:textSize="15dp"
android:visibility="invisible" />
<ImageView
android:id="@+id/navigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center_vertical"
android:paddingBottom="5dp"
android:src="@drawable/icon_navigation" />
</RelativeLayout>
<EditText
android:id="@+id/addressDetail"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@drawable/bg_input_black_react"
android:drawablePadding="5dp"
android:hint="地址详情"
android:padding="3dp"
android:paddingStart="2dp"
android:paddingEnd="15dp"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
</LinearLayout>
<TextView
style="@style/sale_item_text"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@color/top_tab_selected_bg"
android:gravity="center"
android:text="请设置您的可服务的设备类型"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="15dp"
android:paddingTop="10dp"
android:paddingEnd="15dp">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:background="@color/default_text_color" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:overScrollMode="never" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="right"
android:orientation="horizontal"
android:orientation="vertical"
android:paddingStart="10dp"
android:paddingTop="10dp"
android:paddingEnd="10dp">
<TextView
style="@style/sale_item_text"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/top_tab_selected_bg"
android:gravity="center"
android:paddingEnd="10dp"
android:text="您期望的接单费用:"
android:paddingTop="10dp"
android:paddingBottom="20dp"
android:text="本平台采取信用机制,不收取接单保证金"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<Spinner
android:id="@+id/dayPrice"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_input_black_react"
android:drawableEnd="@drawable/icon_arrow_down_gray32"
android:inputType="number"
tools:text="100" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/icon_arrow_down_gray32" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="horizontal"
android:paddingStart="10dp"
android:paddingTop="10dp"
android:paddingEnd="10dp">
android:textSize="18dp" />
<TextView
style="@style/sale_item_text"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/top_tab_selected_bg"
android:background="@color/color_ee"
android:gravity="center"
android:paddingEnd="10dp"
android:text="填写您的真实姓名:"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:text="请确认您的真实姓名:"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
android:textSize="16dp" />
<EditText
android:id="@+id/etName"
android:layout_width="0dp"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="@drawable/bg_input_black_react"
android:drawablePadding="5dp"
android:paddingStart="15dp"
android:textColor="@color/default_text_color"
android:textSize="15dp"
tools:text="张三丰" />
</LinearLayout>
<TextView
style="@style/sale_item_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/color_ee"
android:gravity="center"
android:paddingEnd="10dp"
android:paddingTop="5dp"
android:layout_marginTop="20dp"
android:paddingBottom="5dp"
android:text="请确认您的微笑正面头像:"
android:textColor="@color/default_text_color"
android:textSize="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="@dimen/dp_20"
android:orientation="horizontal"
android:paddingTop="10dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:gravity="center">
<ImageView
android:id="@+id/header"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_width="130dp"
android:layout_height="130dp"
android:src="@drawable/icon_register_header" />
</LinearLayout>
......@@ -315,27 +157,43 @@
android:layout_height="wrap_content"
android:gravity="center"
android:paddingEnd="10dp"
android:text="上传真人微笑头像" />
android:text="上传/拍照" />
</LinearLayout>
</LinearLayout>
<TextView
style="@style/sale_item_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/color_ee"
android:gravity="center"
android:paddingEnd="10dp"
android:paddingTop="5dp"
android:layout_marginTop="20dp"
android:paddingBottom="5dp"
android:text="请确认您的身份证正面照片:"
android:textColor="@color/default_text_color"
android:textSize="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="10dp">
android:paddingTop="20dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="2"
android:gravity="center">
<ImageView
android:id="@+id/idetntity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="172dp"
android:layout_height="108dp"
android:src="@drawable/iicon_register_identity" />
</LinearLayout>
......@@ -360,7 +218,7 @@
android:layout_height="wrap_content"
android:gravity="center"
android:paddingEnd="10dp"
android:text="上传身份证正面照" />
android:text="上传/拍照" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<RelativeLayout
android:id="@+id/rootView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/title_back"
style="@style/title">
<TextView
android:id="@+id/tv_title"
style="@style/text_title"
android:text="欢迎您加入大鱼师傅!" />
<ImageView
android:id="@+id/receiving_back"
style="@style/title_image_back"
/>
</RelativeLayout>
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="65dp">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="10dp">
<TextView
style="@style/sale_item_text"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="@color/color_ee"
android:gravity="center"
android:text="请设置您的可接单服务区域"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="center_vertical"
android:paddingStart="15dp"
android:paddingEnd="15dp">
<TextView
android:id="@+id/province"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:background="@drawable/bg_input_black_react"
android:drawableEnd="@drawable/icon_arrow_down_gray32"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:hint="请选择省"
android:paddingStart="2dp"
android:paddingTop="1dp"
android:paddingEnd="10dp"
android:textColor="@color/default_text_color"
android:textColorHint="@color/default_text_color"
android:textSize="15dp" />
<TextView
android:id="@+id/city"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:background="@drawable/bg_input_black_react"
android:drawableEnd="@drawable/icon_arrow_down_gray32"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:hint="@string/setlect_ciy_hint"
android:paddingStart="2dp"
android:paddingEnd="10dp"
android:textColor="@color/default_text_color"
android:textColorHint="@color/default_text_color"
android:textSize="15dp" />
<TextView
android:id="@+id/area"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_gravity="right"
android:layout_weight="1"
android:background="@drawable/bg_input_black_react"
android:drawableEnd="@drawable/icon_arrow_down_gray32"
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:hint="请选择区"
android:paddingStart="2dp"
android:paddingEnd="10dp"
android:textColor="@color/default_text_color"
android:textColorHint="@color/default_text_color"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:visibility="gone">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
style="@style/sale_item_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="所在地区:"
android:textColor="@color/default_text_color"
android:textSize="15dp"
android:visibility="invisible" />
<ImageView
android:id="@+id/navigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center_vertical"
android:paddingBottom="5dp"
android:src="@drawable/icon_navigation" />
</RelativeLayout>
<EditText
android:id="@+id/addressDetail"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@drawable/bg_input_black_react"
android:drawablePadding="5dp"
android:hint="地址详情"
android:padding="3dp"
android:paddingStart="2dp"
android:paddingEnd="15dp"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
</LinearLayout>
<TextView
style="@style/sale_item_text"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="@color/color_ee"
android:gravity="center"
android:text="请设置您的可服务的设备类型"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="15dp"
android:paddingTop="10dp"
android:paddingEnd="15dp">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_marginEnd="5dp"
android:background="@color/default_text_color" />
<android.support.v7.widget.RecyclerView
android:id="@+id/rv_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:overScrollMode="never" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="right"
android:orientation="horizontal"
android:paddingStart="10dp"
android:paddingEnd="10dp">
<TextView
style="@style/sale_item_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/color_ee"
android:gravity="center"
android:paddingEnd="10dp"
android:text="您期望的接单费用:"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<Spinner
android:id="@+id/dayPrice"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_input_black_react"
android:drawableEnd="@drawable/icon_arrow_down_gray32"
android:inputType="number"
tools:text="100" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="@drawable/icon_arrow_down_gray32" />
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:orientation="horizontal"
android:paddingStart="10dp"
android:paddingTop="10dp"
android:paddingEnd="10dp">
<TextView
style="@style/sale_item_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@color/color_ee"
android:gravity="center"
android:paddingEnd="10dp"
android:text="填写您的真实姓名:"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
<EditText
android:id="@+id/etName"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1"
android:background="@drawable/bg_input_black_react"
android:drawablePadding="5dp"
android:paddingStart="15dp"
android:textColor="@color/default_text_color"
android:textSize="15dp"
tools:text="张三丰" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</LinearLayout>
<TextView
android:id="@+id/tv_submit"
style="@style/btn_bottom_common"
android:layout_alignParentBottom="true"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:text="提交" />
</RelativeLayout>
</layout>
\ No newline at end of file
......@@ -393,6 +393,7 @@
android:gravity="center_vertical"
android:paddingStart="2dp"
android:paddingTop="1dp"
android:paddingEnd="10dp"
android:text="请选择省"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
......@@ -408,6 +409,7 @@
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:paddingEnd="10dp"
android:text="@string/setlect_ciy_hint"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
......@@ -423,6 +425,7 @@
android:drawablePadding="10dp"
android:gravity="center_vertical"
android:paddingStart="2dp"
android:paddingEnd="10dp"
android:text="请选择区"
android:textColor="@color/default_text_color"
android:textSize="15dp" />
......@@ -468,8 +471,8 @@
<LinearLayout
style="@style/ll_user_bottom"
android:visibility="gone"
android:layout_marginTop="10dp">
android:layout_marginTop="10dp"
android:visibility="gone">
<LinearLayout
style="@style/ll_user_bottom2"
......
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 sign in to comment