@Override
    protected CommonWeather doInBackground(Void... params) {
      try {
        weathersCall =
            weatherDAO.getOpenWeatherForecast(userLocation, getString(R.string.openweather_key));
        forecastIOCall =
            weatherDAO.getForecastIOForecast(userLocation, getString(R.string.forecastio_key));
        wundergroundCall =
            weatherDAO.getWundergroundForecast(userLocation, getString(R.string.wunderground_key));
        weathersCall.enqueue(openWeatherCallback);
        forecastIOCall.enqueue(forecastIOCallback);
        wundergroundCall.enqueue(wundergroundCallback);
        while (!openWeatherRequested || !forecastIORequested || !wundergroundRequested) {
          Thread.sleep(10);
        }
        if (openWeatherForecasts != null)
          agregator.addNewForecastsSource(openWeatherForecasts.convertToCommonWeather());
        if (forecastIOForecasts != null)
          agregator.addNewForecastsSource(forecastIOForecasts.convertToCommonWeather());
        if (wundergroundForecasts != null)
          agregator.addNewForecastsSource(wundergroundForecasts.convertToCommonWeather());
        return agregator.agregate();
      } catch (Exception e) {
        e.printStackTrace();
      }

      return null;
    }
  /**
   * ###################################################################################
   * ************************************ On Click **************************************
   * ###################################################################################
   */
  public void onClick(View v) {
    Bundle extra = getIntent().getExtras();

    switch (v.getId()) {
      case R.id.btn_customer_tracking_details_order_received:
        cart.setInvoice_ID(extra.getInt("Invoice_ID"));

        Call<Cart> reg = apiService.customerReceivedOrder(cart);

        reg.enqueue(
            new Callback<Cart>() {
              @Override
              public void onResponse(Response<Cart> response, Retrofit retrofit) {
                if (response.message().equalsIgnoreCase("ok")) {
                  Toast.makeText(
                          getBaseContext(), "Your Order is Delivered To You", Toast.LENGTH_LONG)
                      .show();
                  finish();
                }
              }

              @Override
              public void onFailure(Throwable t) {

                Toast.makeText(
                        getBaseContext(),
                        " Oops! An error occurred  + The Throwable is " + t.getMessage().toString(),
                        Toast.LENGTH_LONG)
                    .show();
              }
            });
        break;
    }
  }
  public static void signin(
      String username,
      String password,
      String authToken,
      final PlexHttpUserHandler responseHandler) {
    PlexHttpService service = getService("https://plex.tv", username, password, false);
    Call<PlexUser> call =
        service.signin("Android", VoiceControlForPlexApplication.getUUID(), authToken);
    call.enqueue(
        new Callback<PlexUser>() {
          @Override
          public void onResponse(Response<PlexUser> response) {
            if (response.code() == 200) responseHandler.onSuccess(response.body());
            else if (response.code() == 401) {
              responseHandler.onFailure(response.code());
            }
          }

          @Override
          public void onFailure(Throwable t) {
            t.printStackTrace();
            responseHandler.onFailure(0);
          }
        });
  }
  @Override
  public void onResume() {
    super.onResume();

    Call<HomeFeedResponse> timelineResponseCall =
        ApiManager.getInstance().getService().getHomeFeed();
    timelineResponseCall.enqueue(
        new Callback<HomeFeedResponse>() {
          @Override
          public void onResponse(Response<HomeFeedResponse> response, Retrofit retrofit) {
            if (response.isSuccess()) {
              if (response.body().getHomeFeedOneModel() != null) {
                populateRecycler(response.body().getHomeFeedOneModel());
              } else {
                NotesHelpers.toastMessage(
                    context, getResources().getString(R.string.error_something_is_wrong));
              }
            }
          }

          @Override
          public void onFailure(Throwable t) {
            NotesHelpers.toastMessage(
                context, getResources().getString(R.string.error_something_is_wrong));
          }
        });
  }
  public static void createArtistPlayQueue(
      Connection connection, PlexDirectory artist, final PlexPlayQueueHandler responseHandler) {
    Map qs = new HashMap<>();
    qs.put("type", "audio");
    qs.put("shuffle", "1");
    String uri =
        String.format(
            "library://%s/item/%%2flibrary%%2fmetadata%%2f%s",
            artist.server.machineIdentifier, artist.ratingKey);
    Logger.d("URI: %s", uri);
    qs.put("uri", uri);
    if (artist.server.accessToken != null)
      qs.put(PlexHeaders.XPlexToken, artist.server.accessToken);
    qs.put("continuous", "0");
    qs.put("includeRelated", "1");
    PlexHttpService service =
        getService(String.format("http://%s:%s", connection.address, connection.port));
    Call<MediaContainer> call =
        service.createPlayQueue(qs, VoiceControlForPlexApplication.getUUID());
    call.enqueue(
        new Callback<MediaContainer>() {
          @Override
          public void onResponse(Response<MediaContainer> response) {
            if (responseHandler != null) responseHandler.onSuccess(response.body());
          }

          @Override
          public void onFailure(Throwable t) {
            Logger.d("createPlayQueue failure.");
            t.printStackTrace();
          }
        });
  }
  public static void subscribe(
      PlexClient client,
      int subscriptionPort,
      int commandId,
      String uuid,
      String deviceName,
      final PlexHttpResponseHandler responseHandler) {
    String url = String.format("http://%s:%s", client.address, client.port);
    Logger.d("Subscribing at url %s", url);
    PlexHttpService service = getService(url, true);

    Call<PlexResponse> call = service.subscribe(uuid, deviceName, subscriptionPort, commandId);
    call.enqueue(
        new Callback<PlexResponse>() {
          @Override
          public void onResponse(Response<PlexResponse> response) {
            Logger.d("Subscribe code: %d", response.code());
            if (responseHandler != null) {
              if (response.code() == 200) responseHandler.onSuccess(response.body());
              else responseHandler.onFailure(new Throwable());
            }
          }

          @Override
          public void onFailure(Throwable t) {
            Logger.d("subscribe onFailure:");
            PlexResponse response = new PlexResponse();
            response.status = "ok";
            if (responseHandler != null) responseHandler.onSuccess(response);
            t.printStackTrace();
            if (responseHandler != null) responseHandler.onFailure(t);
          }
        });
  }
