package com.cssoft.speedlocker;
import com.cssoft.fonts.MyFonts;
import com.cssoft.validation.Validations;
import com.cssoft.webservices.Login_User;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.style.TtsSpan.TextBuilder;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class LoginActivity extends Activity {
private TextView txt_username, txt_password, txt_forgot;
private EditText edit_username, edit_password;
private Button btn_login;
private Validations valid;
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
valid = new Validations(LoginActivity.this);
getUI();
setFonts();
clickEvents();
}
private void getUI() {
txt_username = (TextView) findViewById(R.id.txt_login_username);
txt_password = (TextView) findViewById(R.id.txt_login_password);
txt_forgot = (TextView) findViewById(R.id.txt_login_forgot);
edit_username = (EditText) findViewById(R.id.edit_login_username);
edit_password = (EditText) findViewById(R.id.edit_login_password);
btn_login = (Button) findViewById(R.id.btn_login);
}
private void setFonts() {
txt_username.setTypeface(MyFonts.RobotoMedium(LoginActivity.this));
txt_password.setTypeface(MyFonts.RobotoMedium(LoginActivity.this));
txt_forgot.setTypeface(MyFonts.RobotoMedium(LoginActivity.this));
edit_username.setTypeface(MyFonts.RobotoMedium(LoginActivity.this));
edit_password.setTypeface(MyFonts.RobotoMedium(LoginActivity.this));
btn_login.setTypeface(MyFonts.RobotoMedium(LoginActivity.this));
}
private void clickEvents() {
txt_forgot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(LoginActivity.this,
ForgotActivity.class));
overridePendingTransition(R.anim.zoomin, R.anim.fadeout);
}
});
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String username = edit_username.getText().toString().trim();
String password = edit_password.getText().toString().trim();
if (!valid.isEmpty(username)) {
Toast.makeText(getApplicationContext(), "Enter Username",
Toast.LENGTH_SHORT).show();
} else if (!valid.isEmpty(password)) {
Toast.makeText(getApplicationContext(), "Enter Password",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "OK",
Toast.LENGTH_SHORT).show();
new Login_User(LoginActivity.this).execute(username,
password);
}
}
});
}
}
import com.cssoft.fonts.MyFonts;
import com.cssoft.validation.Validations;
import com.cssoft.webservices.Login_User;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.style.TtsSpan.TextBuilder;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class LoginActivity extends Activity {
private TextView txt_username, txt_password, txt_forgot;
private EditText edit_username, edit_password;
private Button btn_login;
private Validations valid;
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
valid = new Validations(LoginActivity.this);
getUI();
setFonts();
clickEvents();
}
private void getUI() {
txt_username = (TextView) findViewById(R.id.txt_login_username);
txt_password = (TextView) findViewById(R.id.txt_login_password);
txt_forgot = (TextView) findViewById(R.id.txt_login_forgot);
edit_username = (EditText) findViewById(R.id.edit_login_username);
edit_password = (EditText) findViewById(R.id.edit_login_password);
btn_login = (Button) findViewById(R.id.btn_login);
}
private void setFonts() {
txt_username.setTypeface(MyFonts.RobotoMedium(LoginActivity.this));
txt_password.setTypeface(MyFonts.RobotoMedium(LoginActivity.this));
txt_forgot.setTypeface(MyFonts.RobotoMedium(LoginActivity.this));
edit_username.setTypeface(MyFonts.RobotoMedium(LoginActivity.this));
edit_password.setTypeface(MyFonts.RobotoMedium(LoginActivity.this));
btn_login.setTypeface(MyFonts.RobotoMedium(LoginActivity.this));
}
private void clickEvents() {
txt_forgot.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(LoginActivity.this,
ForgotActivity.class));
overridePendingTransition(R.anim.zoomin, R.anim.fadeout);
}
});
btn_login.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String username = edit_username.getText().toString().trim();
String password = edit_password.getText().toString().trim();
if (!valid.isEmpty(username)) {
Toast.makeText(getApplicationContext(), "Enter Username",
Toast.LENGTH_SHORT).show();
} else if (!valid.isEmpty(password)) {
Toast.makeText(getApplicationContext(), "Enter Password",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), "OK",
Toast.LENGTH_SHORT).show();
new Login_User(LoginActivity.this).execute(username,
password);
}
}
});
}
}
No comments:
Post a Comment