| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -5,19 +5,25 @@ package cc.winboll.studio.contacts.adapters;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 * @Date 2025/02/26 13:35:44
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 * @Describe ContactAdapter
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				 */
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.content.ClipData;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.content.ClipboardManager;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.content.Context;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.content.Intent;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.view.LayoutInflater;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.view.MenuItem;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.view.View;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.view.ViewGroup;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.widget.Button;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.widget.LinearLayout;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.widget.PopupMenu;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.widget.TextView;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import android.widget.Toast;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import androidx.annotation.NonNull;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import androidx.recyclerview.widget.RecyclerView;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cc.winboll.studio.contacts.R;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cc.winboll.studio.contacts.beans.ContactModel;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import com.hjq.toast.ToastUtils;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import java.util.List;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import cc.winboll.studio.libaes.views.AOHPCTCSeekBar;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactViewHolder> {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -26,8 +32,10 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactV
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    private static final int REQUEST_CALL_PHONE = 1;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    private List<ContactModel> contactList;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					Context mContext;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public ContactAdapter(List<ContactModel> contactList) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public ContactAdapter(Context context, List<ContactModel> contactList) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						mContext = context;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        this.contactList = contactList;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -41,6 +49,37 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactV
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    @Override
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public void onBindViewHolder(@NonNull ContactViewHolder holder, int position) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        final ContactModel contact = contactList.get(position);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						holder.llPhoneNumberMain.setOnLongClickListener(new View.OnLongClickListener() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								@Override
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								public boolean onLongClick(View p1) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									// 弹出复制菜单
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									PopupMenu menu = new PopupMenu(mContext, holder.llPhoneNumberMain);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									//加载菜单资源
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									menu.getMenuInflater().inflate(R.menu.toolbar_contact_phonenumber, menu.getMenu());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									//设置点击事件的响应
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
											@Override
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
											public boolean onMenuItemClick(MenuItem menuItem) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
												int nItemId = menuItem.getItemId();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
												if (nItemId == R.id.item_contact_phonenumber_copy) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
													// Gets a handle to the clipboard service.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
													ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
													// Creates a new text clip to put on the clipboard
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
													ClipData clip = ClipData.newPlainText("simple text", contact.getNumber());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
													// Set the clipboard's primary clip.
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
													clipboard.setPrimaryClip(clip);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
													Toast.makeText(mContext, "Copy to clipboard.", Toast.LENGTH_SHORT).show();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
												}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
												return true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
											}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
										});
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									//一定要调用show()来显示弹出式菜单
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									menu.show();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									return true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							});
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        holder.contactName.setText(contact.getName());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        holder.contactNumber.setText(contact.getNumber());
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -69,12 +108,14 @@ public class ContactAdapter extends RecyclerView.Adapter<ContactAdapter.ContactV
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    public class ContactViewHolder extends RecyclerView.ViewHolder {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						LinearLayout llPhoneNumberMain;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        TextView contactName;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        TextView contactNumber;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        AOHPCTCSeekBar dialAOHPCTCSeekBar;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public ContactViewHolder(@NonNull View itemView) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            super(itemView);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							llPhoneNumberMain = itemView.findViewById(R.id.itemcontactLinearLayout1);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            contactName = itemView.findViewById(R.id.contact_name);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            contactNumber = itemView.findViewById(R.id.contact_number);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            dialAOHPCTCSeekBar = itemView.findViewById(R.id.aohpctcseekbar_dial);
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				 
 |