|
@@ -1,5 +1,6 @@
|
|
|
package com.common.im.ui.contact;
|
|
|
|
|
|
+import android.os.Bundle;
|
|
|
import android.view.View;
|
|
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
@@ -22,7 +23,10 @@ import java.util.List;
|
|
|
* @author Ryan
|
|
|
* 类说明:
|
|
|
*/
|
|
|
-public class ContactListTabFragment extends BaseMVPFragment<FragmentContactListTabBinding, ContactListTabPresenter> implements View.OnClickListener {
|
|
|
+public class ContactListTabFragment extends BaseMVPFragment<FragmentContactListTabBinding, ContactListTabPresenter> implements View.OnClickListener {
|
|
|
+ private boolean isSelectContact = false;
|
|
|
+ public static final String IS_SELECT_CONTACT = "IS_SELECT_CONTACT";
|
|
|
+
|
|
|
@Override
|
|
|
protected FragmentContactListTabBinding getLayoutView() {
|
|
|
return FragmentContactListTabBinding.inflate(getLayoutInflater());
|
|
@@ -32,10 +36,14 @@ public class ContactListTabFragment extends BaseMVPFragment<FragmentContactList
|
|
|
protected ContactListTabPresenter createPresenter() {
|
|
|
return new ContactListTabPresenter();
|
|
|
}
|
|
|
+
|
|
|
private ViewPager viewPager;
|
|
|
|
|
|
@Override
|
|
|
protected void initView(View rootView) {
|
|
|
+ if (getArguments() != null) {
|
|
|
+ isSelectContact = getArguments().getBoolean(IS_SELECT_CONTACT, false);
|
|
|
+ }
|
|
|
viewPager = mViewBinding.viewpager;
|
|
|
mViewBinding.llRoom.setOnClickListener(this);
|
|
|
mViewBinding.llSingle.setOnClickListener(this);
|
|
@@ -48,9 +56,9 @@ public class ContactListTabFragment extends BaseMVPFragment<FragmentContactList
|
|
|
|
|
|
@Override
|
|
|
public void onPageSelected(int position) {
|
|
|
- if (position==0){
|
|
|
+ if (position == 0) {
|
|
|
selectSingle();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
selectRoom();
|
|
|
}
|
|
|
}
|
|
@@ -62,14 +70,14 @@ public class ContactListTabFragment extends BaseMVPFragment<FragmentContactList
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private void selectSingle(){
|
|
|
+ private void selectSingle() {
|
|
|
mViewBinding.imContactRoom.setBackgroundResource(R.drawable.icon_contact_room_normal);
|
|
|
mViewBinding.imContactSingle.setBackgroundResource(R.drawable.icon_contact_single_select);
|
|
|
mViewBinding.tvContactRoom.setTextColor(getResources().getColor(com.cooleshow.base.R.color.color_666666));
|
|
|
mViewBinding.tvContactSingle.setTextColor(getResources().getColor(com.cooleshow.base.R.color.color_2dc7aa));
|
|
|
}
|
|
|
|
|
|
- private void selectRoom(){
|
|
|
+ private void selectRoom() {
|
|
|
mViewBinding.imContactRoom.setBackgroundResource(R.drawable.icon_contact_room_select);
|
|
|
mViewBinding.imContactSingle.setBackgroundResource(R.drawable.icon_contact_single_normal);
|
|
|
mViewBinding.tvContactRoom.setTextColor(getResources().getColor(com.cooleshow.base.R.color.color_2dc7aa));
|
|
@@ -86,13 +94,16 @@ public class ContactListTabFragment extends BaseMVPFragment<FragmentContactList
|
|
|
|
|
|
private void initTabLayoutAndViewPager() {
|
|
|
fragments.clear();
|
|
|
- /* for (int i = 0; i < titles.size(); i++) {
|
|
|
- tabLayout.addTab(tabLayout.newTab().setText(titles.get(i)));
|
|
|
- Fragment adFragment = HomeWorkFragment.newInstance(auditStatusList.get(i));
|
|
|
- fragments.add(adFragment);
|
|
|
- }*/
|
|
|
- fragments.add(new ContactPersonListFragment());
|
|
|
- fragments.add(new ContactRoomListFragment());
|
|
|
+ ContactPersonListFragment contactPersonListFragment = new ContactPersonListFragment();
|
|
|
+ Bundle bundle = new Bundle();
|
|
|
+ bundle.putBoolean(IS_SELECT_CONTACT, isSelectContact);
|
|
|
+ contactPersonListFragment.setArguments(bundle);
|
|
|
+ fragments.add(contactPersonListFragment);
|
|
|
+ Bundle bundle2 = new Bundle();
|
|
|
+ bundle2.putBoolean(IS_SELECT_CONTACT, isSelectContact);
|
|
|
+ ContactRoomListFragment contactRoomListFragment = new ContactRoomListFragment();
|
|
|
+ contactRoomListFragment.setArguments(bundle2);
|
|
|
+ fragments.add(contactRoomListFragment);
|
|
|
|
|
|
viewPager.setAdapter(new ContactListTabPagerAdapter(getParentFragmentManager(), fragments, titles));
|
|
|
}
|
|
@@ -107,8 +118,8 @@ public class ContactListTabFragment extends BaseMVPFragment<FragmentContactList
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void refreshContactList(){
|
|
|
- if(fragments.size()>0) {
|
|
|
+ public void refreshContactList() {
|
|
|
+ if (fragments.size() > 0) {
|
|
|
ContactPersonListFragment fragment = (ContactPersonListFragment) fragments.get(0);
|
|
|
if (fragment != null) {
|
|
|
fragment.initData();
|