예제 #1
0
  public void getRideEstimates() {
    MyVolley.init(context);
    RequestQueue queue = MyVolley.getRequestQueue();
    StringRequest myReq =
        new StringRequest(
            Request.Method.GET,
            "https://api.uber.com/v1/estimates/price",
            reqSuccessListenerFoodList(),
            reqErrorListenerFoodList()) {

          @Override
          public Map<String, String> getHeaders() throws AuthFailureError {
            Map<String, String> headers = new HashMap<String, String>();
            headers.put("server_token", "maMItAGDV5HHqKAG3nLfLTlhMOnQscAONF_aeFcu");
            return headers;
          }

          protected Map<String, String> getParams() throws com.android.volley.AuthFailureError {
            Map<String, String> params = new HashMap<String, String>();

            params.put("start_latitude", String.valueOf((float) 28.613939));
            params.put("start_longitude", String.valueOf((float) 77.209021));
            params.put("end_latitude", String.valueOf((float) 28.7499));
            params.put("end_longitude", String.valueOf((float) 77.1170));

            return params;
          }
        };
    myReq.setRetryPolicy(new DefaultRetryPolicy(25000, 1, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    queue.add(myReq);
  }
예제 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_update_books);
    MyVolley.init(this.getApplicationContext());
    mqueue = MyVolley.getRequestQueue();
    sh = getSharedPreferences("update", Context.MODE_PRIVATE);
    tv = (TextView) findViewById(R.id.no_of_books);
    data = new ArrayList<>();
    recyclerView = (RecyclerView) findViewById(R.id.inventorylist);
    recyclerView.addItemDecoration(
        new DividerItemDecoration(getApplicationContext(), R.drawable.divider));
    ScaleInAnimator animator = new ScaleInAnimator();
    animator.setAddDuration(1000);
    animator.setRemoveDuration(1000);
    recyclerView.setItemAnimator(animator);
    rInventoryAdapter = new RInventoryAdapter(UpdateBooks.this, data);
    AlphaInAnimationAdapter alphaAdapter = new AlphaInAnimationAdapter(rInventoryAdapter);
    recyclerView.setAdapter(new ScaleInAnimationAdapter(alphaAdapter));
    // recyclerView.setAdapter(RVadapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
    recyclerView.setHasFixedSize(true);
    recyclerView.addOnItemTouchListener(
        new RecyclerItemClickListener(
            this,
            new RecyclerItemClickListener.OnItemClickListener() {
              @Override
              public void onItemClick(View view, int position) {
                Log.e("clicked", "true1");
                Log.e("pos:", String.valueOf(position));
                ItemPosition = position;
                Log.e("vid:", String.valueOf(view.getId()));
                FragmentManager fm = getSupportFragmentManager();
                CustDialog cd = new CustDialog();
                cd.show(fm, "Action");
              }
            }));

    VolleyConnect();
  }
예제 #3
0
  // utils
  public static void updateImageView(final ImageView imageView, final String url) {
    if (null != imageView && !TextUtils.isEmpty(url)) {
      MyVolley.getImageLoader()
          .get(
              url,
              new ImageLoader.ImageListener() {
                @Override
                public void onResponse(ImageLoader.ImageContainer imageContainer, boolean b) {
                  if (null != imageContainer.getBitmap()) {
                    imageView.setImageBitmap(imageContainer.getBitmap());
                    imageView.setVisibility(View.VISIBLE);
                  }
                }

                @Override
                public void onErrorResponse(VolleyError volleyError) {}
              });
    }
  }
예제 #4
0
 @Override
 public void onCreate() {
   super.onCreate();
   Database.getInstance().open(getApplicationContext());
   MyVolley.init(getApplicationContext());
 }