Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile-Cn-Ko-En
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-Cn-Ko-En
Commits
bdde3484
Commit
bdde3484
authored
Jun 06, 2019
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
arrange mycard module
parent
6e834260
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
181 additions
and
194 deletions
+181
-194
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MyCard.java
...e/src/main/java/cn/garymb/ygomobile/ui/mycard/MyCard.java
+33
-33
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MyCardActivity.java
...in/java/cn/garymb/ygomobile/ui/mycard/MyCardActivity.java
+4
-5
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/X5WebView.java
...rc/main/java/cn/garymb/ygomobile/ui/mycard/X5WebView.java
+5
-5
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/ChatMessage.java
...ava/cn/garymb/ygomobile/ui/mycard/mcchat/ChatMessage.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/McchatActivity.java
.../cn/garymb/ygomobile/ui/mycard/mcchat/McchatActivity.java
+13
-17
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
.../cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
+43
-43
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/adapter/ChatAdapter.java
...arymb/ygomobile/ui/mycard/mcchat/adapter/ChatAdapter.java
+17
-20
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/management/ServiceManagement.java
...mobile/ui/mycard/mcchat/management/ServiceManagement.java
+43
-47
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/management/UserManagement.java
...ygomobile/ui/mycard/mcchat/management/UserManagement.java
+4
-4
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/util/ImageUtil.java
.../cn/garymb/ygomobile/ui/mycard/mcchat/util/ImageUtil.java
+9
-10
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/util/TaxiConnectionListener.java
...omobile/ui/mycard/mcchat/util/TaxiConnectionListener.java
+6
-6
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/util/Util.java
.../java/cn/garymb/ygomobile/ui/mycard/mcchat/util/Util.java
+3
-3
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MyCard.java
View file @
bdde3484
...
@@ -40,28 +40,9 @@ public class MyCard {
...
@@ -40,28 +40,9 @@ public class MyCard {
private
static
final
Charset
UTF_8
=
Charset
.
forName
(
"UTF-8"
);
private
static
final
Charset
UTF_8
=
Charset
.
forName
(
"UTF-8"
);
private
final
DefWebViewClient
mDefWebViewClient
;
private
final
DefWebViewClient
mDefWebViewClient
;
private
final
User
mUser
=
new
User
();
private
final
User
mUser
=
new
User
();
private
final
SharedPreferences
lastModified
;
private
MyCardListener
mMyCardListener
;
private
MyCardListener
mMyCardListener
;
private
Activity
mContext
;
private
Activity
mContext
;
private
final
SharedPreferences
lastModified
;
public
interface
MyCardListener
{
void
onLogin
(
String
name
,
String
icon
,
String
statu
);
void
watchReplay
();
void
puzzleMode
();
void
openDrawer
();
void
closeDrawer
();
void
backHome
();
void
share
(
String
text
);
void
onHome
();
}
public
MyCard
(
Activity
context
)
{
public
MyCard
(
Activity
context
)
{
mContext
=
context
;
mContext
=
context
;
...
@@ -95,6 +76,17 @@ public class MyCard {
...
@@ -95,6 +76,17 @@ public class MyCard {
};
};
}
}
private
static
String
byteArrayToHexString
(
byte
[]
array
)
{
StringBuilder
hexString
=
new
StringBuilder
();
for
(
byte
b
:
array
)
{
int
intVal
=
b
&
0xff
;
if
(
intVal
<
0x10
)
hexString
.
append
(
"0"
);
hexString
.
append
(
Integer
.
toHexString
(
intVal
));
}
return
hexString
.
toString
();
}
public
String
getArenaUrl
()
{
public
String
getArenaUrl
()
{
return
mArenaUrl
;
return
mArenaUrl
;
}
}
...
@@ -107,15 +99,8 @@ public class MyCard {
...
@@ -107,15 +99,8 @@ public class MyCard {
return
mDefWebViewClient
;
return
mDefWebViewClient
;
}
}
private
static
String
byteArrayToHexString
(
byte
[]
array
)
{
public
String
getHomeUrl
()
{
StringBuilder
hexString
=
new
StringBuilder
();
return
mHomeUrl
;
for
(
byte
b
:
array
)
{
int
intVal
=
b
&
0xff
;
if
(
intVal
<
0x10
)
hexString
.
append
(
"0"
);
hexString
.
append
(
Integer
.
toHexString
(
intVal
));
}
return
hexString
.
toString
();
}
}
// public String getLoginUrl() throws NoSuchAlgorithmException, InvalidKeyException {
// public String getLoginUrl() throws NoSuchAlgorithmException, InvalidKeyException {
...
@@ -133,10 +118,6 @@ public class MyCard {
...
@@ -133,10 +118,6 @@ public class MyCard {
// return requestBuilder.build().toString();
// return requestBuilder.build().toString();
// }
// }
public
String
getHomeUrl
()
{
return
mHomeUrl
;
}
public
String
getBBSUrl
()
{
public
String
getBBSUrl
()
{
return
mCommunityUrl
;
return
mCommunityUrl
;
}
}
...
@@ -155,6 +136,25 @@ public class MyCard {
...
@@ -155,6 +136,25 @@ public class MyCard {
}
}
}
}
public
interface
MyCardListener
{
void
onLogin
(
String
name
,
String
icon
,
String
statu
);
void
watchReplay
();
void
puzzleMode
();
void
openDrawer
();
void
closeDrawer
();
void
backHome
();
void
share
(
String
text
);
void
onHome
();
}
public
static
class
User
{
public
static
class
User
{
int
external_id
;
int
external_id
;
String
username
;
String
username
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/MyCardActivity.java
View file @
bdde3484
...
@@ -27,7 +27,6 @@ import com.tencent.smtt.sdk.WebChromeClient;
...
@@ -27,7 +27,6 @@ import com.tencent.smtt.sdk.WebChromeClient;
import
com.tencent.smtt.sdk.WebSettings
;
import
com.tencent.smtt.sdk.WebSettings
;
import
com.tencent.smtt.sdk.WebView
;
import
com.tencent.smtt.sdk.WebView
;
import
java.io.File
;
import
java.text.MessageFormat
;
import
java.text.MessageFormat
;
import
cn.garymb.ygomobile.YGOStarter
;
import
cn.garymb.ygomobile.YGOStarter
;
...
@@ -35,15 +34,14 @@ import cn.garymb.ygomobile.lite.BuildConfig;
...
@@ -35,15 +34,14 @@ import cn.garymb.ygomobile.lite.BuildConfig;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.ui.cards.DeckManagerActivity
;
import
cn.garymb.ygomobile.ui.cards.DeckManagerActivity
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.SplashActivity
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.SplashActivity
;
public
class
MyCardActivity
extends
BaseActivity
implements
MyCard
.
MyCardListener
,
NavigationView
.
OnNavigationItemSelectedListener
{
public
class
MyCardActivity
extends
BaseActivity
implements
MyCard
.
MyCardListener
,
NavigationView
.
OnNavigationItemSelectedListener
{
private
static
final
int
FILECHOOSER_RESULTCODE
=
10
;
private
static
final
int
FILECHOOSER_RESULTCODE
=
10
;
protected
DrawerLayout
mDrawerlayout
;
private
MyCardWebView
mWebViewPlus
;
private
MyCardWebView
mWebViewPlus
;
private
MyCard
mMyCard
;
private
MyCard
mMyCard
;
protected
DrawerLayout
mDrawerlayout
;
private
ImageView
mHeadView
;
private
ImageView
mHeadView
;
private
TextView
mNameView
,
mStatusView
;
private
TextView
mNameView
,
mStatusView
;
...
@@ -88,7 +86,7 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
...
@@ -88,7 +86,7 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
mWebViewPlus
.
setWebChromeClient
(
new
WebChromeClient
()
{
mWebViewPlus
.
setWebChromeClient
(
new
WebChromeClient
()
{
@Override
@Override
public
void
onProgressChanged
(
WebView
view
,
int
newProgress
)
{
public
void
onProgressChanged
(
WebView
view
,
int
newProgress
)
{
if
(
newProgress
==
100
)
{
if
(
newProgress
==
100
)
{
mProgressBar
.
setVisibility
(
View
.
GONE
);
mProgressBar
.
setVisibility
(
View
.
GONE
);
}
else
{
}
else
{
if
(
View
.
GONE
==
mProgressBar
.
getVisibility
())
{
if
(
View
.
GONE
==
mProgressBar
.
getVisibility
())
{
...
@@ -105,7 +103,7 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
...
@@ -105,7 +103,7 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
Intent
i
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
Intent
i
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
i
.
addCategory
(
Intent
.
CATEGORY_OPENABLE
);
i
.
addCategory
(
Intent
.
CATEGORY_OPENABLE
);
i
.
setType
(
"*/*"
);
i
.
setType
(
"*/*"
);
startActivityForResult
(
Intent
.
createChooser
(
i
,
"File Browser"
),
FILECHOOSER_RESULTCODE
);
startActivityForResult
(
Intent
.
createChooser
(
i
,
"File Browser"
),
FILECHOOSER_RESULTCODE
);
}
}
...
@@ -197,6 +195,7 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
...
@@ -197,6 +195,7 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
}
}
}
}
}
}
@TargetApi
(
Build
.
VERSION_CODES
.
LOLLIPOP
)
@TargetApi
(
Build
.
VERSION_CODES
.
LOLLIPOP
)
private
void
onActivityResultAboveL
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
private
void
onActivityResultAboveL
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
requestCode
!=
FILECHOOSER_RESULTCODE
if
(
requestCode
!=
FILECHOOSER_RESULTCODE
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/X5WebView.java
View file @
bdde3484
...
@@ -31,6 +31,11 @@ public class X5WebView extends WebView {
...
@@ -31,6 +31,11 @@ public class X5WebView extends WebView {
this
.
getView
().
setClickable
(
true
);
this
.
getView
().
setClickable
(
true
);
}
}
public
X5WebView
(
Context
arg0
)
{
super
(
arg0
);
setBackgroundColor
(
85621
);
}
private
void
initWebViewSettings
()
{
private
void
initWebViewSettings
()
{
WebSettings
webSetting
=
this
.
getSettings
();
WebSettings
webSetting
=
this
.
getSettings
();
webSetting
.
setJavaScriptEnabled
(
true
);
webSetting
.
setJavaScriptEnabled
(
true
);
...
@@ -90,10 +95,5 @@ public class X5WebView extends WebView {
...
@@ -90,10 +95,5 @@ public class X5WebView extends WebView {
return
super
.
drawChild
(
canvas
,
child
,
drawingTime
);
return
super
.
drawChild
(
canvas
,
child
,
drawingTime
);
}
}
public
X5WebView
(
Context
arg0
)
{
super
(
arg0
);
setBackgroundColor
(
85621
);
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/ChatMessage.java
View file @
bdde3484
...
@@ -34,7 +34,7 @@ public class ChatMessage {
...
@@ -34,7 +34,7 @@ public class ChatMessage {
}
}
String
names
=
message
.
getFrom
().
toString
();
String
names
=
message
.
getFrom
().
toString
();
String
name
=
names
.
substring
(
names
.
indexOf
(
ServiceManagement
.
GROUP_ADDRESS
)
+
ServiceManagement
.
GROUP_ADDRESS
.
length
()
+
1
,
names
.
length
()
);
String
name
=
names
.
substring
(
names
.
indexOf
(
ServiceManagement
.
GROUP_ADDRESS
)
+
ServiceManagement
.
GROUP_ADDRESS
.
length
()
+
1
);
ChatMessage
cm
=
new
ChatMessage
();
ChatMessage
cm
=
new
ChatMessage
();
cm
.
setName
(
name
);
cm
.
setName
(
name
);
//cm.setTime(ss);
//cm.setTime(ss);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/McchatActivity.java
View file @
bdde3484
...
@@ -21,6 +21,14 @@ import cn.garymb.ygomobile.ui.mycard.mcchat.util.Util;
...
@@ -21,6 +21,14 @@ import cn.garymb.ygomobile.ui.mycard.mcchat.util.Util;
public
class
McchatActivity
extends
Activity
implements
ChatListener
{
public
class
McchatActivity
extends
Activity
implements
ChatListener
{
private
EditText
main_send_message
;
private
ImageButton
main_send
;
private
RecyclerView
main_rec
;
private
TextView
main_title
;
private
LinearLayout
main_bottom_bar
;
private
ChatAdapter
cadp
;
private
ServiceManagement
su
;
@Override
@Override
public
void
reLogin
(
boolean
state
)
{
public
void
reLogin
(
boolean
state
)
{
main_bottom_bar
.
setVisibility
(
View
.
GONE
);
main_bottom_bar
.
setVisibility
(
View
.
GONE
);
...
@@ -44,7 +52,6 @@ public class McchatActivity extends Activity implements ChatListener {
...
@@ -44,7 +52,6 @@ public class McchatActivity extends Activity implements ChatListener {
// TODO: Implement this method
// TODO: Implement this method
}
}
@Override
@Override
public
void
addMessage
(
Message
message
)
{
public
void
addMessage
(
Message
message
)
{
cadp
.
sx
();
cadp
.
sx
();
...
@@ -58,17 +65,6 @@ public class McchatActivity extends Activity implements ChatListener {
...
@@ -58,17 +65,6 @@ public class McchatActivity extends Activity implements ChatListener {
// TODO: Implement this method
// TODO: Implement this method
}
}
private
EditText
main_send_message
;
private
ImageButton
main_send
;
private
RecyclerView
main_rec
;
private
TextView
main_title
;
private
LinearLayout
main_bottom_bar
;
private
ChatAdapter
cadp
;
private
ServiceManagement
su
;
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
...
@@ -79,11 +75,11 @@ public class McchatActivity extends Activity implements ChatListener {
...
@@ -79,11 +75,11 @@ public class McchatActivity extends Activity implements ChatListener {
private
void
initView
()
{
private
void
initView
()
{
main_rec
=
(
RecyclerView
)
findViewById
(
R
.
id
.
main_rec
);
main_rec
=
findViewById
(
R
.
id
.
main_rec
);
main_send
=
(
ImageButton
)
findViewById
(
R
.
id
.
main_send
);
main_send
=
findViewById
(
R
.
id
.
main_send
);
main_send_message
=
(
EditText
)
findViewById
(
R
.
id
.
main_send_message
);
main_send_message
=
findViewById
(
R
.
id
.
main_send_message
);
main_title
=
(
TextView
)
findViewById
(
R
.
id
.
main_title
);
main_title
=
findViewById
(
R
.
id
.
main_title
);
main_bottom_bar
=
(
LinearLayout
)
findViewById
(
R
.
id
.
main_bottom_bar
);
main_bottom_bar
=
findViewById
(
R
.
id
.
main_bottom_bar
);
su
=
ServiceManagement
.
getDx
();
su
=
ServiceManagement
.
getDx
();
cadp
=
new
ChatAdapter
(
this
,
su
.
getData
());
cadp
=
new
ChatAdapter
(
this
,
su
.
getData
());
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/SplashActivity.java
View file @
bdde3484
...
@@ -25,6 +25,48 @@ public class SplashActivity extends Activity {
...
@@ -25,6 +25,48 @@ public class SplashActivity extends Activity {
ProgressBar
sp_jz
;
ProgressBar
sp_jz
;
TextView
sp_tv
;
TextView
sp_tv
;
LinearLayout
sp_li
;
LinearLayout
sp_li
;
Handler
han
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
// TODO: Implement this method
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
0
:
su
.
setIsConnected
(
false
);
sp_jz
.
setVisibility
(
View
.
GONE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_failed
));
Util
.
show
(
SplashActivity
.
this
,
getString
(
R
.
string
.
failed_reason
)
+
msg
.
obj
);
break
;
case
1
:
startActivity
(
new
Intent
(
SplashActivity
.
this
,
McchatActivity
.
class
));
finish
();
break
;
case
2
:
su
.
setIsListener
(
false
);
sp_jz
.
setVisibility
(
View
.
GONE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_failed
));
break
;
case
3
:
sp_jz
.
setVisibility
(
View
.
VISIBLE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_in
));
break
;
case
4
:
sp_jz
.
setVisibility
(
View
.
VISIBLE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_in
));
break
;
case
5
:
/*sp_jz.setVisibility(View.GONE);
sp_tv.setText("用户名或密码为空");*/
startActivity
(
new
Intent
(
SplashActivity
.
this
,
MyCardActivity
.
class
));
finish
();
break
;
}
}
};
@Override
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
@@ -102,6 +144,7 @@ public class SplashActivity extends Activity {
...
@@ -102,6 +144,7 @@ public class SplashActivity extends Activity {
try
{
try
{
su
.
login
(
name
,
password
);
su
.
login
(
name
,
password
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Log
.
e
(
"登录失败"
,
"登录失败"
+
e
);
Message
me
=
new
Message
();
Message
me
=
new
Message
();
me
.
obj
=
e
;
me
.
obj
=
e
;
me
.
what
=
0
;
me
.
what
=
0
;
...
@@ -113,47 +156,4 @@ public class SplashActivity extends Activity {
...
@@ -113,47 +156,4 @@ public class SplashActivity extends Activity {
// TODO: Implement this method
// TODO: Implement this method
}
}
Handler
han
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
// TODO: Implement this method
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
0
:
su
.
setIsConnected
(
false
);
sp_jz
.
setVisibility
(
View
.
GONE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_failed
));
Util
.
show
(
SplashActivity
.
this
,
getString
(
R
.
string
.
failed_reason
)
+
msg
.
obj
);
break
;
case
1
:
startActivity
(
new
Intent
(
SplashActivity
.
this
,
McchatActivity
.
class
));
finish
();
break
;
case
2
:
su
.
setIsListener
(
false
);
sp_jz
.
setVisibility
(
View
.
GONE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_failed
));
break
;
case
3
:
sp_jz
.
setVisibility
(
View
.
VISIBLE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_in
));
break
;
case
4
:
sp_jz
.
setVisibility
(
View
.
VISIBLE
);
sp_tv
.
setText
(
getString
(
R
.
string
.
logining_in
));
break
;
case
5
:
/*sp_jz.setVisibility(View.GONE);
sp_tv.setText("用户名或密码为空");*/
startActivity
(
new
Intent
(
SplashActivity
.
this
,
MyCardActivity
.
class
));
finish
();
break
;
}
}
};
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/adapter/ChatAdapter.java
View file @
bdde3484
...
@@ -22,12 +22,16 @@ import cn.garymb.ygomobile.ui.mycard.mcchat.util.Util;
...
@@ -22,12 +22,16 @@ import cn.garymb.ygomobile.ui.mycard.mcchat.util.Util;
public
class
ChatAdapter
extends
RecyclerView
.
Adapter
<
ChatAdapter
.
ViewHolder
>
{
public
class
ChatAdapter
extends
RecyclerView
.
Adapter
<
ChatAdapter
.
ViewHolder
>
{
private
static
final
int
CHAT
=
0
;
private
static
final
int
CHAT_ME
=
1
;
private
List
<
ChatMessage
>
data
;
private
List
<
ChatMessage
>
data
;
private
Context
context
;
private
Context
context
;
private
static
final
int
CHAT
=
0
;
private
static
final
int
CHAT_ME
=
1
;
public
ChatAdapter
(
Context
context
,
List
<
ChatMessage
>
data
)
{
this
.
context
=
context
;
this
.
data
=
data
;
}
@Override
@Override
public
ViewHolder
onCreateViewHolder
(
ViewGroup
p1
,
int
p2
)
{
public
ViewHolder
onCreateViewHolder
(
ViewGroup
p1
,
int
p2
)
{
...
@@ -55,7 +59,6 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
...
@@ -55,7 +59,6 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
}
}
}
}
@Override
@Override
public
void
onBindViewHolder
(
ViewHolder
vh
,
int
position
)
{
public
void
onBindViewHolder
(
ViewHolder
vh
,
int
position
)
{
final
ChatMessage
cm
=
data
.
get
(
position
);
final
ChatMessage
cm
=
data
.
get
(
position
);
...
@@ -104,10 +107,10 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
...
@@ -104,10 +107,10 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
return
data
.
size
();
return
data
.
size
();
}
}
public
void
sx
()
{
notifyDataSetChanged
();
public
ChatAdapter
(
Context
context
,
List
<
ChatMessage
>
data
)
{
this
.
context
=
context
;
this
.
data
=
data
;
}
}
class
ViewHolder
extends
RecyclerView
.
ViewHolder
{
class
ViewHolder
extends
RecyclerView
.
ViewHolder
{
...
@@ -121,25 +124,19 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
...
@@ -121,25 +124,19 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
super
(
v
);
super
(
v
);
vh
=
v
;
vh
=
v
;
if
(
position
==
CHAT
)
{
if
(
position
==
CHAT
)
{
ic_dialog
=
(
LinearLayout
)
v
.
findViewById
(
R
.
id
.
ic_dialog
);
ic_dialog
=
v
.
findViewById
(
R
.
id
.
ic_dialog
);
ic_name
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
ic_name
);
ic_name
=
v
.
findViewById
(
R
.
id
.
ic_name
);
ic_avatar
=
(
ImageView
)
v
.
findViewById
(
R
.
id
.
ic_avatar
);
ic_avatar
=
v
.
findViewById
(
R
.
id
.
ic_avatar
);
ic_message
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
ic_message
);
ic_message
=
v
.
findViewById
(
R
.
id
.
ic_message
);
}
else
{
}
else
{
ic_name
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
icm_name
);
ic_name
=
v
.
findViewById
(
R
.
id
.
icm_name
);
ic_avatar
=
(
ImageView
)
v
.
findViewById
(
R
.
id
.
icm_avatar
);
ic_avatar
=
v
.
findViewById
(
R
.
id
.
icm_avatar
);
ic_message
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
icm_message
);
ic_message
=
v
.
findViewById
(
R
.
id
.
icm_message
);
ic_dialog
=
(
LinearLayout
)
v
.
findViewById
(
R
.
id
.
icm_dialog
);
ic_dialog
=
v
.
findViewById
(
R
.
id
.
icm_dialog
);
}
}
}
}
}
}
public
void
sx
()
{
notifyDataSetChanged
();
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/management/ServiceManagement.java
View file @
bdde3484
...
@@ -35,11 +35,54 @@ public class ServiceManagement {
...
@@ -35,11 +35,54 @@ public class ServiceManagement {
private
boolean
isListener
=
false
;
private
boolean
isListener
=
false
;
private
List
<
ChatMessage
>
data
=
new
ArrayList
<
ChatMessage
>();
private
List
<
ChatMessage
>
data
=
new
ArrayList
<
ChatMessage
>();
private
List
<
ChatListener
>
cl
=
new
ArrayList
<
ChatListener
>();
private
List
<
ChatListener
>
cl
=
new
ArrayList
<
ChatListener
>();
Handler
han
=
new
Handler
()
{
@Override
public
void
handleMessage
(
android
.
os
.
Message
msg
)
{
// TODO: Implement this method
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
0
:
for
(
ChatListener
c
:
cl
)
{
if
(
c
!=
null
)
{
c
.
addMessage
((
Message
)
msg
.
obj
);
}
else
{
cl
.
remove
(
c
);
}
}
break
;
case
1
:
for
(
ChatListener
c
:
cl
)
{
if
(
c
!=
null
)
{
c
.
reLogin
((
boolean
)
msg
.
obj
);
}
else
{
cl
.
remove
(
c
);
}
}
break
;
case
2
:
for
(
ChatListener
c
:
cl
)
{
if
(
c
!=
null
)
{
c
.
reJoin
((
boolean
)
msg
.
obj
);
}
else
{
cl
.
remove
(
c
);
}
}
break
;
}
}
};
private
ServiceManagement
()
{
private
ServiceManagement
()
{
}
}
public
static
ServiceManagement
getDx
()
{
return
su
;
}
public
void
addListener
(
ChatListener
c
)
{
public
void
addListener
(
ChatListener
c
)
{
cl
.
add
(
c
);
cl
.
add
(
c
);
}
}
...
@@ -64,7 +107,6 @@ public class ServiceManagement {
...
@@ -64,7 +107,6 @@ public class ServiceManagement {
return
isConnected
;
return
isConnected
;
}
}
public
XMPPTCPConnection
getCon
()
{
public
XMPPTCPConnection
getCon
()
{
return
con
;
return
con
;
}
}
...
@@ -81,7 +123,6 @@ public class ServiceManagement {
...
@@ -81,7 +123,6 @@ public class ServiceManagement {
return
con
;
return
con
;
}
}
public
boolean
login
(
String
name
,
String
password
)
throws
IOException
,
SmackException
,
XMPPException
,
InterruptedException
{
public
boolean
login
(
String
name
,
String
password
)
throws
IOException
,
SmackException
,
XMPPException
,
InterruptedException
{
XMPPTCPConnection
con
=
getConnextion
(
name
,
password
);
XMPPTCPConnection
con
=
getConnextion
(
name
,
password
);
...
@@ -123,47 +164,6 @@ public class ServiceManagement {
...
@@ -123,47 +164,6 @@ public class ServiceManagement {
}
}
}
}
Handler
han
=
new
Handler
()
{
@Override
public
void
handleMessage
(
android
.
os
.
Message
msg
)
{
// TODO: Implement this method
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
0
:
for
(
ChatListener
c
:
cl
)
{
if
(
c
!=
null
)
{
c
.
addMessage
((
Message
)
msg
.
obj
);
}
else
{
cl
.
remove
(
c
);
}
}
break
;
case
1
:
for
(
ChatListener
c
:
cl
)
{
if
(
c
!=
null
)
{
c
.
reLogin
((
boolean
)
msg
.
obj
);
}
else
{
cl
.
remove
(
c
);
}
}
break
;
case
2
:
for
(
ChatListener
c
:
cl
)
{
if
(
c
!=
null
)
{
c
.
reJoin
((
boolean
)
msg
.
obj
);
}
else
{
cl
.
remove
(
c
);
}
}
break
;
}
}
};
public
void
setreLogin
(
boolean
state
)
{
public
void
setreLogin
(
boolean
state
)
{
android
.
os
.
Message
me
=
new
android
.
os
.
Message
();
android
.
os
.
Message
me
=
new
android
.
os
.
Message
();
me
.
what
=
1
;
me
.
what
=
1
;
...
@@ -178,10 +178,6 @@ public class ServiceManagement {
...
@@ -178,10 +178,6 @@ public class ServiceManagement {
han
.
sendMessage
(
me
);
han
.
sendMessage
(
me
);
}
}
public
static
ServiceManagement
getDx
()
{
return
su
;
}
public
void
disSerVice
()
{
public
void
disSerVice
()
{
con
.
disconnect
();
con
.
disconnect
();
setIsConnected
(
false
);
setIsConnected
(
false
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/management/UserManagement.java
View file @
bdde3484
...
@@ -14,16 +14,16 @@ public class UserManagement {
...
@@ -14,16 +14,16 @@ public class UserManagement {
return
userName
;
return
userName
;
}
}
public
static
String
getUserPassword
()
{
return
userPassword
;
}
public
static
void
setUserName
(
String
name
)
{
public
static
void
setUserName
(
String
name
)
{
userName
=
name
;
userName
=
name
;
}
}
public
static
String
getUserPassword
()
{
return
userPassword
;
}
public
static
void
setUserPassword
(
String
password
)
{
public
static
void
setUserPassword
(
String
password
)
{
userPassword
=
password
;
userPassword
=
password
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/util/ImageUtil.java
View file @
bdde3484
...
@@ -9,17 +9,16 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
...
@@ -9,17 +9,16 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
public
class
ImageUtil
public
class
ImageUtil
{
{
public
static
void
tuxian
(
Context
context
,
String
url
,
final
ImageView
im
)
{
public
static
void
tuxian
(
Context
context
,
String
url
,
final
ImageView
im
){
if
(
url
!=
null
)
{
if
(
url
!=
null
){
Glide
.
with
(
context
)
Glide
.
with
(
context
)
.
load
(
Uri
.
parse
(
url
))
.
load
(
Uri
.
parse
(
url
))
.
asBitmap
()
.
asBitmap
()
.
diskCacheStrategy
(
DiskCacheStrategy
.
SOURCE
)
.
diskCacheStrategy
(
DiskCacheStrategy
.
SOURCE
)
.
placeholder
(
R
.
drawable
.
avatar
)
.
placeholder
(
R
.
drawable
.
avatar
)
.
into
(
im
);
.
into
(
im
);
}
}
}
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/util/TaxiConnectionListener.java
View file @
bdde3484
...
@@ -18,6 +18,12 @@ import cn.garymb.ygomobile.ui.mycard.mcchat.management.UserManagement;
...
@@ -18,6 +18,12 @@ import cn.garymb.ygomobile.ui.mycard.mcchat.management.UserManagement;
public
class
TaxiConnectionListener
implements
ConnectionListener
{
public
class
TaxiConnectionListener
implements
ConnectionListener
{
private
Timer
tExit
;
private
String
username
;
private
String
password
;
private
int
logintime
=
2000
;
private
ServiceManagement
sm
=
ServiceManagement
.
getDx
();
@Override
@Override
public
void
connected
(
XMPPConnection
p1
)
{
public
void
connected
(
XMPPConnection
p1
)
{
Log
.
e
(
"TaxiConnectionListener"
,
"开始连接"
);
Log
.
e
(
"TaxiConnectionListener"
,
"开始连接"
);
...
@@ -53,12 +59,6 @@ public class TaxiConnectionListener implements ConnectionListener {
...
@@ -53,12 +59,6 @@ public class TaxiConnectionListener implements ConnectionListener {
// TODO: Implement this method
// TODO: Implement this method
}
}
private
Timer
tExit
;
private
String
username
;
private
String
password
;
private
int
logintime
=
2000
;
private
ServiceManagement
sm
=
ServiceManagement
.
getDx
();
@Override
@Override
public
void
connectionClosed
()
{
public
void
connectionClosed
()
{
//正常关闭连接
//正常关闭连接
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/util/Util.java
View file @
bdde3484
...
@@ -29,12 +29,12 @@ public class Util {
...
@@ -29,12 +29,12 @@ public class Util {
//复制字符串到剪贴板
//复制字符串到剪贴板
public
static
void
fzMessage
(
Context
context
,
String
message
)
{
public
static
void
fzMessage
(
Context
context
,
String
message
)
{
ClipboardManager
cmb
=
(
ClipboardManager
)
context
.
getSystemService
(
c
ontext
.
CLIPBOARD_SERVICE
);
ClipboardManager
cmb
=
(
ClipboardManager
)
context
.
getSystemService
(
C
ontext
.
CLIPBOARD_SERVICE
);
cmb
.
setText
(
message
);
//复制命令
cmb
.
setText
(
message
);
//复制命令
}
}
public
static
void
startDuelService
(
Context
context
){
public
static
void
startDuelService
(
Context
context
)
{
if
(
AppsSettings
.
get
().
isServiceDuelAssistant
())
{
if
(
AppsSettings
.
get
().
isServiceDuelAssistant
())
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
DialogPlus
dialogPlus
=
PermissionUtil
.
isNotificationPermission
(
context
);
DialogPlus
dialogPlus
=
PermissionUtil
.
isNotificationPermission
(
context
);
if
(
dialogPlus
==
null
)
if
(
dialogPlus
==
null
)
...
...
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