Beispiel #7
0
  /**
   * Load nearby place from Google Place with type Create list of markers on the map
   *
   * @param type
   */
  private void createMarker(String type) {
    final ProgressDialog progressDialog = new ProgressDialog(this);
    progressDialog.setMessage("Loading " + type + "...");
    progressDialog.setProgressStyle(R.style.ProgressBar);
    progressDialog.setIndeterminate(true);
    progressDialog.show();

    getLastLocation();
    if (mLastLocation != null) {
      mCall =
          mPlaceSearchService.loadPlaceSearchResults(
              getResources().getString(R.string.google_web_service_key),
              convertLocationToString(mLastLocation.getLatitude(), mLastLocation.getLongitude()),
              "1000",
              type);
      mCall.enqueue(
          new Callback<Data>() {

            @Override
            public void onResponse(Response<Data> response, Retrofit retrofit) {
              addListMakerToMap(response.body().getPlaceSearchResults());
              progressDialog.dismiss();
            }

            @Override
            public void onFailure(Throwable t) {}
          });
    } else {
      Snackbar.make(mCoordinator, "Can not find your location", Snackbar.LENGTH_LONG).show();
      progressDialog.dismiss();
    }
  }
Beispiel #8
0
 /**
  * Upload file.
  *
  * @param fileContent File to upload.
  * @param fileName File name to upload. Name has to be spelled exactly as written here.
  * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
  * @return the {@link Call} object
  */
 public Call<ResponseBody> uploadFileAsync(
     InputStream fileContent,
     String fileName,
     final ServiceCallback<InputStream> serviceCallback) {
   if (fileContent == null) {
     serviceCallback.failure(
         new IllegalArgumentException("Parameter fileContent is required and cannot be null."));
     return null;
   }
   if (fileName == null) {
     serviceCallback.failure(
         new IllegalArgumentException("Parameter fileName is required and cannot be null."));
     return null;
   }
   Call<ResponseBody> call = service.uploadFile(fileContent, fileName);
   call.enqueue(
       new ServiceResponseCallback<InputStream>(serviceCallback) {
         @Override
         public void onResponse(Response<ResponseBody> response, Retrofit retrofit) {
           try {
             serviceCallback.success(uploadFileDelegate(response, retrofit));
           } catch (ServiceException | IOException exception) {
             serviceCallback.failure(exception);
           }
         }
       });
   return call;
 }
  private View getReviewPageView(ViewGroup container) {

    final View view =
        getActivity().getLayoutInflater().inflate(R.layout.review_page, container, false);

    int movieId = getArguments().getInt(MovieDetailActivity.MOVIE_ID);

    Call<ReviewDatas> call =
        MyMovieDbApi.getInstance().getMoviesReviewsDatas(movieId, Constants.MOVIEDB_API_KEY);
    call.enqueue(
        new Callback<ReviewDatas>() {
          @Override
          public void onResponse(Response<ReviewDatas> response, Retrofit retrofit) {
            ReviewDatas data = response.body();
            List<ReviewData> reviewDatas = data.getReviewDatas();
            if (reviewDatas.size() > 0) {
              ListView reviewListView = (ListView) view.findViewById(R.id.review_list);
              reviewListView.setAdapter(new ReviewAdapter(getActivity(), reviewDatas));
            } else {
              TextView noReviewTextView = (TextView) view.findViewById(R.id.no_review_textview);
              noReviewTextView.setVisibility(View.VISIBLE);
            }
          }

          @Override
          public void onFailure(Throwable t) {}
        });

    return view;
  }
  public static void createPlayQueue(
      Connection connection,
      final PlexMedia media,
      final String key,
      String transientToken,
      final PlexPlayQueueHandler responseHandler) {
    Map qs = new HashMap<>();
    qs.put("type", media.getType());
    qs.put("next", "0");

    boolean hasOffset = media.viewOffset != null && Integer.parseInt(media.viewOffset) > 0;
    if (media.isMovie() && !hasOffset) {
      qs.put(
          "extrasPrefixCount",
          Integer.toString(
              VoiceControlForPlexApplication.getInstance()
                  .prefs
                  .get(Preferences.NUM_CINEMA_TRAILERS, 0)));
    }

    String uri =
        String.format(
            "library://%s/item/%%2flibrary%%2fmetadata%%2f%s", media.server.machineIdentifier, key);
    qs.put("uri", uri);
    qs.put("window", "50"); // no idea what this is for
    if (transientToken != null) qs.put("token", transientToken);
    if (media.server.accessToken != null) qs.put(PlexHeaders.XPlexToken, media.server.accessToken);

    Logger.d("Qs: ", qs);
    PlexHttpService service =
        getService(String.format("http://%s:%s", connection.address, connection.port));
    Call<MediaContainer> call =
        service.createPlayQueue(qs, VoiceControlForPlexApplication.getUUID());
    call.enqueue(
        new Callback<MediaContainer>() {
          @Override
          public void onResponse(Response<MediaContainer> response) {
            if (responseHandler != null) {
              MediaContainer mc = response.body();
              for (int i = 0; i < mc.tracks.size(); i++) {
                mc.tracks.get(i).server = media.server;
              }
              for (int i = 0; i < mc.videos.size(); i++) {
                mc.videos.get(i).server = media.server;
                if (mc.videos.get(i).isClip()) mc.videos.get(i).setClipDuration();
              }
              responseHandler.onSuccess(mc);
            }
          }

          @Override
          public void onFailure(Throwable t) {
            Logger.d("createPlayQueue failure.");
            t.printStackTrace();
          }
        });
  }
