package me.myatminsoe.mdetect;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.EditText;

public class MMEditText extends EditText {

  public MMEditText(final Context context) {
    super(context);
    if (MDetect.isUnicode()) {
      setHint(getHint());
    } else {
      setHint(Rabbit.uni2zg(getHint().toString()));
    }
  }

  public MMEditText(final Context context, AttributeSet attrs) {
    super(context, attrs);
    if (MDetect.isUnicode()) {
      setHint(getHint());
    } else {
      setHint(Rabbit.uni2zg(getHint().toString()));
    }
  }

  public MMEditText(final Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (MDetect.isUnicode()) {
      setHint(getHint());
    } else {
      setHint(Rabbit.uni2zg(getHint().toString()));
    }
  }

  /**
   * method for setting text
   *
   * @param unicodeString string in Myanmar Unicode
   */
  public void setMMText(String unicodeString) {
    if (MDetect.isUnicode()) {
      setText(unicodeString);
    } else {
      setText(Rabbit.uni2zg(unicodeString));
    }
  }

  /**
   * method for getting text
   *
   * @return CharSequence in Myanmar Unicode
   */
  public CharSequence getMMText() {
    return MDetect.isUnicode() ? getText() : Rabbit.zg2uni(getText().toString());
  }
}

@@ -233,16 +233,48 @@
 ntext);%0A
+%0A    if (getHint() != null) %7B%0A  
     if (
@@ -288,32 +288,34 @@
 .isUnicode()) %7B%0A
+  
       setHint(ge
@@ -320,32 +320,34 @@
 getHint());%0A    
+  
 %7D else %7B%0A      s
@@ -331,32 +331,34 @@
 %0A      %7D else %7B%0A
+  
       setHint(Ra
@@ -385,32 +385,40 @@
 ).toString()));%0A
+      %7D%0A
     %7D%0A  %7D%0A%0A  pub
@@ -504,16 +504,47 @@
 attrs);%0A
+    if (getHint() != null) %7B%0A  
     if (
@@ -564,32 +564,34 @@
 code()) %7B%0A      
+  
 setHint(getHint(
@@ -590,32 +590,34 @@
 getHint());%0A    
+  
 %7D else %7B%0A      s
@@ -601,32 +601,34 @@
 %0A      %7D else %7B%0A
+  
       setHint(Ra
@@ -659,30 +659,38 @@
 String()));%0A
+  
     %7D%0A
+    %7D%0A
   %7D%0A%0A  publi
@@ -798,16 +798,47 @@
 Style);%0A
+    if (getHint() != null) %7B%0A  
     if (
@@ -852,32 +852,34 @@
 .isUnicode()) %7B%0A
+  
       setHint(ge
@@ -888,24 +888,26 @@
 int());%0A    
+  
 %7D else %7B%0A   
@@ -895,32 +895,34 @@
 %0A      %7D else %7B%0A
+  
       setHint(Ra
@@ -953,24 +953,32 @@
 String()));%0A
+      %7D%0A
     %7D%0A  %7D%0A%0A 

Fix crashing due to when hint is not set