use of retrofit.RetrofitError in project glasquare by davidvavra.
the class CheckInActivity method addPhoto.
private void addPhoto() {
String checkInId = mCheckInResponse.getCheckInId();
TypedFile typedFile = new TypedFile("image/jpeg", mPhoto);
Api.get().create(Photos.class).add(checkInId, typedFile, new Callback<Photos.PhotoAddResponse>() {
@Override
public void success(Photos.PhotoAddResponse photoAddResponse, Response response) {
showCheckInComplete();
}
@Override
public void failure(RetrofitError retrofitError) {
showCheckInComplete();
}
});
}
use of retrofit.RetrofitError in project glasquare by davidvavra.
the class VenueListActivity method searchVenues.
private void searchVenues(String ll) {
Callback<ExploreVenues.ExploreVenuesResponse> callback = new Callback<ExploreVenues.ExploreVenuesResponse>() {
@Override
public void success(ExploreVenues.ExploreVenuesResponse exploreVenuesResponse, Response response) {
if (exploreVenuesResponse.getVenues().size() == 0) {
showError(R.string.no_venues_found);
} else {
showContent(new VenuesAdapter(exploreVenuesResponse.getVenues()), new CardSelectedListener() {
@Override
public void onCardSelected(Object item) {
mSelectedVenue = (ExploreVenues.Venue) item;
openOptionsMenu();
}
});
}
}
@Override
public void failure(RetrofitError retrofitError) {
showError(R.string.error_please_try_again);
DebugLog.e(retrofitError);
}
};
int type = getIntent().getIntExtra(EXTRA_TYPE, TYPE_EXPLORE);
switch(type) {
case TYPE_EXPLORE:
Api.get().create(ExploreVenues.class).best(ll, callback);
break;
case TYPE_SEARCH:
String query = getIntent().getStringExtra(EXTRA_QUERY);
Api.get().create(ExploreVenues.class).search(ll, query, callback);
break;
}
}
use of retrofit.RetrofitError in project cw-omnibus by commonsguy.
the class QuestionsFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setLayoutManager(new LinearLayoutManager(getActivity()));
so.questions("android", new Callback<SOQuestions>() {
@Override
public void success(SOQuestions results, Response response) {
for (Item item : results.items) {
Question question = new Question(item);
questions.add(question);
questionMap.put(question.id, question);
}
setAdapter(new QuestionsAdapter(questions));
}
@Override
public void failure(RetrofitError error) {
onError(error);
}
});
}
use of retrofit.RetrofitError in project glasquare by davidvavra.
the class CheckInActivity method checkIn.
private void checkIn() {
final String venueId = getIntent().getStringExtra(EXTRA_VENUE_ID);
final Location location = LocationUtils.getLastLocation();
final String ll = LocationUtils.getLatLon(location);
int accuracy = (int) location.getAccuracy();
int altitude = (int) location.getAltitude();
showProgress(R.string.checking_in);
showCheckInInfo();
String broadcast = getBroadcast();
Api.get().create(CheckIns.class).add(venueId, ll, mShout, broadcast, accuracy, altitude, new Callback<CheckIns.CheckInResponse>() {
@Override
public void success(final CheckIns.CheckInResponse checkInResponse, Response response) {
mCheckInResponse = checkInResponse;
if (mAddingPhoto) {
ImageUtils.processPictureWhenReady(CheckInActivity.this, mPhoto, new ImageUtils.OnPictureReadyListener() {
@Override
public void onPictureReady() {
new BaseAsyncTask() {
@Override
public void inBackground() {
ImageUtils.resize(mPhoto);
}
@Override
public void postExecute() {
addPhoto();
}
}.start();
}
});
} else {
showCheckInComplete();
}
}
@Override
public void failure(RetrofitError retrofitError) {
if (!Auth.handle(CheckInActivity.this, retrofitError)) {
showError(R.string.error_please_try_again);
}
}
});
}
use of retrofit.RetrofitError in project glasquare by davidvavra.
the class CheckInSearchActivity method loadData.
@Override
protected void loadData() {
showProgress(R.string.loading);
LocationUtils.getRecentLocation(new LocationUtils.LocationListener() {
@Override
public void onLocationAcquired(Location location) {
String ll = LocationUtils.getLatLon(location);
Api.get().create(SearchVenues.class).searchForCheckIn(ll, new Callback<SearchVenues.SearchResponse>() {
@Override
public void success(SearchVenues.SearchResponse venuesResponse, Response response) {
showContent(new CheckInSearchAdapter(venuesResponse.getVenues()), new CardSelectedListener() {
@Override
public void onCardSelected(Object item) {
SearchVenues.Venue venue = (SearchVenues.Venue) item;
CheckInActivity.call(CheckInSearchActivity.this, venue.id, venue.name);
}
});
}
@Override
public void failure(RetrofitError retrofitError) {
showError(R.string.error_please_try_again);
}
});
}
@Override
public void onLocationFailed() {
showError(R.string.no_location);
}
});
}
Aggregations