Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
IMSDK_Demo
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王文龙
IMSDK_Demo
Commits
2e25dd96
Commit
2e25dd96
authored
Dec 25, 2020
by
王文龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add]添加环境配置切换
parent
4c9ec549
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
6 deletions
+32
-6
build.gradle
app/build.gradle
+1
-1
MyApp.java
app/src/main/java/com/offcn/imclient/MyApp.java
+4
-1
ContactListFragment.java
.../main/java/com/offcn/imclient/ui/ContactListFragment.java
+1
-1
LoginActivity.java
app/src/main/java/com/offcn/imclient/ui/LoginActivity.java
+2
-1
Constants.java
app/src/main/java/com/offcn/imclient/util/Constants.java
+2
-0
Utils.java
app/src/main/java/com/offcn/imclient/util/Utils.java
+22
-2
No files found.
app/build.gradle
View file @
2e25dd96
...
...
@@ -94,7 +94,7 @@ dependencies {
implementation
'com.android.support:multidex:1.0.3'
implementation
(
"com.offcn.live:titleview:1.1.0-s1"
)
implementation
(
"com.offcn.live:imsdk-kit:1.0.0.3
0
"
)
implementation
(
"com.offcn.live:imsdk-kit:1.0.0.3
1
"
)
// DB
implementation
'org.greenrobot:greendao:3.2.2'
...
...
app/src/main/java/com/offcn/imclient/MyApp.java
View file @
2e25dd96
...
...
@@ -23,6 +23,8 @@ import androidx.multidex.MultiDexApplication;
public
class
MyApp
extends
MultiDexApplication
{
private
static
final
String
TAG
=
MyApp
.
class
.
getSimpleName
();
private
boolean
mEnvIsTest
=
true
;
@Override
protected
void
attachBaseContext
(
Context
base
)
{
super
.
attachBaseContext
(
base
);
...
...
@@ -33,13 +35,14 @@ public class MyApp extends MultiDexApplication {
public
void
onCreate
()
{
super
.
onCreate
();
Constants
.
ENV_IS_TEST
=
mEnvIsTest
;
// 初始化 OIMSDK
initOIMSDK
();
}
private
void
initOIMSDK
()
{
UserBeanDaoManager
.
getInstance
().
init
(
this
);
OIMSDK
.
init
(
this
,
true
);
OIMSDK
.
init
(
this
,
mEnvIsTest
);
ZGLLogUtils
.
setLogEnabled
(
true
);
OIMSDK
.
getInstance
().
setOnUnreadMsgCountChangedListener
(
new
OIMCallback
.
OnUnreadMsgCountChangedListener
()
{
@Override
...
...
app/src/main/java/com/offcn/imclient/ui/ContactListFragment.java
View file @
2e25dd96
...
...
@@ -259,7 +259,7 @@ public class ContactListFragment extends BaseFragment {
jsonObject
.
put
(
"im_token"
,
LoginManager
.
getToken
(
getActivity
()));
RequestQueue
requestQueue
=
Volley
.
newRequestQueue
(
getActivity
());
JsonObjectRequest
jsonObjectRequest
=
new
JsonObjectRequest
(
Request
.
Method
.
POST
,
"http://api.study.t.eoffcn.com/web/v2/im/userlist"
,
jsonObject
,
JsonObjectRequest
jsonObjectRequest
=
new
JsonObjectRequest
(
Request
.
Method
.
POST
,
Utils
.
getServerContactUrl
()
,
jsonObject
,
new
Response
.
Listener
<
JSONObject
>()
{
@Override
public
void
onResponse
(
JSONObject
response
)
{
...
...
app/src/main/java/com/offcn/imclient/ui/LoginActivity.java
View file @
2e25dd96
...
...
@@ -21,6 +21,7 @@ import com.jyall.base.util.ValidateUtils;
import
com.offcn.imclient.R
;
import
com.offcn.imclient.bean.UserBean
;
import
com.offcn.imclient.util.LoginManager
;
import
com.offcn.imclient.util.Utils
;
import
com.offcn.live.im.util.ZGLLogUtils
;
import
com.offcn.live.im.util.ZGLParseUtils
;
...
...
@@ -110,7 +111,7 @@ public class LoginActivity extends BaseActivity {
jsonObject
.
put
(
"password"
,
pwd
);
RequestQueue
requestQueue
=
Volley
.
newRequestQueue
(
this
);
JsonObjectRequest
jsonObjectRequest
=
new
JsonObjectRequest
(
Request
.
Method
.
POST
,
"http://api.study.t.eoffcn.com/web/v2/im/login"
,
jsonObject
,
JsonObjectRequest
jsonObjectRequest
=
new
JsonObjectRequest
(
Request
.
Method
.
POST
,
Utils
.
getServerLoginUrl
()
,
jsonObject
,
new
Response
.
Listener
<
JSONObject
>()
{
@Override
public
void
onResponse
(
JSONObject
response
)
{
...
...
app/src/main/java/com/offcn/imclient/util/Constants.java
View file @
2e25dd96
...
...
@@ -2,6 +2,8 @@ package com.offcn.imclient.util;
public
class
Constants
{
public
static
boolean
ENV_IS_TEST
=
true
;
public
static
class
EventCode
{
public
static
final
int
Code_Count_Changed
=
1
;
public
static
final
int
Code_New_Msg
=
2
;
...
...
app/src/main/java/com/offcn/imclient/util/Utils.java
View file @
2e25dd96
...
...
@@ -6,11 +6,31 @@ import com.offcn.imclient.bean.UserBean;
import
com.offcn.live.im.OIMSDK
;
public
class
Utils
{
public
static
void
logout
(
Context
context
){
/**
* 退出登录,销毁
*
* @param context
*/
public
static
void
logout
(
Context
context
)
{
OIMSDK
.
getInstance
().
destroy
();
LoginManager
.
logout
(
context
);
UserBeanDaoManager
.
getInstance
().
deleteAll
();
}
public
static
String
getServerLoginUrl
()
{
if
(
Constants
.
ENV_IS_TEST
)
{
return
"http://api.study.t.eoffcn.com/web/v2/im/login"
;
}
else
{
return
"http://api.study.eoffcn.com/web/v2/im/login"
;
}
}
public
static
String
getServerContactUrl
()
{
if
(
Constants
.
ENV_IS_TEST
)
{
return
"http://api.study.t.eoffcn.com/web/v2/im/userlist"
;
}
else
{
return
"http://api.study.eoffcn.com/web/v2/im/userlist"
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment