├── .DS_Store └── methodandproperties ├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── app ├── .gitignore ├── build.gradle ├── libs │ └── org.apache.http.legacy.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── example │ │ └── hussienalrubaye │ │ └── myapplication │ │ └── ApplicationTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── example │ │ │ └── hussienalrubaye │ │ │ └── myapplication │ │ │ ├── Main2Activity.java │ │ │ └── MainActivity.java │ └── res │ │ ├── layout │ │ ├── activity_main.xml │ │ └── activity_main2.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── example │ └── hussienalrubaye │ └── myapplication │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hussien89aa/AsynTaskWithNodeServer/5d5e59a9a6a73ced3c4bb6e26da9921b38ce32ad/.DS_Store -------------------------------------------------------------------------------- /methodandproperties/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /methodandproperties/.idea/.name: -------------------------------------------------------------------------------- 1 | My Application -------------------------------------------------------------------------------- /methodandproperties/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /methodandproperties/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /methodandproperties/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /methodandproperties/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /methodandproperties/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /methodandproperties/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /methodandproperties/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /methodandproperties/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /methodandproperties/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.example.hussienalrubaye.myapplication" 9 | minSdkVersion 12 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | useLibrary 'org.apache.http.legacy' 21 | } 22 | 23 | dependencies { 24 | compile fileTree(dir: 'libs', include: ['*.jar']) 25 | testCompile 'junit:junit:4.12' 26 | compile 'com.android.support:appcompat-v7:23.1.1' 27 | } 28 | -------------------------------------------------------------------------------- /methodandproperties/app/libs/org.apache.http.legacy.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hussien89aa/AsynTaskWithNodeServer/5d5e59a9a6a73ced3c4bb6e26da9921b38ce32ad/methodandproperties/app/libs/org.apache.http.legacy.jar -------------------------------------------------------------------------------- /methodandproperties/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/hussienalrubaye/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /methodandproperties/app/src/androidTest/java/com/example/hussienalrubaye/myapplication/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.example.hussienalrubaye.myapplication; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /methodandproperties/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /methodandproperties/app/src/main/java/com/example/hussienalrubaye/myapplication/Main2Activity.java: -------------------------------------------------------------------------------- 1 | package com.example.hussienalrubaye.myapplication; 2 | 3 | import android.os.AsyncTask; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | import android.widget.TextView; 7 | 8 | import org.apache.http.HttpResponse; 9 | import org.apache.http.client.HttpClient; 10 | import org.apache.http.client.methods.HttpGet; 11 | import org.apache.http.impl.client.DefaultHttpClient; 12 | 13 | import java.io.BufferedReader; 14 | import java.io.InputStream; 15 | import java.io.InputStreamReader; 16 | import java.net.URL; 17 | import java.net.URLEncoder; 18 | 19 | public class Main2Activity extends AppCompatActivity { 20 | TextView txtv; 21 | @Override 22 | protected void onCreate(Bundle savedInstanceState) { 23 | super.onCreate(savedInstanceState); 24 | setContentView(R.layout.activity_main2); 25 | txtv=(TextView)findViewById(R.id.textView3); 26 | 27 | String myurl = "http://selling.alruabye.net/UsersWS.asmx/Login?UserName=a&Password=حسين" ; 28 | new MyAsyncTaskgetNews().execute(myurl); 29 | } 30 | public class MyAsyncTaskgetNews extends AsyncTask { 31 | @Override 32 | protected void onPreExecute() { 33 | 34 | 35 | } 36 | @Override 37 | protected String doInBackground(String... params) { 38 | String NewsData=""; 39 | try { 40 | InputStream inputStream; 41 | HttpClient httpClient =new DefaultHttpClient(); 42 | HttpResponse httpResponse =httpClient.execute(new HttpGet(params[0])); 43 | inputStream = httpResponse.getEntity().getContent(); 44 | NewsData=Stream2String(inputStream); 45 | publishProgress(NewsData ); 46 | 47 | } catch (Exception e) { 48 | // TODO Auto-generated catch block 49 | 50 | } 51 | return null; 52 | } 53 | protected void onProgressUpdate(String... progress) { 54 | 55 | try { 56 | 57 | txtv.setText(progress[0]); 58 | 59 | 60 | } catch (Exception ex) { 61 | ex.printStackTrace(); 62 | } 63 | 64 | } 65 | protected void onPostExecute(String result2){ 66 | 67 | } 68 | 69 | 70 | 71 | 72 | } 73 | public String Stream2String(InputStream inputStream) { 74 | BufferedReader bureader=new BufferedReader( new InputStreamReader(inputStream)); 75 | String line ; 76 | String Text=""; 77 | try{ 78 | while((line=bureader.readLine())!=null) { 79 | Text+=line; 80 | } 81 | inputStream.close(); 82 | }catch (Exception ex){} 83 | return Text; 84 | } 85 | 86 | 87 | } 88 | -------------------------------------------------------------------------------- /methodandproperties/app/src/main/java/com/example/hussienalrubaye/myapplication/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example.hussienalrubaye.myapplication; 2 | 3 | import android.content.Intent; 4 | import android.os.AsyncTask; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.os.Bundle; 7 | import android.text.Html; 8 | import android.view.View; 9 | 10 | import android.widget.EditText; 11 | import android.widget.TextView; 12 | 13 | 14 | import java.io.BufferedInputStream; 15 | import java.io.BufferedReader; 16 | 17 | import java.io.InputStream; 18 | import java.io.InputStreamReader; 19 | import java.net.HttpURLConnection; 20 | import java.net.URL; 21 | import java.net.URLEncoder; 22 | 23 | public class MainActivity extends AppCompatActivity { 24 | TextView txtv; 25 | @Override 26 | protected void onCreate(Bundle savedInstanceState) { 27 | super.onCreate(savedInstanceState); 28 | setContentView(R.layout.activity_main); 29 | txtv=(TextView)findViewById(R.id.textView3); 30 | 31 | 32 | } 33 | 34 | 35 | public void buclick(View view) { 36 | String myurl = "http://10.0.2.2:3000/comments"; 37 | new MyAsyncTaskgetNews().execute(myurl); 38 | 39 | 40 | } 41 | 42 | public void BuAdd(View view) { 43 | EditText ETName=(EditText)findViewById(R.id.ETName); 44 | EditText ETComment=(EditText)findViewById(R.id.ETComment); 45 | String myurl = "http://10.0.2.2:3000/add?PersonName="+ ETName.getText().toString()+"&PersonComment=" +ETComment.getText().toString(); 46 | new MyAsyncTaskgetNews().execute(myurl); 47 | } 48 | String NewsData=""; 49 | public class MyAsyncTaskgetNews extends AsyncTask { 50 | @Override 51 | protected void onPreExecute() { 52 | NewsData=""; 53 | 54 | } 55 | @Override 56 | protected String doInBackground(String... params) { 57 | 58 | publishProgress("open connection" ); 59 | try 60 | { 61 | URL url = new URL(params[0]); 62 | HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); 63 | InputStream in = new BufferedInputStream(urlConnection.getInputStream()); 64 | publishProgress("start read buffer" ); 65 | NewsData=Stream2String(in); 66 | in.close(); 67 | 68 | 69 | 70 | } catch (Exception e) { 71 | publishProgress("cannot connect to server" ); 72 | } 73 | 74 | return null; 75 | 76 | } 77 | protected void onProgressUpdate(String... progress) { 78 | 79 | txtv.setText(progress[0]); 80 | 81 | } 82 | protected void onPostExecute(String result2){ 83 | 84 | txtv.setText(NewsData); 85 | } 86 | 87 | 88 | 89 | 90 | } 91 | 92 | public String Stream2String(InputStream inputStream) { 93 | BufferedReader bureader=new BufferedReader( new InputStreamReader(inputStream)); 94 | String line ; 95 | String Text=""; 96 | try{ 97 | while((line=bureader.readLine())!=null) { 98 | Text+=line; 99 | } 100 | inputStream.close(); 101 | }catch (Exception ex){} 102 | return Text; 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /methodandproperties/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 16 | 17 | 21 | 22 | 26 | 27 | 33 | 34 | 40 | 41 | 42 | 43 | 48 | 49 | 54 | 55 | 61 | 62 | 63 | 64 | 65 | 69 | 70 |