Beispiel #11
0
  private static void testInstance() {
    // This can be used in any Activity, etc.
    HttpApi api = HttpApi.getInstance();

    // Add headers to be added to every api request
    api.addHeader("Authorization", "MyToken123");

    // Prepare the HTTP request & asynchronously execute HTTP request
    Call<HttpApi.HttpBinResponse> call =
        api.getService().postWithJson(new HttpApi.LoginData("username", "secret"));
    call.enqueue(
        new Callback<HttpApi.HttpBinResponse>() {
          /** onResponse is called when any kind of response has been received. */
          public void onResponse(Response<HttpApi.HttpBinResponse> response, Retrofit retrofit) {
            // http response status code + headers
            System.out.println("Response status code: " + response.code());

            // isSuccess is true if response code => 200 and <= 300
            if (!response.isSuccess()) {
              // print response body if unsuccessful
              try {
                System.out.println(response.errorBody().string());
              } catch (IOException e) {
                // do nothing
              }
              return;
            }

            // if parsing the JSON body failed, `response.body()` returns null
            HttpApi.HttpBinResponse decodedResponse = response.body();
            if (decodedResponse == null) return;

            // at this point the JSON body has been successfully parsed
            System.out.println("Response (contains request infos):");
            System.out.println("- url:         " + decodedResponse.url);
            System.out.println("- ip:          " + decodedResponse.origin);
            System.out.println("- headers:     " + decodedResponse.headers);
            System.out.println("- args:        " + decodedResponse.args);
            System.out.println("- form params: " + decodedResponse.form);
            System.out.println("- json params: " + decodedResponse.json);
          }

          /**
           * onFailure gets called when the HTTP request didn't get through. For instance if the URL
           * is invalid / host not reachable
           */
          public void onFailure(Throwable t) {
            System.out.println("onFailure");
            System.out.println(t.getMessage());
          }
        });
  }
  private void refreshData() {

    if (editMenu) {
      Call<Menu> call = Utils.getApi(this).getMenu(menuId);

      call.enqueue(
          new Callback<Menu>() {
            @Override
            public void onResponse(Response<Menu> response, Retrofit retrofit) {

              Menu menu = response.body();

              if (menu != null) {
                setTitle("Redigera " + menu.getMenuTypeString() + "meny");
                adapter = new MenuAdapter(MenuActivity.this, menu, editMenu, MenuActivity.this);
                rv.setAdapter(adapter);
              }
            }

            @Override
            public void onFailure(Throwable t) {
              Log.i(MenuActivity.class.getName(), "Failed to fetch data: " + t.getMessage());
            }
          });

    } else {

      Call<List<Menu>> call = Utils.getApi(this).getMenus();

      call.enqueue(
          new Callback<List<Menu>>() {
            @Override
            public void onResponse(Response<List<Menu>> response, Retrofit retrofit) {

              List<Menu> menus = response.body();

              if (menus != null) {
                Menu menu = Menu.mergedMenuAtCurrentTime(menus);
                setTitle(menu.getMenuTypeString() + "meny");
                adapter = new MenuAdapter(MenuActivity.this, menu, editMenu, MenuActivity.this);
                rv.setAdapter(adapter);
              }
            }

            @Override
            public void onFailure(Throwable t) {
              Log.i(MenuActivity.class.getName(), "Failed to fetch data: " + t.getMessage());
            }
          });
    }
  }
 /**
  * Get null datetime value.
  *
  * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
  * @return the {@link Call} object
  */
 public Call<ResponseBody> getNullAsync(final ServiceCallback<DateTime> serviceCallback) {
   Call<ResponseBody> call = service.getNull();
   call.enqueue(
       new ServiceResponseCallback<DateTime>(serviceCallback) {
         @Override
         public void onResponse(Response<ResponseBody> response, Retrofit retrofit) {
           try {
             serviceCallback.success(getNullDelegate(response, retrofit));
           } catch (ErrorException | IOException exception) {
             serviceCallback.failure(exception);
           }
         }
       });
   return call;
 }
  private void loadQuestionsList() {
    Call<Wrapper> call = stackExchangeService.listQuestions();
    call.enqueue(
        new Callback<Wrapper>() {
          @Override
          public void onResponse(Response<Wrapper> response) {
            findViewById(R.id.loadingPanel).setVisibility(View.GONE);
            List<Item> items = response.body().getItems();
            questionsAdapter.addAll(items);
          }

          @Override
          public void onFailure(Throwable t) {}
        });
  }
  public static void getPinCode(final PlexPinResponseHandler responseHandler) {
    PlexHttpService service = getService("https://plex.tv:443");
    Call<Pin> call = service.getPinCode(VoiceControlForPlexApplication.getUUID());
    call.enqueue(
        new Callback<Pin>() {
          @Override
          public void onResponse(Response<Pin> response) {
            responseHandler.onSuccess(response.body());
          }

          @Override
          public void onFailure(Throwable t) {
            responseHandler.onFailure(t);
          }
        });
  }
  @Override
  public void getTopStories(final LoadStoriesCallback callback) {
    Call<Story.StoryResult> call = Net.getApi(StoryApi.class).latestStories();
    call.enqueue(
        new Callback<Story.StoryResult>() {
          @Override
          public void onResponse(Response<Story.StoryResult> response, Retrofit retrofit) {
            if (response.body() != null) callback.onStoriesLoaded(response.body().top_stories);
          }

          @Override
          public void onFailure(Throwable t) {
            callback.onDataNotAvailable();
          }
        });
  }
 /**
  * Test implicitly optional body parameter.
  *
  * @param bodyParameter the String value
  * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
  * @return the {@link Call} object
  */
 public Call<ResponseBody> putOptionalBodyAsync(
     String bodyParameter, final ServiceCallback<Void> serviceCallback) {
   Call<ResponseBody> call = service.putOptionalBody(bodyParameter);
   call.enqueue(
       new ServiceResponseCallback<Void>(serviceCallback) {
         @Override
         public void onResponse(Response<ResponseBody> response, Retrofit retrofit) {
           try {
             serviceCallback.success(putOptionalBodyDelegate(response, retrofit));
           } catch (ErrorException | IOException exception) {
             serviceCallback.failure(exception);
           }
         }
       });
   return call;
 }
 /**
  * Test implicitly optional query parameter.
  *
  * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
  * @return the {@link Call} object
  */
 public Call<ResponseBody> getOptionalGlobalQueryAsync(
     final ServiceCallback<Error> serviceCallback) {
   Call<ResponseBody> call = service.getOptionalGlobalQuery(this.client.getOptionalGlobalQuery());
   call.enqueue(
       new ServiceResponseCallback<Error>(serviceCallback) {
         @Override
         public void onResponse(Response<ResponseBody> response, Retrofit retrofit) {
           try {
             serviceCallback.success(getOptionalGlobalQueryDelegate(response, retrofit));
           } catch (ErrorException | IOException exception) {
             serviceCallback.failure(exception);
           }
         }
       });
   return call;
 }
