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
f496a915
Commit
f496a915
authored
May 15, 2018
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove chat room
parent
0b010d98
Changes
25
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
357 additions
and
1329 deletions
+357
-1329
LICENSE
LICENSE
+339
-0
README.md
README.md
+2
-0
build.gradle
build.gradle
+1
-0
mobile/build.gradle
mobile/build.gradle
+3
-3
mobile/src/main/res/layout/activity_splash.xml
mobile/src/main/res/layout/activity_splash.xml
+0
-23
mobile/src/main/res/layout/item_chat.xml
mobile/src/main/res/layout/item_chat.xml
+0
-51
mobile/src/main/res/layout/item_chat_me.xml
mobile/src/main/res/layout/item_chat_me.xml
+0
-51
mobile/src/main/res/layout/main.xml
mobile/src/main/res/layout/main.xml
+0
-75
mobile/src/main/res/menu/nav_mycard_menu.xml
mobile/src/main/res/menu/nav_mycard_menu.xml
+2
-2
mobile/src/main/res/values-ko/strings.xml
mobile/src/main/res/values-ko/strings.xml
+2
-0
mobile/src/mycard/AndroidManifest.xml
mobile/src/mycard/AndroidManifest.xml
+2
-2
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/MyCard.java
...src/mycard/java/cn/garymb/ygomobile/ui/online/MyCard.java
+3
-3
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/MyCardActivity.java
...rd/java/cn/garymb/ygomobile/ui/online/MyCardActivity.java
+3
-3
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/ChatApplication.java
...cn/garymb/ygomobile/ui/online/mcchat/ChatApplication.java
+0
-22
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/ChatListener.java
...va/cn/garymb/ygomobile/ui/online/mcchat/ChatListener.java
+0
-11
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/ChatMessage.java
...ava/cn/garymb/ygomobile/ui/online/mcchat/ChatMessage.java
+0
-84
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/McchatActivity.java
.../cn/garymb/ygomobile/ui/online/mcchat/McchatActivity.java
+0
-142
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/SplashActivity.java
.../cn/garymb/ygomobile/ui/online/mcchat/SplashActivity.java
+0
-167
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/adapter/ChatAdapter.java
...arymb/ygomobile/ui/online/mcchat/adapter/ChatAdapter.java
+0
-139
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/management/ServiceManagement.java
...mobile/ui/online/mcchat/management/ServiceManagement.java
+0
-197
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/management/UserManagement.java
...ygomobile/ui/online/mcchat/management/UserManagement.java
+0
-36
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/util/ImageUtil.java
.../cn/garymb/ygomobile/ui/online/mcchat/util/ImageUtil.java
+0
-23
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/util/TaxiConnectionListener.java
...omobile/ui/online/mcchat/util/TaxiConnectionListener.java
+0
-140
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/util/Util.java
.../java/cn/garymb/ygomobile/ui/online/mcchat/util/Util.java
+0
-31
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/view/YuanImage.java
.../cn/garymb/ygomobile/ui/online/mcchat/view/YuanImage.java
+0
-124
No files found.
LICENSE
0 → 100644
View file @
f496a915
This diff is collapsed.
Click to expand it.
README.md
View file @
f496a915
# License
GPL
# YGOMobile
# YGOMobile
Android编译环境
Android编译环境
---------------------
---------------------
...
...
build.gradle
View file @
f496a915
...
@@ -21,6 +21,7 @@ ext {
...
@@ -21,6 +21,7 @@ ext {
allprojects
{
allprojects
{
repositories
{
repositories
{
jcenter
()
jcenter
()
google
()
maven
{
url
"https://jitpack.io"
}
maven
{
url
"https://jitpack.io"
}
}
}
}
}
...
...
mobile/build.gradle
View file @
f496a915
...
@@ -79,7 +79,7 @@ dependencies {
...
@@ -79,7 +79,7 @@ dependencies {
implementation
'com.tubb.smrv:swipemenu-recyclerview:5.4.0'
implementation
'com.tubb.smrv:swipemenu-recyclerview:5.4.0'
//
//
mycardImplementation
(
name:
'xwalk_core_library-22.52.561.4'
,
ext:
'aar'
)
mycardImplementation
(
name:
'xwalk_core_library-22.52.561.4'
,
ext:
'aar'
)
implementation
'org.igniterealtime.smack:smack-android-extensions:4.2.0'
/*
implementation 'org.igniterealtime.smack:smack-android-extensions:4.2.0'
implementation 'org.igniterealtime.smack:smack-tcp:4.2.0'
implementation 'org.igniterealtime.smack:smack-tcp:4.2.0'
implementation 'org.igniterealtime.smack:smack-android:4.2.0'
implementation 'org.igniterealtime.smack:smack-android:4.2.0'
implementation 'org.igniterealtime.smack:smack-core:4.2.0'
implementation 'org.igniterealtime.smack:smack-core:4.2.0'
...
@@ -87,7 +87,7 @@ dependencies {
...
@@ -87,7 +87,7 @@ dependencies {
implementation 'org.igniterealtime.smack:smack-im:4.2.0'
implementation 'org.igniterealtime.smack:smack-im:4.2.0'
implementation 'org.igniterealtime.smack:smack-resolver-minidns:4.2.0'
implementation 'org.igniterealtime.smack:smack-resolver-minidns:4.2.0'
implementation 'org.igniterealtime.smack:smack-sasl-provided:4.2.0'
implementation 'org.igniterealtime.smack:smack-sasl-provided:4.2.0'
implementation
'xpp3:xpp3:1.1.4c'
//
implementation 'xpp3:xpp3:1.1.4c'
implementation 'org.jxmpp:jxmpp-core:0.5.0'
implementation 'org.jxmpp:jxmpp-core:0.5.0'
implementation 'org.jxmpp:jxmpp-jid:0.5.0'
implementation 'org.jxmpp:jxmpp-jid:0.5.0'
implementation 'org.jxmpp:jxmpp-util-cache:0.5.0'
implementation 'org.jxmpp:jxmpp-util-cache:0.5.0'
...
@@ -97,7 +97,7 @@ dependencies {
...
@@ -97,7 +97,7 @@ dependencies {
implementation 'de.measite.minidns:minidns-dnssec:0.2.4'
implementation 'de.measite.minidns:minidns-dnssec:0.2.4'
implementation 'de.measite.minidns:minidns-iterative-resolver:0.2.4'
implementation 'de.measite.minidns:minidns-iterative-resolver:0.2.4'
implementation
'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
*/
//
//
implementation
'com.nightonke:boommenu:2.1.0'
implementation
'com.nightonke:boommenu:2.1.0'
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
...
...
mobile/src/main/res/layout/activity_splash.xml
deleted
100644 → 0
View file @
0b010d98
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"fill_parent"
android:layout_height=
"fill_parent"
android:orientation=
"horizontal"
android:gravity=
"center"
android:id=
"@+id/sp_li"
>
<ProgressBar
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:id=
"@+id/sp_jz"
/>
<TextView
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:text=
"登录中,请稍等"
android:textSize=
"18sp"
android:id=
"@+id/sp_tv"
/>
</LinearLayout>
mobile/src/main/res/layout/item_chat.xml
deleted
100644 → 0
View file @
0b010d98
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"#00000000"
>
<com.mcchat.feihua.view.YuanImage
android:layout_height=
"35dp"
android:layout_width=
"35dp"
android:id=
"@+id/ic_avatar"
android:scaleType=
"centerCrop"
android:layout_marginTop=
"5dp"
android:layout_marginLeft=
"10dp"
/>
<LinearLayout
android:layout_alignTop=
"@id/ic_avatar"
android:layout_toRightOf=
"@id/ic_avatar"
android:descendantFocusability=
"blocksDescendants"
android:padding=
"8dp"
android:background=
"@drawable/chat_message_background"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
android:id=
"@+id/ic_dialog"
android:layout_marginRight=
"10dp"
android:layout_marginBottom=
"5dp"
android:layout_marginLeft=
"10dp"
>
<TextView
android:id=
"@+id/ic_name"
android:text=
"name"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:paddingBottom=
"4dp"
android:textSize=
"13sp"
android:textColor=
"#B8630C"
android:textStyle=
"bold"
/>
<TextView
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:text=
"message"
android:textColor=
"#000000"
android:id=
"@+id/ic_message"
android:textSize=
"16sp"
/>
</LinearLayout>
</RelativeLayout>
mobile/src/main/res/layout/item_chat_me.xml
deleted
100644 → 0
View file @
0b010d98
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:background=
"#00000000"
>
<com.mcchat.feihua.view.YuanImage
android:id=
"@+id/icm_avatar"
android:layout_width=
"35dp"
android:layout_height=
"35dp"
android:layout_alignParentRight=
"true"
android:layout_marginRight=
"10dp"
android:layout_marginTop=
"5dp"
android:scaleType=
"centerCrop"
/>
<LinearLayout
android:id=
"@+id/icm_dialog"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignTop=
"@id/icm_avatar"
android:layout_marginBottom=
"5dp"
android:layout_marginLeft=
"10dp"
android:layout_marginRight=
"10dp"
android:layout_toLeftOf=
"@id/icm_avatar"
android:background=
"@drawable/chat_message_me_background"
android:descendantFocusability=
"blocksDescendants"
android:orientation=
"vertical"
android:padding=
"8dp"
>
<TextView
android:id=
"@+id/icm_name"
android:layout_width=
"0px"
android:layout_height=
"0px"
android:paddingBottom=
"4dp"
android:text=
"name"
android:textColor=
"#B8630C"
android:textSize=
"13sp"
android:textStyle=
"bold"
/>
<TextView
android:id=
"@+id/icm_message"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"message"
android:textColor=
"#000000"
android:textSize=
"16sp"
/>
</LinearLayout>
</RelativeLayout>
mobile/src/main/res/layout/main.xml
deleted
100644 → 0
View file @
0b010d98
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:background=
"@color/background"
android:gravity=
"center"
>
<RelativeLayout
android:background=
"@color/colorMain"
android:layout_height=
"wrap_content"
android:layout_width=
"match_parent"
>
<TextView
android:textColor=
"@color/white"
android:layout_height=
"wrap_content"
android:layout_width=
"wrap_content"
android:text=
"@string/app_name"
android:layout_margin=
"10dp"
android:textSize=
"20sp"
android:id=
"@+id/main_title"
/>
</RelativeLayout>
<android.support.v7.widget.RecyclerView
android:id=
"@+id/main_rec"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_weight=
"1000"
/>
<LinearLayout
android:gravity=
"center"
android:layout_width=
"fill_parent"
android:layout_height=
"wrap_content"
android:background=
"@color/white"
android:orientation=
"horizontal"
android:padding=
"7dp"
android:id=
"@+id/main_bottom_bar"
>
<EditText
android:background=
"@drawable/chat_edittext_background"
android:padding=
"7dp"
android:id=
"@+id/main_send_message"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:textSize=
"15sp"
android:layout_weight=
"10"
android:maxEms=
"3"
/>
<LinearLayout
android:layout_marginLeft=
"7dp"
android:layout_width=
"0dp"
android:layout_height=
"33dp"
android:gravity=
"center"
android:layout_weight=
"2"
android:orientation=
"vertical"
>
<ImageButton
android:background=
"@drawable/chat_message_background"
android:src=
"@drawable/ic_send_black_24dp"
android:id=
"@+id/main_send"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:text=
"@string/send"
android:gravity=
"center"
android:textSize=
"12sp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
mobile/src/main/res/menu/nav_mycard_menu.xml
View file @
f496a915
...
@@ -5,10 +5,10 @@
...
@@ -5,10 +5,10 @@
android:icon=
"@drawable/ic_home"
android:icon=
"@drawable/ic_home"
android:title=
"@string/mc_home"
android:title=
"@string/mc_home"
/>
/>
<item
<
!--
item
android:id="@+id/action_chat"
android:id="@+id/action_chat"
android:icon="?android:attr/textSelectHandleLeft"
android:icon="?android:attr/textSelectHandleLeft"
android:title=
"@string/mc_chat"
/>
android:title="@string/mc_chat" /
--
>
<item
<item
android:id=
"@+id/action_bbs"
android:id=
"@+id/action_bbs"
android:icon=
"@drawable/ic_forum"
android:icon=
"@drawable/ic_forum"
...
...
mobile/src/main/res/values-ko/strings.xml
View file @
f496a915
...
@@ -179,6 +179,8 @@
...
@@ -179,6 +179,8 @@
<string
name=
"mycard"
>
MYcard
</string>
<string
name=
"mycard"
>
MYcard
</string>
<string
name=
"arena"
>
듀얼리스트db
</string>
<string
name=
"arena"
>
듀얼리스트db
</string>
<string
name=
"mc_home"
>
홈화면
</string>
<string
name=
"mc_home"
>
홈화면
</string>
<string
name=
"mc_chat"
>
채팅
</string>
<string
name=
"send"
>
보내기
</string>
<string
name=
"bbs"
>
커뮤니티
</string>
<string
name=
"bbs"
>
커뮤니티
</string>
<string
name=
"settings_pref_settings_only_game"
>
앱 실행시 YGOCORE 바로 실행(설정하지마십시오)
</string>
<string
name=
"settings_pref_settings_only_game"
>
앱 실행시 YGOCORE 바로 실행(설정하지마십시오)
</string>
<string
name=
"only_game_tip"
>
앱의 초기화를 위해 설정을 초기화 해야합니다.
</string>
<string
name=
"only_game_tip"
>
앱의 초기화를 위해 설정을 초기화 해야합니다.
</string>
...
...
mobile/src/mycard/AndroidManifest.xml
View file @
f496a915
...
@@ -10,12 +10,12 @@
...
@@ -10,12 +10,12 @@
android:launchMode=
"singleTop"
android:launchMode=
"singleTop"
android:theme=
"@style/AppTheme.Mycard"
android:theme=
"@style/AppTheme.Mycard"
android:windowSoftInputMode=
"stateAlwaysHidden|adjustResize"
/>
android:windowSoftInputMode=
"stateAlwaysHidden|adjustResize"
/>
<activity
<
!--
activity
android:name="cn.garymb.ygomobile.ui.online.mcchat.McchatActivity"
android:name="cn.garymb.ygomobile.ui.online.mcchat.McchatActivity"
android:windowSoftInputMode="stateHidden|adjustResize"
android:windowSoftInputMode="stateHidden|adjustResize"
android:label="@string/app_name"/>
android:label="@string/app_name"/>
<activity
<activity
android:name=
"cn.garymb.ygomobile.ui.online.mcchat.SplashActivity"
/>
android:name="cn.garymb.ygomobile.ui.online.mcchat.SplashActivity"/
--
>
</application>
</application>
</manifest>
</manifest>
\ No newline at end of file
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/MyCard.java
View file @
f496a915
...
@@ -26,7 +26,7 @@ import cn.garymb.ygomobile.AppsSettings;
...
@@ -26,7 +26,7 @@ import cn.garymb.ygomobile.AppsSettings;
import
cn.garymb.ygomobile.YGOStarter
;
import
cn.garymb.ygomobile.YGOStarter
;
import
cn.garymb.ygomobile.ui.cards.DeckManagerActivity
;
import
cn.garymb.ygomobile.ui.cards.DeckManagerActivity
;
import
cn.garymb.ygomobile.ui.plus.DefWebViewClient
;
import
cn.garymb.ygomobile.ui.plus.DefWebViewClient
;
import
cn.garymb.ygomobile.ui.online.mcchat.management.UserManagement
;
//
import cn.garymb.ygomobile.ui.online.mcchat.management.UserManagement;
import
static
junit
.
framework
.
Assert
.
assertEquals
;
import
static
junit
.
framework
.
Assert
.
assertEquals
;
...
@@ -78,8 +78,8 @@ public class MyCard {
...
@@ -78,8 +78,8 @@ public class MyCard {
mUser
.
avatar_url
=
info
.
getQueryParameter
(
"avatar_url"
);
mUser
.
avatar_url
=
info
.
getQueryParameter
(
"avatar_url"
);
mUser
.
admin
=
info
.
getBooleanQueryParameter
(
"admin"
,
false
);
mUser
.
admin
=
info
.
getBooleanQueryParameter
(
"admin"
,
false
);
mUser
.
moderator
=
info
.
getBooleanQueryParameter
(
"moderator"
,
false
);
mUser
.
moderator
=
info
.
getBooleanQueryParameter
(
"moderator"
,
false
);
UserManagement
.
setUserName
(
mUser
.
username
);
//
UserManagement.setUserName(mUser.username);
UserManagement
.
setUserPassword
(
mUser
.
external_id
+
""
);
//
UserManagement.setUserPassword(mUser.external_id+"");
mUser
.
login
=
true
;
mUser
.
login
=
true
;
if
(
getMyCardListener
()
!=
null
)
{
if
(
getMyCardListener
()
!=
null
)
{
getMyCardListener
().
onLogin
(
mUser
.
name
,
mUser
.
avatar_url
,
null
);
getMyCardListener
().
onLogin
(
mUser
.
name
,
mUser
.
avatar_url
,
null
);
...
...
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/MyCardActivity.java
View file @
f496a915
...
@@ -31,7 +31,7 @@ import cn.garymb.ygomobile.lite.BuildConfig;
...
@@ -31,7 +31,7 @@ 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.online.mcchat.SplashActivity
;
//
import cn.garymb.ygomobile.ui.online.mcchat.SplashActivity;
public
class
MyCardActivity
extends
BaseActivity
implements
MyCard
.
MyCardListener
,
NavigationView
.
OnNavigationItemSelectedListener
{
public
class
MyCardActivity
extends
BaseActivity
implements
MyCard
.
MyCardListener
,
NavigationView
.
OnNavigationItemSelectedListener
{
...
@@ -168,9 +168,9 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
...
@@ -168,9 +168,9 @@ public class MyCardActivity extends BaseActivity implements MyCard.MyCardListene
case
R
.
id
.
action_bbs
:
case
R
.
id
.
action_bbs
:
mWebViewPlus
.
loadUrl
(
mMyCard
.
getBBSUrl
());
mWebViewPlus
.
loadUrl
(
mMyCard
.
getBBSUrl
());
break
;
break
;
case
R
.
id
.
action_chat
:
/*
case R.id.action_chat:
startActivity(new Intent(MyCardActivity.this,SplashActivity.class));
startActivity(new Intent(MyCardActivity.this,SplashActivity.class));
break
;
break;
*/
default
:
default
:
return
false
;
return
false
;
}
}
...
...
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/ChatApplication.java
deleted
100644 → 0
View file @
0b010d98
package
cn.garymb.ygomobile.ui.online.mcchat
;
import
android.app.*
;
import
android.content.*
;
public
class
ChatApplication
extends
Application
{
private
static
Context
context
;
@Override
public
void
onCreate
()
{
// TODO: Implement this method
super
.
onCreate
();
context
=
getApplicationContext
();
}
public
static
Context
getContext
(){
return
context
;
}
}
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/ChatListener.java
deleted
100644 → 0
View file @
0b010d98
package
cn.garymb.ygomobile.ui.online.mcchat
;
import
org.jivesoftware.smack.packet.*
;
public
interface
ChatListener
{
void
addMessage
(
Message
message
);
void
removeMessage
(
Message
message
);
void
reLogin
(
boolean
state
);
void
reJoin
(
boolean
state
);
}
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/ChatMessage.java
deleted
100644 → 0
View file @
0b010d98
package
cn.garymb.ygomobile.ui.online.mcchat
;
import
org.jivesoftware.smack.packet.Message
;
import
cn.garymb.ygomobile.ui.online.mcchat.management.*
;
public
class
ChatMessage
{
private
String
name
;
//private String time;
private
String
message
;
private
String
avatar
;
public
void
setAvatar
(
String
avatar
)
{
this
.
avatar
=
avatar
;
}
public
String
getAvatar
()
{
return
avatar
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
this
.
avatar
=
getAvatarUrl
(
name
);
}
public
String
getName
()
{
return
name
;
}
/*
public void setTime(String time)
{
this.time = time;
}
public String getTime()
{
return time;
}
*/
public
static
ChatMessage
toChatMessage
(
Message
message
){
if
(
message
.
getBody
()!=
null
)
{
String
xs
=
message
.
toXML
().
toString
();
int
cc
=
xs
.
indexOf
(
"stamp='"
);
if
(
cc
!=-
1
){
String
ss
=
xs
.
substring
(
cc
+
7
,
xs
.
indexOf
(
"'"
,
cc
+
7
));
}
else
{
}
String
names
=
message
.
getFrom
().
toString
();
String
name
=
names
.
substring
(
names
.
indexOf
(
ServiceManagement
.
GROUP_ADDRESS
)+
ServiceManagement
.
GROUP_ADDRESS
.
length
()+
1
,
names
.
length
());
ChatMessage
cm
=
new
ChatMessage
();
cm
.
setName
(
name
);
//cm.setTime(ss);
cm
.
setMessage
(
message
.
getBody
());
return
cm
;
}
return
null
;
}
public
String
getAvatarUrl
(
String
userName
){
return
"https://api.moecube.com/accounts/users/"
+
userName
+
".png"
;
}
}
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/McchatActivity.java
deleted
100644 → 0
View file @
0b010d98
package
cn.garymb.ygomobile.ui.online.mcchat
;
import
android.app.*
;
import
android.os.*
;
import
android.util.*
;
import
org.jivesoftware.smack.packet.Message
;
import
android.widget.*
;
import
android.support.v7.widget.*
;
import
android.view.View.*
;
import
android.view.*
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.online.mcchat.adapter.*
;
import
cn.garymb.ygomobile.ui.online.mcchat.util.*
;
import
cn.garymb.ygomobile.ui.online.mcchat.management.*
;
public
class
McchatActivity
extends
Activity
implements
ChatListener
{
@Override
public
void
reLogin
(
boolean
state
)
{
main_bottom_bar
.
setVisibility
(
View
.
GONE
);
if
(
state
){
main_title
.
setText
(
"登录成功"
);
}
else
{
main_title
.
setText
(
"连接断开,重新登录中……"
);
}
// TODO: Implement this method
}
@Override
public
void
reJoin
(
boolean
state
)
{
if
(
state
){
main_bottom_bar
.
setVisibility
(
View
.
VISIBLE
);
main_title
.
setText
(
getResources
().
getString
(
R
.
string
.
app_name
));
}
else
{
main_bottom_bar
.
setVisibility
(
View
.
GONE
);
main_title
.
setText
(
"重新加入聊天室中……"
);
}
// TODO: Implement this method
}
@Override
public
void
addMessage
(
Message
message
)
{
cadp
.
sx
();
main_rec
.
smoothScrollToPosition
(
su
.
getData
().
size
()-
1
);
// TODO: Implement this method
}
@Override
public
void
removeMessage
(
Message
message
)
{
// 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
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
main
);
initView
();
}
private
void
initView
()
{
main_rec
=(
RecyclerView
)
findViewById
(
R
.
id
.
main_rec
);
main_send
=(
ImageButton
)
findViewById
(
R
.
id
.
main_send
);
main_send_message
=(
EditText
)
findViewById
(
R
.
id
.
main_send_message
);
main_title
=(
TextView
)
findViewById
(
R
.
id
.
main_title
);
main_bottom_bar
=(
LinearLayout
)
findViewById
(
R
.
id
.
main_bottom_bar
);
su
=
ServiceManagement
.
getDx
();
cadp
=
new
ChatAdapter
(
this
,
su
.
getData
());
su
.
addListener
(
this
);
LinearLayoutManager
linearLayoutManager
=
new
LinearLayoutManager
(
McchatActivity
.
this
,
LinearLayoutManager
.
VERTICAL
,
false
);
linearLayoutManager
.
setStackFromEnd
(
true
);
//关键 设置此项,当软键盘弹出时,布局会自动顶上去,在结合AndroidManifest.xml设置属性
main_rec
.
setLayoutManager
(
linearLayoutManager
);
main_rec
.
setAdapter
(
cadp
);
initListener
();
// TODO: Implement this method
}
private
void
initListener
()
{
main_send
.
setOnClickListener
(
new
OnClickListener
(){
@Override
public
void
onClick
(
View
p1
)
{
String
message
=
main_send_message
.
getText
().
toString
().
trim
();
if
(
message
.
equals
(
""
)){
Util
.
show
(
"发送内容不能为空"
);
}
else
{
try
{
su
.
sendMessage
(
message
);
main_send_message
.
setText
(
""
);
}
catch
(
Exception
e
){
Util
.
show
(
"发送失败"
);
Log
.
e
(
"错误"
,
"错误为"
+
e
);
}
}
// TODO: Implement this method
}
});
// TODO: Implement this method
}
@Override
protected
void
onDestroy
()
{
// TODO: Implement this method
super
.
onDestroy
();
su
.
disClass
();
UserManagement
.
setUserName
(
null
);
UserManagement
.
setUserPassword
(
null
);
finish
();
}
}
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/SplashActivity.java
deleted
100644 → 0
View file @
0b010d98
package
cn.garymb.ygomobile.ui.online.mcchat
;
import
android.app.*
;
import
android.os.*
;
import
android.content.*
;
import
android.util.*
;
import
android.widget.*
;
import
android.view.*
;
import
android.view.View.*
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.online.MyCardActivity
;
import
cn.garymb.ygomobile.ui.online.mcchat.util.*
;
import
cn.garymb.ygomobile.ui.online.mcchat.management.*
;
public
class
SplashActivity
extends
Activity
{
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("MyCardUser", Context.MODE_PRIVATE);
UserManagement.setUserName(lastModified.getString("name",null));
UserManagement.setUserPassword(lastModified.getString("id",null));
*/
su
=
ServiceManagement
.
getDx
();
join
();
}
private
void
join
()
{
if
(!
su
.
isListener
())
{
new
Thread
(
new
Runnable
(){
@Override
public
void
run
()
{
if
(!
su
.
isConnected
()){
han
.
sendEmptyMessage
(
4
);
login
();
}
if
(
su
.
isConnected
()){
han
.
sendEmptyMessage
(
3
);
try
{
su
.
joinChat
();
han
.
sendEmptyMessage
(
1
);
}
catch
(
Exception
e
)
{
han
.
sendEmptyMessage
(
2
);
}
}
// TODO: Implement this method
}
}).
start
();
}
else
{
han
.
sendEmptyMessage
(
1
);
}
// TODO: Implement this method
}
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
(
new
OnClickListener
(){
@Override
public
void
onClick
(
View
p1
)
{
join
();
// TODO: Implement this method
}
});
// TODO: Implement this method
}
private
void
login
()
{
String
name
=
UserManagement
.
getUserName
();
String
password
=
UserManagement
.
getUserPassword
();
if
(
name
!=
null
&&
password
!=
null
)
{
try
{
su
.
login
(
name
,
password
);
}
catch
(
Exception
e
){
Log
.
e
(
"登录失败"
,
"登录失败"
+
e
);
Message
me
=
new
Message
();
me
.
obj
=
e
;
me
.
what
=
0
;
han
.
sendMessage
(
me
);
}
}
else
{
han
.
sendEmptyMessage
(
5
);
}
// 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
(
"登录失败,点击重新登录"
);
Util
.
show
(
"登录失败,原因为"
+
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
(
"加入聊天室失败,点击重新加入"
);
break
;
case
3
:
sp_jz
.
setVisibility
(
View
.
VISIBLE
);
sp_tv
.
setText
(
"正在加入聊天室,请稍等"
);
break
;
case
4
:
sp_jz
.
setVisibility
(
View
.
VISIBLE
);
sp_tv
.
setText
(
"登录中,请稍等"
);
break
;
case
5
:
/*sp_jz.setVisibility(View.GONE);
sp_tv.setText("用户名或密码为空");*/
startActivity
(
new
Intent
(
SplashActivity
.
this
,
MyCardActivity
.
class
));
finish
();
break
;
}
}
};
}
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/adapter/ChatAdapter.java
deleted
100644 → 0
View file @
0b010d98
package
cn.garymb.ygomobile.ui.online.mcchat.adapter
;
import
android.content.*
;
import
android.support.v7.widget.*
;
import
android.view.*
;
import
android.widget.*
;
import
android.view.View.*
;
import
java.util.*
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.online.mcchat.*
;
import
cn.garymb.ygomobile.ui.online.mcchat.util.*
;
import
cn.garymb.ygomobile.ui.online.mcchat.management.*
;
import
android.app.*
;
public
class
ChatAdapter
extends
RecyclerView
.
Adapter
<
ChatAdapter
.
ViewHolder
>
{
private
List
<
ChatMessage
>
data
;
private
Context
context
;
private
static
final
int
CHAT
=
0
;
private
static
final
int
CHAT_ME
=
1
;
@Override
public
ChatAdapter
.
ViewHolder
onCreateViewHolder
(
ViewGroup
p1
,
int
p2
)
{
View
v
=
null
;
switch
(
p2
)
{
case
CHAT:
v
=
LayoutInflater
.
from
(
p1
.
getContext
()).
inflate
(
R
.
layout
.
item_chat
,
p1
,
false
);
break
;
case
CHAT_ME:
v
=
LayoutInflater
.
from
(
p1
.
getContext
()).
inflate
(
R
.
layout
.
item_chat_me
,
p1
,
false
);
break
;
}
ViewHolder
viewHolder
=
new
ViewHolder
(
v
,
p2
);
// TODO: Implement this method
return
viewHolder
;
}
@Override
public
int
getItemViewType
(
int
position
)
{
if
(
data
.
get
(
position
).
getName
().
equals
(
UserManagement
.
getUserName
()))
{
return
CHAT_ME
;
}
else
{
return
CHAT
;
}
}
@Override
public
void
onBindViewHolder
(
ChatAdapter
.
ViewHolder
vh
,
int
position
)
{
final
ChatMessage
cm
=
data
.
get
(
position
);
vh
.
ic_name
.
setText
(
cm
.
getName
());
//vh.ic_time.setText(cm.getTime());
vh
.
ic_message
.
setText
(
cm
.
getMessage
());
ImageUtil
.
tuxian
(
context
,
cm
.
getAvatar
(),
vh
.
ic_avatar
);
if
(
position
!=
0
)
{
if
(
cm
.
getName
().
equals
(
data
.
get
(
position
-
1
).
getName
()))
{
vh
.
ic_name
.
setVisibility
(
View
.
GONE
);
vh
.
ic_avatar
.
setVisibility
(
View
.
INVISIBLE
);
}
else
{
vh
.
ic_name
.
setVisibility
(
View
.
VISIBLE
);
vh
.
ic_avatar
.
setVisibility
(
View
.
VISIBLE
);
}
}
else
{
vh
.
ic_name
.
setVisibility
(
View
.
VISIBLE
);
vh
.
ic_avatar
.
setVisibility
(
View
.
VISIBLE
);
}
vh
.
ic_dialog
.
setOnLongClickListener
(
new
OnLongClickListener
()
{
@Override
public
boolean
onLongClick
(
View
p1
)
{
Util
.
fzMessage
(
cm
.
getMessage
());
Util
.
show
(
"已复制到剪贴板"
);
// TODO: Implement this method
return
true
;
}
});
vh
.
vh
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
p1
)
{
Util
.
closeKeyboard
((
Activity
)
context
);
// TODO: Implement this method
}
});
// TODO: Implement this method
}
@Override
public
int
getItemCount
()
{
// TODO: Implement this method
return
data
.
size
();
}
public
ChatAdapter
(
Context
context
,
List
<
ChatMessage
>
data
)
{
this
.
context
=
context
;
this
.
data
=
data
;
}
class
ViewHolder
extends
RecyclerView
.
ViewHolder
{
TextView
ic_name
,
ic_message
;
ImageView
ic_avatar
;
LinearLayout
ic_dialog
;
View
vh
;
public
ViewHolder
(
View
v
,
int
position
)
{
super
(
v
);
vh
=
v
;
if
(
position
==
CHAT
)
{
ic_dialog
=
(
LinearLayout
)
v
.
findViewById
(
R
.
id
.
ic_dialog
);
ic_name
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
ic_name
);
ic_avatar
=
(
ImageView
)
v
.
findViewById
(
R
.
id
.
ic_avatar
);
ic_message
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
ic_message
);
}
else
{
ic_name
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
icm_name
);
ic_avatar
=
(
ImageView
)
v
.
findViewById
(
R
.
id
.
icm_avatar
);
ic_message
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
icm_message
);
ic_dialog
=
(
LinearLayout
)
v
.
findViewById
(
R
.
id
.
icm_dialog
);
}
}
}
public
void
sx
()
{
notifyDataSetChanged
();
}
}
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/management/ServiceManagement.java
deleted
100644 → 0
View file @
0b010d98
package
cn.garymb.ygomobile.ui.online.mcchat.management
;
import
android.util.*
;
import
java.util.*
;
import
java.io.*
;
import
org.jivesoftware.smack.*
;
import
org.jivesoftware.smack.packet.*
;
import
org.jivesoftware.smack.tcp.*
;
import
org.jivesoftware.smackx.muc.*
;
import
org.jxmpp.jid.impl.*
;
import
org.jxmpp.jid.parts.*
;
import
org.jxmpp.stringprep.*
;
import
android.os.Handler
;
import
cn.garymb.ygomobile.ui.online.mcchat.util.*
;
import
cn.garymb.ygomobile.ui.online.mcchat.*
;
public
class
ServiceManagement
{
public
static
final
String
GROUP_ADDRESS
=
"ygopro_china_north@conference.mycard.moe"
;
private
static
ServiceManagement
su
=
new
ServiceManagement
();
private
XMPPTCPConnection
con
;
private
MultiUserChat
muc
;
private
boolean
isConnected
=
false
;
private
boolean
isListener
=
false
;
private
List
<
ChatMessage
>
data
=
new
ArrayList
<
ChatMessage
>();
private
List
<
ChatListener
>
cl
=
new
ArrayList
<
ChatListener
>();
private
ServiceManagement
(){
}
public
void
addListener
(
ChatListener
c
){
cl
.
add
(
c
);
}
public
List
<
ChatMessage
>
getData
()
{
return
data
;
}
public
void
setIsListener
(
boolean
isListener
)
{
this
.
isListener
=
isListener
;
}
public
boolean
isListener
()
{
return
isListener
;
}
public
void
setIsConnected
(
boolean
isConnected
)
{
this
.
isConnected
=
isConnected
;
}
public
boolean
isConnected
()
{
return
isConnected
;
}
public
XMPPTCPConnection
getCon
()
{
return
con
;
}
private
XMPPTCPConnection
getConnextion
(
String
name
,
String
password
)
throws
XmppStringprepException
{
XMPPTCPConnectionConfiguration
config
=
XMPPTCPConnectionConfiguration
.
builder
()
.
setUsernameAndPassword
(
name
,
password
)
.
setXmppDomain
(
"mycard.moe"
)
.
setKeystoreType
(
null
)
.
setSecurityMode
(
ConnectionConfiguration
.
SecurityMode
.
disabled
)
.
build
();
con
=
new
XMPPTCPConnection
(
config
);
return
con
;
}
public
boolean
login
(
String
name
,
String
password
)
throws
IOException
,
SmackException
,
XMPPException
,
InterruptedException
{
XMPPTCPConnection
con
=
getConnextion
(
name
,
password
);
con
.
connect
();
if
(
con
.
isConnected
()){
con
.
login
();
con
.
addConnectionListener
(
new
TaxiConnectionListener
());
setIsConnected
(
true
);
return
true
;
}
setIsConnected
(
false
);
return
false
;
}
public
void
sendMessage
(
String
message
)
throws
SmackException
.
NotConnectedException
,
InterruptedException
{
muc
.
sendMessage
(
message
);
}
public
void
joinChat
()
throws
SmackException
.
NoResponseException
,
XMPPException
.
XMPPErrorException
,
MultiUserChatException
.
NotAMucServiceException
,
SmackException
.
NotConnectedException
,
XmppStringprepException
,
MultiUserChatException
.
MucAlreadyJoinedException
,
InterruptedException
{
if
(!
isListener
){
MultiUserChatManager
multiUserChatManager
=
MultiUserChatManager
.
getInstanceFor
(
getCon
());
muc
=
multiUserChatManager
.
getMultiUserChat
(
JidCreate
.
entityBareFrom
(
GROUP_ADDRESS
));
muc
.
createOrJoin
(
Resourcepart
.
from
(
UserManagement
.
getUserName
()));
data
.
clear
();
muc
.
addMessageListener
(
new
MessageListener
()
{
@Override
public
void
processMessage
(
Message
message
)
{
Log
.
e
(
"接收消息"
,
"接收"
+
message
);
ChatMessage
cm
=
ChatMessage
.
toChatMessage
(
message
);
if
(
cm
!=
null
){
data
.
add
(
cm
);
han
.
sendEmptyMessage
(
0
);
}
}
});
setIsListener
(
true
);
}
}
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
){
android
.
os
.
Message
me
=
new
android
.
os
.
Message
();
me
.
what
=
1
;
me
.
obj
=
state
;
han
.
sendMessage
(
me
);
}
public
void
setreJoin
(
boolean
state
){
android
.
os
.
Message
me
=
new
android
.
os
.
Message
();
me
.
what
=
2
;
me
.
obj
=
state
;
han
.
sendMessage
(
me
);
}
public
static
ServiceManagement
getDx
(){
return
su
;
}
public
void
disSerVice
(){
con
.
disconnect
();
setIsConnected
(
false
);
}
public
void
disClass
(){
disSerVice
();
setIsConnected
(
false
);
setIsListener
(
false
);
data
.
clear
();
cl
.
clear
();
}
}
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/management/UserManagement.java
deleted
100644 → 0
View file @
0b010d98
package
cn.garymb.ygomobile.ui.online.mcchat.management
;
public
class
UserManagement
{
private
static
UserManagement
um
=
new
UserManagement
();
private
static
String
userName
,
userPassword
;
private
UserManagement
(){
}
public
static
String
getUserName
(){
return
userName
;
}
public
static
String
getUserPassword
(){
return
userPassword
;
}
public
static
void
setUserName
(
String
name
){
userName
=
name
;
}
public
static
void
setUserPassword
(
String
password
){
userPassword
=
password
;
}
public
static
UserManagement
getDx
(){
return
um
;
}
}
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/util/ImageUtil.java
deleted
100644 → 0
View file @
0b010d98
package
cn.garymb.ygomobile.ui.online.mcchat.util
;
import
android.widget.*
;
import
com.bumptech.glide.*
;
import
android.net.*
;
import
android.content.*
;
import
com.bumptech.glide.load.engine.*
;
import
cn.garymb.ygomobile.lite.R
;
public
class
ImageUtil
{
public
static
void
tuxian
(
Context
context
,
String
url
,
final
ImageView
im
){
if
(
url
!=
null
){
Glide
.
with
(
context
)
.
load
(
Uri
.
parse
(
url
))
.
asBitmap
()
.
diskCacheStrategy
(
DiskCacheStrategy
.
SOURCE
)
.
placeholder
(
R
.
drawable
.
avatar
)
.
into
(
im
);
}
}
}
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/util/TaxiConnectionListener.java
deleted
100644 → 0
View file @
0b010d98
package
cn.garymb.ygomobile.ui.online.mcchat.util
;
/**
* 连接监听类
*
*
*/
import
android.util.*
;
import
cn.garymb.ygomobile.ui.online.mcchat.*
;
import
java.util.*
;
//import org.apache.commons.codec.net.*;
import
org.jivesoftware.smack.*
;
import
cn.garymb.ygomobile.ui.online.mcchat.management.*
;
import
java.io.*
;
import
org.jivesoftware.smack.SmackException.*
;
import
org.jivesoftware.smack.XMPPException.*
;
import
org.jivesoftware.smackx.muc.MultiUserChatException.*
;
import
org.jxmpp.stringprep.*
;
import
android.os.*
;
public
class
TaxiConnectionListener
implements
ConnectionListener
{
@Override
public
void
connected
(
XMPPConnection
p1
)
{
Log
.
e
(
"TaxiConnectionListener"
,
"开始连接"
);
//连接
// TODO: Implement this method
}
@Override
public
void
authenticated
(
XMPPConnection
p1
,
boolean
p2
)
{
Log
.
e
(
"TaxiConnectionListener"
,
"通过身份验证"
);
//通过身份验证
// TODO: Implement this method
}
@Override
public
void
reconnectionSuccessful
()
{
//重新连接成功
Log
.
e
(
"TaxiConnectionListener"
,
"重连成功"
);
// TODO: Implement this method
}
@Override
public
void
reconnectingIn
(
int
p1
)
{
//正在重连
Log
.
e
(
"TaxiConnectionListener"
,
"正在重连"
+
p1
);
// TODO: Implement this method
}
@Override
public
void
reconnectionFailed
(
Exception
p1
)
{
//重新连接失败
Log
.
e
(
"重连失败"
,
"失败"
+
p1
);
// TODO: Implement this method
}
private
Timer
tExit
;
private
String
username
;
private
String
password
;
private
int
logintime
=
2000
;
private
ServiceManagement
sm
=
ServiceManagement
.
getDx
();
@Override
public
void
connectionClosed
()
{
//正常关闭连接
Log
.
e
(
"TaxiConnectionListener"
,
"连接关闭"
);
// 重连服务器
//tExit = new Timer();
//tExit.schedule(new timetask(), logintime);
}
@Override
public
void
connectionClosedOnError
(
Exception
e
)
{
//非正常关闭连接
Log
.
e
(
"TaxiConnectionListener"
,
"连接关闭异常"
+
e
);
sm
.
setIsListener
(
false
);
// 重连服务器
tExit
=
new
Timer
();
tExit
.
schedule
(
new
timetask
(),
logintime
);
}
class
timetask
extends
TimerTask
{
@Override
public
void
run
()
{
username
=
UserManagement
.
getUserName
();
password
=
UserManagement
.
getUserPassword
();
if
(
username
!=
null
&&
password
!=
null
)
{
sm
.
setreLogin
(
false
);
Log
.
e
(
"TaxiConnectionListener"
,
"尝试登录"
);
// 连接服务器
try
{
if
(
sm
.
login
(
username
,
password
))
{
sm
.
setreLogin
(
true
);
Log
.
e
(
"TaxiConnectionListener"
,
"登录成功"
);
tExit
.
schedule
(
new
timeJoin
(),
logintime
);
}
else
{
Log
.
e
(
"TaxiConnectionListener"
,
"重新登录"
);
tExit
.
schedule
(
new
timetask
(),
logintime
);
}
}
catch
(
Exception
e
){
tExit
.
schedule
(
new
timetask
(),
logintime
);
}
}
}
class
timeJoin
extends
TimerTask
{
@Override
public
void
run
()
{
sm
.
setreJoin
(
false
);
Log
.
e
(
"TaxiConnectionListener"
,
"尝试加入房间"
);
try
{
sm
.
joinChat
();
sm
.
setreJoin
(
true
);
Log
.
e
(
"TaxiConnectionListener"
,
"加入房间成功"
);
}
catch
(
Exception
e
){
Log
.
e
(
"TaxiConnectionListener"
,
"重新加入房间"
);
tExit
.
schedule
(
new
timeJoin
(),
logintime
);
}
// TODO: Implement this method
}
}
}
}
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/util/Util.java
deleted
100644 → 0
View file @
0b010d98
package
cn.garymb.ygomobile.ui.online.mcchat.util
;
import
android.app.*
;
import
android.content.*
;
import
android.view.inputmethod.*
;
import
android.widget.*
;
import
cn.garymb.ygomobile.ui.online.mcchat.*
;
public
class
Util
{
//提示
public
static
void
show
(
String
message
){
Toast
.
makeText
(
ChatApplication
.
getContext
(),
message
,
Toast
.
LENGTH_SHORT
).
show
();
}
//关闭输入法
public
static
void
closeKeyboard
(
Activity
activity
){
InputMethodManager
inputMethodManager
=
(
InputMethodManager
)
activity
.
getSystemService
(
Context
.
INPUT_METHOD_SERVICE
);
inputMethodManager
.
hideSoftInputFromWindow
((
activity
).
getCurrentFocus
().
getWindowToken
()
,
InputMethodManager
.
HIDE_NOT_ALWAYS
);
}
//复制字符串到剪贴板
public
static
void
fzMessage
(
String
message
){
ClipboardManager
cmb
=
(
ClipboardManager
)
ChatApplication
.
getContext
().
getSystemService
(
ChatApplication
.
getContext
().
CLIPBOARD_SERVICE
);
cmb
.
setText
(
message
);
//复制命令
}
}
mobile/src/mycard/java/cn/garymb/ygomobile/ui/online/mcchat/view/YuanImage.java
deleted
100644 → 0
View file @
0b010d98
package
cn.garymb.ygomobile.ui.online.mcchat.view
;
import
android.content.Context
;
import
android.content.res.TypedArray
;
import
android.graphics.Bitmap
;
import
android.graphics.Bitmap.Config
;
import
android.graphics.Canvas
;
import
android.graphics.Paint
;
import
android.graphics.PorterDuff.Mode
;
import
android.graphics.PorterDuffXfermode
;
import
android.graphics.Rect
;
import
android.graphics.drawable.BitmapDrawable
;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.NinePatchDrawable
;
import
android.util.AttributeSet
;
import
android.util.Log
;
import
android.widget.ImageView
;
/*
* 圆形ImageView
*/
public
class
YuanImage
extends
android
.
support
.
v7
.
widget
.
AppCompatImageView
{
private
Context
mContext
;
// 控件默认长、宽
private
int
defaultWidth
=
0
;
private
int
defaultHeight
=
0
;
public
YuanImage
(
Context
context
)
{
super
(
context
);
mContext
=
context
;
}
public
YuanImage
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
mContext
=
context
;
}
public
YuanImage
(
Context
context
,
AttributeSet
attrs
,
int
defStyle
)
{
super
(
context
,
attrs
,
defStyle
);
mContext
=
context
;
}
@Override
protected
void
onDraw
(
Canvas
canvas
)
{
Drawable
drawable
=
getDrawable
()
;
if
(
drawable
==
null
)
{
return
;
}
if
(
getWidth
()
==
0
||
getHeight
()
==
0
)
{
return
;
}
this
.
measure
(
0
,
0
);
if
(
drawable
.
getClass
()
==
NinePatchDrawable
.
class
)
return
;
Bitmap
b
=
((
BitmapDrawable
)
drawable
).
getBitmap
();
Bitmap
bitmap
=
b
.
copy
(
Bitmap
.
Config
.
ARGB_8888
,
true
);
if
(
defaultWidth
==
0
)
{
defaultWidth
=
getWidth
();
}
if
(
defaultHeight
==
0
)
{
defaultHeight
=
getHeight
();
}
int
radius
=
(
defaultWidth
<
defaultHeight
?
defaultWidth
:
defaultHeight
)
/
2
;
Bitmap
roundBitmap
=
getCroppedRoundBitmap
(
bitmap
,
radius
);
canvas
.
drawBitmap
(
roundBitmap
,
defaultWidth
/
2
-
radius
,
defaultHeight
/
2
-
radius
,
null
);
}
/**
* 获取裁剪后的圆形图片
* @param radius 半径
*/
public
Bitmap
getCroppedRoundBitmap
(
Bitmap
bmp
,
int
radius
)
{
Bitmap
scaledSrcBmp
;
int
diameter
=
radius
*
2
;
// 为了防止宽高不相等,造成圆形图片变形,因此截取长方形中处于中间位置最大的正方形图片
int
bmpWidth
=
bmp
.
getWidth
();
int
bmpHeight
=
bmp
.
getHeight
();
int
squareWidth
=
0
,
squareHeight
=
0
;
int
x
=
0
,
y
=
0
;
Bitmap
squareBitmap
;
if
(
bmpHeight
>
bmpWidth
)
{
// 高大于宽
squareWidth
=
squareHeight
=
bmpWidth
;
x
=
0
;
y
=
(
bmpHeight
-
bmpWidth
)
/
2
;
// 截取正方形图片
squareBitmap
=
Bitmap
.
createBitmap
(
bmp
,
x
,
y
,
squareWidth
,
squareHeight
);
}
else
if
(
bmpHeight
<
bmpWidth
)
{
// 宽大于高
squareWidth
=
squareHeight
=
bmpHeight
;
x
=
(
bmpWidth
-
bmpHeight
)
/
2
;
y
=
0
;
squareBitmap
=
Bitmap
.
createBitmap
(
bmp
,
x
,
y
,
squareWidth
,
squareHeight
);
}
else
{
squareBitmap
=
bmp
;
}
if
(
squareBitmap
.
getWidth
()
!=
diameter
||
squareBitmap
.
getHeight
()
!=
diameter
)
{
scaledSrcBmp
=
Bitmap
.
createScaledBitmap
(
squareBitmap
,
diameter
,
diameter
,
true
);
}
else
{
scaledSrcBmp
=
squareBitmap
;
}
Bitmap
output
=
Bitmap
.
createBitmap
(
scaledSrcBmp
.
getWidth
(),
scaledSrcBmp
.
getHeight
(),
Config
.
ARGB_8888
);
Canvas
canvas
=
new
Canvas
(
output
);
Paint
paint
=
new
Paint
();
Rect
rect
=
new
Rect
(
0
,
0
,
scaledSrcBmp
.
getWidth
(),
scaledSrcBmp
.
getHeight
());
paint
.
setAntiAlias
(
true
);
paint
.
setFilterBitmap
(
true
);
paint
.
setDither
(
true
);
canvas
.
drawARGB
(
0
,
0
,
0
,
0
);
canvas
.
drawCircle
(
scaledSrcBmp
.
getWidth
()
/
2
,
scaledSrcBmp
.
getHeight
()
/
2
,
scaledSrcBmp
.
getWidth
()
/
2
,
paint
);
paint
.
setXfermode
(
new
PorterDuffXfermode
(
Mode
.
SRC_IN
));
canvas
.
drawBitmap
(
scaledSrcBmp
,
rect
,
rect
,
paint
);
bmp
=
null
;
squareBitmap
=
null
;
scaledSrcBmp
=
null
;
return
output
;
}
}
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