erjan / it-ebooks.info Goto Github PK
View Code? Open in Web Editor NEWit-ebooks.info android app - search and download best new software, IT ebooks
License: GNU General Public License v2.0
it-ebooks.info android app - search and download best new software, IT ebooks
License: GNU General Public License v2.0
public class ProcessData extends AsyncTask<String, Void, String> {
private final String LOG_TAG = ProcessData.class.getSimpleName();
Uri destinationURL ;
public String createValidURL(String query) {
Log.d(LOG_TAG, "create Valid url......");
Log.d(LOG_TAG, "search word: " + query) ;
String BASE_URL = "http://it-ebooks-api.info/v1/search" ;
String searchBy = "type";
destinationURL = Uri.parse(BASE_URL).buildUpon()
.appendPath(query)
.appendQueryParameter(searchBy, "title")
.build();
String result = destinationURL.toString();
Log.d(LOG_TAG," actual url we use:" + result);
Log.d(LOG_TAG, " ");
return " "; //THIS WAS STUPID ERROR!
}
public String MakeConnectionAndReadData(String validUrl){
Log.d(LOG_TAG, "make connection and read data");
Log.d(LOG_TAG, "VALID url:" + validUrl);
HttpURLConnection urlConnection = null;
BufferedReader reader = null;
try {
URL url = new URL(validUrl);
urlConnection = (HttpURLConnection) url.openConnection();
if(urlConnection == null)
Log.e(LOG_TAG, "url connection is null! ERROR");
urlConnection.setRequestMethod("GET");
urlConnection.connect();
InputStream inputStream = urlConnection.getInputStream();
if(inputStream == null) {
Log.e(LOG_TAG, "input stream failed to create!!!");
return null;
}
StringBuffer buffer = new StringBuffer();
reader = new BufferedReader(new InputStreamReader(inputStream));
String line;
while((line = reader.readLine()) != null) {
Log.d(LOG_TAG, line) ;
Log.d(LOG_TAG, "--->") ;
buffer.append(line + "\n");
}
Log.d(LOG_TAG, " ");
Log.d(LOG_TAG, "buffer: " + buffer.toString());
return buffer.toString();
} catch(IOException e) {
Log.e(LOG_TAG, "Error", e);
return null;
} finally {
if(urlConnection != null) {
urlConnection.disconnect();
}
if(reader != null) {
try {
reader.close();
} catch(final IOException e) {
Log.e(LOG_TAG,"Error closing stream", e);
}
}
}
}
public String doInBackground(String ...params){
String validUrl = createValidURL(params[0]);
Log.d(LOG_TAG, "the url I got from createValidUrl() method:" + validUrl);
Log.d(LOG_TAG, " ");
String bigData = MakeConnectionAndReadData(validUrl);
return bigData ;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.