Code review changes

This commit is contained in:
Gabriel Calero 2018-05-18 19:43:41 -03:00
parent 85cff19020
commit 054e6041af

View file

@ -53,23 +53,23 @@ public class DomainAdapter extends RecyclerView.Adapter<DomainAdapter.ViewHolder
domainProvider.retrieve(filterText, new DomainProvider.DomainCallback() { domainProvider.retrieve(filterText, new DomainProvider.DomainCallback() {
@Override @Override
public void retrieveOk(List<Domain> domain) { public void retrieveOk(List<Domain> domain) {
Domain lastVisitedDomain = new Domain(mContext.getString(R.string.your_last_location), mLastLocation, DEFAULT_THUMBNAIL_PLACE); if (filterText.length() == 0) {
if (!mLastLocation.isEmpty() && mLastLocation.contains("://")) { Domain lastVisitedDomain = new Domain(mContext.getString(R.string.your_last_location), mLastLocation, DEFAULT_THUMBNAIL_PLACE);
int startIndex = mLastLocation.indexOf("://"); if (!mLastLocation.isEmpty() && mLastLocation.contains("://")) {
int endIndex = mLastLocation.indexOf("/", startIndex + 3); int startIndex = mLastLocation.indexOf("://");
String toSearch = mLastLocation.substring(0, endIndex + 1).toLowerCase(); int endIndex = mLastLocation.indexOf("/", startIndex + 3);
for (Domain d : domain) { String toSearch = mLastLocation.substring(0, endIndex + 1).toLowerCase();
if (d.url.toLowerCase().startsWith(toSearch)) { for (Domain d : domain) {
lastVisitedDomain.thumbnail = d.thumbnail; if (d.url.toLowerCase().startsWith(toSearch)) {
lastVisitedDomain.thumbnail = d.thumbnail;
}
} }
} }
}
if (filterText.length() == 0) {
domain.add(0, lastVisitedDomain); domain.add(0, lastVisitedDomain);
} }
for (Domain d : domain) { for (Domain d : domain) {
// we override the default picture added in the server by an android specific version
if (d.thumbnail != null && if (d.thumbnail != null &&
d.thumbnail.endsWith("assets/places/thumbnail-default-place-e5a3f33e773ab699495774990a562f9f7693dc48ef90d8be6985c645a0280f75.png")) { d.thumbnail.endsWith("assets/places/thumbnail-default-place-e5a3f33e773ab699495774990a562f9f7693dc48ef90d8be6985c645a0280f75.png")) {
d.thumbnail = DEFAULT_THUMBNAIL_PLACE; d.thumbnail = DEFAULT_THUMBNAIL_PLACE;