Commit 6e4bf02f authored by fallenstardust's avatar fallenstardust

调整聊天室为萌卡fragment初始化即登录

parent a9f6f6b8
...@@ -12,42 +12,56 @@ import android.os.Bundle; ...@@ -12,42 +12,56 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.Gravity; import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.drawerlayout.widget.DrawerLayout;
import com.google.android.material.navigation.NavigationView; import com.ourygo.assistant.util.Util;
import com.tencent.smtt.sdk.ValueCallback; import com.tencent.smtt.sdk.ValueCallback;
import com.tencent.smtt.sdk.WebChromeClient; 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.text.MessageFormat; import java.text.MessageFormat;
import java.util.List;
import cn.garymb.ygomobile.YGOStarter; import cn.garymb.ygomobile.YGOStarter;
import cn.garymb.ygomobile.base.BaseFragemnt; import cn.garymb.ygomobile.base.BaseFragemnt;
import cn.garymb.ygomobile.lite.BuildConfig; import cn.garymb.ygomobile.lite.BuildConfig;
import cn.garymb.ygomobile.lite.R; 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.SplashActivity;
import cn.garymb.ygomobile.ui.mycard.mcchat.management.ServiceManagement;
import cn.garymb.ygomobile.utils.glide.GlideCompat; import cn.garymb.ygomobile.utils.glide.GlideCompat;
public class MycardFragment extends BaseFragemnt implements View.OnClickListener, MyCard.MyCardListener { public class MycardFragment extends BaseFragemnt implements View.OnClickListener, MyCard.MyCardListener, OnJoinChatListener, ChatListener {
private static final int FILECHOOSER_RESULTCODE = 10; private static final int FILECHOOSER_RESULTCODE = 10;
private static final int TYPE_MC_LOGIN = 0; private static final int TYPE_MC_LOGIN = 0;
//头像昵称账号
private MyCardWebView mWebViewPlus;
private MyCard mMyCard;
private ImageView mHeadView; private ImageView mHeadView;
private TextView mNameView, mStatusView; private TextView mNameView, mStatusView;
private TextView tv_back_mc;
//萌卡webview
private MyCardWebView mWebViewPlus;
private MyCard mMyCard;
//聊天室
private RelativeLayout rl_chat;
private TextView tv_message;
private ProgressBar pb_chat_loading;
private ServiceManagement serviceManagement;
private ChatMessage currentMessage;
@SuppressLint("HandlerLeak") @SuppressLint("HandlerLeak")
Handler handler = new Handler() { Handler handler = new Handler() {
@Override @Override
...@@ -64,7 +78,6 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener ...@@ -64,7 +78,6 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
} }
}; };
private ProgressBar mProgressBar; private ProgressBar mProgressBar;
private TextView tv_back_mc;
private ValueCallback<Uri> uploadMessage; private ValueCallback<Uri> uploadMessage;
private ValueCallback<Uri[]> mUploadCallbackAboveL; private ValueCallback<Uri[]> mUploadCallbackAboveL;
...@@ -92,6 +105,14 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener ...@@ -92,6 +105,14 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
mStatusView = view.findViewById(R.id.tv_dp); mStatusView = view.findViewById(R.id.tv_dp);
//mWebViewPlus.enableHtml5(); //mWebViewPlus.enableHtml5();
rl_chat = view.findViewById(R.id.rl_chat);
rl_chat.setOnClickListener(this);
tv_message = view.findViewById(R.id.tv_message);
pb_chat_loading = view.findViewById(R.id.pb_chat_loading);
serviceManagement = ServiceManagement.getDx();
serviceManagement.addJoinRoomListener(this);
serviceManagement.addListener(this);
WebSettings settings = mWebViewPlus.getSettings(); WebSettings settings = mWebViewPlus.getSettings();
settings.setUserAgentString(settings.getUserAgentString() + MessageFormat.format( settings.setUserAgentString(settings.getUserAgentString() + MessageFormat.format(
" YGOMobile/{0} ({1} {2,number,#})", " YGOMobile/{0} ({1} {2,number,#})",
...@@ -319,4 +340,81 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener ...@@ -319,4 +340,81 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
public void onHome() { public void onHome() {
mWebViewPlus.loadUrl(mMyCard.getHomeUrl()); mWebViewPlus.loadUrl(mMyCard.getHomeUrl());
} }
@Override
public void onChatLogin(String exception) {
Log.e("MyCardFragment", "登录情况" + exception);
pb_chat_loading.setVisibility(View.GONE);
if (TextUtils.isEmpty(exception)) {
if (currentMessage == null) {
List<ChatMessage> data = serviceManagement.getData();
if (data != null && data.size() > 0)
currentMessage = data.get(data.size() - 1);
}
if (currentMessage == null)
tv_message.setText("聊天信息加载中");
else
tv_message.setText(currentMessage.getName() + ":" + currentMessage.getMessage());
} else {
tv_message.setText(R.string.logining_failed);
}
}
@Override
public void onChatLoginLoading() {
Log.e("MyCardFragment", "加载中");
pb_chat_loading.setVisibility(View.VISIBLE);
tv_message.setText(R.string.logining_in);
}
@Override
public void onJoinRoomLoading() {
Log.e("MyCardFragment", "加入房间中");
pb_chat_loading.setVisibility(View.VISIBLE);
tv_message.setText(R.string.logining_in);
}
@Override
public void onChatUserNull() {
Log.e("MyCardFragment", "为空");
pb_chat_loading.setVisibility(View.GONE);
tv_message.setText("登录失败,请退出登录后重新登录");
}
@Override
public boolean isListenerEffective() {
return Util.isContextExisted(getActivity());
}
@Override
public void addChatMessage(ChatMessage message) {
currentMessage = message;
if (message != null)
tv_message.setText(message.getName() + ":" + message.getMessage());
}
@Override
public void removeChatMessage(ChatMessage message) {
}
@Override
public void reChatLogin(boolean state) {
pb_chat_loading.setVisibility(View.VISIBLE);
if (state) {
tv_message.setText("登录成功");
} else {
tv_message.setText("连接断开,重新登录中……");
}
}
@Override
public void reChatJoin(boolean state) {
pb_chat_loading.setVisibility(View.VISIBLE);
if (state) {
onChatLogin(null);
} else {
tv_message.setText("重新加入聊天室中……");
}
}
} }
...@@ -3,12 +3,14 @@ package cn.garymb.ygomobile.ui.mycard.mcchat; ...@@ -3,12 +3,14 @@ package cn.garymb.ygomobile.ui.mycard.mcchat;
import org.jivesoftware.smack.packet.Message; import org.jivesoftware.smack.packet.Message;
public interface ChatListener { public interface ChatListener {
void addMessage(Message message); void addChatMessage(ChatMessage message);
void removeMessage(Message message); void removeChatMessage(ChatMessage message);
void reLogin(boolean state); void reChatLogin(boolean state);
void reJoin(boolean state); void reChatJoin(boolean state);
boolean isListenerEffective();
} }
...@@ -11,7 +11,7 @@ import android.widget.TextView; ...@@ -11,7 +11,7 @@ import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import org.jivesoftware.smack.packet.Message; import com.ourygo.assistant.util.Util;
import cn.garymb.ygomobile.lite.R; import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.mycard.mcchat.adapter.ChatAdapter; import cn.garymb.ygomobile.ui.mycard.mcchat.adapter.ChatAdapter;
...@@ -30,7 +30,7 @@ public class McchatActivity extends Activity implements ChatListener { ...@@ -30,7 +30,7 @@ public class McchatActivity extends Activity implements ChatListener {
private ServiceManagement su; private ServiceManagement su;
@Override @Override
public void reLogin(boolean state) { public void reChatLogin(boolean state) {
main_bottom_bar.setVisibility(View.GONE); main_bottom_bar.setVisibility(View.GONE);
if (state) { if (state) {
main_title.setText("登录成功"); main_title.setText("登录成功");
...@@ -41,7 +41,7 @@ public class McchatActivity extends Activity implements ChatListener { ...@@ -41,7 +41,7 @@ public class McchatActivity extends Activity implements ChatListener {
} }
@Override @Override
public void reJoin(boolean state) { public void reChatJoin(boolean state) {
if (state) { if (state) {
main_bottom_bar.setVisibility(View.VISIBLE); main_bottom_bar.setVisibility(View.VISIBLE);
main_title.setText(getResources().getString(R.string.app_name)); main_title.setText(getResources().getString(R.string.app_name));
...@@ -53,7 +53,12 @@ public class McchatActivity extends Activity implements ChatListener { ...@@ -53,7 +53,12 @@ public class McchatActivity extends Activity implements ChatListener {
} }
@Override @Override
public void addMessage(Message message) { public boolean isListenerEffective() {
return Util.isContextExisted(this);
}
@Override
public void addChatMessage(ChatMessage message) {
cadp.sx(); cadp.sx();
main_rec.smoothScrollToPosition(su.getData().size() - 1); main_rec.smoothScrollToPosition(su.getData().size() - 1);
...@@ -61,7 +66,7 @@ public class McchatActivity extends Activity implements ChatListener { ...@@ -61,7 +66,7 @@ public class McchatActivity extends Activity implements ChatListener {
} }
@Override @Override
public void removeMessage(Message message) { public void removeChatMessage(ChatMessage message) {
// TODO: Implement this method // TODO: Implement this method
} }
......
package cn.garymb.ygomobile.ui.mycard.mcchat.management; package cn.garymb.ygomobile.ui.mycard.mcchat.management;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Handler; import android.os.Handler;
import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.ConnectionConfiguration;
...@@ -22,24 +25,40 @@ import java.io.IOException; ...@@ -22,24 +25,40 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import cn.garymb.ygomobile.App;
import cn.garymb.ygomobile.ui.mycard.base.OnJoinChatListener;
import cn.garymb.ygomobile.ui.mycard.mcchat.ChatListener; import cn.garymb.ygomobile.ui.mycard.mcchat.ChatListener;
import cn.garymb.ygomobile.ui.mycard.mcchat.ChatMessage; import cn.garymb.ygomobile.ui.mycard.mcchat.ChatMessage;
import cn.garymb.ygomobile.ui.mycard.mcchat.util.TaxiConnectionListener; import cn.garymb.ygomobile.ui.mycard.mcchat.util.TaxiConnectionListener;
import cn.garymb.ygomobile.utils.HandlerUtil;
public class ServiceManagement { public class ServiceManagement {
public static final String GROUP_ADDRESS = "ygopro_china_north@conference.mycard.moe"; public static final String GROUP_ADDRESS = "ygopro_china_north@conference.mycard.moe";
public static final int TYPE_ADD_MESSAGE=0; public static final int TYPE_ADD_MESSAGE = 0;
public static final int TYPE_RE_LOGIN=1; public static final int TYPE_RE_LOGIN = 1;
public static final int TYPE_RE_JOIN=2; public static final int TYPE_RE_JOIN = 2;
public static final int CHAT_LOGIN_EXCEPTION_RE = 3;
public static final int CHAT_LOGIN_OK = 4;
public static final int CHAT_LOGIN_EXCEPTION = 5;
public static final int CHAT_LOGIN_LOADING = 6;
public static final int CHAT_JOIN_ROOM_LOADING = 7;
public static final int CHAT_USER_NULL = 8;
private static ServiceManagement su = new ServiceManagement(); private static ServiceManagement su = new ServiceManagement();
private XMPPTCPConnection con; private XMPPTCPConnection con;
private MultiUserChat muc; private MultiUserChat muc;
private boolean isConnected = false; private boolean isConnected = false;
private boolean isListener = false; private boolean isListener = false;
private boolean isStartLoading=false;
private List<ChatMessage> chatMessageList; private List<ChatMessage> chatMessageList;
private List<ChatListener> chatListenerList; private List<ChatListener> chatListenerList;
private List<OnJoinChatListener> joinChatListenerList;
@SuppressLint("HandlerLeak") @SuppressLint("HandlerLeak")
Handler han = new Handler() { Handler han = new Handler() {
...@@ -47,31 +66,105 @@ public class ServiceManagement { ...@@ -47,31 +66,105 @@ public class ServiceManagement {
public void handleMessage(android.os.Message msg) { public void handleMessage(android.os.Message msg) {
// TODO: Implement this method // TODO: Implement this method
super.handleMessage(msg); super.handleMessage(msg);
int i = 0;
switch (msg.what) { switch (msg.what) {
case TYPE_ADD_MESSAGE: case TYPE_ADD_MESSAGE:
for (ChatListener c : chatListenerList) { while (i < chatListenerList.size()) {
if (c != null) { ChatListener c = chatListenerList.get(i);
c.addMessage((Message) msg.obj); if (c.isListenerEffective()) {
c.addChatMessage((ChatMessage) msg.obj);
i++;
} else { } else {
chatListenerList.remove(c); chatListenerList.remove(i);
} }
} }
break; break;
case TYPE_RE_LOGIN: case TYPE_RE_LOGIN:
for (ChatListener c : chatListenerList) { while (i < chatListenerList.size()) {
if (c != null) { ChatListener c = chatListenerList.get(i);
c.reLogin((boolean) msg.obj); if (c.isListenerEffective()) {
c.reChatLogin((boolean) msg.obj);
i++;
} else { } else {
chatListenerList.remove(c); chatListenerList.remove(i);
} }
} }
break; break;
case TYPE_RE_JOIN: case TYPE_RE_JOIN:
for (ChatListener c : chatListenerList) {
if (c != null) { while (i < chatListenerList.size()) {
c.reJoin((boolean) msg.obj); ChatListener c = chatListenerList.get(i);
if (c.isListenerEffective()) {
c.reChatJoin((boolean) msg.obj);
i++;
} else { } else {
chatListenerList.remove(c); chatListenerList.remove(i);
}
}
break;
case CHAT_LOGIN_EXCEPTION_RE:
// while (i < joinChatListenerList.size()) {
// OnJoinChatListener ou = joinChatListenerList.get(i);
// if (ou.isListenerEffective()) {
// ou.onLoginExceptionClickRe();
// i++;
// } else {
// joinChatListenerList.remove(i);
// }
// }
// break;
case CHAT_LOGIN_OK:
while (i < joinChatListenerList.size()) {
OnJoinChatListener ou = joinChatListenerList.get(i);
if (ou.isListenerEffective()) {
ou.onChatLogin(null);
i++;
} else {
joinChatListenerList.remove(i);
}
}
break;
case CHAT_LOGIN_EXCEPTION:
while (i < joinChatListenerList.size()) {
OnJoinChatListener ou = joinChatListenerList.get(i);
if (ou.isListenerEffective()) {
ou.onChatLogin(msg.obj + "");
i++;
} else {
joinChatListenerList.remove(i);
}
}
break;
case CHAT_LOGIN_LOADING:
while (i < joinChatListenerList.size()) {
OnJoinChatListener ou = joinChatListenerList.get(i);
if (ou.isListenerEffective()) {
ou.onChatLoginLoading();
i++;
} else {
joinChatListenerList.remove(i);
}
}
break;
case CHAT_JOIN_ROOM_LOADING:
while (i < joinChatListenerList.size()) {
OnJoinChatListener ou = joinChatListenerList.get(i);
if (ou.isListenerEffective()) {
ou.onJoinRoomLoading();
i++;
} else {
joinChatListenerList.remove(i);
}
}
break;
case CHAT_USER_NULL:
while (i < joinChatListenerList.size()) {
OnJoinChatListener ou = joinChatListenerList.get(i);
if (ou.isListenerEffective()) {
ou.onChatUserNull();
i++;
} else {
joinChatListenerList.remove(i);
} }
} }
break; break;
...@@ -80,8 +173,9 @@ public class ServiceManagement { ...@@ -80,8 +173,9 @@ public class ServiceManagement {
}; };
private ServiceManagement() { private ServiceManagement() {
chatMessageList=new ArrayList<>(); chatMessageList = new ArrayList<>();
chatListenerList=new ArrayList<>(); chatListenerList = new ArrayList<>();
joinChatListenerList = new ArrayList<>();
} }
public static ServiceManagement getDx() { public static ServiceManagement getDx() {
...@@ -145,22 +239,25 @@ public class ServiceManagement { ...@@ -145,22 +239,25 @@ public class ServiceManagement {
muc.sendMessage(message); muc.sendMessage(message);
} }
public int getMemberNum(){
if (!isListener)
return 0;
return muc.getOccupantsCount();
}
public void joinChat() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, MultiUserChatException.NotAMucServiceException, SmackException.NotConnectedException, XmppStringprepException, MultiUserChatException.MucAlreadyJoinedException, InterruptedException { public void joinChat() throws SmackException.NoResponseException, XMPPException.XMPPErrorException, MultiUserChatException.NotAMucServiceException, SmackException.NotConnectedException, XmppStringprepException, MultiUserChatException.MucAlreadyJoinedException, InterruptedException {
if (!isListener) { if (!isListener) {
MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(getCon()); MultiUserChatManager multiUserChatManager = MultiUserChatManager.getInstanceFor(getCon());
muc = multiUserChatManager.getMultiUserChat(JidCreate.entityBareFrom(GROUP_ADDRESS)); muc = multiUserChatManager.getMultiUserChat(JidCreate.entityBareFrom(GROUP_ADDRESS));
muc.createOrJoin(Resourcepart.from(UserManagement.getUserName())); muc.createOrJoin(Resourcepart.from(UserManagement.getUserName()));
chatMessageList.clear(); chatMessageList.clear();
muc.addMessageListener(new MessageListener() { muc.addMessageListener(message -> {
@Override
public void processMessage(Message message) { Log.e("接收消息", "接收" + message);
ChatMessage cm = ChatMessage.toChatMessage(message);
Log.e("接收消息", "接收" + message); if (cm != null) {
ChatMessage cm = ChatMessage.toChatMessage(message); chatMessageList.add(cm);
if (cm != null) { HandlerUtil.sendMessage(han,TYPE_ADD_MESSAGE,cm);
chatMessageList.add(cm);
han.sendEmptyMessage(TYPE_ADD_MESSAGE);
}
} }
}); });
setIsListener(true); setIsListener(true);
...@@ -182,7 +279,7 @@ public class ServiceManagement { ...@@ -182,7 +279,7 @@ public class ServiceManagement {
} }
public void disSerVice() { public void disSerVice() {
if(con!=null) { if (con != null) {
con.disconnect(); con.disconnect();
} }
setIsConnected(false); setIsConnected(false);
...@@ -194,6 +291,90 @@ public class ServiceManagement { ...@@ -194,6 +291,90 @@ public class ServiceManagement {
setIsListener(false); setIsListener(false);
chatMessageList.clear(); chatMessageList.clear();
chatListenerList.clear(); chatListenerList.clear();
joinChatListenerList.clear();
}
public void addJoinRoomListener(OnJoinChatListener onJoinChatListener) {
joinChatListenerList.add(onJoinChatListener);
}
public void removeJoinRoomListener(OnJoinChatListener onJoinChatListener) {
joinChatListenerList.remove(onJoinChatListener);
}
public void start() {
if (isStartLoading)
return;
isStartLoading=true;
String name, password;
SharedPreferences lastModified = App.get().getSharedPreferences("lastModified", Context.MODE_PRIVATE);
UserManagement.setUserName(lastModified.getString("user_name", null));
UserManagement.setUserPassword(lastModified.getString("user_external_id", null));
name = UserManagement.getUserName();
password = UserManagement.getUserPassword();
if (TextUtils.isEmpty(name) || TextUtils.isEmpty(password)) {
isStartLoading=false;
han.sendEmptyMessage(CHAT_USER_NULL);
return;
}
if (su.isListener()) {
isStartLoading=false;
han.sendEmptyMessage(CHAT_LOGIN_OK);
return;
}
new Thread(() -> {
if (!su.isConnected()) {
han.sendEmptyMessage(CHAT_LOGIN_LOADING);
android.os.Message me = new android.os.Message();
me.what = CHAT_LOGIN_EXCEPTION;
try {
su.login(name, password);
} catch (InterruptedException e) {
e.printStackTrace();
isStartLoading=false;
me.obj = "InterruptedException:" + e;
han.sendMessage(me);
} catch (IOException e) {
isStartLoading=false;
me.obj = "IOException:" + e;
e.printStackTrace();
han.sendMessage(me);
} catch (SmackException e) {
isStartLoading=false;
me.obj = "SmackException:" + e;
e.printStackTrace();
han.sendMessage(me);
} catch (XMPPException e) {
isStartLoading=false;
me.obj = "XMPPException:" + e;
e.printStackTrace();
han.sendMessage(me);
} catch (Exception e) {
isStartLoading=false;
me.obj = "其他错误:" + e;
e.printStackTrace();
han.sendMessage(me);
}
}
if (su.isConnected()) {
han.sendEmptyMessage(CHAT_JOIN_ROOM_LOADING);
try {
su.joinChat();
isStartLoading=false;
han.sendEmptyMessage(CHAT_LOGIN_OK);
} catch (Exception e) {
isStartLoading=false;
HandlerUtil.sendMessage(han, CHAT_LOGIN_EXCEPTION, e);
}
}
// TODO: Implement this method
}).start();
} }
} }
package cn.garymb.ygomobile.ui.mycard.mcchat.management; package cn.garymb.ygomobile.ui.mycard.mcchat.management;
public class UserManagement { public class UserManagement {
private static UserManagement um = new UserManagement(); private static UserManagement userManagement = new UserManagement();
private static String userName, userPassword; private static String userName, userPassword;
private UserManagement() { private UserManagement() {
} }
public static String getUserName() { public static String getUserName() {
return userName; return userName;
} }
public static void setUserName(String name) { public static void setUserName(String name) {
userName = name; userName = name;
} }
public static String getUserPassword() { public static String getUserPassword() {
...@@ -25,11 +20,10 @@ public class UserManagement { ...@@ -25,11 +20,10 @@ public class UserManagement {
} }
public static void setUserPassword(String password) { public static void setUserPassword(String password) {
userPassword = password; userPassword = password;
} }
public static UserManagement getDx() { public static UserManagement getDx() {
return um; return userManagement;
} }
} }
package cn.garymb.ygomobile.utils;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
public class HandlerUtil {
public static void sendMessage(Handler handler, String exception, int ok, Object okObject, int no) {
Message message = new Message();
if (TextUtils.isEmpty(exception)) {
message.what = ok;
message.obj = okObject;
} else {
message.what = no;
message.obj = exception;
}
handler.sendMessage(message);
}
public static void sendMessage(Handler handler, String exception, int ok, int no) {
sendMessage(handler, exception, ok, null, no);
}
public static void sendMessage(Handler handler, int what, Object object) {
Message message = new Message();
message.obj = object;
message.what = what;
handler.sendMessage(message);
}
}
...@@ -4,75 +4,75 @@ ...@@ -4,75 +4,75 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/dialogshort" android:background="@drawable/dialogshort"
android:weightSum="10" android:weightSum="12"
android:orientation="vertical"> android:orientation="vertical">
<RelativeLayout <FrameLayout
android:id="@+id/rl_head" android:id="@+id/rl_head"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="20dp" android:padding="10dp">
android:paddingTop="10dp"
android:paddingRight="20dp"
android:paddingBottom="10dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/img_head"
android:layout_width="@dimen/label_width_50dp"
android:layout_height="@dimen/label_width_50dp"
android:src="@drawable/avatar" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.LinearLayoutCompat
android:id="@+id/tv_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_toRightOf="@id/img_head" android:layout_weight="1"
android:text="@string/mc_chat" android:orientation="horizontal">
android:textColor="@color/holo_green_bright"
android:textSize="18sp"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/tv_dp" android:id="@+id/img_head"
android:layout_width="wrap_content" android:layout_width="40dp"
android:layout_height="wrap_content" android:layout_height="40dp"
android:layout_below="@id/tv_name" android:layout_marginRight="@dimen/dp_10"
android:layout_marginTop="5dp" android:src="@drawable/avatar" />
android:layout_toRightOf="@id/img_head"
android:ellipsize="end"
android:lines="1"
android:text="account"
android:textColor="@color/holo_orange_bright"
android:textSize="13sp" />
<androidx.appcompat.widget.AppCompatImageButton <androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="@dimen/dp_40" android:layout_width="wrap_content"
android:layout_height="@dimen/dp_40" android:layout_height="match_parent"
android:nextFocusRight="@string/mc_chat"/> android:orientation="vertical">
</RelativeLayout> <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="@color/holo_green_bright"
android:textSize="15sp"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_back_mc" android:id="@+id/tv_dp"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/list_item_bg" android:layout_below="@id/tv_name"
android:gravity="center" android:layout_marginTop="5dp"
android:paddingTop="6dp" android:layout_toRightOf="@id/img_head"
android:paddingBottom="6dp" android:ellipsize="end"
android:text="@string/back_to_mycard_home" android:lines="1"
android:textColor="@color/holo_green_bright" android:text=""
android:textSize="13sp" android:textColor="@color/holo_orange_bright"
android:textStyle="bold" android:textSize="10sp" />
android:visibility="gone" /> </androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/tv_back_mc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:background="@drawable/button_bg"
android:gravity="center"
android:text="@string/back_to_mycard_home"
android:visibility="gone" />
</FrameLayout>
<cn.garymb.ygomobile.ui.mycard.MyCardWebView <cn.garymb.ygomobile.ui.mycard.MyCardWebView
android:id="@+id/webbrowser" android:id="@+id/webbrowser"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="8"> android:layout_weight="10">
<ProgressBar <ProgressBar
android:id="@+id/progressBar" android:id="@+id/progressBar"
...@@ -87,12 +87,8 @@ ...@@ -87,12 +87,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@drawable/list_item_bg"
android:orientation="vertical" android:orientation="vertical"
android:paddingLeft="20dp" android:padding="10dp">
android:paddingTop="10dp"
android:paddingRight="20dp"
android:paddingBottom="10dp">
<androidx.appcompat.widget.AppCompatTextView <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_message_s" android:id="@+id/tv_message_s"
...@@ -100,7 +96,6 @@ ...@@ -100,7 +96,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/mc_chat" android:text="@string/mc_chat"
android:textColor="@color/holo_green_bright" android:textColor="@color/holo_green_bright"
android:textSize="18sp"
android:textStyle="bold" /> android:textStyle="bold" />
<ProgressBar <ProgressBar
...@@ -121,6 +116,6 @@ ...@@ -121,6 +116,6 @@
android:lines="1" android:lines="1"
android:text="" android:text=""
android:textColor="@color/holo_orange_bright" android:textColor="@color/holo_orange_bright"
android:textSize="13sp" /> android:textSize="10sp" />
</RelativeLayout> </RelativeLayout>
</LinearLayout> </LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment