IOS
hefeixia
2021-02-18 49f3c1374873f73dbde2983ca0fcf1fb10bfedbf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package cn.wildfire.chat.kit.contact.newfriend;
 
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.widget.LinearLayout;
import butterknife.BindView;
import cn.wildfire.chat.kit.R;
import cn.wildfire.chat.kit.R2;
import cn.wildfire.chat.kit.WfcBaseActivity;
import cn.wildfire.chat.kit.contact.model.PhoneDto;
import cn.wildfire.chat.kit.contact.model.SearchDoctorList;
import cn.wildfire.chat.kit.AppServices;
import cn.wildfire.chat.kit.net.BaseResultCallBack;
import cn.wildfire.chat.kit.utils.ThreadPool;
import cn.wildfire.chat.kit.widget.SearchView;
import cn.wildfirechat.model.FriendRequest;
import com.alibaba.fastjson.JSON;
 
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
 
public class AddressBookListActivity extends WfcBaseActivity {
 
    @BindView(R2.id.sv_seatch)
    SearchView mSvSeatch;
    @BindView(R2.id.ll_friend_container)
    LinearLayout mLlFriendContainer;
    @BindView(R2.id.ll_add_note)
    LinearLayout mLlAddNote;
    private FriendRequestListFragment friendRequestListFragment;
    private String TAG = "AddressBookListActivity";
    private List<PhoneDto> phoneRawList;
 
 
    @Override
    protected void afterViews() {
        Intent intent = getIntent();
 
        String data = intent.getStringExtra("data");
        if (TextUtils.isEmpty(data)) {
            return;
        }
        phoneRawList = JSON.parseArray(data, PhoneDto.class);
        getCheckDoctor();
 
        mLlAddNote.setVisibility(View.GONE);
        mLlFriendContainer.setVisibility(View.VISIBLE);
        mSvSeatch.setHint("医生姓名/手机号");
        mSvSeatch.setmActionListener(new SearchView.OnActionQueryListener() {
            @Override
            public void onQueryTextChange(String s) {
                if (friendRequestListFragment != null) {
                    friendRequestListFragment.refreshSearchData(s);
                }
            }
        });
    }
 
    private void getCheckDoctor() {
        if (phoneRawList == null) {
            return;
        }
        List<String> phoneList = new ArrayList<>();
        for (PhoneDto phoneDto : phoneRawList) {
            String telPhone = phoneDto.getTelPhone();
            if (TextUtils.isEmpty(telPhone)) {
                continue;
            }
            phoneList.add(telPhone);
        }
        AppServices.Instance().getDoctorListByPhone(phoneList, new BaseResultCallBack<SearchDoctorList>() {
            @Override
            public void onUiSuccess(SearchDoctorList searchDoctorList) {
                if (searchDoctorList == null) {
                    showEmpty();
                    return;
                }
                List<SearchDoctorList.DoctorParamVoListDTO> doctorParamETOList = searchDoctorList.getDoctorParamETOList();
                if (doctorParamETOList == null) {
                    showEmpty();
                    return;
                }
                ThreadPool.getInstance().getCachedPools().execute(new Runnable() {
                    @Override
                    public void run() {
                        List<FriendRequest> result= new ArrayList<>();
                        for (SearchDoctorList.DoctorParamVoListDTO doctorParamVoListDTO : doctorParamETOList) {
                            FriendRequest friendRequest = new FriendRequest();
                            friendRequest.portrait = doctorParamVoListDTO.getDoctorAvatar();
                            friendRequest.showName = doctorParamVoListDTO.getDoctorName();
                            friendRequest.target = doctorParamVoListDTO.getMedoDoctorId();
                            String doctorMobile = doctorParamVoListDTO.getDoctorMobile();
                            friendRequest.isRequest = false;
                            friendRequest.phone = doctorMobile;
                            friendRequest.subInfo = MessageFormat.format("{0} {1} {2}", doctorParamVoListDTO.getDoctorProfessional(), doctorParamVoListDTO.getMedoHospitalName(), doctorParamVoListDTO.getMediDiseaseClassifyName02());
                            for (PhoneDto phoneDto : phoneRawList) {
                                String telPhone = phoneDto.getTelPhone();
                                if (doctorMobile.trim().equalsIgnoreCase(telPhone.trim())) {
                                    friendRequest.reason = MessageFormat.format("手机联系人:{0}", phoneDto.getName());
                                }
                            }
                            result.add(friendRequest);
                        }
                        friendRequestListFragment = new FriendRequestListFragment();
                        Bundle bundle = new Bundle();
                        bundle.putBoolean("isContact", true);
                        bundle.putString("data", JSON.toJSONString(result));
                        friendRequestListFragment.setArguments(bundle);
                        getSupportFragmentManager().beginTransaction()
                                .replace(R.id.containerFrameLayout, friendRequestListFragment)
                                .commit();
                    }
                });
 
 
            }
 
 
            @Override
            public void onUiFailure(int code, String msg) {
 
            }
        });
    }
 
    private void showEmpty() {
    }
 
 
    @Override
    protected int contentLayout() {
        return R.layout.fragment_container_activity;
    }
 
    @Override
    protected int menu() {
        return R.menu.channel_list;
    }
 
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == R.id.more_common) {
            addContact();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
 
    void addContact() {
        Intent intent = new Intent(this, SearchUserActivity.class);
        startActivity(intent);
    }
 
 
}