use of net.iGap.adapter.payment.ChargeContactNumberAdapter in project iGap-Android by KianIranian-STDG.
the class ChargeFragment method contactButtonClicked.
private View.OnClickListener contactButtonClicked() {
return v -> {
hideKeyboard();
progressBar.setVisibility(View.VISIBLE);
closeKeyboard(editTextNumber);
try {
HelperPermission.getContactPermision(getActivity(), new OnGetPermission() {
@Override
public void Allow() {
ChargeContactNumberAdapter adapter = new ChargeContactNumberAdapter();
contactButton.setEnabled(false);
PhoneContactProvider.getInstance().getAllPhoneContactForPayment(contactNumbers -> {
if (getContext() == null) {
return;
}
contactButton.setEnabled(true);
progressBar.setVisibility(View.GONE);
if (contactNumbers.size() == 0) {
HelperError.showSnackMessage(getResources().getString(R.string.no_number_found), false);
} else {
adapter.setContactNumbers(contactNumbers);
MaterialDialog dialog = new MaterialDialog.Builder(getContext()).customView(R.layout.popup_paymet_contact, false).build();
View contactDialogView = dialog.getCustomView();
if (contactDialogView != null) {
RecyclerView contactRecyclerView = contactDialogView.findViewById(R.id.rv_contact);
EditText editText = contactDialogView.findViewById(R.id.etSearch);
setDialogBackground(contactRecyclerView);
setDialogBackground(editText);
contactRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
contactRecyclerView.setAdapter(adapter);
adapter.setOnItemClickListener(position -> {
contactPositionClicked = position;
onContactItemClicked(adapter);
dialog.dismiss();
});
ChargeContactNumberAdapter adapterContactNumber = (ChargeContactNumberAdapter) contactRecyclerView.getAdapter();
if (textWatcher != null)
editText.removeTextChangedListener(textWatcher);
textWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (adapterContactNumber != null)
adapterContactNumber.search(s.toString());
}
@Override
public void afterTextChanged(Editable s) {
}
};
editText.addTextChangedListener(textWatcher);
contactDialogView.findViewById(R.id.closeView).setOnClickListener(v12 -> dialog.dismiss());
}
dialog.show();
}
});
}
@Override
public void deny() {
progressBar.setVisibility(View.GONE);
showDeniedPermissionMessage(G.context.getString(R.string.permission_contact));
}
});
} catch (IOException e) {
e.printStackTrace();
}
};
}
use of net.iGap.adapter.payment.ChargeContactNumberAdapter in project iGap-Android by KianIranian-STDG.
the class InternetFragment method onContactNumberButtonClick.
private void onContactNumberButtonClick() {
progressBar.setVisibility(View.VISIBLE);
frameContact.setEnabled(false);
closeKeyboard(editTextNumber);
try {
HelperPermission.getContactPermision(getActivity(), new OnGetPermission() {
@Override
public void Allow() {
ChargeContactNumberAdapter adapterContact = new ChargeContactNumberAdapter();
PhoneContactProvider.getInstance().getAllPhoneContactForPayment(contactNumbers -> {
if (getContext() == null) {
return;
}
frameContact.setEnabled(true);
progressBar.setVisibility(View.GONE);
if (contactNumbers.size() == 0) {
HelperError.showSnackMessage(getActivity().getString(R.string.no_number_found), false);
} else {
adapterContact.setContactNumbers(contactNumbers);
MaterialDialog dialog = new MaterialDialog.Builder(getContext()).customView(R.layout.popup_paymet_contact, false).build();
View contactDialogView = dialog.getCustomView();
if (contactDialogView != null) {
RecyclerView contactRecyclerView = contactDialogView.findViewById(R.id.rv_contact);
EditText editText = contactDialogView.findViewById(R.id.etSearch);
setDialogBackground(contactRecyclerView);
setDialogBackground(editText);
contactRecyclerView.setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false));
adapterContact.setOnItemClickListener(position -> {
clickedPosition = position;
onContactClicked(adapterContact);
dialog.dismiss();
});
contactRecyclerView.setAdapter(adapterContact);
if (watcher != null)
editText.removeTextChangedListener(watcher);
watcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s != null)
adapterContact.search(s.toString());
}
@Override
public void afterTextChanged(Editable s) {
}
};
editText.addTextChangedListener(watcher);
contactDialogView.findViewById(R.id.closeView).setOnClickListener(v12 -> dialog.dismiss());
}
dialog.show();
}
});
}
@Override
public void deny() {
progressBar.setVisibility(View.GONE);
showDeniedPermissionMessage(G.context.getString(R.string.permission_contact));
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations