@Override
  public boolean performLongClick() {
    if (super.performLongClick()) {
      return true;
    }

    if (!mCheatSheetEnabled) {
      return false;
    }

    final int[] screenPos = new int[2];
    final Rect displayFrame = new Rect();
    getLocationOnScreen(screenPos);
    getWindowVisibleDisplayFrame(displayFrame);

    final Context context = getContext();
    final int width = getWidth();
    final int height = getHeight();
    final int midy = screenPos[1] + height / 2;
    final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;

    Toast cheatSheet =
        Toast.makeText(context, R.string.mr_button_content_description, Toast.LENGTH_SHORT);
    if (midy < displayFrame.height()) {
      // Show along the top; follow action buttons
      cheatSheet.setGravity(
          Gravity.TOP | GravityCompat.END, screenWidth - screenPos[0] - width / 2, height);
    } else {
      // Show along the bottom center
      cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
    }
    cheatSheet.show();
    performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
    return true;
  }
Ejemplo n.º 2
0
        @Override
        public void onOneShotClick(View v) {
          String codeRegex = "_{1}?([a-z0-9]+(%))+";
          String inputEmailCode = edtEmailCode.getText().toString();
          Boolean matches = Pattern.matches(codeRegex, inputEmailCode);
          if (inputEmailCode.equals("") || !matches) {
            Toast toast =
                Toast.makeText(
                    getApplicationContext(),
                    "Lütfen e-posta adresinize gönderilen kodu giriniz.",
                    Toast.LENGTH_LONG);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
            return;
          }
          String inputPassword = edtNewPassword.getText().toString();
          String inputRePassword = edtRePassword.getText().toString();

          if ((inputPassword.equals("") || inputRePassword.equals(""))
              || (!inputPassword.equals(inputRePassword))) {
            Toast toast =
                Toast.makeText(
                    getApplicationContext(), "Girdiğiniz şifreler eşleşmiyor.", Toast.LENGTH_LONG);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
            return;
          }
          getNewPassWithLogin(sendEmailCodeModel(inputEmailCode, inputPassword, inputRePassword));
        }
Ejemplo n.º 3
0
        @Override
        public void onLoadFinished(Loader<LoginResponse> loader, LoginResponse data) {
          if (data == null) {
            final ApiException apiException = ((LoginAsyncTaskLoader) loader).e;
            if (apiException != null) {
              UIUtils.showToastByException(getActivity(), apiException);
            }
          }
          if (data.getUserCreate() == 0) {
            ((MyApplication) getActivity().getApplication())
                .getLocalData()
                .setSessionId(data.sessionID);
            Toast toast = Toast.makeText(getActivity(), "Красава", Toast.LENGTH_LONG);
            toast.setGravity(Gravity.BOTTOM, 10, 50);
            toast.show();

            SharedPreferences preferences =
                getActivity().getSharedPreferences(PREF_SETTINGS, Context.MODE_PRIVATE);
            String stringPreference = preferences.getString("login", "");
            if (!TextUtils.isEmpty(stringPreference)
                && !(stringPreference.equals(eLogin.getText().toString()))) {
              getActivity().getContentResolver().delete(MyContentProvider.URI_NOTE, null, null);
            }
            saveLastLogin();
            Intent intent = new Intent(getActivity(), NoteActivity.class);
            startActivity(intent);
          }
          if (data.getUserCreate() == 1) {
            Toast toast1 = Toast.makeText(getActivity(), "Попробуй позже", Toast.LENGTH_LONG);
            toast1.setGravity(Gravity.BOTTOM, 10, 50);
            toast1.show();
          }
        }
