Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CustomTextInputLayout.java « widget « maps « mapswithme « com « src « android - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bdf6200fe965d86a227d60c85760dbc266761af5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.mapswithme.maps.widget;

import android.content.Context;
import android.graphics.Canvas;
import androidx.annotation.Nullable;
import com.google.android.material.textfield.TextInputLayout;
import androidx.core.view.ViewCompat;
import android.text.TextUtils;
import android.util.AttributeSet;

/**
 * Fixes bug mentioned here https://code.google.com/p/android/issues/detail?id=175228
 */
public class CustomTextInputLayout extends TextInputLayout
{
  private boolean mHintChanged = true;

  public CustomTextInputLayout(Context context)
  {
    super(context);
  }

  public CustomTextInputLayout(Context context, AttributeSet attrs)
  {
    super(context, attrs);
  }

  @Override
  protected void onDraw(Canvas canvas)
  {
    super.onDraw(canvas);

    if (mHintChanged && ViewCompat.isLaidOut(this))
    {
      // In case that hint is changed programmatically
      CharSequence currentEditTextHint = getEditText().getHint();
      if (!TextUtils.isEmpty(currentEditTextHint))
        setHint(currentEditTextHint);
      mHintChanged = false;
    }
  }

  @Override
  public void setHint(@Nullable CharSequence hint)
  {
    super.setHint(hint);
    mHintChanged = true;
  }
}