Beispiel #19
0
  public void search() {
    Map<String, String> params = new HashMap<>();

    // general params
    params.put("term", query);
    params.put("limit", "3");

    Log.d(
        TAG,
        "Searching "
            + query
            + " in location "
            + location.getLatitude()
            + ","
            + location.getLongitude());
    // coordinates
    CoordinateOptions coordinate =
        CoordinateOptions.builder()
            .latitude(location.getLatitude())
            .longitude(location.getLongitude())
            .build();
    Call<SearchResponse> call = yelpAPI.search(coordinate, params);
    // Response<SearchResponse> response = call.execute();

    // Call<SearchResponse> call = yelpAPI.search("Chicago", params);

    Callback<SearchResponse> searchResponseCallback =
        new Callback<SearchResponse>() {
          @Override
          public void onResponse(Response<SearchResponse> response, Retrofit retrofit) {
            SearchResponse searchResponse = response.body();
            Log.d(TAG, "Yelp has returned " + searchResponse.total() + " results");

            YelpDataObject yelpDataObject = new YelpDataObject();
            List<YelpPoint> yelpPoints = new ArrayList<YelpPoint>();
            yelpPoints.addAll(yelpDataObject.populate(response.body()));
            yelpHelperListener.updateYelpPoints(yelpPoints);
          }

          @Override
          public void onFailure(Throwable t) {
            Log.d(TAG, "Error on Yelp Search: " + t.toString());
            yelpHelperListener.errorOnYelp();
          }
        };
    call.enqueue(searchResponseCallback);
  }
  public void loadBeritaStream(String paslondId) {
    Call<NewsResponse> call =
        service.getListBeritaCandidate(paslondId, ApiConfig.API_KEY, null, null);
    call.enqueue(
        new Callback<NewsResponse>() {
          @Override
          public void onResponse(Response<NewsResponse> response, Retrofit retrofit) {
            if (response.body() != null) {
              NewsResponse newsResponse = response.body();
              videoView.showListBerita(newsResponse);
            }
          }

          @Override
          public void onFailure(Throwable t) {}
        });
  }
  public static void fetchPin(int pinID, final PlexPinResponseHandler responseHandler) {
    String url = "https://plex.tv:443";
    PlexHttpService service = getService(url);
    Call<Pin> call =
        service.fetchPin(pinID, VoiceControlForPlexApplication.getInstance().prefs.getUUID());
    call.enqueue(
        new Callback<Pin>() {
          @Override
          public void onResponse(Response<Pin> response) {
            responseHandler.onSuccess(response.body());
          }

          @Override
          public void onFailure(Throwable t) {
            responseHandler.onFailure(t);
          }
        });
  }
  void loadMovies(String sortBy) {
    call = service.getMovies(sortBy, StringConstants.API_KEY);
    call.enqueue(
        new Callback<MovieResponse>() {
          @Override
          public void onResponse(Response<MovieResponse> response, Retrofit retrofit) {
            movieResponse = response.body();
            mImageAdapter = new ImageAdapter(getActivity(), mBaseUrl, movieResponse.movies);
            mMovieGrid.setAdapter(mImageAdapter);
          }

          @Override
          public void onFailure(Throwable t) {
            Toast.makeText(getActivity(), getString(R.string.cannot_load), Toast.LENGTH_LONG)
                .show();
          }
        });
  }
  public void getPGSettings(final Callback<String> callback) {
    final Call<JsonElement> jsonElementCall = pgAPIClient.getMerchantPaymentOptions("testing");
    jsonElementCall.enqueue(
        new retrofit.Callback<JsonElement>() {
          @Override
          public void onResponse(Response<JsonElement> response, Retrofit retrofit) {
            if (response.isSuccess()) {
              String message = response.body().toString();
              callback.onResponse(message);
            } else {
              String message = new String(response.errorBody().toString());
              callback.onError(new Error(message));
            }
          }

          @Override
          public void onFailure(Throwable t) {}
        });
  }
  private void validateSubmit() {
    hideToolTip();

    if (CustomInputValidator.checkError(mEtDeviceName)) return;
    if (CustomInputValidator.checkError(mEtDeviceDesc)) return;
    if (CustomInputValidator.checkError(mEtAndroidVersion)) return;

    Devices device = new Devices();
    device.setAndroidId(mAndroidVersionId);
    device.setDeviceDesc(mEtDeviceDesc.getText().toString().trim());
    device.setDeviceName(mEtDeviceName.getText().toString().trim());
    device.setImageURL("");

    if (RestClient.isNetworkAvailable()) {
      mDbHelper.insertNewDevice(device);

      Call call = new RestClient().getApiService().addDevice(device);
      call.enqueue(
          new Callback() {
            @Override
            public void onResponse(Response response, Retrofit retrofit) {
              if (response.errorBody() == null) {
                Toast.makeText(
                        ShowCaseApp.getAppContext(),
                        "Device added successfully!",
                        Toast.LENGTH_LONG)
                    .show();
                onBackPressed();
              }
            }

            @Override
            public void onFailure(Throwable t) {}
          });
    } else {
      Toast.makeText(
              ShowCaseApp.getAppContext(),
              ShowCaseApp.getAppContext().getResources().getString(R.string.no_internet),
              Toast.LENGTH_LONG)
          .show();
    }
  }
  private void fetchDataFromServer(String query) {
    Call<Flickr> call = jsonPlaceholderService.getSearch(query);
    call.enqueue(
        new Callback<Flickr>() {
          @Override
          public void onResponse(Response<Flickr> response, Retrofit retrofit) {
            int statusCode = response.code();
            // Post post = response.body();
            Flickr flickr = response.body();
            mSampleAdapter.setmItems(flickr.getItems());
            mSampleAdapter.notifyDataSetChanged();
          }

          @Override
          public void onFailure(Throwable t) {
            // Log error here since request failed
            Log.v("", "error");
          }
        });
  }
  public static void get(
      String baseHostname, String path, final PlexHttpResponseHandler responseHandler) {
    PlexHttpService service = getService(baseHostname, true);
    Call<PlexResponse> call =
        service.getPlexResponse(
            VoiceControlForPlexApplication.getInstance().prefs.getUUID(),
            path.replaceFirst("^/", ""));
    call.enqueue(
        new Callback<PlexResponse>() {
          @Override
          public void onResponse(Response<PlexResponse> response) {
            if (responseHandler != null) responseHandler.onSuccess(response.body());
          }

          @Override
          public void onFailure(Throwable t) {
            if (responseHandler != null) responseHandler.onFailure(t);
          }
        });
  }
  private void createTripRequest() {

    String nameTrip = edNameTrip.getText().toString();
    String typeTrip = edTypeOfTrip.getText().toString();
    String dateTrip = txtDate.getText().toString();

    Call<ResponseTrip> createTrip =
        reqCall.createTrip(
            appPreferences.getUserToken().getToken(),
            nameTrip,
            typeTrip,
            "",
            dateTrip,
            String.valueOf(lat_location),
            String.valueOf(longi_location),
            String.valueOf(longi_pickup),
            String.valueOf(lat_pickup),
            invited_friends);

    progressBar.setVisibility(View.VISIBLE);
    //        System.out.println("Durim list2 : " + invited_friends);
    createTrip.enqueue(
        new Callback<ResponseTrip>() {
          @Override
          public void onResponse(Response<ResponseTrip> response) {

            progressBar.setVisibility(View.GONE);
            if (response.code() == 200) {
              if (response.body() != null) {
                Toast.makeText(CreateTrip.this, "Your Trip Is Created", Toast.LENGTH_SHORT).show();
                finish();
              }
            }
          }

          @Override
          public void onFailure(Throwable t) {
            progressBar.setVisibility(View.GONE);
          }
        });
  }
 /**
  * Test implicitly required path parameter.
  *
  * @param pathParameter the String value
  * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
  * @return the {@link Call} object
  */
 public Call<ResponseBody> getRequiredPathAsync(
     String pathParameter, final ServiceCallback<Error> serviceCallback) {
   if (pathParameter == null) {
     serviceCallback.failure(
         new IllegalArgumentException("Parameter pathParameter is required and cannot be null."));
     return null;
   }
   Call<ResponseBody> call = service.getRequiredPath(pathParameter);
   call.enqueue(
       new ServiceResponseCallback<Error>(serviceCallback) {
         @Override
         public void onResponse(Response<ResponseBody> response, Retrofit retrofit) {
           try {
             serviceCallback.success(getRequiredPathDelegate(response, retrofit));
           } catch (ErrorException | IOException exception) {
             serviceCallback.failure(exception);
           }
         }
       });
   return call;
 }
 /**
  * Put min datetime value 0001-01-01T00:00:00Z.
  *
  * @param datetimeBody the DateTime value
  * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
  * @return the {@link Call} object
  */
 public Call<ResponseBody> putUtcMinDateTimeAsync(
     DateTime datetimeBody, final ServiceCallback<Void> serviceCallback) {
   if (datetimeBody == null) {
     serviceCallback.failure(
         new IllegalArgumentException("Parameter datetimeBody is required and cannot be null."));
     return null;
   }
   Call<ResponseBody> call = service.putUtcMinDateTime(datetimeBody);
   call.enqueue(
       new ServiceResponseCallback<Void>(serviceCallback) {
         @Override
         public void onResponse(Response<ResponseBody> response, Retrofit retrofit) {
           try {
             serviceCallback.success(putUtcMinDateTimeDelegate(response, retrofit));
           } catch (ErrorException | IOException exception) {
             serviceCallback.failure(exception);
           }
         }
       });
   return call;
 }
  /**
   * Starts the login flow with the given Email and Password. Email must exist and belong to a
   * registered user.
   *
   * @param email a non empty email string
   * @param password a non empty password string
   */
  private void performEmailAndPasswordLogin(String email, String password) {
    Log.d(TAG, "Email&Password login in progress..");
    EPRequest data = new EPRequest(mAuthClientId, email, password);
    Call<EPLoginResponse> call = mLoginApi.emailLogin(data);
    call.enqueue(
        new Callback<EPLoginResponse>() {
          @Override
          public void onResponse(Response<EPLoginResponse> response, Retrofit retrofit) {
            if (response.body() == null) {
              if (response.code() == 401) {
                Log.e(TAG, "Invalid username or password");
                Toast.makeText(
                        SimpleAuthActivity.this,
                        R.string.simpleauth_toast_response_invalid_username_password,
                        Toast.LENGTH_SHORT)
                    .show();
                mEmailInput.setText("");
                mPasswordInput.setText("");
              } else {
                Log.e(TAG, "Error parsing the response");
              }
              // err
            } else {
              sendBackResult(response.body().getAccessToken());
            }
            Log.d(TAG, "Email&Password login success");
          }

          @Override
          public void onFailure(Throwable t) {
            Toast.makeText(
                    SimpleAuthActivity.this,
                    R.string.simpleauth_toast_connection_error,
                    Toast.LENGTH_SHORT)
                .show();
            Log.d(TAG, "Email&Password failure.");
            Log.d(TAG, t.getMessage());
          }
        });
  }