mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2024-11-09 23:20:27 -06:00
Add asynctask login class
This commit is contained in:
parent
d36e1f4f95
commit
2152da687c
@ -0,0 +1,41 @@
|
||||
package leszcz_team.wulkanowy.activity.main;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
|
||||
import leszcz_team.wulkanowy.R;
|
||||
|
||||
public class Login extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
String email;
|
||||
String password;
|
||||
String county;
|
||||
Activity activity;
|
||||
|
||||
public Login(String emailT, String passwordT, String countyT, Activity mainAC){
|
||||
|
||||
email = emailT;
|
||||
password = passwordT;
|
||||
county = "powiat" + countyT;
|
||||
activity = mainAC;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
super.onPostExecute(result);
|
||||
new AlertDialog.Builder(activity)
|
||||
.setTitle(R.string.warning_label)
|
||||
.setMessage(R.string.error_feature_text)
|
||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {}
|
||||
})
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
}
|
||||
}
|
@ -4,15 +4,18 @@ import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.Toast;
|
||||
|
||||
import leszcz_team.wulkanowy.R;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
private static final String[] COUNTRIES = new String[] {
|
||||
"Jarosławski", "Przeworski"
|
||||
"Powiat jarosławski", "Powiat przeworski"
|
||||
};
|
||||
|
||||
@Override
|
||||
@ -38,8 +41,25 @@ public class MainActivity extends Activity {
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
|
||||
android.R.layout.simple_dropdown_item_1line, COUNTRIES);
|
||||
AutoCompleteTextView textView = (AutoCompleteTextView)
|
||||
findViewById(R.id.county_text);
|
||||
findViewById(R.id.countyText);
|
||||
textView.setAdapter(adapter);
|
||||
|
||||
}
|
||||
|
||||
public void login(View a){
|
||||
EditText adressEmail = (EditText)findViewById(R.id.emailText);
|
||||
EditText passwordText = (EditText)findViewById(R.id.passwordText);
|
||||
EditText countyText = (EditText)findViewById(R.id.countyText);
|
||||
String password = passwordText.getText().toString();
|
||||
String email = adressEmail.getText().toString();
|
||||
String county = countyText.getText().toString();
|
||||
|
||||
if (password.isEmpty()|| email.isEmpty() || county.isEmpty()){
|
||||
Toast.makeText(this, R.string.data_text, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else{
|
||||
new Login(email, password, county, this).execute();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -67,10 +67,11 @@
|
||||
tools:layout_constraintLeft_creator="1"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.712" />
|
||||
app:layout_constraintVertical_bias="0.712"
|
||||
android:onClick="login"/>
|
||||
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/county_text"
|
||||
android:id="@+id/countyText"
|
||||
android:layout_width="215dp"
|
||||
android:layout_height="45dp"
|
||||
android:hint="@string/county_hint"
|
||||
|
@ -9,4 +9,6 @@
|
||||
<string name="county_hint">Powiat</string>
|
||||
<string name="warning_text">Aplikacja ta nie jest ukończona, więc mogą występować różnego rodzaju błędy lub dane funkcje nie bedą działać. Prosimy o cierpliwość i wyrozumiałość.</string>
|
||||
<string name="warning_label">Ostrzeżenie</string>
|
||||
<string name="data_text">Brak danych logowania</string>
|
||||
<string name="error_feature_text">Funkcja którą chciałeś urucThe function you wanted to run does not workhomić nie działa</string>
|
||||
</resources>
|
@ -8,4 +8,6 @@
|
||||
<string name="county_hint">County</string>
|
||||
<string name="warning_text">This application is not complete, so there may be a variety of errors or features that will not work. Please be patient and understanding.</string>
|
||||
<string name="warning_label">Warning</string>
|
||||
<string name="data_text">No login data</string>
|
||||
<string name="error_feature_text">The function you wanted to run does not work</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user