Example #1
0
 // save button action
 public void saveData(View view) {
   // check if the input fields are empty or not
   if (!etBookName.equals("")
       && !etAuthorName.equals("")
       && !etCategory.equals("")
       && !etDescription.equals("")) {
     // if input fields are not empty collect the inputs
     String bookName = etBookName.getText().toString();
     String authorName = etAuthorName.getText().toString();
     String category = etCategory.getText().toString();
     String description = etDescription.getText().toString();
     // make a new book with the inputs
     book = new Book(bookName, authorName, category, description);
     // add book to database
     boolean saved = booksDataSource.addBook(book);
     if (saved) {
       Toast.makeText(AddBookActivity.this, bookName + " saved successfully!", Toast.LENGTH_SHORT)
           .show();
       this.finish();
     } else {
       Toast.makeText(AddBookActivity.this, bookName + " was not saved!", Toast.LENGTH_SHORT)
           .show();
     }
   } else {
     Toast.makeText(this, "Enter information properly", Toast.LENGTH_SHORT).show();
   }
 }
Example #2
0
 @Override
 public void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   if (ean != null && !ean.equals("")) {
     outState.putString(EAN_CONTENT, ean.getText().toString());
   }
 }
Example #3
0
  @Override
  public void onClick(View view) {
    System.out.println("view.getId() : " + view.getId());
    System.out.println("button Clicked!");

    // ID
    EditText editTextID = (EditText) findViewById(R.id.editTextID);
    // PASSWORD
    EditText editTextPassword = (EditText) findViewById(R.id.editTextPassword);
    System.out.println("ID : " + editTextID.getText());
    System.out.println("Password : " + editTextPassword.getText());

    final AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
    alertDialog.setTitle("경고");
    alertDialog.setPositiveButton(
        "확인",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            System.out.println("Dialog Button Clicked!");
            System.out.println("which : " + which);
          }
        });

    if (editTextID.equals(null) || "".equals(editTextID.getText().toString())) {
      System.out.println("Blank ID!");
      alertDialog.setMessage("ID를 입력하시오.");
      alertDialog.show();
    } else if (editTextPassword.equals(null) || "".equals(editTextPassword.getText().toString())) {
      System.out.println("Blank Password!");
      alertDialog.setMessage("Password를 입력하시오.");
      alertDialog.show();
    } else {
      Intent intent = new Intent(MainActivity.this, SubActivity.class);
      intent.putExtra("inputId", editTextID.getText().toString());
      startActivity(intent);
    }
  }
Example #4
0
  public void searchContact(View view) {
    if (SearchName == null || SearchName.equals("")) {
      Toast.makeText(this, "Please Enter Name", Toast.LENGTH_SHORT).show();
      return;
    } else {
      /*Intent callIntent = new Intent(Intent.ACTION_CALL);
      callIntent.setData(Uri.parse("tel:0862335871"));
      startActivity(callIntent);*/
      searchName = SearchName.getText().toString();
      userDb = new UserDb(getApplicationContext());
      sqLiteDatabase = userDb.getReadableDatabase();
      Cursor cursor = userDb.getContact(searchName, sqLiteDatabase);
      if (cursor.moveToFirst()) {
        String mobile = cursor.getString(0);
        String email = cursor.getString(1);

        Phone.setText(mobile);
        Email.setText(email);

        /*//CALL THE PERSON ON SEARCH BUTTON
        Log.d("Hi","I want to call "+ mobile);
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:"+mobile));
        startActivity(callIntent);*/

        // SEND SOME EMERGENNCY MESSGAe
        /*String messageToSend = "this is a message";
        String number = "0877845450";
        SmsManager.getDefault().sendTextMessage(number, null, messageToSend, null, null);*/

        Email.setVisibility(View.VISIBLE);
        Phone.setVisibility(View.VISIBLE);
        CallButton.setVisibility(View.VISIBLE);
        EmailButton.setVisibility(View.VISIBLE);
        MapButton.setVisibility(View.VISIBLE);
        MessageButton.setVisibility(View.VISIBLE);
        TextMobile.setVisibility(View.VISIBLE);
        TextEmail.setVisibility(View.VISIBLE);
        // InstantSms.setVisibility(View.VISIBLE);

        /*Latitude.setVisibility(View.VISIBLE);
        Longitude.setVisibility(View.VISIBLE);
        AddressName.setVisibility(View.VISIBLE);
        Address.setVisibility(View.VISIBLE);*/

        /*Message.setVisibility(View.GONE);
        MessageButton.setVisibility(View.GONE);*/
      }
    }
  }