@Override
 public View getView(int position, View convertView, ViewGroup parent) {
   View view = super.getView(position, convertView, parent);
   AppCompatTextView text1 = (AppCompatTextView) view.findViewById(android.R.id.text1);
   if (position == 0) {
     Drawable drawable = ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_home);
     drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_IN);
     text1.setCompoundDrawablesWithIntrinsicBounds(null, null, drawable, null);
   } else {
     text1.setCompoundDrawables(null, null, null, null);
   }
   return view;
 }
  @Override
  public void setText(@Nullable CharSequence text, BufferType type) {
    if (useSystemEmoji()) {
      super.setText(text, type);
      return;
    }

    source = EmojiProvider.getInstance(getContext()).emojify(text, this);
    setTextEllipsized(source);
  }
  public void startTextAnimation() {

    mTxtTitle.setText(mConfigSplash.getTitleSplash());
    mSubTxtTitle.setText(mConfigSplash.getSubTitleSplash());
    mTxtTitle.setTextSize(mConfigSplash.getTitleTextSize());
    mTxtTitle.setTextColor(getResources().getColor(mConfigSplash.getTitleTextColor()));
    if (!mConfigSplash.getTitleFont().isEmpty()) setFont(mConfigSplash.getTitleFont());

    if (!mConfigSplash.getSubTitleFont().isEmpty()) setSubFont(mConfigSplash.getSubTitleFont());

    RelativeLayout.LayoutParams params =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.BELOW, R.id.flCentral);
    params.addRule(RelativeLayout.CENTER_HORIZONTAL);
    mTxtTitle.setLayoutParams(params);
    mTxtTitle.setVisibility(View.VISIBLE);
    mSubTxtTitle.setVisibility(View.VISIBLE);
    YoYo.with(mConfigSplash.getAnimTitleTechnique())
        .withListener(
            new Animator.AnimatorListener() {
              @Override
              public void onAnimationStart(Animator animation) {}

              @Override
              public void onAnimationEnd(Animator animation) {
                animationsFinished();
              }

              @Override
              public void onAnimationCancel(Animator animation) {}

              @Override
              public void onAnimationRepeat(Animator animation) {}
            })
        .duration(mConfigSplash.getAnimTitleDuration())
        .playOn(mTxtTitle);

    YoYo.with(mConfigSplash.getAnimTitleTechnique())
        .withListener(
            new Animator.AnimatorListener() {
              @Override
              public void onAnimationStart(Animator animation) {}

              @Override
              public void onAnimationEnd(Animator animation) {
                animationsFinished();
              }

              @Override
              public void onAnimationCancel(Animator animation) {}

              @Override
              public void onAnimationRepeat(Animator animation) {}
            })
        .duration(mConfigSplash.getAnimTitleDuration())
        .playOn(mSubTxtTitle);
  }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   final int size = MeasureSpec.getSize(widthMeasureSpec);
   final int mode = MeasureSpec.getMode(widthMeasureSpec);
   if (!useSystemEmoji()
       && getEllipsize() == TruncateAt.END
       && !TextUtils.isEmpty(source)
       && (mode == MeasureSpec.AT_MOST || mode == MeasureSpec.EXACTLY)
       && getPaint().breakText(source, 0, source.length() - 1, true, size, null)
           != source.length()) {
     needsEllipsizing = true;
     FontMetricsInt font = getPaint().getFontMetricsInt();
     super.onMeasure(
         MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY),
         MeasureSpec.makeMeasureSpec(Math.abs(font.top - font.bottom), MeasureSpec.EXACTLY));
   } else {
     needsEllipsizing = false;
     super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   }
 }
  private void initUI() {

    firebaseAuth = FirebaseAuth.getInstance();

    if (firebaseAuth.getCurrentUser() != null) {
      startActivity(new Intent(this, MainActivity.class));
      finish();
    }

    tilEmail = (TextInputLayout) findViewById(R.id.tilEmail);
    clGeneral = (CoordinatorLayout) findViewById(R.id.clGeneral);
    tilPassword = (TextInputLayout) findViewById(R.id.tilPassword);
    tieEmail = (TextInputEditText) findViewById(R.id.tieEmail);
    tiePassword = (TextInputEditText) findViewById(R.id.tiePassword);
    btnLogin = (AppCompatButton) findViewById(R.id.btnLogin);
    lblRecoveryPassword = (AppCompatTextView) findViewById(R.id.lblRecoveryPassword);
    lblCreateAccount = (AppCompatTextView) findViewById(R.id.lblCreateAccount);

    btnLogin.setOnClickListener(this);
    lblRecoveryPassword.setOnClickListener(this);
    lblCreateAccount.setOnClickListener(this);

    tieEmail.addTextChangedListener(new CustomTextWatcher(tieEmail));
    tiePassword.addTextChangedListener(new CustomTextWatcher(tiePassword));

    tiePassword.setOnEditorActionListener(
        new TextView.OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_GO) {
              btnLogin.performClick();
              return true;
            }
            return false;
          }
        });
  }
