use of in.testpress.testpress.util.FormatDate in project android by testpress.
the class ProfileDetailsActivity method validate.
private boolean validate() {
// Email Validation
if (email.getText().toString().trim().length() == 0) {
email.setError("This is a required field");
email.requestFocus();
return false;
} else if (!android.util.Patterns.EMAIL_ADDRESS.matcher(email.getText().toString().trim()).matches()) {
email.setError("Please enter a valid Email address");
email.requestFocus();
return false;
}
// Phone number Validation
if (phone.getText().toString().trim().length() == 0) {
phone.setError("This is a required field");
phone.requestFocus();
return false;
} else {
Pattern phoneNumberPattern = Pattern.compile("\\d{10}");
Matcher phoneNumberMatcher = phoneNumberPattern.matcher(phone.getText().toString().trim());
if (!phoneNumberMatcher.matches()) {
phone.setError("This field may contain only 10 digit valid Mobile Numbers");
phone.requestFocus();
return false;
}
}
// Date Of Birth Validation
if (dateOfBirth.getText().toString().trim().length() != 0) {
FormatDate formatDate = new FormatDate();
if (!formatDate.isDateValid(dateOfBirth.getText().toString().trim())) {
dateOfBirth.setError("Date is invalid or wrong format. Use YYYY-MM-DD");
dateOfBirth.requestFocus();
return false;
}
}
// pin code verification
if (dateOfBirth.getText().toString().trim().length() != 0 && pinCode.getText().toString().trim().length() != 6) {
pinCode.setError("Enter 6 digit valid pin number");
pinCode.requestFocus();
return false;
}
return true;
}
use of in.testpress.testpress.util.FormatDate in project android by testpress.
the class ProductDetailsActivity method onLoadFinished.
public void onLoadFinished(final Loader<ProductDetails> loader, final ProductDetails productDetails) {
if (productDetails == null) {
// noinspection ThrowableResultOfMethodCallIgnored
Exception exception = ((ThrowableLoader<ProductDetails>) loader).clearException();
exception.printStackTrace();
if (exception.getMessage() != null && exception.getMessage().equals("404 NOT FOUND")) {
gotoMainActivity();
} else if (exception.getCause() instanceof IOException) {
setEmptyText(R.string.network_error, R.string.no_internet_try_again, R.drawable.ic_error_outline_black_18dp);
} else {
setEmptyText(R.string.error_loading_products, R.string.try_after_sometime, R.drawable.ic_error_outline_black_18dp);
}
progressBar.setVisibility(View.GONE);
return;
}
progressBar.setVisibility(View.GONE);
productDetailsView.setVisibility(View.VISIBLE);
FormatDate date = new FormatDate();
ImageLoader imageLoader = ImageLoader.getInstance();
DisplayImageOptions options = new DisplayImageOptions.Builder().cacheInMemory(true).cacheOnDisc(true).resetViewBeforeLoading(true).showImageForEmptyUri(R.drawable.icon).showImageOnFail(R.drawable.icon).showImageOnLoading(R.drawable.icon).build();
// download and display image from url
imageLoader.displayImage(productDetails.getImages()[0].getOriginal(), image, options);
titleText.setText(productDetails.getTitle());
try {
if (Float.parseFloat(productDetails.getPrice()) == 0) {
buyButton.setText("Start Now - Free");
}
} catch (Exception e) {
}
if (productDetails.getExams().size() != 0) {
totalExams.setText(productDetails.getExams().size() + " Exams");
totalExamsContainer.setVisibility(View.VISIBLE);
} else {
totalExamsContainer.setVisibility(View.GONE);
}
if (productDetails.getNotes().size() != 0) {
totalNotes.setText(productDetails.getNotes().size() + " Documents");
totalNotesContainer.setVisibility(View.VISIBLE);
} else {
totalNotesContainer.setVisibility(View.GONE);
}
if (date.getDate(productDetails.getStartDate(), productDetails.getEndDate()) != null) {
dateText.setVisibility(View.VISIBLE);
dateText.setText(date.getDate(productDetails.getStartDate(), productDetails.getEndDate()));
}
// Price & Categories
String categories = Arrays.toString(productDetails.getCategories().toArray());
categoriesText.setText(categories.substring(1, categories.length() - 1));
priceText.setText(productDetails.getPrice());
// Update product description
if (productDetails.getDescription().isEmpty()) {
descriptionContainer.setVisibility(View.GONE);
} else {
descriptionContainer.setVisibility(View.VISIBLE);
Spanned html = Html.fromHtml(productDetails.getDescription(), new UILImageGetter(descriptionText, this), null);
ZoomableImageString zoomableImageHtml = new ZoomableImageString(this);
descriptionText.setText(zoomableImageHtml.convertString(html), TextView.BufferType.SPANNABLE);
descriptionText.setMovementMethod(LinkMovementMethod.getInstance());
descriptionText.setVisibility(View.VISIBLE);
}
// Update exams list
if (productDetails.getExams().isEmpty()) {
examsListContainer.setVisibility(View.GONE);
} else {
examsListContainer.setVisibility(View.VISIBLE);
examsListView.setFocusable(false);
examsListView.setAdapter(new ProductExamsAdapter(this.getApplicationContext(), productDetails.getExams()));
setListViewHeightBasedOnChildren(examsListView);
}
// Update notes list
if (productDetails.getNotes().isEmpty()) {
notesListContainer.setVisibility(View.GONE);
} else {
notesListContainer.setVisibility(View.VISIBLE);
notesListView.setFocusable(false);
notesListView.setAdapter(new NotesListAdapter(this.getLayoutInflater(), productDetails.getNotes(), R.layout.product_notes_list_item));
setListViewHeightBasedOnChildren(notesListView);
}
this.productDetails = productDetails;
}
use of in.testpress.testpress.util.FormatDate in project android by testpress.
the class OrdersListAdapter method update.
@Override
protected void update(final int position, final Order item) {
if (item.getOrderItems().size() != 0)
setText(0, item.getOrderItems().get(0).getProduct().split("/")[6]);
setText(1, "OrderId: " + item.getOrderId());
setText(2, "Status: " + item.getStatus());
FormatDate date = new FormatDate();
setText(3, date.formatDateTime(item.getDate()));
setText(4, "₹ " + item.getAmount());
}
Aggregations