SHARE
TWEET

Untitled

a guest Jun 15th, 2017 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.msf.ket.login;
  2.  
  3. import java.util.Hashtable;
  4.  
  5. import android.content.Intent;
  6. import android.net.Uri;
  7. import android.os.Bundle;
  8. import android.os.Handler;
  9. import android.os.Message;
  10. import android.util.Log;
  11. import android.view.View;
  12. import android.view.View.OnClickListener;
  13. import android.view.Window;
  14. import android.widget.Button;
  15. import android.widget.EditText;
  16.  
  17. import com.msf.activity.BaseActivity;
  18. import com.msf.ket.R;
  19. import com.msf.parser.responses.ResponseParser;
  20. import com.msf.protocol.request.Request;
  21. import com.msf.util.MSFPopUp;
  22. import com.msf.util.StringStuff;
  23.  
  24. public class BrokerLogin extends BaseActivity {
  25.     private Button login, helpDesk;
  26.     private EditText user, passwd;
  27.  
  28.     @Override
  29.     protected void onCreate(Bundle savedInstanceState) {
  30.         super.onCreate(savedInstanceState);;
  31.         setupViews();
  32.     }
  33.  
  34.  
  35.     private void setupViews() {
  36.         // TODO Auto-generated method stub
  37.         requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
  38.  
  39.         setContentView(R.layout.broker_login);
  40.         getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
  41.                 R.layout.logo_text);
  42.  
  43.         login = (Button) findViewById(R.id.login);
  44.         login.setOnClickListener(loginClick);
  45.        
  46.         helpDesk = (Button) findViewById(R.id.help_desk);
  47.         helpDesk.setOnClickListener(helpDeskClick);
  48.        
  49.         user = (EditText) findViewById(R.id.user);
  50.         passwd = (EditText) findViewById(R.id.passwd);
  51.        
  52.         user.setText("test5678");
  53.         passwd.setText("21ketrade");
  54.     }
  55.  
  56.     protected OnClickListener loginClick = new OnClickListener() {
  57.         @Override
  58.         public void onClick(View v) {
  59.             String username = user.getText().toString();
  60.             String password = passwd.getText().toString();
  61.            
  62.            
  63.             boolean userNameEmpty = !StringStuff.isNotStringEmpty(username);
  64.             boolean pwdEmpty = !StringStuff.isNotStringEmpty(password);
  65.  
  66.             if (userNameEmpty && pwdEmpty)
  67.                 MSFPopUp.showToast(BrokerLogin.this, R.string.empty_username, true);
  68.             else if (userNameEmpty)
  69.                 MSFPopUp.showToast(BrokerLogin.this, R.string.empty_username, true);
  70.             else if (pwdEmpty)
  71.                 MSFPopUp.showToast(BrokerLogin.this, R.string.empty_password, true);
  72.             else {
  73.                
  74.                 new Request(responseHandler).doBrokerLogin(username, password);
  75.             }
  76.         }
  77.     };
  78.    
  79.    
  80.     private OnClickListener helpDeskClick = new OnClickListener() {
  81.  
  82.         @Override
  83.         public void onClick(View v) {
  84.             // TODO Auto-generated method stub
  85.             Intent dialIntent = new Intent(Intent.ACTION_DIAL,
  86.                     Uri.parse("tel:+6562316688"));
  87.             startActivity(dialIntent);
  88.         }
  89.     };
  90.    
  91.     private  Handler responseHandler = new Handler() {
  92.        
  93.         @Override
  94.         public void handleMessage(Message msg) {
  95.             ResponseParser response = (ResponseParser) msg.obj;
  96.            
  97.             if(response.getValue("status").equals("OK")) {
  98.                
  99.             } else {
  100.                 Hashtable h  = (Hashtable) response.getValue("External Modifier"); 
  101.                 MSFPopUp.showAlert(BrokerLogin.this, (String) h.get("REASON"));
  102.             }
  103.         }
  104.        
  105.     };
  106.    
  107. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top