Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
fallenstardust
YGOMobile
Commits
bf2b1a3f
Commit
bf2b1a3f
authored
Jul 29, 2022
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
在萌卡fragment实现splashactivity流程
移除splashactivity 更改聊天室布局文件名 将聊天室从activity改为fragment
parent
02a223c1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
84 additions
and
159 deletions
+84
-159
mobile/src/main/AndroidManifest.xml
mobile/src/main/AndroidManifest.xml
+0
-8
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
...in/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
+21
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/MycardChatFragment.java
...garymb/ygomobile/ui/mycard/mcchat/MycardChatFragment.java
+59
-26
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
.../cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
+0
-122
mobile/src/main/res/layout/fragment_mycard_chating_room.xml
mobile/src/main/res/layout/fragment_mycard_chating_room.xml
+4
-1
No files found.
mobile/src/main/AndroidManifest.xml
View file @
bf2b1a3f
...
...
@@ -147,14 +147,6 @@
android:launchMode=
"singleTop"
android:theme=
"@style/AppTheme.Mycard"
android:windowSoftInputMode=
"stateAlwaysHidden|adjustResize"
/>
<activity
android:name=
"cn.garymb.ygomobile.ui.mycard.mcchat.McchatActivity"
android:label=
"@string/app_name"
android:windowSoftInputMode=
"stateHidden|adjustResize"
/>
<activity
android:name=
"cn.garymb.ygomobile.ui.mycard.mcchat.SplashActivity"
android:theme=
"@style/AppTheme.Mycard"
/>
<activity
android:name=
"cn.garymb.ygomobile.ui.activities.FileLogActivity"
/>
<activity
android:name=
"cn.garymb.ygomobile.ui.activities.PermissionsActivity"
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MycardFragment.java
View file @
bf2b1a3f
...
...
@@ -5,7 +5,9 @@ import static android.app.Activity.RESULT_OK;
import
android.annotation.SuppressLint
;
import
android.annotation.TargetApi
;
import
android.content.ClipData
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Bundle
;
...
...
@@ -41,8 +43,9 @@ import cn.garymb.ygomobile.lite.R;
import
cn.garymb.ygomobile.ui.mycard.base.OnJoinChatListener
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.ChatListener
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.ChatMessage
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.SplashActivity
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.ServiceManagement
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.UserManagement
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
cn.garymb.ygomobile.utils.glide.GlideCompat
;
public
class
MycardFragment
extends
BaseFragemnt
implements
View
.
OnClickListener
,
MyCard
.
MyCardListener
,
OnJoinChatListener
,
ChatListener
{
...
...
@@ -74,6 +77,7 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
}
mNameView
.
setText
(
ss
[
0
]);
mStatusView
.
setText
(
ss
[
2
]);
initData
();
}
}
};
...
...
@@ -109,6 +113,11 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
rl_chat
.
setOnClickListener
(
this
);
tv_message
=
view
.
findViewById
(
R
.
id
.
tv_message
);
pb_chat_loading
=
view
.
findViewById
(
R
.
id
.
pb_chat_loading
);
SharedPreferences
lastModified
=
getActivity
().
getSharedPreferences
(
"lastModified"
,
Context
.
MODE_PRIVATE
);
UserManagement
.
setUserName
(
lastModified
.
getString
(
"user_name"
,
null
));
UserManagement
.
setUserPassword
(
lastModified
.
getString
(
"user_external_id"
,
null
));
serviceManagement
=
ServiceManagement
.
getDx
();
serviceManagement
.
addJoinRoomListener
(
this
);
serviceManagement
.
addListener
(
this
);
...
...
@@ -166,6 +175,14 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
mWebViewPlus
.
loadUrl
(
mMyCard
.
getHomeUrl
());
}
private
void
initData
()
{
if
(
UserManagement
.
getUserName
()
!=
null
)
{
serviceManagement
.
start
();
}
else
{
}
}
@Override
public
void
onResume
()
{
YGOStarter
.
onResumed
(
getActivity
());
...
...
@@ -307,7 +324,7 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
onHome
();
break
;
case
R
.
id
.
rl_chat
:
startActivity
(
new
Intent
(
getActivity
(),
SplashActivity
.
class
));
//这里显示聊天室fragment
break
;
}
}
...
...
@@ -357,6 +374,8 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
tv_message
.
setText
(
currentMessage
.
getName
()
+
":"
+
currentMessage
.
getMessage
());
}
else
{
tv_message
.
setText
(
R
.
string
.
logining_failed
);
serviceManagement
.
setIsListener
(
false
);
YGOUtil
.
show
(
getString
(
R
.
string
.
failed_reason
)
+
exception
);
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/M
cchatActivity
.java
→
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/M
ycardChatFragment
.java
View file @
bf2b1a3f
package
cn.garymb.ygomobile.ui.mycard.mcchat
;
import
android.app.Activity
;
import
android.os.Bundle
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.EditText
;
import
android.widget.ImageButton
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.ourygo.assistant.util.Util
;
import
cn.garymb.ygomobile.base.BaseFragemnt
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.adapter.ChatAdapter
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.ServiceManagement
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.UserManagement
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
public
class
M
cchatActivity
extends
Activity
implements
ChatListener
{
public
class
M
ycardChatFragment
extends
BaseFragemnt
implements
ChatListener
{
private
EditText
main_send_message
;
private
ImageButton
main_send
;
...
...
@@ -29,11 +32,21 @@ public class McchatActivity extends Activity implements ChatListener {
private
ChatAdapter
cadp
;
private
ServiceManagement
su
;
@Nullable
@Override
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreateView
(
inflater
,
container
,
savedInstanceState
);
View
view
;
view
=
inflater
.
inflate
(
R
.
layout
.
fragment_mycard_chating_room
,
container
,
false
);
initView
(
view
);
return
view
;
}
@Override
public
void
reChatLogin
(
boolean
state
)
{
main_bottom_bar
.
setVisibility
(
View
.
GONE
);
if
(
state
)
{
main_title
.
setText
(
"登录成功"
);
main_title
.
setText
(
R
.
string
.
logining_in
);
}
else
{
main_title
.
setText
(
"连接断开,重新登录中……"
);
}
...
...
@@ -54,7 +67,7 @@ public class McchatActivity extends Activity implements ChatListener {
@Override
public
boolean
isListenerEffective
()
{
return
Util
.
isContextExisted
(
this
);
return
Util
.
isContextExisted
(
getActivity
()
);
}
@Override
...
...
@@ -70,26 +83,18 @@ public class McchatActivity extends Activity implements ChatListener {
// TODO: Implement this method
}
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
main
);
initView
();
}
private
void
initView
()
{
main_rec
=
findViewById
(
R
.
id
.
main_rec
);
main_send
=
findViewById
(
R
.
id
.
main_send
);
main_send_message
=
findViewById
(
R
.
id
.
main_send_message
);
main_title
=
findViewById
(
R
.
id
.
main_title
);
main_bottom_bar
=
findViewById
(
R
.
id
.
main_bottom_bar
);
private
void
initView
(
View
view
)
{
main_rec
=
view
.
findViewById
(
R
.
id
.
main_rec
);
main_send
=
view
.
findViewById
(
R
.
id
.
main_send
);
main_send_message
=
view
.
findViewById
(
R
.
id
.
main_send_message
);
main_title
=
view
.
findViewById
(
R
.
id
.
main_title
);
main_bottom_bar
=
view
.
findViewById
(
R
.
id
.
main_bottom_bar
);
su
=
ServiceManagement
.
getDx
();
cadp
=
new
ChatAdapter
(
this
,
su
.
getData
());
cadp
=
new
ChatAdapter
(
getContext
()
,
su
.
getData
());
su
.
addListener
(
this
);
LinearLayoutManager
linearLayoutManager
=
new
LinearLayoutManager
(
McchatActivity
.
this
,
LinearLayoutManager
.
VERTICAL
,
false
);
LinearLayoutManager
linearLayoutManager
=
new
LinearLayoutManager
(
getContext
()
,
LinearLayoutManager
.
VERTICAL
,
false
);
linearLayoutManager
.
setStackFromEnd
(
true
);
//关键 设置此项,当软键盘弹出时,布局会自动顶上去,在结合AndroidManifest.xml设置属性
main_rec
.
setLayoutManager
(
linearLayoutManager
);
main_rec
.
setAdapter
(
cadp
);
...
...
@@ -117,14 +122,42 @@ public class McchatActivity extends Activity implements ChatListener {
}
@Override
p
rotected
void
onDestroy
()
{
p
ublic
void
onDestroy
()
{
// TODO: Implement this method
super
.
onDestroy
();
su
.
disClass
();
UserManagement
.
setUserName
(
null
);
UserManagement
.
setUserPassword
(
null
);
finish
();
// su.disClass();
// UserManagement.setUserName(null);
// UserManagement.setUserPassword(null);
}
@Override
public
void
onFirstUserVisible
()
{
}
@Override
public
void
onUserVisible
()
{
}
@Override
public
void
onFirstUserInvisible
()
{
}
@Override
public
void
onUserInvisible
()
{
}
@Override
public
void
onBackHome
()
{
}
@Override
public
void
onBackPressed
()
{
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
deleted
100644 → 0
View file @
02a223c1
package
cn.garymb.ygomobile.ui.mycard.mcchat
;
import
android.app.Activity
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.os.Bundle
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.View
;
import
android.widget.LinearLayout
;
import
android.widget.ProgressBar
;
import
android.widget.TextView
;
import
com.ourygo.assistant.util.Util
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.mycard.base.OnJoinChatListener
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.ServiceManagement
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.management.UserManagement
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
public
class
SplashActivity
extends
Activity
implements
OnJoinChatListener
{
public
static
final
int
CHAT_LOGIN_EXCEPTION_RE
=
0
;
public
static
final
int
CHAT_LOGIN_OK
=
1
;
public
static
final
int
CHAT_LOGIN_EXCEPTION
=
2
;
public
static
final
int
CHAT_LOGIN_LOADING
=
3
;
public
static
final
int
CHAT_JOIN_ROOM_LOADING
=
4
;
public
static
final
int
CHAT_USER_NULL
=
5
;
ServiceManagement
su
;
ProgressBar
sp_jz
;
TextView
sp_tv
;
LinearLayout
sp_li
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
// TODO: Implement this method
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_splash
);
initView
();
/*String name=getIntent().getStringExtra("name");
String password=getIntent().getStringExtra("password");
UserManagement.setUserName(name);
UserManagement.setUserPassword(password);*/
//UserManagement.setUserName("废话多");
//UserManagement.setUserPassword("19709");
SharedPreferences
lastModified
=
getSharedPreferences
(
"lastModified"
,
Context
.
MODE_PRIVATE
);
UserManagement
.
setUserName
(
lastModified
.
getString
(
"user_name"
,
null
));
UserManagement
.
setUserPassword
(
lastModified
.
getString
(
"user_external_id"
,
null
));
su
=
ServiceManagement
.
getDx
();
su
.
addJoinRoomListener
(
this
);
su
.
start
();
}
private
void
initView
()
{
sp_jz
=
findViewById
(
R
.
id
.
sp_jz
);
sp_tv
=
findViewById
(
R
.
id
.
sp_tv
);
sp_li
=
findViewById
(
R
.
id
.
sp_li
);
sp_li
.
setOnClickListener
(
p1
->
{
su
.
start
();
// TODO: Implement this method
});
// TODO: Implement this method
}
// @Override
// public void onLoginExceptionClickRe() {
// su.setIsConnected(false);
// sp_jz.setVisibility(View.GONE);
// sp_tv.setText(getString(R.string.logining_failed));
// YGOUtil.show(getString(R.string.failed_reason) + msg.obj);
// }
@Override
public
void
onChatLogin
(
String
exception
)
{
Log
.
e
(
"SplashActivity"
,
"登录情况"
+
exception
);
sp_jz
.
setVisibility
(
View
.
GONE
);
if
(
TextUtils
.
isEmpty
(
exception
))
{
startActivity
(
new
Intent
(
SplashActivity
.
this
,
McchatActivity
.
class
));
finish
();
}
else
{
su
.
setIsListener
(
false
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_failed
));
YGOUtil
.
show
(
getString
(
R
.
string
.
failed_reason
)
+
exception
);
}
}
@Override
public
void
onChatLoginLoading
()
{
Log
.
e
(
"SplashActivity"
,
"登录中"
);
sp_jz
.
setVisibility
(
View
.
VISIBLE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_in
));
}
@Override
public
void
onJoinRoomLoading
()
{
Log
.
e
(
"SplashActivity"
,
"加入房间中"
);
sp_jz
.
setVisibility
(
View
.
VISIBLE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_in
));
}
@Override
public
void
onChatUserNull
()
{
Log
.
e
(
"SplashActivity"
,
"用户为空"
);
finish
();
}
@Override
public
boolean
isListenerEffective
()
{
return
Util
.
isContextExisted
(
this
);
}
}
mobile/src/main/res/layout/
main
.xml
→
mobile/src/main/res/layout/
fragment_mycard_chating_room
.xml
View file @
bf2b1a3f
...
...
@@ -15,7 +15,10 @@
android:id=
"@+id/main_title"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_margin=
"10dp"
android:layout_marginStart=
"10dp"
android:layout_marginTop=
"10dp"
android:layout_marginEnd=
"10dp"
android:layout_marginBottom=
"10dp"
android:text=
"@string/mc_chat"
android:textColor=
"@color/white"
android:textSize=
"20sp"
/>
...
...
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