Esempio n. 6
0
  private void getPic(Intent data) {
    if (null != data) {
      // 取出所选图片的路径
      Uri selectedImage = data.getData();
      String[] filePathColumn = {MediaStore.Images.Media.DATA};

      Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
      cursor.moveToFirst();

      int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
      String picuri = cursor.getString(columnIndex);
      cursor.close();

      // 将图片贴到控件上
      BitmapFactory.Options options = new BitmapFactory.Options();
      options.inJustDecodeBounds = true;
      BitmapFactory.decodeFile(picuri, options);
      int width = options.outWidth;
      int height = options.outHeight;
      if (100 > width || 40 > height) {
        // 图片分辨率太低
        Toast.makeText(this, getString(R.string.question_imagetoosmall), Toast.LENGTH_SHORT).show();
        MobclickAgent.onEvent(this, "addQP_F");
        return;
      }

      BitmapFactory.Options opts = new BitmapFactory.Options();
      opts.inJustDecodeBounds = true;
      BitmapFactory.decodeFile(picuri, opts);
      opts.inSampleSize = computeSampleSize(opts, -1, 700 * 272);
      opts.inJustDecodeBounds = false;
      try {
        bitmap = BitmapFactory.decodeFile(picuri, opts);
      } catch (OutOfMemoryError err) {
        // showNotification("图片过大!");
        MobclickAgent.onEvent(this, "addQP_F");
        Toast.makeText(this, getString(R.string.question_imagetoolarge), Toast.LENGTH_SHORT).show();
        return;
      }
      MobclickAgent.onEvent(this, "addQP_S");
      image.setScaleType(ImageView.ScaleType.FIT_CENTER);
      image.setImageBitmap(bitmap);
      hint.setText(getString(R.string.question_removeimage_hint));
    }
  }
 @Override
 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
   if (changed && !useSystemEmoji()) setTextEllipsized(source);
   super.onLayout(changed, left, top, right, bottom);
 }
 @Override
 public void invalidateDrawable(@NonNull Drawable drawable) {
   if (drawable instanceof EmojiDrawable) invalidate();
   else super.invalidateDrawable(drawable);
 }
 private void setTextEllipsized(final @Nullable CharSequence source) {
   super.setText(
       needsEllipsizing ? ViewUtil.ellipsize(source, this) : source, BufferType.SPANNABLE);
 }
Esempio n. 10
0
  /** *** CAST THE LAYOUT ELEMENTS **** */
  private void castLayoutElements() {

    /* CATEGORY SELECTOR */
    spnMenuCategory = (AppCompatSpinner) findViewById(R.id.spnMenuCategory);
    AppCompatTextView txtAddNewCategory = (AppCompatTextView) findViewById(R.id.txtAddNewCategory);

    /* MENU / DISH DETAILS */
    inputDishName = (TextInputLayout) findViewById(R.id.inputDishName);
    edtDishName = (AppCompatEditText) findViewById(R.id.edtDishName);
    inputDishDescription = (TextInputLayout) findViewById(R.id.inputDishDescription);
    edtDishDescription = (AppCompatEditText) findViewById(R.id.edtDishDescription);
    inputDishPrice = (TextInputLayout) findViewById(R.id.inputDishPrice);
    edtDishPrice = (AppCompatEditText) findViewById(R.id.edtDishPrice);
    RadioGroup rdgDishType = (RadioGroup) findViewById(R.id.rdgDishType);
    spnServes = (AppCompatSpinner) findViewById(R.id.spnServes);
    imgvwAddPhoto = (AppCompatImageView) findViewById(R.id.imgvwAddPhoto);

    /** CHANGE THE MEAL TYPE * */
    rdgDishType.setOnCheckedChangeListener(
        new RadioGroup.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {

            switch (checkedId) {
              case R.id.rdbtnVeg:
                /** SET THE DISH TYPE TO "VEG" * */
                MEAL_TYPE = "Veg";
                break;
              case R.id.rdbtnNonVeg:
                /** SET THE DISH TYPE TO "NON-VEG" * */
                MEAL_TYPE = "Non-veg";
                break;
              default:
                break;
            }
          }
        });

    /** *** CREATE A NEW CATEGORY **** */
    txtAddNewCategory.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent newCategory = new Intent(MenuCreator.this, CategoryCreator.class);
            startActivityForResult(newCategory, ACTION_REQUEST_NEW_CATEGORY);
          }
        });

    /** *** SELECT A PHOTO FOR THE DISH **** */
    imgvwAddPhoto.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            EasyImage.openChooser(MenuCreator.this, "Pick Image Source", true);
          }
        });

    /** POPULATE THE SPINNER * */
    String[] strServes = getResources().getStringArray(R.array.menuServes);
    final List<String> arrServes;
    arrServes = Arrays.asList(strServes);
    spnServes.setAdapter(
        new MenuServesAdapter(MenuCreator.this, R.layout.custom_spinner_row, arrServes));

    /** CHANGE THE MENU SERVES NUMBER * */
    spnServes.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            //                Toast.makeText(getApplication(), arrServes.get(position),
            // Toast.LENGTH_SHORT).show();
            MEAL_SERVES = arrServes.get(position);
          }

          @Override
          public void onNothingSelected(AdapterView<?> parent) {}
        });
  }
 public void setSubFont(String font) {
   Typeface typeSub = Typeface.createFromAsset(getAssets(), font);
   mSubTxtTitle.setTypeface(typeSub);
 }
 public void setFont(String font) {
   Typeface type = Typeface.createFromAsset(getAssets(), font);
   mTxtTitle.setTypeface(type);
 }
Esempio n. 13
0
 private void hideProgress() {
   progressBar.setVisibility(View.GONE);
   upload.setVisibility(View.GONE);
 }
Esempio n. 14
0
 private void showProgress() {
   progressBar.setVisibility(View.VISIBLE);
   upload.setVisibility(View.VISIBLE);
 }