Java Code Examples for com.android.volley.toolbox.Volley#newRequestQueue()
The following examples show how to use
com.android.volley.toolbox.Volley#newRequestQueue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From android-advanced-light with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); iv_image = (ImageView) this.findViewById(R.id.iv_image); bt_send = (Button) this.findViewById(R.id.bt_send); nv_image = (NetworkImageView) this.findViewById(R.id.nv_image); mQueue = Volley.newRequestQueue(getApplicationContext()); bt_send.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // UseStringRequest(); UseJsonRequest(); // UseImageRequest(); // UseImageLoader(); // UseNetworkImageView(); } }); }
Example 2
Source File: AppController.java From video-player with MIT License | 5 votes |
public RequestQueue getRequestQueue() { if (mRequestQueue == null) { mRequestQueue = Volley.newRequestQueue(getApplicationContext()); } return mRequestQueue; }
Example 3
Source File: RssListAdapter.java From android-opensource-library-56 with Apache License 2.0 | 5 votes |
public RssListAdapter(Context context, List<Item> items) { super(context, 0, items); mItems = items; mInflator = (LayoutInflater) getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE); mQueue = Volley.newRequestQueue(context); mImageLoader = new ImageLoader(mQueue, new LruImageCache()); }
Example 4
Source File: HTTPRequest.java From indigenous-android with GNU General Public License v3.0 | 5 votes |
/** * Do a Volley String POST Request. * * @param endpoint * The endpoint to query. * @param params * The params to send. */ public void doPostRequest(String endpoint, final Map<String, String> params) { StringRequest getRequest = new StringRequest(Request.Method.POST, endpoint, new Response.Listener<String>() { @Override public void onResponse(String response) { if (volleyRequestListener != null) { volleyRequestListener.OnSuccessRequest(response); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { if (volleyRequestListener != null) { volleyRequestListener.OnFailureRequest(error); } } } ) { @Override protected Map<String, String> getParams() { return params; } @Override public Map<String, String> getHeaders() { HashMap<String, String> headers = new HashMap<>(); headers.put("Accept", "application/json"); headers.put("Authorization", "Bearer " + user.getAccessToken()); return headers; } }; RequestQueue queue = Volley.newRequestQueue(context); queue.add(getRequest); }
Example 5
Source File: OdooWrapper.java From framework with GNU Affero General Public License v3.0 | 5 votes |
public OdooWrapper(Context context, String baseURL) { serverURL = stripURL(baseURL); gson = new Gson(); responseQueue = new OdooResponseQueue(); requestQueue = Volley.newRequestQueue(context, new HttpClientStack(OdooSafeClient.getSafeClient(true))); }
Example 6
Source File: Model.java From UPMiss with GNU General Public License v3.0 | 5 votes |
public static RequestQueue getRequestQueue() { if (REQUEST_QUEUE == null) { synchronized (Model.class) { if (REQUEST_QUEUE == null) { REQUEST_QUEUE = Volley.newRequestQueue(APPLICATION); } } } return REQUEST_QUEUE; }
Example 7
Source File: MyVolley.java From Android-SDK with MIT License | 5 votes |
public RequestQueue getRequestQueue() { if (mRequestQueue == null) mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext()); mRequestQueue.getCache().clear(); return mRequestQueue; }
Example 8
Source File: VolleyUrlLoader.java From RecyclerAdapterBase with Apache License 2.0 | 5 votes |
private static RequestQueue getInternalQueue(Context context) { if (internalQueue == null) { synchronized (VolleyUrlLoader.Factory.class) { if (internalQueue == null) { internalQueue = Volley.newRequestQueue(context); } } } return internalQueue; }
Example 9
Source File: KCommands.java From kboard with GNU General Public License v3.0 | 5 votes |
public void curl(int n, String parameter) { // Instantiate the RequestQueue. RequestQueue queue = Volley.newRequestQueue(mIme); final int repeat = n; // Request a string response from the provided URL. StringRequest stringRequest = new StringRequest(Request.Method.GET, parameter, new Response.Listener<String>() { @Override public void onResponse(String response) { i(repeat, response); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { } }) { @Override public Map<String, String> getHeaders(){ Map<String, String> headers = new HashMap<>(); headers.put("User-agent", "curl"); headers.put("Accept", "text/plain"); return headers; } }; // Add the request to the RequestQueue. queue.add(stringRequest); }
Example 10
Source File: NetworkSingleton.java From custom-auth-samples with Apache License 2.0 | 5 votes |
public RequestQueue getRequestQueue() { if (mRequestQueue == null) { // getApplicationContext() is key, it keeps you from leaking the // Activity or BroadcastReceiver if someone passes one in. mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext()); } return mRequestQueue; }
Example 11
Source File: WebServiceCoordinator.java From opentok-android-sdk-samples with MIT License | 5 votes |
public void fetchSessionConnectionData(String sessionInfoUrlEndpoint) { RequestQueue reqQueue = Volley.newRequestQueue(context); reqQueue.add(new JsonObjectRequest(Request.Method.GET, sessionInfoUrlEndpoint, null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { try { String apiKey = response.getString("apiKey"); String sessionId = response.getString("sessionId"); String token = response.getString("token"); Log.i(LOG_TAG, "WebServiceCoordinator returned session information"); delegate.onSessionConnectionDataReady(apiKey, sessionId, token); } catch (JSONException e) { delegate.onWebServiceCoordinatorError(e); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { delegate.onWebServiceCoordinatorError(error); } })); }
Example 12
Source File: VolleyResourcesSingleton.java From m2x-android with MIT License | 5 votes |
public RequestQueue getRequestQueue() { if (mRequestQueue == null) { // getApplicationContext() is key, it keeps you from leaking the // Activity or BroadcastReceiver if someone passes one in. mRequestQueue = Volley.newRequestQueue(mCtx.getApplicationContext()); } return mRequestQueue; }
Example 13
Source File: RQManager.java From MaterialCalendar with Apache License 2.0 | 5 votes |
public RequestQueue getRequestQueue() { if (mRequestQueue == null) { // getApplicationContext() is key, it keeps you from leaking the // Activity or BroadcastReceiver if someone passes one in. mRequestQueue = Volley.newRequestQueue(MainApplication.getApplication()); } return mRequestQueue; }
Example 14
Source File: CatnutApp.java From catnut with MIT License | 5 votes |
@Override public void onCreate() { super.onCreate(); sApp = this; mPreferences = PreferenceManager.getDefaultSharedPreferences(this); mRequestQueue = Volley.newRequestQueue(this, new OkHttpStack()); checkAccessToken(); }
Example 15
Source File: UserFragment.java From android-kubernetes-blockchain with Apache License 2.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_user, container, false); // ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); // actionBar.show(); // actionBar.setTitle("Footsteps"); // attach labels userSteps = rootView.findViewById(R.id.numberOfSteps); distanceFromSteps = rootView.findViewById(R.id.distance); userId = rootView.findViewById(R.id.userIdText); coinsBalance = rootView.findViewById(R.id.numberOfCoins); swipeRefreshLayout = rootView.findViewById(R.id.swipeRefresh); swipeRefreshLayout.setOnRefreshListener(this); // request queue queue = Volley.newRequestQueue((AppCompatActivity) getActivity()); // initialize shared preferences - persistent data SharedPreferences sharedPreferences = ((AppCompatActivity) getActivity()).getSharedPreferences("shared_preferences_fitcoin", Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); // check if enrolled in blockchain network if (sharedPreferences.contains("BlockchainUserId")) { userIdFromStorage = sharedPreferences.getString("BlockchainUserId","Something went wrong..."); userId.setText(userIdFromStorage); if (!userIdFromStorage.equals("Something went wrong...")) { getStateOfUser(userIdFromStorage); } } else { userId.setText(R.string.notEnrolled); } // Get the date now Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); // if DateStarted is existing, use it if (sharedPreferences.contains("DateStarted")) { userStartingDate = sharedPreferences.getLong("DateStarted", cal.getTimeInMillis()); } else { // else use time and date now and persist it for later use userStartingDate = cal.getTimeInMillis(); editor.putLong("DateStarted",userStartingDate); editor.apply(); } // build the fitness options FitnessOptions fitnessOptions = FitnessOptions.builder() .addDataType(DataType.TYPE_STEP_COUNT_DELTA, FitnessOptions.ACCESS_READ) .addDataType(DataType.AGGREGATE_STEP_COUNT_DELTA, FitnessOptions.ACCESS_READ) .addDataType(DataType.TYPE_DISTANCE_DELTA, FitnessOptions.ACCESS_READ) .build(); // check if app has permissions if (!GoogleSignIn.hasPermissions(GoogleSignIn.getLastSignedInAccount((AppCompatActivity) getActivity()), fitnessOptions)) { GoogleSignIn.requestPermissions( this, REQUEST_OAUTH_REQUEST_CODE, GoogleSignIn.getLastSignedInAccount((AppCompatActivity) getActivity()), fitnessOptions); } else { accessGoogleFit(); } return rootView; }
Example 16
Source File: BitmapTools.java From volley with Apache License 2.0 | 4 votes |
public static void init(Context context) { if (sRequestQueue == null) { sRequestQueue = Volley.newRequestQueue(context.getApplicationContext()); } }
Example 17
Source File: VolleyManager.java From EventApp with Apache License 2.0 | 4 votes |
private VolleyManager(Context context) { mRequestQueue = Volley.newRequestQueue(context); mRequestQueue.start(); }
Example 18
Source File: CameraWS.java From timelapse-sony with GNU General Public License v3.0 | 4 votes |
CameraWS(Context context) { mJsonQueue = Volley.newRequestQueue(context); mRequestId = 1; }
Example 19
Source File: SearchActivity.java From QuickNews with MIT License | 3 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); ActionBar actionBar=getSupportActionBar(); actionBar.hide(); initView(); mRequestQueue= Volley.newRequestQueue(this); }
Example 20
Source File: VolleyHelper.java From SimplifyReader with Apache License 2.0 | 2 votes |
/** * init volley helper * * @param context */ public void init(Context context) { requestQueue = Volley.newRequestQueue(context, new OkHttpStack(new OkHttpClient())); }