|
@@ -223,10 +223,14 @@ |
223 |
223 |
|
case 0: { |
224 |
224 |
|
successRequest += 1; |
225 |
225 |
|
if (localeAdditionalLayout.getVisibility() == View.VISIBLE) { |
226 |
|
- |
addLocal(); |
|
226 |
+ |
PrefsManager.setLogin(c, user, pass, id, token); |
|
227 |
+ |
addLocal(path,id); |
|
228 |
+ |
}else |
|
229 |
+ |
{ |
|
230 |
+ |
registerSuccesfully(user, pass, id, path, token); |
227 |
231 |
|
} |
228 |
232 |
|
|
229 |
|
- |
registerSuccesfully(user, pass, id, path, token); |
|
233 |
+ |
|
230 |
234 |
|
|
231 |
235 |
|
} |
232 |
236 |
|
break; |
|
@@ -253,7 +257,7 @@ |
253 |
257 |
|
} |
254 |
258 |
|
|
255 |
259 |
|
|
256 |
|
- |
private void addLocal() { |
|
260 |
+ |
private void addLocal(final String path, final int id) { |
257 |
261 |
|
new Thread(new Runnable() { |
258 |
262 |
|
public void run() { |
259 |
263 |
|
|
|
@@ -293,28 +297,78 @@ |
293 |
297 |
|
local_id = resp.getInt("local_id"); |
294 |
298 |
|
PrefsManager.addLocal(c, s1, nomelocale); |
295 |
299 |
|
|
296 |
|
- |
if (successRequest >= 3) { |
297 |
|
- |
if (localeAdditionalLayout.getVisibility() == View.GONE) { |
298 |
|
- |
|
299 |
|
- |
PrefsManager.setUserType(c); |
300 |
|
- |
Intent i = new Intent(RegisterActivity.this, SelectionActivity.class); |
301 |
|
- |
startActivity(i); |
302 |
|
- |
finish(); |
303 |
|
- |
} else { |
304 |
|
- |
|
305 |
|
- |
PrefsManager.setLocaleType(c); |
306 |
|
- |
Intent i = new Intent(RegisterActivity.this, SetPositionLocaleActivity.class); |
307 |
|
- |
i.putExtra("idlocale", local_id); |
308 |
|
- |
startActivity(i); |
309 |
|
- |
finish(); |
310 |
|
- |
|
311 |
|
- |
|
312 |
|
- |
startActivity(i); |
313 |
|
- |
|
|
300 |
+ |
new Thread(new Runnable() { |
|
301 |
+ |
public void run() { |
314 |
302 |
|
|
|
303 |
+ |
MultipartEntity mpEntity = new MultipartEntity(); |
|
304 |
+ |
runOnUiThread(new Runnable() { |
|
305 |
+ |
@Override |
|
306 |
+ |
public void run() { |
|
307 |
+ |
Animation aAnimation = (Animation) AnimationUtils.loadAnimation(c, R.anim.zoom); |
|
308 |
+ |
|
|
309 |
+ |
|
|
310 |
+ |
(findViewById(R.id.avatarImage)).startAnimation(aAnimation); |
|
311 |
+ |
} |
|
312 |
+ |
}); |
|
313 |
+ |
|
|
314 |
+ |
try { |
|
315 |
+ |
//Se non c'è l'immagine metti null risponde comunque bene |
|
316 |
+ |
ContentBody bab; |
|
317 |
+ |
ContentBody str_; |
|
318 |
+ |
if(selectedAvatar != null){ |
|
319 |
+ |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
|
320 |
+ |
((BitmapDrawable) ((ImageView) findViewById(R.id.avatarImage)).getDrawable()).getBitmap().compress(Bitmap.CompressFormat.JPEG, 75, baos); |
|
321 |
+ |
byte[] imageBytes = baos.toByteArray(); |
|
322 |
+ |
|
|
323 |
+ |
bab = new ByteArrayBody(imageBytes, "file.jpeg"); |
|
324 |
+ |
|
|
325 |
+ |
str_ = new StringBody(path); |
|
326 |
+ |
} else { |
|
327 |
+ |
bab = null; |
|
328 |
+ |
str_ = new StringBody(""); |
|
329 |
+ |
} |
|
330 |
+ |
|
|
331 |
+ |
ContentBody id_ = new StringBody(String.valueOf(id)); |
|
332 |
+ |
|
|
333 |
+ |
if(selectedAvatar != null) { |
|
334 |
+ |
mpEntity.addPart("avatar_file", bab); |
|
335 |
+ |
} |
|
336 |
+ |
|
|
337 |
+ |
mpEntity.addPart("user_id", id_); |
|
338 |
+ |
mpEntity.addPart("avatar_name", str_); |
|
339 |
+ |
mpEntity.addPart("token", new StringBody(PrefsManager.getToken(c))); |
|
340 |
+ |
JSONObject resp = HttpClient.SendHttpPostDirect(EndPoint.MAIN_END_POINT + "/upload_avatar.php", mpEntity); |
|
341 |
+ |
int id = resp.getInt("return"); |
|
342 |
+ |
switch (id) { |
|
343 |
+ |
case 0: { |
|
344 |
+ |
PrefsManager.setAvatar(c, resp.getString("avatar_name")); |
|
345 |
+ |
successRequest += 1; |
|
346 |
+ |
Log.e("successRequest", String.valueOf(successRequest)); |
|
347 |
+ |
|
|
348 |
+ |
|
|
349 |
+ |
PrefsManager.setLocaleType(c); |
|
350 |
+ |
Intent i = new Intent(RegisterActivity.this, SetPositionLocaleActivity.class); |
|
351 |
+ |
i.putExtra("idlocale", local_id); |
|
352 |
+ |
startActivity(i); |
|
353 |
+ |
finish(); |
|
354 |
+ |
|
|
355 |
+ |
} |
|
356 |
+ |
break; |
|
357 |
+ |
default: { |
|
358 |
+ |
showRegisterFailedToast(getString(R.string.avatar_error)); |
|
359 |
+ |
} |
|
360 |
+ |
} |
|
361 |
+ |
|
|
362 |
+ |
|
|
363 |
+ |
} catch (UnsupportedEncodingException e) { |
|
364 |
+ |
e.printStackTrace(); |
|
365 |
+ |
|
|
366 |
+ |
} catch (JSONException e) { |
|
367 |
+ |
e.printStackTrace(); |
|
368 |
+ |
} |
315 |
369 |
|
} |
|
370 |
+ |
}).start(); |
316 |
371 |
|
|
317 |
|
- |
} |
318 |
372 |
|
|
319 |
373 |
|
} |
320 |
374 |
|
break; |
|
@@ -388,18 +442,12 @@ |
388 |
442 |
|
successRequest += 1; |
389 |
443 |
|
Log.e("successRequest", String.valueOf(successRequest)); |
390 |
444 |
|
|
391 |
|
- |
if (localeAdditionalLayout.getVisibility() == View.GONE) { |
|
445 |
+ |
|
392 |
446 |
|
PrefsManager.setUserType(c); |
393 |
447 |
|
Intent i = new Intent(RegisterActivity.this, SelectionActivity.class); |
394 |
448 |
|
startActivity(i); |
395 |
449 |
|
finish(); |
396 |
|
- |
} else if (successRequest >= 3) { |
397 |
|
- |
PrefsManager.setLocaleType(c); |
398 |
|
- |
Intent i = new Intent(RegisterActivity.this, SetPositionLocaleActivity.class); |
399 |
|
- |
i.putExtra("idlocale", local_id); |
400 |
|
- |
startActivity(i); |
401 |
|
- |
finish(); |
402 |
|
- |
} |
|
450 |
+ |
|
403 |
451 |
|
} |
404 |
452 |
|
break; |
405 |
453 |
|
default: { |