Commit 367a8b99 by 王文龙

[update]完善UI

parent 6ab9e186
package com.offcn.imclient.adapter;
import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.jyall.base.adapter.BaseRecyclerViewAdapter;
import com.jyall.base.adapter.RecyclerViewHolderUtil;
import com.jyall.base.util.ValidateUtils;
import com.offcn.imclient.R;
import com.offcn.imclient.bean.UserBean;
import com.offcn.live.im.bean.OIMUserInfo;
import com.offcn.live.imkit.view.CircleImageView;
import java.util.List;
/**
* 最近会话列表适配器
*
* @author wangwenlong
* @date 2020/9/11
*/
public class ContactListAdapter extends BaseRecyclerViewAdapter<UserBean> {
public ContactListAdapter(Context paramContext) {
super(paramContext);
}
public ContactListAdapter(Context context, List<UserBean> list) {
super(context, list);
}
@Override
public int onCreateViewLayoutID(int i) {
return R.layout.item_contact_list;
}
@Override
public void bindItemViewHolder(RecyclerViewHolderUtil holderUtil, int position) {
CircleImageView mHeadImg = holderUtil.get(R.id.rc_img);
TextView mTvName = holderUtil.get(R.id.tv_name);
View line = holderUtil.get(R.id.view_line);
UserBean friend = getItem(position);
if (friend == null) {
return;
}
// String sectionForPosition = getSectionForPosition(position);
// if (position == getPositionForSection(sectionForPosition)) {
// mTvCategory.setVisibility(View.VISIBLE);
// mTvCategory.setText(friend.getFirst_char());
// } else {
// mTvCategory.setVisibility(View.GONE);
// mTvCategory.setText("");
// }
// if (friend.isLast()) {
// line.setVisibility(View.GONE);
// } else {
// line.setVisibility(View.VISIBLE);
// }
RequestOptions options = new RequestOptions();
options.placeholder(R.mipmap.ic_teacher).error(R.mipmap.ic_teacher);
options.diskCacheStrategy(DiskCacheStrategy.ALL);
mTvName.setText(friend.getName());
if (friend.getAvatar().startsWith("file")) {
Uri uri = Uri.parse(friend.getAvatar());
Glide.with(mContext).load(uri).apply(options).into(mHeadImg);
} else {
Glide.with(mContext).load(friend.getAvatar()).apply(options).into(mHeadImg);
}
}
// public String getSectionForPosition(int position) {
// if (!ValidateUtils.isEmpty(mList)) {
// UserBean friend = getItem(position);
// if (friend != null) {
// String firstChar = friend.getFirst_char();
// if (!TextUtils.isEmpty(firstChar)) {
// return firstChar;
// } else {
// return "";
// }
//
// } else {
// return "";
// }
// } else {
// return "";
// }
//
// }
//
// public int getPositionForSection(String section) {
// if (ValidateUtils.isEmpty(mList)) {
// return -1;
// }
// for (int i = 0; i < mList.size(); i++) {
// UserBean friend = getItem(i);
// if (friend != null) {
// String sortStr = friend.getFirst_char();
// if (!TextUtils.isEmpty(sortStr)) {
// if (sortStr.equals(section)) {
// return i;
// }
// }
// }
// }
// return -1;
// }
}
......@@ -31,11 +31,14 @@ import java.util.List;
*/
public class ContactListExpandableAdapter extends AnimatedExpandableListView.AnimatedExpandableListAdapter {
private Context mContext;
private LayoutInflater inflater;
private List<ServerContactBean> items;
public ContactListExpandableAdapter(Context context, List<ServerContactBean> list) {
mContext = context;
inflater = LayoutInflater.from(context);
items = list;
}
......@@ -63,6 +66,7 @@ public class ContactListExpandableAdapter extends AnimatedExpandableListView.Ani
holder = new ChildHolder();
convertView = inflater.inflate(R.layout.item_contact_child, parent, false);
holder.title = (TextView) convertView.findViewById(R.id.tv_name);
holder.avatar = convertView.findViewById(R.id.iv_avatar);
convertView.setTag(holder);
} else {
holder = (ChildHolder) convertView.getTag();
......@@ -70,6 +74,12 @@ public class ContactListExpandableAdapter extends AnimatedExpandableListView.Ani
holder.title.setText(item.getName());
if (childPosition == 0) {
holder.avatar.setImageResource(R.mipmap.ic_chat_group_mixed);
} else {
Glide.with(mContext).load(item.getAvatar()).placeholder(R.mipmap.ic_teacher).into(holder.avatar);
}
return convertView;
}
......@@ -103,6 +113,7 @@ public class ContactListExpandableAdapter extends AnimatedExpandableListView.Ani
holder.title = (TextView) convertView.findViewById(R.id.tv_name);
holder.count = (TextView) convertView.findViewById(R.id.tv_count);
holder.ivChat = convertView.findViewById(R.id.iv_chat);
holder.ivIndicator = convertView.findViewById(R.id.iv_indicator);
convertView.setTag(holder);
} else {
holder = (GroupHolder) convertView.getTag();
......@@ -128,6 +139,7 @@ public class ContactListExpandableAdapter extends AnimatedExpandableListView.Ani
}
}
});
holder.ivIndicator.setImageResource(isExpanded ? R.mipmap.ic_group_indicator_on : R.mipmap.ic_group_indicator_off);
return convertView;
}
......@@ -152,6 +164,7 @@ public class ContactListExpandableAdapter extends AnimatedExpandableListView.Ani
TextView title;
TextView count;
ImageView ivChat;
ImageView ivIndicator;
}
......@@ -164,4 +177,6 @@ public class ContactListExpandableAdapter extends AnimatedExpandableListView.Ani
public interface OnContactItemElementClickListener {
void onClickChat(int groupPosition, int childPosition);
}
}
package com.offcn.imclient.ui;
import android.content.Intent;
import android.view.View;
import android.widget.ExpandableListView;
import android.widget.RelativeLayout;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.jyall.base.base.BaseFragment;
import com.jyall.base.util.CommonUtils;
import com.jyall.base.util.ValidateUtils;
import com.offcn.imclient.R;
import com.offcn.imclient.adapter.ContactListExpandableAdapter;
import com.offcn.imclient.bean.ServerContactBean;
import com.offcn.imclient.bean.ServerContactBeanWrapper;
import com.offcn.imclient.bean.UserBean;
import com.offcn.imclient.util.LoginManager;
import com.offcn.imclient.util.UserBeanDaoManager;
import com.offcn.imclient.util.Utils;
import com.offcn.imclient.view.AnimatedExpandableListView;
import com.offcn.live.im.OIMSDK;
import com.offcn.live.im.bean.OIMSendTypeEnum;
import com.offcn.live.im.util.ZGLLogUtils;
import com.offcn.live.im.util.ZGLParseUtils;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
/**
* 会话列表
*
* @author wangwenlong
* @date 2020/12/9
*/
public class ChatListFragmentWrapper extends BaseFragment {
private static final String TAG = ChatListFragmentWrapper.class.getSimpleName();
@Override
protected int getContentViewId() {
return R.layout.fragment_chat_list_wrapper;
}
@Override
protected void init(View view) {
}
@Override
protected boolean setLoadAlways() {
return false;
}
}
package com.offcn.imclient.ui;
import android.content.Intent;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.volley.Request;
......@@ -34,6 +37,9 @@ public class LoginActivity extends BaseActivity {
EditText mEtName, mEtPwd;
TextView mTvLogin;
ImageView mIvClear, mIvEye;
private boolean isShowPassWord = true;
@Override
protected int getContentViewLayoutId() {
......@@ -45,7 +51,23 @@ public class LoginActivity extends BaseActivity {
mEtName = findViewById(R.id.et_name);
mEtPwd = findViewById(R.id.et_pwd);
mTvLogin = findViewById(R.id.tv_login);
mIvClear = findViewById(R.id.iv_delete);
mIvEye = findViewById(R.id.iv_eye);
mIvClear.setOnClickListener(v -> mEtName.setText(""));
mIvEye.setOnClickListener(v -> {
if (isShowPassWord) {
mIvEye.setImageDrawable(getResources().getDrawable(R.mipmap.ic_et_eye_on));
mEtPwd.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
mEtPwd.setSelection(mEtPwd.getText().toString().length());
isShowPassWord = !isShowPassWord;
} else {
mIvEye.setImageDrawable(getResources().getDrawable(R.mipmap.ic_et_eye_off));
mEtPwd.setTransformationMethod(PasswordTransformationMethod.getInstance());
mEtPwd.setSelection(mEtPwd.getText().toString().length());
isShowPassWord = !isShowPassWord;
}
});
mTvLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......
package com.offcn.imclient.ui;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.android.material.tabs.TabLayout;
import com.jyall.base.adapter.BaseVPAdapter;
......@@ -19,6 +25,7 @@ import com.offcn.live.im.bean.OIMCode;
import com.offcn.live.im.util.ZGLCommonUtils;
import com.offcn.live.im.util.ZGLLogUtils;
import com.offcn.live.imkit.ui.ChatListFragment;
import com.offcn.live.imkit.view.ScrollEnabledViewPager;
import java.util.ArrayList;
import java.util.List;
......@@ -33,7 +40,7 @@ public class MainActivity extends BaseActivity {
private static final String TAG = MainActivity.class.getSimpleName();
TabLayout mTabLayout;
ViewPager mViewPager;
ScrollEnabledViewPager mViewPager;
String[] titles = new String[]{"聊天", "通讯录", "我的"};
......@@ -106,7 +113,7 @@ public class MainActivity extends BaseActivity {
List<Fragment> fragmentList = new ArrayList<>();
fragmentList.add(new ChatListFragment());
fragmentList.add(new ChatListFragmentWrapper());
fragmentList.add(new ContactListFragment());
fragmentList.add(new MeFragment());
for (int i = 0; i < titles.length; i++) {
......@@ -115,10 +122,32 @@ public class MainActivity extends BaseActivity {
BaseVPAdapter adapter = new BaseVPAdapter(getSupportFragmentManager(), fragmentList);
mViewPager.setOffscreenPageLimit(fragmentList.size());
mViewPager.setAdapter(adapter);
mTabLayout.setupWithViewPager(mViewPager, false);
mViewPager.setPagingEnabled(false);
for (int i = 0; i < titles.length; i++) {
mTabLayout.getTabAt(i).setText(titles[i]);
mTabLayout.getTabAt(i).setCustomView(getTabView(i));
}
/**
* 设置TabLayout的选中监听
*/
mTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
mViewPager.setCurrentItem(tab.getPosition());
changeTabSelect(tab); //Tab获取焦点
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
changeTabNormal(tab); //Tab失去焦点
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
@Override
......@@ -142,4 +171,77 @@ public class MainActivity extends BaseActivity {
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
}
private View getTabView(int index) {
View view = LayoutInflater.from(this).inflate(R.layout.item_tab, null);
TextView title = (TextView) view.findViewById(R.id.tv_title);
ImageView iv = (ImageView) view.findViewById(R.id.iv_pic);
title.setText(titles[index]);
if (index == 0) {
iv.setImageResource(R.mipmap.ic_chat_tab_on);
title.setTextColor(getResources().getColor(R.color.colorPrimary));
} else if (index == 1) {
iv.setImageResource(R.mipmap.ic_contact_tab_off);
title.setTextColor(getResources().getColor(R.color.color_333333));
} else if (index == 2) {
iv.setImageResource(R.mipmap.ic_me_off);
title.setTextColor(getResources().getColor(R.color.color_333333));
}
return view;
}
private void changeTabSelect(TabLayout.Tab tab) {
final View view = tab.getCustomView();
int index = tab.getPosition();
TextView title = (TextView) view.findViewById(R.id.tv_title);
ImageView iv = (ImageView) view.findViewById(R.id.iv_pic);
title.setText(titles[index]);
setTabView(true, index, title, iv);
}
/**
* 改变TabLayout的View到未选中状态
*/
private void changeTabNormal(TabLayout.Tab tab) {
final View view = tab.getCustomView();
int index = tab.getPosition();
TextView title = (TextView) view.findViewById(R.id.tv_title);
ImageView iv = (ImageView) view.findViewById(R.id.iv_pic);
title.setText(titles[index]);
setTabView(false, index, title, iv);
}
private void setTabView(boolean isSelected, int index, TextView title, ImageView iv) {
switch (index) {
case 0:
if (isSelected) {
iv.setImageResource(R.mipmap.ic_chat_tab_on);
title.setTextColor(getResources().getColor(R.color.colorPrimary));
} else {
iv.setImageResource(R.mipmap.ic_chat_tab_off);
title.setTextColor(getResources().getColor(R.color.color_333333));
}
break;
case 1:
if (isSelected) {
iv.setImageResource(R.mipmap.ic_contact_tab_on);
title.setTextColor(getResources().getColor(R.color.colorPrimary));
} else {
iv.setImageResource(R.mipmap.ic_contact_tab_off);
title.setTextColor(getResources().getColor(R.color.color_333333));
}
break;
case 2:
if (isSelected) {
iv.setImageResource(R.mipmap.ic_me_on);
title.setTextColor(getResources().getColor(R.color.colorPrimary));
} else {
iv.setImageResource(R.mipmap.ic_me_off);
title.setTextColor(getResources().getColor(R.color.color_333333));
}
break;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#33777777" />
<size
android:height="1dp"
android:width="500dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/ic_group_indicator_on" android:state_expanded="true" />
<item android:drawable="@mipmap/ic_group_indicator_off" />
</selector>
\ No newline at end of file
......@@ -8,28 +8,71 @@
android:focusableInTouchMode="true"
android:orientation="vertical">
<com.jyall.base.view.ClearEditText
android:id="@+id/et_name"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="60dp"
android:layout_gravity="center_horizontal"
android:drawableTop="@mipmap/ic_logo"
android:drawablePadding="20dp"
android:text="在线课堂教师版"
android:textColor="@color/color_333333"
android:textSize="20sp"
android:textStyle="bold" />
<RelativeLayout
android:id="@+id/rl_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入用户名"
android:singleLine="true" />
android:layout_marginTop="40dp">
<EditText
android:id="@+id/et_name"
style="@style/loginEditText"
android:layout_centerVertical="true"
android:hint="请输入工号"
android:inputType="textPassword"
android:maxLength="11" />
<com.jyall.base.view.ClearEditText
android:id="@+id/et_pwd"
<ImageView
android:id="@+id/iv_delete"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:padding="5dp"
android:src="@mipmap/ic_et_clear" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/rl_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="请输入密码"
android:singleLine="true" />
android:layout_marginTop="20dp">
<EditText
android:id="@+id/et_pwd"
style="@style/loginEditText"
android:layout_centerVertical="true"
android:hint="请输入密码"
android:inputType="textPassword" />
<ImageView
android:id="@+id/iv_eye"
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:padding="5dp"
android:src="@mipmap/ic_et_eye_off" />
</RelativeLayout>
<TextView
android:id="@+id/tv_login"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="50dp"
android:layout_marginTop="60dp"
android:background="@color/colorPrimary"
android:gravity="center"
android:text="登录"
......@@ -40,7 +83,7 @@
android:id="@+id/tv_login_test"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="50dp"
android:layout_marginTop="10dp"
android:background="@color/colorPrimary"
android:gravity="center"
android:text="测试一键登录(lqy62094)"
......
......@@ -2,15 +2,15 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout"
style="@style/MyTablayoutstyle"
android:layout_alignParentBottom="true"
app:tabIndicatorHeight="0dp"
android:layout_width="match_parent"
android:layout_height="50dp" />
android:layout_height="60dp" />
<View
android:layout_width="match_parent"
......@@ -19,7 +19,7 @@
android:layout_above="@+id/tab_layout"
android:background="@android:color/darker_gray"/>
<androidx.viewpager.widget.ViewPager
<com.offcn.live.imkit.view.ScrollEnabledViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_above="@+id/view_line"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:paddingTop="@dimen/toolbar_padding_top">
<fragment
android:name="com.offcn.live.imkit.ui.ChatListFragment"
android:id="@+id/chat_list_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
......@@ -4,6 +4,7 @@
android:layout_height="match_parent"
android:gravity="center"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:paddingTop="@dimen/toolbar_padding_top"
android:orientation="vertical">
<RelativeLayout
......@@ -13,6 +14,7 @@
<com.offcn.imclient.view.AnimatedExpandableListView
android:id="@+id/recycler_view"
android:groupIndicator="@null"
android:layout_width="match_parent"
android:layout_height="match_parent" />
......
......@@ -4,32 +4,37 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:background="@mipmap/ic_me_bg"
android:paddingTop="@dimen/toolbar_padding_top"
android:orientation="vertical">
<com.offcn.live.imkit.view.CircleImageView
android:id="@+id/avatar"
android:layout_marginTop="50dp"
android:layout_width="50dp"
android:layout_height="50dp" />
android:layout_marginTop="70dp"
android:scaleType="centerCrop"
android:layout_width="130dp"
android:layout_height="130dp" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textSize="16sp"
android:textColor="@color/color_333333"
android:layout_marginTop="30dp"
android:textSize="18sp"
android:textColor="@android:color/white"
tools:text="我是名字" />
<TextView
android:id="@+id/btn_logout"
android:layout_marginTop="70dp"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_margin="50dp"
android:background="@color/colorPrimary"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@android:color/white"
android:gravity="center"
android:padding="10dp"
android:textColor="@android:color/white"
android:textColor="@color/color_333333"
android:text="退出登录"
android:textSize="16sp" />
......
......@@ -3,8 +3,15 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="center_vertical"
android:paddingLeft="40dp">
android:gravity="center_vertical">
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_marginLeft="10dp"
tools:src="@mipmap/ic_group_indicator_off"
android:id="@+id/iv_indicator"
android:layout_marginRight="10dp" />
<TextView
android:id="@+id/tv_name"
......@@ -26,8 +33,9 @@
<ImageView
android:id="@+id/iv_chat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:src="@mipmap/ic_teacher" />
android:layout_height="match_parent"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:src="@mipmap/ic_chat_group" />
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="50dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/iv_pic"
android:layout_width="20dp"
android:layout_height="20dp"
android:scaleType="centerCrop"
tools:src="@mipmap/ic_me_on" />
<TextView
android:id="@+id/tv_title"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
tools:text="我的" />
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
......@@ -26,4 +26,17 @@
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="loginEditText">
<item name="android:layout_marginLeft">0dp</item>
<item name="android:layout_marginRight">0dp</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textSize">15sp</item>
<item name="android:background">@null</item>
<item name="android:drawablePadding">10dp</item>
<item name="android:drawableBottom">@drawable/login_edit_line</item>
<item name="android:textColorHint">#888888</item>
</style>
</resources>
\ 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