| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 
 | public class test extends Activity  implements Runnable{
	private ProgressDialog pd;	
 
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.textview);
 
        txt = (TextView) findViewById(R.id.textViewText);
        txt_ta1 = (TextView) findViewById(R.id.textViewTa1);
        txt_ta2 = (TextView) findViewById(R.id.textViewTa2);
        txt_ta3 = (TextView) findViewById(R.id.textViewTa3);
 
        launchWait();
 
        }
	public static final String strURL = "http://10.0.0.2/android/fichier.php";
	public static final String strURL_bis = "http://10.0.0.2/android/fichier2.php";
 
 
 
	 Intent intent = null;  // Reusable Intent for each tab
 
	private void lancement(String p,  String l, String id, String c) {
 
 
		getServerData("", p, l, id, c);
 
	}
 
 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//							Affiche intitulé 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
 
 
	private void getServerData(String returnString, String p, String  l, String id, String c) {
 
 
 
		InputStream is = null;
		String result = "";
 
		// Envoyer la requête au script PHP.
		ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
		nameValuePairs.add(new BasicNameValuePair("re", id));
		nameValuePairs.add(new BasicNameValuePair("ty",  l));
		nameValuePairs.add(new BasicNameValuePair("p", p));
 
		// Envoie de la commande http
		try{
			HttpClient httpclient = new DefaultHttpClient();
			HttpPost httppost = new HttpPost(strURL);
			httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
			HttpResponse response = httpclient.execute(httppost);
			HttpEntity entity = response.getEntity();
			is = entity.getContent();
 
		}catch(Exception e){
			Log.e("log_tag", "Error in http connection " + e.toString());
		}
 
		// Convertion de la requête en string
		try{
			BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
			StringBuilder sb = new StringBuilder();
			String line = null;
			while ((line = reader.readLine()) != null) {
				sb.append(line + "\n");
			}
			is.close();
			result=sb.toString();
		}catch(Exception e){
			Log.e("log_tag", "Error converting result " + e.toString());
		}
		// Parse les données JSON
		try{
			Log.e("log_tag", "result  " +result);
			JSONArray jArray = new JSONArray(result);
			for(int i=0;i<jArray.length();i++){
				JSONObject json_data = jArray.getJSONObject(i);			
 
				libelle = json_data.getString("libelle");		
				id_ty = json_data.getString("id_ty");
 
					tla+= "<br/>" + libelle +"<br/>"; 
 
 
 
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//							SOUS PARTIE
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 
				 getServerData_ss(id_ty, p, id, c);	
 
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//							FIN SOUS PARTIE
///////////////////////////////////////////////////////////////////////////////////////////////////////////////				
 
 
			}
		}catch(JSONException e){
			Log.e("log_tag", "1 Error parsing data " + e);
		}}
		//return returnString; 
 
//////////////FONTION Sous parti/////////////////////////////////////////////
 
		private void getServerData_ss(String id_ty, String p, String id, String c) {
			InputStream is = null;
			String result_bis="";
 
 
			// Envoyer la requête au script PHP.
			ArrayList<NameValuePair> name = new ArrayList<NameValuePair>();
			name.add(new BasicNameValuePair("id_ty", id_ty));
			name.add(new BasicNameValuePair("re", id));
			name.add(new BasicNameValuePair("p", p));
			// Envoie de la commande http
			try{
				HttpClient httpclient = new DefaultHttpClient();
				HttpPost httppost = new HttpPost(strURL_bis);
				httppost.setEntity(new UrlEncodedFormEntity(name));
				HttpResponse response = httpclient.execute(httppost);
				HttpEntity entity = response.getEntity();
				is = entity.getContent();
 
			}catch(Exception e){
				Log.e("log_tag", " 2 Error in http connection " + e.toString());
			}
 
			// Convertion de la requête en string
			try{
				BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
				StringBuilder sb_bis = new StringBuilder();
				String line = null;
				while ((line = reader.readLine()) != null) {
					sb_bis.append(line + "\n");
				}
				is.close();
				result_bis=sb_bis.toString();
			}catch(Exception e){
				Log.e("log_tag", "2 Error converting result " + e.toString());
			}
			// Parse les données JSON
			try{
				Log.e("log_tag", "result_bis  " +result_bis);
				JSONArray jAr = new JSONArray(result_bis);
 
				for(int j=0;j<jAr.length();j++){
 
					JSONObject json = jAr.getJSONObject(j);
 
					//recupertation donner JSON 
					 ingr = json.getString("ingr");
					 nb1=json.getString("nb1");
					 nb2=json.getString("nb2");
					 libelle = json.getString("libelle");
					 ta1=json.getString("ta1");
					 ta2=json.getString("ta2");
					 ta3=json.getString("ta3");
					 nb3=json.getString("nb3");
 
					tla+= "<br/><tt><FONT color ='"+c+"'>"+ libelle+"</tt></font>";
 
						txt_ta3.setText(Html.fromHtml(ta3));
						txt_ta2.setText(Html.fromHtml(ta2));
						txt_ta1.setText(Html.fromHtml(ta1));
 
					txt.setText(Html.fromHtml(plat));
 
				}
				// handler.sendEmptyMessage(0);
 
			}catch(JSONException e){
				Log.e("log_tag", "2 Error parsing data " + e.toString());
			}
 
}
		   public void launchWait() {
				pd = ProgressDialog.show(this, "Patientez...", "Chargement", true,false);
 
				Thread thread = new Thread(this);
				thread.start();
			}
 
			public void run() {			 
				//recupere la Lan
			    Lan lan_suite =getIntent().getExtras().getParcelable("lan_suite");
			    String p = lan_suite.getmLan();
 
 
			    //recupere le ty 
			    Ty ty_suite =getIntent().getExtras().getParcelable("ty_suite");
			    String l = ty_suite.getmty();
 
			  //recupere id re
			    Re re_suite =getIntent().getExtras().getParcelable("re_suite");
			    String id = re_suite.getmre();
 
			  //c
			    c c_suite =getIntent().getExtras().getParcelable("c_suite");
			    String c = c_suite.getmc();
 
				lancement(p,  l, id, c);    
 
 
				handler.sendEmptyMessage(0);
			}
 
			private Handler handler = new Handler() {
 
				@Override
				public void handleMessage(Message msg) {
		                        //Le handler a reçu une notification
		                        //On ferme la boîte de dialogue
		                        //Les bonnes pratiques voudraient qu'on teste le msg ...
		 			pd.dismiss();
				}
			};
 
 
		   } |