диплом (Мобильное приложение для оформления заказов на транспортировку товаров), страница 10
Описание файла
Файл "диплом" внутри архива находится в следующих папках: Мобильное приложение для оформления заказов на транспортировку товаров, Аршиева К.К. Документ из архива "Мобильное приложение для оформления заказов на транспортировку товаров", который расположен в категории "". Всё это находится в предмете "дипломы и вкр" из 8 семестр, которые можно найти в файловом архиве ДВГУПС. Не смотря на прямую связь этого архива с ДВГУПС, его также можно найти и в других разделах. .
Онлайн просмотр документа "диплом"
Текст 10 страницы из документа "диплом"
Листинг В.4 – Активити профиля пользователя
package com.example.acid.continent;
import android.app.ProgressDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.os.AsyncTask;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import android.util.Log;
import java.util.HashMap;
import org.json.JSONObject;
import org.json.JSONException;
public class Profile extends AppCompatActivity {
private static final String[] headers = new String[] {"Мои заявки", "Подать заявку", "Архив заявок", "Настройки", "Выйти из аккаунта"};
private ProgressDialog progrDialog;
private ListView listView;
private String userText,passText;
private JSONRequest jsonRequest = new JSONRequest();
private SessionManager session;
private HashGenerator shaHash = new HashGenerator();
private static final String tagSuccess = "success";
private static final String tagMessage = "message";
private static final String logUrl = "http://ancnt.esy.es/login.php";
private static final String logOutUrl = "http://ancnt.esy.es/logout.php";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile);
listView = (ListView)findViewById(R.id.lvMenu);
session = new SessionManager(getApplicationContext());
session.checkLogin();
HashMap<String,String> userData = session.getSessionData();
if(session.isLoggedIn()) {
userText = userData.get(SessionManager.login);
passText = userData.get(SessionManager.pass);
if (Validator.isNetworkAvailable(Profile.this))
new serverLogin().execute();
}
ArrayAdapter<String> adapter= new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,
android.R.id.text1,headers);
listView.setAdapter(adapter);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
int itemPos = position;
switch (itemPos){
case 0:
Intent in = new Intent(Profile.this,MyOrders.class);
in.putExtra("aim",0);
startActivity(in);
break;
case 1:
Intent intent = new Intent(Profile.this,OrderPlacement.class);
startActivity(intent);
break;
case 2:
Intent intent1 = new Intent(Profile.this,MyOrders.class);
intent1.putExtra("aim",1);
startActivity(intent1);
break;
case 3:
Intent intent2 = new Intent(Profile.this,ProfileSettings.class);
startActivity(intent2);
break;
case 4: if(Validator.isNetworkAvailable(Profile.this)) {
session.logOut();
new serverLogOut().execute();
}
else Toast.makeText(Profile.this,"Пожалуйста подключитесь к сети", Toast.LENGTH_LONG).show();
break;
default:
break;
}
}
});
}
class serverLogin extends AsyncTask<String, String, String>{
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(String... params) {
int success;
try {
HashMap<String, String> arg = new HashMap<>();
arg.put("username", userText);
arg.put("password", passText);
Log.d("Получен запрос", "Начать выполнение");
JSONObject json = jsonRequest.makeHttpRequest(logUrl, "POST", arg);
Log.d("Попытка входа", json.toString());
success = json.getInt(tagSuccess);
if (success == 1) {
Log.d("Вход успешно выполнен!", json.toString());
return json.getString(tagMessage);
} else {
Log.d("Вход не выполнен!", json.getString(tagMessage));
Intent intent = new Intent(Profile.this,Login.class);
finish();
startActivity(intent);
return json.getString(tagMessage);
}
} catch (JSONException ex) {
ex.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s) {
}
}
class serverLogOut extends AsyncTask<String, String, String>{
@Override
protected void onPreExecute() {
super.onPreExecute();
progrDialog = new ProgressDialog(Profile.this);
progrDialog.setMessage("Выход из аккаунта...");
progrDialog.setCancelable(false);
progrDialog.show();
}
@Override
protected String doInBackground(String... params) {
int success;
try {
HashMap<String, String> arg = new HashMap<>();
Log.d("Получен запрос", "Начать выполнение");
JSONObject json = jsonRequest.makeHttpRequest(logOutUrl, "POST", arg);
Log.d("Попытка выхода", json.toString());
success = json.getInt(tagSuccess);
if (success == 1) {
Log.d("Сеанс завершен!", json.getString(tagMessage));
Intent intent = new Intent(Profile.this,Login.class);
finish();
startActivity(intent);
return json.getString(tagMessage);
} else {
Log.d("Попробуйте снова!", json.toString());
return json.getString(tagMessage);
}
} catch (JSONException ex) {
ex.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s) {
progrDialog.dismiss();
}
}
}