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
93c9f846
Commit
93c9f846
authored
Dec 23, 2020
by
王文龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[fix]修复各种细节问题
parent
036e248b
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
189 additions
and
79 deletions
+189
-79
build.gradle
app/build.gradle
+3
-3
ContactListFragment.java
.../main/java/com/offcn/imclient/ui/ContactListFragment.java
+22
-5
LoginActivity.java
app/src/main/java/com/offcn/imclient/ui/LoginActivity.java
+2
-1
MainActivity.java
app/src/main/java/com/offcn/imclient/ui/MainActivity.java
+70
-26
bg_dot.xml
app/src/main/res/drawable/bg_dot.xml
+11
-0
activity_login.xml
app/src/main/res/layout/activity_login.xml
+25
-9
fragment_contact_list.xml
app/src/main/res/layout/fragment_contact_list.xml
+17
-10
item_contact_child.xml
app/src/main/res/layout/item_contact_child.xml
+1
-2
item_tab.xml
app/src/main/res/layout/item_tab.xml
+38
-20
styles.xml
app/src/main/res/values/styles.xml
+0
-3
No files found.
app/build.gradle
View file @
93c9f846
...
...
@@ -57,7 +57,7 @@ android {
applicationVariants
.
all
{
variant
->
variant
.
outputs
.
all
{
outputFileName
=
"im
client
_v${defaultConfig.versionName}_${releaseTimeFull()}_${buildType.name}.apk"
;
outputFileName
=
"im
teacher
_v${defaultConfig.versionName}_${releaseTimeFull()}_${buildType.name}.apk"
;
}
}
}
...
...
@@ -71,7 +71,7 @@ android {
applicationVariants
.
all
{
variant
->
variant
.
outputs
.
all
{
outputFileName
=
"im
client
_v${defaultConfig.versionName}_${releaseTimeFull()}_${buildType.name}.apk"
;
outputFileName
=
"im
teacher
_v${defaultConfig.versionName}_${releaseTimeFull()}_${buildType.name}.apk"
;
}
}
}
...
...
@@ -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.1
4
"
)
implementation
(
"com.offcn.live:imsdk-kit:1.0.0.1
7
"
)
// DB
implementation
'org.greenrobot:greendao:3.2.2'
...
...
app/src/main/java/com/offcn/imclient/ui/ContactListFragment.java
View file @
93c9f846
...
...
@@ -34,6 +34,8 @@ import java.sql.SQLInvalidAuthorizationSpecException;
import
java.util.ArrayList
;
import
java.util.List
;
import
androidx.swiperefreshlayout.widget.SwipeRefreshLayout
;
/**
* 通讯录页
*
...
...
@@ -46,6 +48,7 @@ public class ContactListFragment extends BaseFragment {
private
RelativeLayout
mContainerContact
;
private
AnimatedExpandableListView
mRecyclerView
;
private
RelativeLayout
mSearch
;
private
SwipeRefreshLayout
mSwipeRefreshLayout
;
private
List
<
ServerContactBean
>
friends
=
new
ArrayList
<>();
private
ContactListExpandableAdapter
mAdapter
;
...
...
@@ -59,7 +62,15 @@ public class ContactListFragment extends BaseFragment {
protected
void
init
(
View
view
)
{
mContainerContact
=
view
.
findViewById
(
R
.
id
.
container_list
);
mRecyclerView
=
view
.
findViewById
(
R
.
id
.
recycler_view
);
mSwipeRefreshLayout
=
view
.
findViewById
(
R
.
id
.
refresh_layout
);
mSearch
=
view
.
findViewById
(
R
.
id
.
search
);
mSwipeRefreshLayout
.
setOnRefreshListener
(
new
SwipeRefreshLayout
.
OnRefreshListener
()
{
@Override
public
void
onRefresh
()
{
getContactList
();
}
});
mAdapter
=
new
ContactListExpandableAdapter
(
getContext
(),
friends
);
mRecyclerView
.
setAdapter
(
mAdapter
);
mRecyclerView
.
setOnChildClickListener
(
new
ExpandableListView
.
OnChildClickListener
()
{
...
...
@@ -150,7 +161,6 @@ public class ContactListFragment extends BaseFragment {
});
getContactList
();
}
@Override
...
...
@@ -181,7 +191,7 @@ public class ContactListFragment extends BaseFragment {
return
;
}
showLoading
();
//
showLoading();
try
{
JSONObject
jsonObject
=
new
JSONObject
();
...
...
@@ -195,19 +205,22 @@ public class ContactListFragment extends BaseFragment {
public
void
onResponse
(
JSONObject
response
)
{
ZGLLogUtils
.
e
(
TAG
,
"contact success "
+
response
.
toString
());
dismissLoading
();
if
(
mSwipeRefreshLayout
!=
null
)
{
mSwipeRefreshLayout
.
setRefreshing
(
false
);
}
UserBeanDaoManager
.
getInstance
().
deleteAll
();
try
{
int
rtnCode
=
response
.
getInt
(
"code"
);
if
(
rtnCode
==
0
)
{
ServerContactBeanWrapper
beanWrapper
=
ZGLParseUtils
.
parseObjectByGson
(
response
.
getJSONObject
(
"data"
).
toString
(),
ServerContactBeanWrapper
.
class
);
if
(
beanWrapper
!=
null
&&
!
ValidateUtils
.
isEmpty
(
beanWrapper
.
user_list
)
)
{
if
(
beanWrapper
!=
null
)
{
friends
=
beanWrapper
.
user_list
;
exeContactList
();
}
else
{
// 数据为空
showEmptyView
();
friends
.
clear
();
}
exeContactList
();
}
else
if
(
rtnCode
==
1
||
rtnCode
==
2
)
{
// {"code":1,"msg":"登陆过期,请重新登陆","params":{"im_token":"0XR5YOS6dg7x2lirfeX3CbjRLqPWmesaFbdsr\/M4IRZS4mYYyZILI82FT8dgqybCA4W+MxfjJDY=@ip6c.cn.rongnav.com;ip6c.cn.rongcfg.com"}}
Utils
.
logout
(
getActivity
());
...
...
@@ -228,6 +241,9 @@ public class ContactListFragment extends BaseFragment {
public
void
onErrorResponse
(
VolleyError
error
)
{
ZGLLogUtils
.
e
(
TAG
,
"contact error "
+
error
.
toString
());
dismissLoading
();
if
(
mSwipeRefreshLayout
!=
null
)
{
mSwipeRefreshLayout
.
setRefreshing
(
false
);
}
CommonUtils
.
showToast
(
getActivity
(),
error
.
toString
());
}
}
...
...
@@ -250,6 +266,7 @@ public class ContactListFragment extends BaseFragment {
userBeanList
.
addAll
(
contactBean
.
getList
());
}
UserBeanDaoManager
.
getInstance
().
insertMulti
(
userBeanList
);
OIMSDK
.
getInstance
().
refreshUserData
();
}
else
{
showEmptyView
();
UserBeanDaoManager
.
getInstance
().
deleteAll
();
...
...
app/src/main/java/com/offcn/imclient/ui/LoginActivity.java
View file @
93c9f846
...
...
@@ -55,6 +55,7 @@ public class LoginActivity extends BaseActivity {
mIvEye
=
findViewById
(
R
.
id
.
iv_eye
);
mIvClear
.
setOnClickListener
(
v
->
mEtName
.
setText
(
""
));
mEtName
.
setTransformationMethod
(
HideReturnsTransformationMethod
.
getInstance
());
mIvEye
.
setOnClickListener
(
v
->
{
if
(
isShowPassWord
)
{
mIvEye
.
setImageDrawable
(
getResources
().
getDrawable
(
R
.
mipmap
.
ic_et_eye_on
));
...
...
@@ -97,7 +98,7 @@ public class LoginActivity extends BaseActivity {
return
;
}
if
(
ValidateUtils
.
isEmpty
(
name
)
||
ValidateUtils
.
isEmpty
(
pwd
))
{
CommonUtils
.
showToast
(
this
,
"请输入
用户名
或密码"
);
CommonUtils
.
showToast
(
this
,
"请输入
工号
或密码"
);
return
;
}
...
...
app/src/main/java/com/offcn/imclient/ui/MainActivity.java
View file @
93c9f846
...
...
@@ -10,6 +10,7 @@ import android.os.Handler;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
android.widget.TextView
;
import
com.google.android.material.tabs.TabLayout
;
...
...
@@ -17,18 +18,26 @@ import com.jyall.base.adapter.BaseVPAdapter;
import
com.jyall.base.base.BaseActivity
;
import
com.jyall.base.util.AppManager
;
import
com.jyall.base.util.CommonUtils
;
import
com.jyall.base.util.EventBusCenter
;
import
com.offcn.imclient.R
;
import
com.offcn.imclient.bean.UserBean
;
import
com.offcn.imclient.util.Constants
;
import
com.offcn.imclient.util.LoginManager
;
import
com.offcn.imclient.util.UserBeanDaoManager
;
import
com.offcn.live.im.OIMCallback
;
import
com.offcn.live.im.OIMSDK
;
import
com.offcn.live.im.bean.OIMCode
;
import
com.offcn.live.im.bean.OIMMsg
;
import
com.offcn.live.im.util.ZGLCommonUtils
;
import
com.offcn.live.im.util.ZGLLogUtils
;
import
com.offcn.live.imkit.ui.ChatListFragment
;
import
com.offcn.live.imkit.util.KitConstants
;
import
com.offcn.live.imkit.view.ScrollEnabledViewPager
;
import
org.greenrobot.eventbus.Subscribe
;
import
org.greenrobot.eventbus.ThreadMode
;
import
org.w3c.dom.Text
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -43,6 +52,7 @@ public class MainActivity extends BaseActivity {
TabLayout
mTabLayout
;
ScrollEnabledViewPager
mViewPager
;
TextView
mRedDot
;
String
[]
titles
=
new
String
[]{
"聊天"
,
"通讯录"
,
"我的"
};
...
...
@@ -54,8 +64,12 @@ public class MainActivity extends BaseActivity {
}
@Override
protected
void
initViewsAndEvents
()
{
public
boolean
isRegisterEventBus
()
{
return
true
;
}
@Override
protected
void
initViewsAndEvents
()
{
mTabLayout
=
findViewById
(
R
.
id
.
tab_layout
);
mViewPager
=
findViewById
(
R
.
id
.
view_pager
);
...
...
@@ -84,34 +98,36 @@ public class MainActivity extends BaseActivity {
||
code
==
OIMCode
.
Code_IM_Disconnect_Kick
||
code
==
OIMCode
.
Code_IM_Error_NoExist
)
{
// 此处注释。内部已调用 destroy() 方法。
// OIMSDK.getInstance(DemoMainActivity.this).destroy();
// 注销登录信息
// CommonUtils.showToast(MainActivity.this, "通道连接异常:" + OIMCode.getCodeDesc(MainActivity.this, code));
LoginManager
.
logout
(
MainActivity
.
this
);
UserBeanDaoManager
.
getInstance
().
deleteAll
();
Activity
curActivity
=
AppManager
.
getAppManager
().
getCurrentActivity
();
if
(
curActivity
!=
null
)
{
AlertDialog
dialog
=
new
AlertDialog
.
Builder
(
curActivity
)
.
setTitle
(
"IM连接失败"
)
.
setMessage
(
code
+
","
+
error
)
.
setPositiveButton
(
"重新登录"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
startActivity
(
new
Intent
(
curActivity
,
LoginActivity
.
class
));
AppManager
.
getAppManager
().
finishAllActivity
();
}
})
.
setNegativeButton
(
"我知道了"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
AppManager
.
getAppManager
().
AppExit
(
curActivity
);
}
})
.
setCancelable
(
false
)
.
create
();
dialog
.
setCanceledOnTouchOutside
(
false
);
dialog
.
show
();
if
(
code
==
OIMCode
.
Code_IM_Disconnect_Kick
)
{
Activity
curActivity
=
AppManager
.
getAppManager
().
getCurrentActivity
();
if
(
curActivity
!=
null
)
{
AlertDialog
dialog
=
new
AlertDialog
.
Builder
(
curActivity
)
.
setTitle
(
"下线通知"
)
.
setMessage
(
error
)
.
setPositiveButton
(
"重新登录"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
startActivity
(
new
Intent
(
curActivity
,
LoginActivity
.
class
));
AppManager
.
getAppManager
().
finishAllActivity
();
}
})
.
setNegativeButton
(
"我知道了"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
AppManager
.
getAppManager
().
AppExit
(
curActivity
);
}
})
.
setCancelable
(
false
)
.
create
();
dialog
.
setCanceledOnTouchOutside
(
false
);
dialog
.
show
();
}
}
}
}
...
...
@@ -147,6 +163,9 @@ public class MainActivity extends BaseActivity {
public
void
onTabSelected
(
TabLayout
.
Tab
tab
)
{
mViewPager
.
setCurrentItem
(
tab
.
getPosition
(),
false
);
changeTabSelect
(
tab
);
//Tab获取焦点
if
(
tab
.
getPosition
()
==
0
)
{
showDot
(
false
);
}
}
@Override
...
...
@@ -191,6 +210,9 @@ public class MainActivity extends BaseActivity {
if
(
index
==
0
)
{
iv
.
setImageResource
(
R
.
mipmap
.
ic_chat_tab_on
);
title
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
colorPrimary
));
mRedDot
=
view
.
findViewById
(
R
.
id
.
dot
);
RelativeLayout
.
LayoutParams
layoutParams
=
(
RelativeLayout
.
LayoutParams
)
mRedDot
.
getLayoutParams
();
layoutParams
.
rightMargin
=
CommonUtils
.
getScreenWidth
(
this
)
/
6
-
CommonUtils
.
dp2px
(
this
,
25
);
}
else
if
(
index
==
1
)
{
iv
.
setImageResource
(
R
.
mipmap
.
ic_contact_tab_off
);
title
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
color_333333
));
...
...
@@ -255,4 +277,26 @@ public class MainActivity extends BaseActivity {
}
@Subscribe
(
threadMode
=
ThreadMode
.
MAIN
)
public
void
onEventBus
(
EventBusCenter
eventBusCenter
)
{
int
eventCode
=
eventBusCenter
.
getEvenCode
();
if
(
eventCode
==
Constants
.
EventCode
.
Code_Count_Changed
)
{
try
{
int
count
=
(
int
)
eventBusCenter
.
getData
();
if
(
count
>
0
)
{
if
(
mViewPager
.
getCurrentItem
()
!=
0
)
{
showDot
(
true
);
}
}
}
catch
(
Exception
e
)
{
}
}
}
private
void
showDot
(
boolean
show
)
{
mRedDot
.
setVisibility
(
show
?
View
.
VISIBLE
:
View
.
GONE
);
}
}
app/src/main/res/drawable/bg_dot.xml
0 → 100644
View file @
93c9f846
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:shape=
"oval"
>
<size
android:width=
"10dp"
android:height=
"10dp"
/>
<solid
android:color=
"@android:color/holo_red_light"
/>
</shape>
\ No newline at end of file
app/src/main/res/layout/activity_login.xml
View file @
93c9f846
...
...
@@ -3,16 +3,16 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_margin=
"20dp"
android:paddingTop=
"@dimen/toolbar_padding_top"
android:focusable=
"true"
android:focusableInTouchMode=
"true"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
android:paddingTop=
"@dimen/toolbar_padding_top"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"60dp"
android:layout_gravity=
"center_horizontal"
android:layout_marginTop=
"60dp"
android:drawableTop=
"@mipmap/ic_logo"
android:drawablePadding=
"20dp"
android:text=
"在线课堂教师版"
...
...
@@ -23,16 +23,16 @@
<RelativeLayout
android:id=
"@+id/rl_username"
android:layout_width=
"match_parent"
android:layout_height=
"
wrap_content
"
android:layout_height=
"
40dp
"
android:layout_marginTop=
"40dp"
>
<EditText
android:id=
"@+id/et_name"
style=
"@style/loginEditText"
android:layout_centerVertical=
"true"
android:layout_toLeftOf=
"@+id/iv_delete"
android:hint=
"请输入工号"
android:inputType=
"textPassword"
android:maxLength=
"11"
/>
android:inputType=
"textPassword"
/>
<ImageView
android:id=
"@+id/iv_delete"
...
...
@@ -42,18 +42,25 @@
android:layout_centerVertical=
"true"
android:padding=
"5dp"
android:src=
"@mipmap/ic_et_clear"
/>
<View
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
android:layout_alignParentBottom=
"true"
android:background=
"@drawable/login_edit_line"
/>
</RelativeLayout>
<RelativeLayout
android:id=
"@+id/rl_password"
android:layout_width=
"match_parent"
android:layout_height=
"
wrap_content
"
android:layout_marginTop=
"
2
0dp"
>
android:layout_height=
"
40dp
"
android:layout_marginTop=
"
1
0dp"
>
<EditText
android:id=
"@+id/et_pwd"
style=
"@style/loginEditText"
android:layout_centerVertical=
"true"
android:layout_toLeftOf=
"@+id/iv_eye"
android:hint=
"请输入密码"
android:inputType=
"textPassword"
/>
...
...
@@ -65,6 +72,13 @@
android:layout_centerVertical=
"true"
android:padding=
"5dp"
android:src=
"@mipmap/ic_et_eye_off"
/>
<View
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
android:layout_alignParentBottom=
"true"
android:background=
"@drawable/login_edit_line"
/>
</RelativeLayout>
...
...
@@ -88,7 +102,8 @@
android:gravity=
"center"
android:text=
"测试一键登录(lqy62094)"
android:textColor=
"@android:color/white"
android:textSize=
"16sp"
/>
android:textSize=
"16sp"
android:visibility=
"visible"
/>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/fragment_contact_list.xml
View file @
93c9f846
...
...
@@ -29,20 +29,27 @@
</RelativeLayout>
<
Relative
Layout
android:id=
"@+id/
container_lis
t"
<
androidx.swiperefreshlayout.widget.SwipeRefresh
Layout
android:id=
"@+id/
refresh_layou
t"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_marginTop=
"15dp"
>
android:layout_height=
"match_parent"
>
<com.offcn.imclient.view.AnimatedExpandableListView
android:id=
"@+id/recycler_view"
android:divider=
"@null"
android:childDivider=
"@null"
<RelativeLayout
android:id=
"@+id/container_list"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:
groupIndicator=
"@null"
/
>
android:
layout_marginTop=
"15dp"
>
</RelativeLayout>
<com.offcn.imclient.view.AnimatedExpandableListView
android:id=
"@+id/recycler_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:childDivider=
"@null"
android:divider=
"@null"
android:groupIndicator=
"@null"
/>
</RelativeLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</LinearLayout>
app/src/main/res/layout/item_contact_child.xml
View file @
93c9f846
...
...
@@ -9,8 +9,7 @@
android:id=
"@+id/iv_avatar"
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:scaleType=
"centerCrop"
android:src=
"@mipmap/ic_teacher"
/>
android:scaleType=
"centerCrop"
/>
<TextView
android:id=
"@+id/tv_name"
...
...
app/src/main/res/layout/item_tab.xml
View file @
93c9f846
...
...
@@ -4,28 +4,45 @@
android:layout_width=
"match_parent"
android:layout_height=
"50dp"
>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_centerInParent=
"true"
android:gravity=
"center"
android:orientation=
"vertical"
>
<ImageView
android:id=
"@+id/iv_pic"
android:layout_width=
"20dp"
android:layout_height=
"20dp"
android:scaleType=
"centerCrop"
tools:src=
"@mipmap/ic_me_on"
/>
<RelativeLayout
android:layout_centerHorizontal=
"true"
android:layout_width=
"wrap_content"
android:layout_height=
"match_parent"
>
<TextView
android:id=
"@+id/tv_title"
android:textSize=
"12sp"
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"2dp"
tools:text=
"我的"
/>
android:layout_height=
"match_parent"
android:layout_centerInParent=
"true"
android:gravity=
"center"
android:orientation=
"vertical"
>
<ImageView
android:id=
"@+id/iv_pic"
android:layout_width=
"20dp"
android:layout_height=
"20dp"
android:scaleType=
"centerCrop"
tools:src=
"@mipmap/ic_chat_tab_off"
/>
<TextView
android:id=
"@+id/tv_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"2dp"
android:textSize=
"12sp"
tools:text=
"我的"
/>
</LinearLayout>
<TextView
android:id=
"@+id/dot"
android:layout_width=
"8dp"
android:layout_height=
"8dp"
android:layout_alignParentRight=
"true"
android:layout_marginTop=
"10dp"
android:background=
"@drawable/bg_dot"
android:visibility=
"gone"
tools:visibility=
"visible"
/>
</
Linear
Layout>
</
Relative
Layout>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/values/styles.xml
View file @
93c9f846
...
...
@@ -35,8 +35,6 @@
<item
name=
"android:layout_height"
>
wrap_content
</item>
<item
name=
"android:textSize"
>
15sp
</item>
<item
name=
"android:background"
>
@null
</item>
<item
name=
"android:drawablePadding"
>
10dp
</item>
<item
name=
"android:drawableBottom"
>
@drawable/login_edit_line
</item>
<item
name=
"android:textColorHint"
>
#888888
</item>
</style>
</resources>
\ No newline at end of file
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