Ejemplo n.º 4
0
  public void onLogin(View view) {
    SharedPreferences sharedPreferences =
        getSharedPreferences(
            "id.ac.unsyiah.elektro.mobile.tugas10_usernamepassword", Context.MODE_PRIVATE);
    String userPref = sharedPreferences.getString("username", "ThugLife");
    String passPref = sharedPreferences.getString("password", "123321");

    EditText user = (EditText) findViewById(R.id.user);
    String username = user.getText().toString();
    EditText pass = (EditText) findViewById(R.id.password);
    String password = pass.getText().toString();

    if (username.equals(userPref)) {
      if (password.equals(passPref)) {
        Intent pesan = new Intent(getApplicationContext(), ActivityUtama.class);
        pesan.putExtra("kecap1", "peu haba");
        pesan.putExtra("kecap2", userPref);
        startActivity(pesan);
      } else {
        Toast toast = Toast.makeText(this, "Password Salah! ", Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
      }

    } else {
      Toast toast = Toast.makeText(this, "Username Tidak Ada! ", Toast.LENGTH_SHORT);
      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();
    }
  }
Ejemplo n.º 5
0
    @Override
    protected void onPostExecute(String jsonString) {
      super.onPostExecute(jsonString);
      // REMOVE DIALOG
      progressAddSettings.setVisibility(View.INVISIBLE);

      ResultParser resultParser = new ResultParser();
      Result result = resultParser.getParsedResults(jsonString);

      if (result.getError().contains("sucess")) {
        edit.putString(Globals.weight, tvWeight.getText().toString());
        if (genderType.equals(Globals.male)) {
          edit.putString(Globals.gender, Globals.male);
        } else {
          edit.putString(Globals.gender, Globals.female);
        }

        edit.commit();

        Toast toast = Toast.makeText(getApplicationContext(), "Settings added", Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();

      } else if (result.getError().contains("failed")) {

        Toast toast = Toast.makeText(getApplicationContext(), "Error retry !!", Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();

      } else {

      }
    }
Ejemplo n.º 6
0
  /**
   * 根据图库图片uri发送图片
   *
   * @param selectedImage
   */
  protected void sendPicByUri(Uri selectedImage) {
    String[] filePathColumn = {MediaStore.Images.Media.DATA};
    Cursor cursor =
        getActivity().getContentResolver().query(selectedImage, filePathColumn, null, null, null);
    if (cursor != null) {
      cursor.moveToFirst();
      int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
      String picturePath = cursor.getString(columnIndex);
      cursor.close();
      cursor = null;

      if (picturePath == null || picturePath.equals("null")) {
        Toast toast =
            Toast.makeText(getActivity(), R.string.cant_find_pictures, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
        return;
      }
      sendImageMessage(picturePath);
    } else {
      File file = new File(selectedImage.getPath());
      if (!file.exists()) {
        Toast toast =
            Toast.makeText(getActivity(), R.string.cant_find_pictures, Toast.LENGTH_SHORT);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
        return;
      }
      sendImageMessage(file.getAbsolutePath());
    }
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    gestureDetector = new GestureDetector(this, new GlAppGestureListener(this));

    surface = new GLSurfaceView(this);
    renderer = new GlRenderer(this);

    Bundle extras = getIntent().getExtras();

    renderer.SetExampleNum(extras.getInt(EXAMPLE_NAME));

    if ((renderer.GetExampleNum() == 5)
        || (renderer.GetExampleNum() == 7)
        || (renderer.GetExampleNum() == 6)) {
      Context context = getApplicationContext();
      Toast toast = Toast.makeText(context, "Используйте двойной клик", Toast.LENGTH_LONG);
      toast.setGravity(Gravity.BOTTOM, 0, 50);
      toast.show();
    }

    if (renderer.GetExampleNum() == 4) {
      Context context = getApplicationContext();
      Toast toast = Toast.makeText(context, "Нажмите и проведите", Toast.LENGTH_LONG);
      toast.setGravity(Gravity.BOTTOM, 0, 50);
      toast.show();
    }

    surface.setRenderer(renderer);
    setContentView(surface);
  }
  /**
   * This method is called to create the appointment. It grabs all of the text etc from the text
   * boxes and adds these to a HashMap. Following this, a POST request is made to the API sending
   * the HashMap of the appointment details. It then will display Appointment added/something went
   * wrong. If appointment is added the method to produce the pop up asking if the user wants to add
   * the appointment to their calendar is called.
   */
  private void createApp() {

    SharedPreferences account = getSharedPreferences("account", 0);
    String username = account.getString("username", null);
    String password = account.getString("password", null);

    HashMap<String, String> details = new HashMap<String, String>();

    // Text Boxes
    details.put("creator", username);
    details.put("name", ((EditText) findViewById(R.id.name)).getText().toString());
    details.put(
        "addressnamenumber",
        ((EditText) findViewById(R.id.buildingNameNumber)).getText().toString());
    details.put("postcode", ((EditText) findViewById(R.id.postcode)).getText().toString());
    details.put("startdate", ((EditText) findViewById(R.id.startDate)).getText().toString());
    details.put("starttime", ((EditText) findViewById(R.id.startTime)).getText().toString());
    details.put("enddate", ((EditText) findViewById(R.id.endDate)).getText().toString());
    details.put("endtime", ((EditText) findViewById(R.id.endTime)).getText().toString());
    details.put("description", ((EditText) findViewById(R.id.details)).getText().toString());

    final Spinner appTypeSpinner = (Spinner) findViewById((R.id.type));
    final String appType = String.valueOf(appTypeSpinner.getSelectedItem());
    details.put("apptype", appType);

    if (((CheckBox) findViewById(R.id.appPrivate)).isChecked() == true) {
      details.put("private", "True");
    } else {
      details.put("private", "False");
    }

    String responseString = Request.post("addPatientAppointment", details, this);
    int id = Integer.parseInt(responseString);
    System.out.println(responseString);

    if (id > 0) {
      // show the alert to say it is successful
      Context context = getApplicationContext();
      CharSequence text = "Appointment Added.";
      // Length
      int duration = Toast.LENGTH_LONG;
      Toast toast = Toast.makeText(context, text, duration);
      // Position
      toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 100);
      toast.show();
      addToCalendarQuestion(details, id);
    } else {
      Context context = getApplicationContext();
      CharSequence text = "Oops, something went wrong. Please try again.";
      // Length
      int duration = Toast.LENGTH_LONG;
      Toast toast = Toast.makeText(context, text, duration);
      // Position
      toast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 100);
      toast.show();
    }
  }
        @Override
        public void onClick(View paramView) {
          String errorMessage = "";
          int litres = 0;

          try {
            // Leave breadcrumb.
            CrashReporter.leaveBreadcrumb("Trip_Stock_Load: onOK");

            // Check for product.
            if (product == null) {
              errorMessage = "Please select a product";
              return;
            }

            // Check loaded quantity.
            try {
              litres = decimalFormat.parse(etLoaded.getText().toString()).intValue();
            } catch (ParseException e) {
              e.printStackTrace();
            }

            if (litres <= 0) {
              errorMessage = "Litres missing";
              return;
            }

            // Update stock locally.
            Active.vehicle.recordLoad(product, litres);

            // Update stock on server.
            trip.sendVehicleStock();

            // Reset UI.
            etLoaded.setText("");

            // Notify user.
            Toast t = Toast.makeText(trip, litres + " loaded", Toast.LENGTH_SHORT);
            t.setGravity(Gravity.CENTER, 0, 0);
            t.show();
          } catch (Exception e) {
            CrashReporter.logHandledException(e);
          } finally {
            // Show error message?
            if (errorMessage.length() > 0) {
              Toast t = Toast.makeText(trip, errorMessage, Toast.LENGTH_SHORT);
              t.setGravity(Gravity.CENTER, 0, 0);
              t.show();
            }
          }
        }
Ejemplo n.º 10
0
 @Override
 public void onClick(View v) {
   if (v == close) {
     overridePendingTransition(R.anim.pull_in_from_left, R.anim.hold);
     finish();
   }
   if (v == login) {
     name = uName.getText().toString();
     pwd = pass.getText().toString();
     db.open();
     Cursor mCursor = db.getAllRecords();
     mCursor.moveToFirst();
     rName = mCursor.getString(1);
     rPass = mCursor.getString(2);
     db.close();
     if (rPass.equals(pwd)) {
       LayoutInflater mInflater = getLayoutInflater();
       View layout =
           mInflater.inflate(R.layout.toast2, (ViewGroup) findViewById(R.id.custom_toast2));
       TextView text = (TextView) layout.findViewById(R.id.toast_text2);
       text.setText("Login in progress!!");
       toast = new Toast(getApplicationContext());
       toast.setDuration(Toast.LENGTH_LONG);
       toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
       toast.setView(layout);
       toast.show();
       intent = new Intent("com.muneebahmad.moneyman.HOME");
       overridePendingTransition(R.anim.pull_in_from_left, R.anim.hold);
       startActivity(intent);
       finish();
     } else {
       LayoutInflater mInflater = getLayoutInflater();
       View layout =
           mInflater.inflate(R.layout.toast2, (ViewGroup) findViewById(R.id.custom_toast2));
       TextView text = (TextView) layout.findViewById(R.id.toast_text2);
       text.setText("for user: [" + rName + "] Please Supply valid password!");
       toast = new Toast(getApplicationContext());
       toast.setDuration(Toast.LENGTH_LONG);
       toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
       toast.setView(layout);
       toast.show();
     }
   }
   if (v == forget) {
     intent = new Intent("com.muneebahmad.moneyman.FORGET");
     startActivity(intent);
     finish();
   }
 } // end onClick()
Ejemplo n.º 11
0
  public void createUser(View v) {
    EditText etUsername = (EditText) findViewById(R.id.etCreateUserUsername);
    EditText etNick = (EditText) findViewById(R.id.etCreateUserNick);
    EditText etNation = (EditText) findViewById(R.id.etCreateUserNation);
    EditText etEmail = (EditText) findViewById(R.id.etCreateUserEmail);
    EditText etPassword = (EditText) findViewById(R.id.etCreateUserPassword);
    EditText etPassword2 = (EditText) findViewById(R.id.etCreateUserPassword2);

    String username = etUsername.getText().toString();
    String nick = etNick.getText().toString();
    String nation = etNation.getText().toString();
    String email = etEmail.getText().toString();
    String password = etPassword.getText().toString();
    String password2 = etPassword2.getText().toString();

    if ((username.equals(""))
        || (nick.equals(""))
        || (email.equals(""))
        || (nation.equals(""))
        || (password.equals(""))
        || (password2.equals(""))) {
      Context context = getApplicationContext();
      CharSequence text = "Todos los campos son obligatorios";
      int duration = Toast.LENGTH_SHORT;

      Toast toast = Toast.makeText(context, text, duration);
      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();
    } else if (!password.equals(password2)) {
      Context context = getApplicationContext();
      CharSequence text = "Las contraseñas no coinciden";
      int duration = Toast.LENGTH_SHORT;

      Toast toast = Toast.makeText(context, text, duration);
      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();
    } else if (username.length() > 20) {
      Context context = getApplicationContext();
      CharSequence text = "El username es demasiado largo";
      int duration = Toast.LENGTH_SHORT;

      Toast toast = Toast.makeText(context, text, duration);
      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();
    } else {
      (new createUserTask()).execute(username, nick, nation, email, password);
    }
  }
Ejemplo n.º 12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    if (getDeviceDefaultOrientation() == Configuration.ORIENTATION_PORTRAIT) {
      setContentView(R.layout.activity_login_port);
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {
      setContentView(R.layout.activity_login_land);
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }

    userid = (EditText) findViewById(R.id.userid);
    pass = (EditText) findViewById(R.id.pass);
    loading = (ProgressBar) findViewById(R.id.login_loading);
    login = (Button) findViewById(R.id.login);
    logtask = null;

    LayoutInflater inflater = getLayoutInflater();
    layout = inflater.inflate(R.layout.info, (ViewGroup) findViewById(R.id.toast_layout_root));
    information = (TextView) layout.findViewById(R.id.information);

    toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.setDuration(Toast.LENGTH_SHORT);
    toast.setView(layout);
  }
 /**
  * 显示错误信息
  *
  * @param err 需要显示的错误信息
  */
 public void ShowError(String err) {
   Toast toast = Toast.makeText(sInstance, "Error: " + err, 500);
   toast.setGravity(Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
   toast.getView().setBackgroundResource(R.drawable.red_round_rect);
   toast.show();
   Log.e(this.getClass().getName(), err);
 }
Ejemplo n.º 14
0
  public void onSaveSettingsClick(View view) {

    if (tvWeight.getText().toString() == null || tvWeight.getText().toString().isEmpty()) {
      Toast toast = Toast.makeText(getApplicationContext(), "Enter Weight", Toast.LENGTH_LONG);
      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();

    } else if (prefs.getString(Globals.gender, null) == null && genderInt == null) {
      Toast toast = Toast.makeText(getApplicationContext(), "Select Gender", Toast.LENGTH_LONG);
      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();

    } else {
      new AddSettingsAsyncTask().execute(genderInt);
    }
  }
Ejemplo n.º 15
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   int id = item.getItemId();
   if (id == R.id.menu_preferences) {
     doPreferences();
   } else if (id == R.id.menu_new_window) {
     doCreateNewWindow();
   } else if (id == R.id.menu_close_window) {
     confirmCloseWindow();
   } else if (id == R.id.menu_window_list) {
     startActivityForResult(new Intent(this, WindowList.class), REQUEST_CHOOSE_WINDOW);
   } else if (id == R.id.menu_reset) {
     doResetTerminal();
     Toast toast = Toast.makeText(this, R.string.reset_toast_notification, Toast.LENGTH_LONG);
     toast.setGravity(Gravity.CENTER, 0, 0);
     toast.show();
   } else if (id == R.id.menu_send_email) {
     doEmailTranscript();
   } else if (id == R.id.menu_special_keys) {
     doDocumentKeys();
   } else if (id == R.id.menu_toggle_soft_keyboard) {
     doToggleSoftKeyboard();
   } else if (id == R.id.menu_toggle_wakelock) {
     doToggleWakeLock();
   } else if (id == R.id.menu_toggle_wifilock) {
     doToggleWifiLock();
   }
   // Hide the action bar if appropriate
   if (mActionBarMode == TermSettings.ACTION_BAR_MODE_HIDES) {
     mActionBar.hide();
   }
   return super.onOptionsItemSelected(item);
 }
  private void displayToastPublished(String s) {

    Toast toast = Toast.makeText(this, " " + s, Toast.LENGTH_LONG);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
    // Toast.makeText(this, " "+ s , Toast.LENGTH_LONG).show();
  }
Ejemplo n.º 17
0
  private void initializeWidgets(View view) {
    imgViewCircle =
        (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_circle);

    imgViewsArray[0] =
        (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_option1_rounded);
    imgViewsArray[1] =
        (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_option2_rounded);
    imgViewsArray[2] =
        (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_option3_rounded);
    imgViewsArray[3] =
        (RoundedImageView) view.findViewById(R.id.simulation_fragment_image_view_option4_rounded);
    for (RoundedImageView roundedImageView : imgViewsArray) {
      roundedImageView.setCornerRadius((float) 20);
    }

    txtViewsArray[0] = (TextView) view.findViewById(R.id.simulation_fragment_text_view_option1);
    txtViewsArray[1] = (TextView) view.findViewById(R.id.simulation_fragment_text_view_option2);
    txtViewsArray[2] = (TextView) view.findViewById(R.id.simulation_fragment_text_view_option3);
    txtViewsArray[3] = (TextView) view.findViewById(R.id.simulation_fragment_text_view_option4);

    View toastView = getActivity().getLayoutInflater().inflate(R.layout.toast_error, null);
    errorToast = new Toast(getActivity().getApplicationContext());
    errorToast.setGravity(Gravity.BOTTOM, 0, 0);
    errorToast.setView(toastView);
  }
Ejemplo n.º 18
0
  /**
   * 展示toast
   *
   * @param context
   * @param str
   */
  public static void showToast(Context context, String str) {
    // Toast toast = Toast.makeText(context, str, Toast.LENGTH_SHORT);

    Toast toast = ToastFactory.getToast(context, str);
    toast.setGravity(Gravity.CENTER, 0, 0);
    toast.show();
  }
  /**
   * Event handler for the search stock button. Which calls the stock query class. Sends the
   * information about the medication and pharmacy to class which will carry out the search.
   *
   * @param view
   */
  public void searchStock(View view) {

    // if statement checks that the medication has been recorded and the pharmacy selected
    if (selectedPharmacy != null && contentTxt != null) {
      // separates the QR result string into individual elements
      String[] separated = temp.split("_");
      String stock_id = separated[0];
      String medication = separated[1];
      String quantity = separated[3];
      // Intent send to the stock query class giving it the information it needs to carry out the
      // stock check.
      Intent dataIntent = new Intent(getApplicationContext(), StockQuery.class);
      // pharmacy name and id have been returned to the main activity after selection on the map
      dataIntent.putExtra("pharmacy name", pharmacy_name);
      dataIntent.putExtra("pharmacy id", pharmacy_id);
      dataIntent.putExtra("stock id", stock_id);
      dataIntent.putExtra("medication", medication);
      dataIntent.putExtra("quantity", quantity);
      // starts the StockQuery activity and sends the intent
      startActivity(dataIntent);
    } else {
      Toast toast =
          Toast.makeText(
              getApplicationContext(),
              "Unable to search please select medication and pharmacy",
              Toast.LENGTH_LONG);
      toast.getView().setBackgroundColor(Color.WHITE);
      TextView v = (TextView) toast.getView().findViewById(android.R.id.message);
      v.setTextColor(Color.BLACK);
      toast.setGravity(Gravity.CENTER, 0, 0);
      toast.show();
    }
  }
Ejemplo n.º 20
0
 @Override
 public void handleMessage(Message msg) {
   // TODO Auto-generated method stub
   super.handleMessage(msg);
   String res = (String) msg.obj;
   if (res.equals("internetfailed")) {
     Toast toast = Toast.makeText(act.getApplicationContext(), "网络未连接,检查更新失败", Toast.LENGTH_LONG);
     toast.setGravity(Gravity.CENTER, 0, 0);
     toast.show();
     conn.setdelaytime(PublicStatic.delaytime * 1000);
     run();
   } else {
     try {
       JSONObject jsonObject = new JSONObject(res);
       this.settingurl =
           jsonObject.getString("cloudurl") + "&mac=" + PublicStatic.getLocalMacAddress();
       conn.seturl(this.settingurl);
       int checkdelay = Integer.parseInt(jsonObject.getString("checkupdatedelay"));
       conn.setdelaytime(checkdelay * 1000);
       int installversion = Integer.parseInt(jsonObject.getString("versioncode"));
       // 没有新版本更新
       if (installversion <= PublicStatic.getVerCode(act)) {
         run();
       }
       Log.e("checksetting", "checked");
     } catch (Exception e) {
       // TODO: handle exception
     } finally {
       reshttp.resStr(res);
     }
   }
 }
Ejemplo n.º 21
0
 @Override
 public void onClick(final View view) {
   final String text = mFileSelector.getSelectedFileName();
   if (checkFileName(text)) {
     final String filePath =
         mFileSelector.getCurrentLocation().getAbsolutePath() + File.separator + text;
     final File file = new File(filePath);
     int messageText = 0;
     // Check file access rights.
     switch (mOperation) {
       case SAVE:
         if ((file.exists()) && (!file.canWrite())) {
           messageText = R.string.cannotSaveFileMessage;
         }
         break;
       case LOAD:
         if (!file.exists()) {
           messageText = R.string.missingFile;
         } else if (!file.canRead()) {
           messageText = R.string.accessDenied;
         }
         break;
     }
     if (messageText != 0) {
       // Access denied.
       final Toast t = Toast.makeText(mContext, messageText, Toast.LENGTH_SHORT);
       t.setGravity(Gravity.CENTER, 0, 0);
       t.show();
     } else {
       // Access granted.
       mFileSelector.mOnHandleFileListener.handleFile(filePath);
       mFileSelector.dismiss();
     }
   }
 }
Ejemplo n.º 22
0
  public void onClick(View arg0) {

    switch (arg0.getId()) {
      case R.id.ButtonDemo:
        if (!TextUtils.isEmpty(eLogin.getText())) {
          final String LOGIN = eLogin.getText().toString();
          final String PASS = LOGIN;
          login(LOGIN, LOGIN, PASS, arg0);
        } else {
          String loginQ = "q";
          login(loginQ, loginQ, loginQ, arg0);
        }
        break;
      case R.id.button_login:
        final String LOGIN = eLogin.getText().toString();
        final String PASS = ePassword.getText().toString();
        Log.d("Разве логин", "?");
        if (LOGIN.isEmpty() || PASS.isEmpty()) {
          Toast toast =
              Toast.makeText(getActivity(), "Введите логин или пароль", Toast.LENGTH_SHORT);
          toast.setGravity(Gravity.BOTTOM, 10, 50);
          toast.show();
        } else {
          login("Красава", LOGIN, PASS, arg0);
        }
    }
  }
Ejemplo n.º 23
0
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   CharSequence message;
   switch (item.getItemId()) {
     case IDM_PHOTO:
       Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
       // intent.putExtra(MediaStore.EXTRA_OUTPUT, generateFileUri(TYPE_PHOTO));
       startActivityForResult(intent, REQUEST_CODE_PHOTO);
       message = "Сфотографировать";
       break;
     case IDM_GALLARY:
       Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
       photoPickerIntent.setType("image/*");
       startActivityForResult(photoPickerIntent, GALLERY_REQUEST);
       message = "Выбрать из галереи";
       break;
     case IDM_INTERNET:
       message = "Загрузить из сети";
       break;
     default:
       return super.onContextItemSelected(item);
   }
   Toast toast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
   toast.setGravity(Gravity.CENTER, 0, 0);
   toast.show();
   return true;
 }
  private void showToast(String mensaje, int numImage) {
    LayoutInflater inflater = getLayoutInflater();

    View layout =
        inflater.inflate(R.layout.toast, (ViewGroup) findViewById(R.id.toast_layout_root));

    ImageView image = (ImageView) layout.findViewById(R.id.image);

    switch (numImage) {
      case 0:
        image.setImageResource(R.drawable.ic_ok);
        break;
      case 1:
        image.setImageResource(R.drawable.ic_error);
        break;
      default:
        image.setImageResource(R.drawable.ic_launcher);
        break;
    }

    TextView text = (TextView) layout.findViewById(R.id.text);
    text.setText(mensaje);

    Toast toast = new Toast(getApplicationContext());
    toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
    toast.setDuration(Toast.LENGTH_SHORT);
    toast.setView(layout);
    toast.show();
  }
Ejemplo n.º 25
0
        @Override
        public void onOneShotClick(View v) {

          String emailRegex =
              "[a-zA-Z0-9]+(?:(\\.|_)[A-Za-z0-9!#$%&'*+/=?^`{|}~-]+)*@(?!([a-zA-Z0-9]*\\.[a-zA-Z0-9]*\\.[a-zA-Z0-9]*\\.))(?:[A-Za-z0-9](?:[a-zA-Z0-9-]*[A-Za-z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?";
          String inputEmail = edtEmailAddress.getText().toString();
          boolean matches = Pattern.matches(emailRegex, inputEmail);

          if (!inputEmail.equals("") && matches) {

            getMailRespone(sendRequestEmailCodeModel(inputEmail));

          } else {

            Toast toast =
                Toast.makeText(
                    getApplicationContext(),
                    "Lütfen kayıt olduğunuz e-posta adresini giriniz.",
                    Toast.LENGTH_LONG);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
          }

          return;
          // String response=getForgotAccResponse();

        }
Ejemplo n.º 26
0
  public static void syncToast(
      Context context,
      String str,
      Handler handler,
      int milliseconds,
      final SyncToastCallback syncToastCallback) {

    if (context == null) {
      Log.e(tag, "syncToast activity == null");
      return;
    }
    if (str == null || str.equals("")) {
      Log.e(tag, "syncToast str == null");
      return;
    }

    if (milliseconds < 1000) {
      milliseconds = 1000;
    } else if (milliseconds > 3500) {
      milliseconds = 3500;
    }
    final Toast toast = Toast.makeText(context, str, Toast.LENGTH_LONG);

    toast.setGravity(Gravity.TOP, 0, 0);
    toast.show();
    handler.postDelayed(
        new Runnable() {
          @Override
          public void run() {
            toast.cancel();
            syncToastCallback.onHide();
          }
        },
        milliseconds);
  }
Ejemplo n.º 27
0
    @Override
    protected void onPostExecute(ArtistsPager artistsPager) {
      myArtistListQuery = new ArrayList<MyArtist>();
      customAdapterSpotify.clear();

      if (artistsPager != null && !artistsPager.artists.items.isEmpty()) {
        MyArtist myArtist;
        for (Artist artist : artistsPager.artists.items) {

          if (artist.images.isEmpty()) {
            myArtist = new MyArtist(artist.name, artist.id);
          } else {
            myArtist = new MyArtist(artist.name, artist.images.get(0).url, artist.id);
          }
          // List to save for recovering when resume application
          myArtistListQuery.add(myArtist);
          // Add to ArrayAdapter
          customAdapterSpotify.add(myArtist);
        }
      } else {
        Toast toast =
            Toast.makeText(
                getActivity(), res.getString(R.string.no_artist_found), Toast.LENGTH_LONG);
        toast.setGravity(Gravity.CENTER, 0, 0);
        toast.show();
      }
    }
Ejemplo n.º 28
0
 /** @param duration Toast.LENGTH_SHORT or Toast.LENGTH_LONG */
 private static void getToast(int duration) {
   if (mToast == null) {
     mToast = new Toast(mContext);
     mToast.setGravity(Gravity.BOTTOM, 0, dp2px(DEFAULT_TOAST_HIGHT));
     mToast.setDuration(duration == Toast.LENGTH_LONG ? Toast.LENGTH_LONG : Toast.LENGTH_SHORT);
   }
 }
Ejemplo n.º 29
0
  // 录音时间太短时Toast显示
  void showWarnToast(String toastText) {
    Toast toast = new Toast(ChatActivity.this);
    LinearLayout linearLayout = new LinearLayout(ChatActivity.this);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setPadding(20, 20, 20, 20);

    // 定义一个ImageView
    ImageView imageView = new ImageView(ChatActivity.this);
    imageView.setImageResource(R.mipmap.voice_to_short); // 图标

    TextView mTv = new TextView(ChatActivity.this);
    mTv.setText(toastText);
    mTv.setTextSize(14);
    mTv.setTextColor(Color.WHITE); // 字体颜色

    // 将ImageView和ToastView合并到Layout中
    linearLayout.addView(imageView);
    linearLayout.addView(mTv);
    linearLayout.setGravity(Gravity.CENTER); // 内容居中
    linearLayout.setBackgroundResource(R.mipmap.record_bg); // 设置自定义toast的背景

    toast.setView(linearLayout);
    toast.setGravity(Gravity.CENTER, 0, 0); // 起点位置为中间
    toast.show();
  }
Ejemplo n.º 30
0
 private void showSetHomeToast() {
   Context context = getActivity();
   CharSequence message = getString(R.string.sethome, getTitle());
   Toast toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
   toast.setGravity(Gravity.CENTER, 0, 0);
   toast.show();
 }