我正在尝试将图像更新到服务器,而我具有aadharcard正面图像和背面图像。当我在那时更新此图像时,它没有更新就给出了旧图像。我也正在更新个人资料图片,但是它的更新效果很好,或者其他值也在更新,唯一的问题是aadhar卡图像
这是我的更新代码
public class UpdateProviderList extends AppCompatActivity implements RecyclerViewClickListener, RefreshData {
private int CAMERA_CODE = 101;
private int CROPING_CODE = 301;
private int GALLERY_CODE = CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE;
AlertDialog alertDialog;
AlertDialog alertDialog1;
AlertDialog.Builder alertDialogBuilder;
AlertDialog.Builder alertDialogBuilder1;
private Button btnFrontAadharBottomSheetAadhar;
private Button btn_back_aadhar_bottom_sheet_aadhar;
private int btn_id = 0;
private Button btn_pan_bottom_sheet;
private Button btn_submit_data;
private Button btn_upload_doc;
private DocumentAdapter documentAdapter;
private EditText et_choose_category, et_name, et_address;
private EditText et_doc_number;
private EditText et_enter_mobile;
private EditText et_select_document;
private FloatingActionButton fab_capture_image;
private File fileAadharBack = null;
private File fileAadharFront = null;
private File filePan = null;
private ImageView ivBackAadharBottomSheetAadhar;
private ImageView ivCloseBottomSheetPan;
private ImageView ivCloseSheetGalleryCamera;
private ImageView ivFrontAadharBottomSheetAadhar;
private ImageView ivPanBottomSheet;
private ImageView iv_guest_new_worker;
private LinearLayout ll_provider;
private BottomSheetBehavior mBottomSheetBehaviorAadhar;
private BottomSheetBehavior mBottomSheetBehaviorPan;
private Uri mImageCaptureUri;
private File outPutFile = null;
private RecyclerView recyclerView_exapndable;
private RadioGroup rg_gender;
private RecyclerView rv_documents;
private RecyclerView rv_service_provider;
private ServiceProviderAdapter serviceProviderAdapter;
private SharedPreferencesDatabase sharedPreferencesDatabase;
private String str_society_id = "";
private String str_staff_id = "", str_servicetypes = "", worker_emp_id = "", str_name = "";
private Toolbar toolbar_provider;
private TextView tv_name_doc;
private Spinner sp_gender;
private static final String[] GENDER = {"Select Gender", "Male", "Female"};
private ArrayAdapter<String> adapter;
private ProgressBar pb_add_data;
private boolean capture_image = false;
private boolean capture_image_document_pan = false;
private boolean capture_image_document1 = false;
private boolean capture_image_document2 = false;
public RefreshData refreshData;
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView((int) R.layout.update_provider_list);
toolbar_provider = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(this.toolbar_provider);
getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
sharedPreferencesDatabase = new SharedPreferencesDatabase(this);
sharedPreferencesDatabase.createDatabase();
if (sharedPreferencesDatabase != null) {
str_society_id = sharedPreferencesDatabase.getData(Config.LOGIN_SOCIETYID);
str_staff_id = sharedPreferencesDatabase.getData(Config.LOGIN_STAFF_ID);
}
toolbar_provider.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
getSupportActionBar().setTitle("Update Service Provider");
et_choose_category = (EditText) findViewById(R.id.et_choose_category);
et_address = (EditText) findViewById(R.id.et_address);
et_select_document = (EditText) findViewById(R.id.et_select_document);
et_doc_number = (EditText) findViewById(R.id.et_doc_number);
et_enter_mobile = (EditText) findViewById(R.id.et_enter_mobile);
et_name = (EditText) findViewById(R.id.et_name);
btn_upload_doc = (Button) findViewById(R.id.btn_upload_doc);
fab_capture_image = (FloatingActionButton) findViewById(R.id.fab_capture_image);
btn_submit_data = (Button) findViewById(R.id.btn_submit_data);
iv_guest_new_worker = (ImageView) findViewById(R.id.iv_guest_new_worker);
ll_provider = (LinearLayout) findViewById(R.id.ll_provider);
sp_gender = (Spinner) findViewById(R.id.sp_gender);
pb_add_data = (ProgressBar) findViewById(R.id.pb_update);
View bottomSheetAadhar = findViewById(R.id.bottom_sheet_aadhar_provider_registration);
btnFrontAadharBottomSheetAadhar = (Button) findViewById(R.id.btn_front_aadhar_bottom_sheet_aadhar);
btn_back_aadhar_bottom_sheet_aadhar = (Button) findViewById(R.id.btn_back_aadhar_bottom_sheet_aadhar);
mBottomSheetBehaviorAadhar = BottomSheetBehavior.from(bottomSheetAadhar);
mBottomSheetBehaviorAadhar = BottomSheetBehavior.from(bottomSheetAadhar);
mBottomSheetBehaviorAadhar.setState(BottomSheetBehavior.STATE_COLLAPSED);
mBottomSheetBehaviorAadhar.setPeekHeight(0);
Functions.setAdapterwithposition(UpdateProviderList.this, GENDER, sp_gender, "Select Gender");
View bottomSheet = findViewById(R.id.bottom_sheet_pan_provider_registration);
tv_name_doc = (TextView) bottomSheet.findViewById(R.id.tv_name_doc);
ivFrontAadharBottomSheetAadhar = (ImageView) findViewById(R.id.iv_front_aadhar_bottom_sheet_aadhar);
ivBackAadharBottomSheetAadhar = (ImageView) findViewById(R.id.iv_back_aadhar_bottom_sheet_aadhar);
btn_pan_bottom_sheet = (Button) findViewById(R.id.btn_pan_bottom_sheet);
ivPanBottomSheet = (ImageView) findViewById(R.id.iv_pan_bottom_sheet);
mBottomSheetBehaviorPan = BottomSheetBehavior.from(bottomSheet);
mBottomSheetBehaviorPan.setState(4);
mBottomSheetBehaviorPan.setPeekHeight(0);
ivCloseSheetGalleryCamera = (ImageView) findViewById(R.id.iv_close_sheet_gallery_camera);
ivCloseBottomSheetPan = (ImageView) findViewById(R.id.iv_close_bottom_sheet_pan);
mBottomSheetBehaviorPan = BottomSheetBehavior.from(bottomSheet);
mBottomSheetBehaviorPan.setState(BottomSheetBehavior.STATE_COLLAPSED);
mBottomSheetBehaviorPan.setPeekHeight(0);
//refreshData = (RefreshData) UpdateProviderList.this;
// refreshData = (RefreshData) UpdateProviderList.this;
et_choose_category.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
chooseCategory(UpdateProviderList.this);
}
});
et_select_document.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
choosDocument(UpdateProviderList.this);
}
});
btnFrontAadharBottomSheetAadhar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
btn_id = 1;
CropImage.activity().start(UpdateProviderList.this);
}
});
btn_back_aadhar_bottom_sheet_aadhar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
btn_id = 2;
CropImage.activity().start(UpdateProviderList.this);
}
});
fab_capture_image.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
btn_id = 4;
CropImage.activity().start(UpdateProviderList.this);
}
});
btn_upload_doc.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String s = et_select_document.getText().toString();
if (s.equals("Aadhar Card")) {
mBottomSheetBehaviorPan.setState(BottomSheetBehavior.STATE_COLLAPSED);
mBottomSheetBehaviorAadhar.setState(BottomSheetBehavior.STATE_EXPANDED);
} else {
mBottomSheetBehaviorAadhar.setState(BottomSheetBehavior.STATE_COLLAPSED);
mBottomSheetBehaviorPan.setState(BottomSheetBehavior.STATE_EXPANDED);
}
}
});
ivCloseSheetGalleryCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mBottomSheetBehaviorAadhar.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
});
ivCloseBottomSheetPan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mBottomSheetBehaviorPan.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
});
btn_pan_bottom_sheet.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
btn_id = 3;
CropImage.activity().start(UpdateProviderList.this);
}
});
Intent intent = getIntent();
if (intent != null) {
str_name = intent.getStringExtra("name");
if (str_name != null && !str_name.isEmpty() && !str_name.equals("null")) {
String profileimage = intent.getStringExtra("profileimage");
String address = intent.getStringExtra("address");
String mobile = intent.getStringExtra("mobile");
String document = intent.getStringExtra("document");
String document_number = intent.getStringExtra("document_number");
String gender = intent.getStringExtra("gender");
String document_img = intent.getStringExtra("document_img");
String service_name = intent.getStringExtra("service_name");
String serviceid = intent.getStringExtra("serviceid");
String document_img2 = intent.getStringExtra("document_img2");
worker_emp_id = intent.getStringExtra("emp_id");
str_servicetypes = serviceid;
et_name.setText(str_name);
et_enter_mobile.setText(mobile);
et_doc_number.setText(document_number);
Functions.setAdapterwithposition(UpdateProviderList.this, GENDER, sp_gender, gender);
et_address.setText(address);
et_select_document.setText(document);
et_choose_category.setText(service_name);
outPutFile = new File(profileimage);
filePan = new File(document_img);
if (document.equals("Aadhar Card")) {
fileAadharBack = new File(document_img2);
fileAadharFront = new File(document_img);
Picasso.get().load(document_img).networkPolicy(NetworkPolicy.NO_CACHE)
.memoryPolicy(MemoryPolicy.NO_CACHE).into(ivFrontAadharBottomSheetAadhar, new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(Exception e) {
}
});
Picasso.get().load(document_img2).networkPolicy(NetworkPolicy.NO_CACHE)
.memoryPolicy(MemoryPolicy.NO_CACHE).into(ivBackAadharBottomSheetAadhar, new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(Exception e) {
}
});
} else {
Picasso.get().load(document_img).networkPolicy(NetworkPolicy.NO_CACHE)
.memoryPolicy(MemoryPolicy.NO_CACHE).into(ivPanBottomSheet, new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(Exception e) {
}
});
}
Picasso.get().load(profileimage).networkPolicy(NetworkPolicy.NO_CACHE)
.memoryPolicy(MemoryPolicy.NO_CACHE).into(iv_guest_new_worker, new Callback() {
@Override
public void onSuccess() {
}
@Override
public void onError(Exception e) {
}
});
}
}
btn_submit_data.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String str_sp_gender = sp_gender.getSelectedItem().toString();
Pattern pattern = Pattern.compile("[A-Z]{5}[0-9]{4}[A-Z]{1}");
String s = et_select_document.getText().toString();
String str_et_enter_mobile = et_enter_mobile.getText().toString();
String str_doc_number = et_doc_number.getText().toString();
String str_doc_type = et_select_document.getText().toString();
String str_name = et_name.getText().toString();
String str_et_address = et_address.getText().toString();
Matcher matcher = pattern.matcher(et_doc_number.getText().toString());
if (TextUtils.isEmpty(et_name.getText().toString())) {
Functions.message(UpdateProviderList.this, "Enter Name", ll_provider);
} else if (TextUtils.isEmpty(et_address.getText().toString())) {
Functions.message(UpdateProviderList.this, "Enter Address", ll_provider);
} else if (TextUtils.isEmpty(et_choose_category.getText().toString())) {
Functions.message(UpdateProviderList.this, "Select Category", ll_provider);
} else if (TextUtils.isEmpty(et_enter_mobile.getText().toString())) {
Functions.message(UpdateProviderList.this, "Enter Mobile Number", ll_provider);
} else if (TextUtils.isEmpty(et_select_document.getText())) {
Functions.message(UpdateProviderList.this, "Select Document First", ll_provider);
} else if (et_enter_mobile.getText().length() < 10) {
Functions.message(UpdateProviderList.this, "Enter Valid Mobile Number", ll_provider);
} else if (outPutFile == null) {
Functions.message(UpdateProviderList.this, "Upload Profile Photo", ll_provider);
} else if (s.equals("Aadhar Card")) {
et_doc_number.setInputType(InputType.TYPE_CLASS_NUMBER);
if (fileAadharFront == null) {
Functions.message(UpdateProviderList.this, "Upload Aadhar Front", ll_provider);
} else if (fileAadharBack == null) {
Functions.message(UpdateProviderList.this, "Upload Aadhar Back", ll_provider);
} else if (TextUtils.isEmpty(et_doc_number.getText().toString())) {
Functions.message(UpdateProviderList.this, "Enter Document Number", ll_provider);
} else if (et_doc_number.length() < 12) {
Functions.message(UpdateProviderList.this, "Enter Valid Aadhar Number", ll_provider);
} else if (str_sp_gender.equals("Select Gender")) {
Functions.message(UpdateProviderList.this, "Select Gender", ll_provider);
} else {
addData(str_staff_id, str_society_id, str_et_enter_mobile, str_name, str_sp_gender, str_servicetypes, str_doc_type, str_doc_number, str_et_address);
}
} else if (s.equals("PAN Card")) {
et_doc_number.setInputType(InputType.TYPE_CLASS_TEXT);
if (filePan == null) {
Functions.message(UpdateProviderList.this, "Upload Pan", ll_provider);
} else if (TextUtils.isEmpty(et_doc_number.getText().toString())) {
Functions.message(UpdateProviderList.this, "Enter Document Number", ll_provider);
} else if (!matcher.matches()) {
Functions.message(UpdateProviderList.this, "Enter Valid Pan Number", ll_provider);
} else if (str_sp_gender.equals("Select Gender")) {
Functions.message(UpdateProviderList.this, "Select Gender", ll_provider);
} else {
addData(str_staff_id, str_society_id, str_et_enter_mobile, str_name, str_sp_gender, str_servicetypes, str_doc_type, str_doc_number, str_et_address);
}
} else if (filePan == null) {
Functions.message(UpdateProviderList.this, "Upload Document", ll_provider);
} else if (TextUtils.isEmpty(et_doc_number.getText().toString())) {
Functions.message(UpdateProviderList.this, "Enter Document Number", ll_provider);
} else if (str_sp_gender.equals("Select Gender")) {
Functions.message(UpdateProviderList.this, "Select Gender", ll_provider);
} else {
addData(str_staff_id, str_society_id, str_et_enter_mobile, str_name, str_sp_gender, str_servicetypes, str_doc_type, str_doc_number, str_et_address);
}
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
if (resultCode == RESULT_OK) {
Uri resultUri = result.getUri();
if (btn_id == 1) {
fileAadharFront = new File(resultUri.getPath());
Picasso.get().load(fileAadharFront).networkPolicy(NetworkPolicy.NO_CACHE)
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE).into(ivFrontAadharBottomSheetAadhar);
capture_image_document1 = true;
if (fileAadharFront != null && fileAadharBack != null) {
mBottomSheetBehaviorAadhar.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
} else if (btn_id == 2) {
fileAadharBack = new File(resultUri.getPath());
capture_image_document2 = true;
Picasso.get().load(fileAadharBack).networkPolicy(NetworkPolicy.NO_CACHE)
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE).into(ivBackAadharBottomSheetAadhar);
if (fileAadharFront != null && fileAadharBack != null) {
mBottomSheetBehaviorAadhar.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
} else if (btn_id == 3) {
filePan = new File(resultUri.getPath());
capture_image_document_pan = true;
Picasso.get().load(filePan).networkPolicy(NetworkPolicy.NO_CACHE)
.memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE).into(ivPanBottomSheet);
if (filePan != null) {
mBottomSheetBehaviorPan.setState(BottomSheetBehavior.STATE_COLLAPSED);
}
} else if (btn_id == 4) {
capture_image = true;
outPutFile = new File(resultUri.getPath());
Picasso.get().load(this.outPutFile).memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE).into(iv_guest_new_worker);
}
} else if (resultCode == CropImage.CROP_IMAGE_ACTIVITY_RESULT_ERROR_CODE) {
Exception error = result.getError();
Toast.makeText(UpdateProviderList.this, error.getMessage(), Toast.LENGTH_SHORT).show();
}
}
}
private void addData(String staff_id, String society_id, String mobile_no, String name, String gender, String service_type_id, String document_type, String document_no, String address) {
btnVisiblity(false, pb_add_data, btn_submit_data);
if (capture_image == false) {
outPutFile = null;
}
if (capture_image_document2 == false) {
fileAadharBack = null;
}
if (capture_image_document1 == false) {
fileAadharFront = null;
}
if (capture_image_document_pan == false) {
filePan = null;
}
if (document_type.equals("Aadhar Card")) {
filePan = fileAadharFront;
}
//userid:1
AndroidNetworking.upload(Config.update_workeremp)
.addMultipartParameter("staff_id", staff_id)
.addMultipartParameter("society_id", society_id)
.addMultipartFile("document", filePan)
.addMultipartFile("document2", fileAadharBack)
.addMultipartFile("image", outPutFile)
.addMultipartParameter("mobile_no", mobile_no)
.addMultipartParameter("name", name)
.addMultipartParameter("address", address)
.addMultipartParameter("gender", gender)
.addMultipartParameter("service_type_id", service_type_id)
.addMultipartParameter("document_type", document_type)
.addMultipartParameter("document_no", document_no)
.addMultipartParameter("worker_emp_id", worker_emp_id)
.setPriority(Priority.MEDIUM)
.build()
.getAsJSONObject(new JSONObjectRequestListener() {
@Override
public void onResponse(JSONObject response) {
try {
if (response.has("status") && response.getString("status").equals("1")) {
Toast.makeText(UpdateProviderList.this, "Updated Successfully", Toast.LENGTH_SHORT).show();
Intent i = new Intent(UpdateProviderList.this, UpdateProvider.class);
startActivityForResult(i, 1);
// refreshData.Update();
finish();
} else {
String msg = response.get("msg").toString();
Snackbar.make(ll_provider, msg, Snackbar.LENGTH_SHORT).show();
}
btnVisiblity(true, pb_add_data, btn_submit_data);
} catch (Exception e) {
Snackbar.make(ll_provider, e.getMessage(), Snackbar.LENGTH_SHORT).show();
btnVisiblity(true, pb_add_data, btn_submit_data);
}
}
@Override
public void onError(ANError anError) {
if (TextUtils.equals("connectionError", anError.getErrorDetail())) {
Snackbar.make(ll_provider, "No Internet Connection", Snackbar.LENGTH_SHORT).show();
} else {
Snackbar.make(ll_provider, "" + anError.getErrorDetail().toString(), Snackbar.LENGTH_SHORT).show();
}
btnVisiblity(true, pb_add_data, btn_submit_data);
}
});
}
public void btnVisiblity(boolean status, ProgressBar pb_bar, Button btn_submit) {
if (status) {
pb_bar.setVisibility(View.GONE);
btn_submit.setVisibility(View.VISIBLE);
} else {
pb_bar.setVisibility(View.VISIBLE);
btn_submit.setVisibility(View.GONE);
}
}
@Override
public void Update() {
}
}