Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccim_sdk_android
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
ccim_sdk_android
Commits
097174c8
Commit
097174c8
authored
Jan 20, 2022
by
sheteng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面上的闪退问题
parent
a210c021
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
233 additions
and
49 deletions
+233
-49
.idea/misc.xml
.idea/misc.xml
+1
-0
app/src/main/AndroidManifest.xml
app/src/main/AndroidManifest.xml
+8
-2
app/src/main/java/com/ccwangluo/im/ui/dashboard/ConnectActivity.java
...n/java/com/ccwangluo/im/ui/dashboard/ConnectActivity.java
+129
-0
app/src/main/java/com/ccwangluo/im/ui/notifications/ConnectChannelActivity.java
...ccwangluo/im/ui/notifications/ConnectChannelActivity.java
+27
-35
app/src/main/java/com/ccwangluo/im/ui/notifications/NotificationsFragment.java
.../ccwangluo/im/ui/notifications/NotificationsFragment.java
+7
-4
app/src/main/res/layout/activity_connect.xml
app/src/main/res/layout/activity_connect.xml
+53
-0
app/src/main/res/layout/activity_connect_channel.xml
app/src/main/res/layout/activity_connect_channel.xml
+0
-0
app/src/main/res/layout/activity_login.xml
app/src/main/res/layout/activity_login.xml
+2
-2
app/src/main/res/navigation/mobile_navigation.xml
app/src/main/res/navigation/mobile_navigation.xml
+6
-6
No files found.
.idea/misc.xml
View file @
097174c8
...
...
@@ -4,6 +4,7 @@
<option
name=
"filePathToZoomLevelMap"
>
<map>
<entry
key=
"..\:/project/ccwangluoIm/app/src/main/res/layout/activity_connect.xml"
value=
"0.3170289855072464"
/>
<entry
key=
"..\:/project/ccwangluoIm/app/src/main/res/layout/activity_connect_channel.xml"
value=
"0.26403985507246375"
/>
<entry
key=
"..\:/project/ccwangluoIm/app/src/main/res/layout/activity_login.xml"
value=
"0.322463768115942"
/>
<entry
key=
"..\:/project/ccwangluoIm/app/src/main/res/layout/activity_main.xml"
value=
"0.20153985507246377"
/>
<entry
key=
"..\:/project/ccwangluoIm/app/src/main/res/layout/activity_main2.xml"
value=
"0.27309782608695654"
/>
...
...
app/src/main/AndroidManifest.xml
View file @
097174c8
...
...
@@ -12,11 +12,17 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/Theme.CcwangluoIm"
>
<activity
android:name=
".ui.dashboard.ConnectActivity"
android:exported=
"false"
/>
<activity
android:name=
".ui.notifications.ConnectChannelActivity"
android:exported=
"false"
/>
<activity
android:name=
".MainActivity2"
android:screenOrientation=
"portrait"
android:exported=
"false"
android:label=
"@string/title_activity_main2"
/>
<!-- <activity -->
android:label=
"@string/title_activity_main2"
android:screenOrientation=
"portrait"
/>
<!-- <activity -->
<!-- android:name=".ui.login.LoginActivity" -->
<!-- android:exported="false" -->
<!-- android:label="@string/title_activity_login" /> -->
...
...
app/src/main/java/com/ccwangluo/im/ui/dashboard/ConnectActivity.java
0 → 100644
View file @
097174c8
package
com.ccwangluo.im.ui.dashboard
;
import
android.os.Bundle
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.lifecycle.Observer
;
import
androidx.lifecycle.ViewModelProvider
;
import
com.ccwangluo.ccim.CCIMClient
;
import
com.ccwangluo.ccim.listener.ResultEventCallback
;
import
com.ccwangluo.ccim.modle.Contact
;
import
com.ccwangluo.ccim.modle.MessageContent
;
import
com.ccwangluo.im.adapter.PrivateMsgAdapter
;
import
com.ccwangluo.im.data.LoginViewModel
;
import
com.ccwangluo.im.databinding.ActivityConnectBinding
;
import
com.ccwangluo.im.util.ToastUtil
;
import
java.util.HashMap
;
import
java.util.List
;
public
class
ConnectActivity
extends
AppCompatActivity
{
private
ActivityConnectBinding
binding
;
private
LoginViewModel
loginViewModel
;
private
PrivateMsgAdapter
privaetMsgAdapter
;
private
HashMap
<
Long
,
MessageContent
>
map
=
new
HashMap
<>();
private
String
filePath
;
private
boolean
isSuccess
=
false
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
binding
=
ActivityConnectBinding
.
inflate
(
getLayoutInflater
());
setContentView
(
binding
.
getRoot
());
loginViewModel
=
new
ViewModelProvider
(
this
)
.
get
(
LoginViewModel
.
class
);
privaetMsgAdapter
=
new
PrivateMsgAdapter
(
map
.
values
(),
this
);
binding
.
msgList
.
setAdapter
(
privaetMsgAdapter
);
Contact
contact
=
(
Contact
)
getIntent
().
getSerializableExtra
(
"contact"
);
loginViewModel
.
privateMsgList
.
observe
(
this
,
new
Observer
<
MessageContent
>()
{
@Override
public
void
onChanged
(
MessageContent
messageContent
)
{
if
(
messageContent
.
getSenderUserId
().
equals
(
contact
.
getContactUserId
())
||
messageContent
.
getReciveUserId
().
equals
(
contact
.
getContactUserId
()))
{
map
.
put
(
messageContent
.
getMsgId
(),
messageContent
);
privaetMsgAdapter
.
refreshData
();
binding
.
msgList
.
setSelection
(
privaetMsgAdapter
.
getCount
()
-
1
);
}
}
});
binding
.
sendBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
String
content
=
binding
.
sendEdit
.
getText
().
toString
();
CCIMClient
.
getInstance
().
sendTextMessage
(
content
,
contact
.
getContactUserId
(),
contact
.
getContactUserName
(),
new
ResultEventCallback
<
MessageContent
>()
{
@Override
public
void
onSuccess
(
MessageContent
messageContent
)
{
binding
.
sendEdit
.
setText
(
""
);
loginViewModel
.
addPrivateMsg
(
messageContent
);
ToastUtil
.
show
(
getApplication
(),
"send Success"
);
}
@Override
public
void
onFailed
(
int
errorCode
)
{
ToastUtil
.
show
(
getApplication
(),
"send onFailed :"
+
errorCode
);
}
});
}
});
binding
.
sendVoice
.
setOnTouchListener
(
new
View
.
OnTouchListener
()
{
@Override
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
if
(
isSuccess
)
CCIMClient
.
getInstance
().
stopAndSendAudioMessage
(
contact
.
getContactUserId
(),
contact
.
getContactUserName
(),
new
ResultEventCallback
<
MessageContent
>()
{
@Override
public
void
onSuccess
(
MessageContent
message
)
{
binding
.
sendEdit
.
setText
(
""
);
loginViewModel
.
addPrivateMsg
(
message
);
ToastUtil
.
show
(
getApplication
(),
"send Success"
);
}
@Override
public
void
onFailed
(
int
errorCode
)
{
ToastUtil
.
show
(
getApplication
(),
"send onFailed :"
+
errorCode
);
}
});
}
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
)
{
CCIMClient
.
getInstance
().
startRecordAudioMessage
(
getApplication
(),
new
ResultEventCallback
<
Void
>()
{
@Override
public
void
onSuccess
(
Void
unused
)
{
isSuccess
=
true
;
}
@Override
public
void
onFailed
(
int
errorCode
)
{
isSuccess
=
false
;
ToastUtil
.
show
(
getApplication
(),
errorCode
+
""
);
}
});
}
return
false
;
}
});
CCIMClient
.
getInstance
().
getPrivateMessage
(
contact
.
getContactUserId
(),
new
ResultEventCallback
<
List
<
MessageContent
>>()
{
@Override
public
void
onSuccess
(
List
<
MessageContent
>
messageContents
)
{
for
(
MessageContent
messageContent
:
messageContents
)
{
map
.
put
(
messageContent
.
getMsgId
(),
messageContent
);
}
privaetMsgAdapter
.
refreshData
();
binding
.
msgList
.
setSelection
(
privaetMsgAdapter
.
getCount
()
-
1
);
}
@Override
public
void
onFailed
(
int
errorCode
)
{
}
});
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/im/ui/notifications/ConnectChannel
Fragment
.java
→
app/src/main/java/com/ccwangluo/im/ui/notifications/ConnectChannel
Activity
.java
View file @
097174c8
package
com.ccwangluo.im.ui.notifications
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
androidx.
fragment.app.Fragment
;
import
androidx.
appcompat.app.AppCompatActivity
;
import
androidx.lifecycle.Observer
;
import
androidx.lifecycle.ViewModelProvider
;
...
...
@@ -15,14 +13,14 @@ import com.ccwangluo.ccim.listener.ResultEventCallback;
import
com.ccwangluo.ccim.modle.MessageContent
;
import
com.ccwangluo.im.adapter.ChannelMsgAdapter
;
import
com.ccwangluo.im.data.LoginViewModel
;
import
com.ccwangluo.im.databinding.
FragmentChannelConnect
Binding
;
import
com.ccwangluo.im.databinding.
ActivityConnectChannel
Binding
;
import
com.ccwangluo.im.util.ToastUtil
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ConnectChannel
Fragment
extends
Fragment
{
private
FragmentChannelConnect
Binding
binding
;
public
class
ConnectChannel
Activity
extends
AppCompatActivity
{
private
ActivityConnectChannel
Binding
binding
;
private
LoginViewModel
loginViewModel
;
private
ChannelMsgAdapter
channelMsgAdapter
;
private
List
<
MessageContent
>
list
=
new
ArrayList
<>();
...
...
@@ -32,22 +30,18 @@ public class ConnectChannelFragment extends Fragment {
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
binding
=
FragmentChannelConnectBinding
.
inflate
(
inflater
,
container
,
false
);
loginViewModel
=
new
ViewModelProvider
(
getActivity
())
binding
=
ActivityConnectChannelBinding
.
inflate
(
getLayoutInflater
());
loginViewModel
=
new
ViewModelProvider
(
this
)
.
get
(
LoginViewModel
.
class
);
setContentView
(
binding
.
getRoot
());
channelMsgAdapter
=
new
ChannelMsgAdapter
(
list
,
getContext
()
);
channelMsgAdapter
=
new
ChannelMsgAdapter
(
list
,
this
);
binding
.
msgList
.
setAdapter
(
channelMsgAdapter
);
long
channelId
=
get
Arguments
().
getLong
(
"channelId"
);
long
channelId
=
get
Intent
().
getLongExtra
(
"channelId"
,
0
);
loginViewModel
.
channelMsgList
.
observe
(
getViewLifecycleOwner
()
,
new
Observer
<
MessageContent
>()
{
loginViewModel
.
channelMsgList
.
observe
(
this
,
new
Observer
<
MessageContent
>()
{
@Override
public
void
onChanged
(
MessageContent
messageContent
)
{
if
(
messageContent
.
getChannelId
().
equals
(
channelId
))
{
...
...
@@ -67,12 +61,12 @@ public class ConnectChannelFragment extends Fragment {
public
void
onSuccess
(
MessageContent
messageContent
)
{
binding
.
sendEdit
.
setText
(
""
);
loginViewModel
.
addChannelMsg
(
messageContent
);
ToastUtil
.
show
(
getContext
()
,
"send Success"
);
ToastUtil
.
show
(
ConnectChannelActivity
.
this
,
"send Success"
);
}
@Override
public
void
onFailed
(
int
errorCode
)
{
ToastUtil
.
show
(
getContext
()
,
"send onFailed :"
+
errorCode
);
ToastUtil
.
show
(
ConnectChannelActivity
.
this
,
"send onFailed :"
+
errorCode
);
}
});
}
...
...
@@ -97,22 +91,22 @@ public class ConnectChannelFragment extends Fragment {
public
boolean
onTouch
(
View
v
,
MotionEvent
event
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
if
(
isSuccess
)
CCIMClient
.
getInstance
().
stopAndSendChannelAudioMessage
(
channelId
,
new
ResultEventCallback
<
MessageContent
>()
{
@Override
public
void
onSuccess
(
MessageContent
message
)
{
binding
.
sendEdit
.
setText
(
""
);
loginViewModel
.
addChannelMsg
(
message
);
ToastUtil
.
show
(
getContext
()
,
"send Success"
);
}
@Override
public
void
onFailed
(
int
errorCode
)
{
ToastUtil
.
show
(
getContext
()
,
"send onFailed :"
+
errorCode
);
}
});
CCIMClient
.
getInstance
().
stopAndSendChannelAudioMessage
(
channelId
,
new
ResultEventCallback
<
MessageContent
>()
{
@Override
public
void
onSuccess
(
MessageContent
message
)
{
binding
.
sendEdit
.
setText
(
""
);
loginViewModel
.
addChannelMsg
(
message
);
ToastUtil
.
show
(
ConnectChannelActivity
.
this
,
"send Success"
);
}
@Override
public
void
onFailed
(
int
errorCode
)
{
ToastUtil
.
show
(
ConnectChannelActivity
.
this
,
"send onFailed :"
+
errorCode
);
}
});
}
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_DOWN
)
{
CCIMClient
.
getInstance
().
startRecordAudioMessage
(
getActivity
()
,
new
ResultEventCallback
<
Void
>()
{
CCIMClient
.
getInstance
().
startRecordAudioMessage
(
ConnectChannelActivity
.
this
,
new
ResultEventCallback
<
Void
>()
{
@Override
public
void
onSuccess
(
Void
unused
)
{
isSuccess
=
true
;
...
...
@@ -121,7 +115,7 @@ public class ConnectChannelFragment extends Fragment {
@Override
public
void
onFailed
(
int
errorCode
)
{
isSuccess
=
false
;
ToastUtil
.
show
(
getContext
()
,
errorCode
+
""
);
ToastUtil
.
show
(
ConnectChannelActivity
.
this
,
errorCode
+
""
);
}
});
}
...
...
@@ -129,7 +123,5 @@ public class ConnectChannelFragment extends Fragment {
return
false
;
}
});
return
binding
.
getRoot
();
}
}
\ No newline at end of file
app/src/main/java/com/ccwangluo/im/ui/notifications/NotificationsFragment.java
View file @
097174c8
...
...
@@ -5,6 +5,7 @@ import android.content.ClipData;
import
android.content.ClipboardManager
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.view.LayoutInflater
;
...
...
@@ -23,7 +24,6 @@ import androidx.navigation.Navigation;
import
com.ccwangluo.ccim.CCIMClient
;
import
com.ccwangluo.ccim.listener.ResultEventCallback
;
import
com.ccwangluo.im.R
;
import
com.ccwangluo.im.adapter.ChannelAdapter
;
import
com.ccwangluo.im.data.LoginViewModel
;
import
com.ccwangluo.im.databinding.FragmentNotificationsBinding
;
...
...
@@ -52,9 +52,12 @@ public class NotificationsFragment extends Fragment {
channelAdapter
=
new
ChannelAdapter
(
list
,
getContext
(),
new
ChannelClickListener
()
{
@Override
public
void
itemClick
(
Long
id
)
{
Bundle
bundle
=
new
Bundle
();
bundle
.
putLong
(
"channelId"
,
id
);
navController
.
navigate
(
R
.
id
.
navigation_channel_connect
,
bundle
);
// Bundle bundle = new Bundle();
// bundle.putLong("channelId", id);
// navController.navigate(R.id.navigation_channel_connect, bundle);
Intent
intent
=
new
Intent
(
getContext
(),
ConnectChannelActivity
.
class
);
intent
.
putExtra
(
"channelId"
,
id
);
startActivity
(
intent
);
}
@Override
...
...
app/src/main/res/layout/activity_connect.xml
0 → 100644
View file @
097174c8
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
tools:context=
".MainActivity2"
>
<ListView
android:id=
"@+id/msg_list"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1"
tools:layout_editor_absoluteX=
"1dp"
tools:layout_editor_absoluteY=
"1dp"
/>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"10dp"
android:orientation=
"horizontal"
>
<EditText
android:id=
"@+id/send_edit"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
/>
<Button
android:id=
"@+id/send_btn"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"发送文字"
/>
</LinearLayout>
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center_vertical"
android:gravity=
"center"
android:layout_marginBottom=
"100dp"
android:orientation=
"horizontal"
>
<Button
android:id=
"@+id/send_voice"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"语音"
/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
app/src/main/res/layout/
fragment_channel_connect
.xml
→
app/src/main/res/layout/
activity_connect_channel
.xml
View file @
097174c8
File moved
app/src/main/res/layout/activity_login.xml
View file @
097174c8
...
...
@@ -14,7 +14,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"Username"
android:text=
"
21
"
android:text=
"
15
"
android:inputType=
"textEmailAddress"
android:selectAllOnFocus=
"true"
app:layout_constraintEnd_toEndOf=
"parent"
...
...
@@ -27,7 +27,7 @@
android:layout_height=
"wrap_content"
android:layout_marginTop=
"8dp"
android:hint=
"UserId"
android:text=
"
21
"
android:text=
"
15
"
android:imeActionLabel=
"@string/action_sign_in_short"
android:imeOptions=
"actionDone"
android:selectAllOnFocus=
"true"
...
...
app/src/main/res/navigation/mobile_navigation.xml
View file @
097174c8
...
...
@@ -30,11 +30,11 @@
app:defaultNavHost=
"true"
tools:layout=
"@layout/fragment_connect"
/>
<fragment
android:id=
"@+id/navigation_channel_connect"
android:name=
"com.ccwangluo.im.ui.notifications.ConnectChannelFragment"
android:label=
"频道聊天"
app:defaultNavHost=
"true"
tools:layout=
"@layout/fragment_connect"
/
>
<!-- <fragment-->
<!-- android:id="@+id/navigation_channel_connect"-->
<!-- android:name="com.ccwangluo.im.ui.notifications.ConnectChannelFragment"-->
<!-- android:label="频道聊天"-->
<!-- app:defaultNavHost="true"-->
<!-- tools:layout="@layout/fragment_connect" />--
>
</navigation>
\ 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