Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

WebRequest

Library for easy work with web requests (modified Volley)

Gradle:

	compile 'com.github.fellowcode:WebRequest:0.0.4'
    compile 'com.android.volley:volley:1.0.0'

For start need make request listener, response - content html:

	RespListener listener = new RespListener() {
				@Override
				public void onResponse(String response) {
					//your code
				}
			};

Send request:

	WebRequest web = new WebRequest("http://google.com", listener);
    	RequestQueue queue = Volley.newRequestQueue(this);
	queue.add(web);

You can send values ​​using the following methods:

	ReqMethod.GET   //GET
	ReqMethod.POST  //POST
	ReqMethod.PUT   //PUT

To select a method, you need to add it to the constructor, the default is GET method:

	WebRequest web = new WebRequest(ReqMethod.POST, "http://google.com", listener);

To add value in request need:

	web.AddField("key", "value")
	
	//Or add list
	ArrayList<String> list = new ArrayList<String>;
	list.add("value1");
	list.add("value2");
	web.AddList("key", list);
	
	//Or for array
	String[] values = {"value1", "value2"};
	web.AddList("key", values);

The values ​​of the list will be added in the following form: key=value1&key=value2

For example:

	TextView notification = (TextView)findViewById(R.id.notification);
	RespListener listener = new RespListener() {
		@Override
		public void onResponse(String response) {
			notification.setText(response);
		}
	};
	WebRequest web = new WebRequest("http://google.com", listener);
	RequestQueue queue = Volley.newRequestQueue(context);
	//Add value
	web.AddField("key1", "value1");

	//Add array
	ArrayList<String> values = new ArrayList<>();
	values.add("value2");
	values.add("value3");
	web.AddList("key2", values);

	//start request
	queue.add(web);

About

Library for easy work with web requests (modified Volley)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages