package org.wikipedia.views;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import org.wikipedia.util.StringUtil;

public class GoneIfEmptyTextView extends TextView {
    public GoneIfEmptyTextView(Context context) {
        super(context);
    }

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

    public GoneIfEmptyTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public GoneIfEmptyTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public void setText(@Nullable String text) {
        super.setText(text);
        setVisibility(StringUtil.emptyIfNull(text).equals("") ? View.GONE : View.VISIBLE);
    }
}

@@ -136,35 +136,54 @@
 oid.
-sup
+text.Editable;%0Aim
 port
-.annotation.Nullable
+ android.text.TextWatcher
 ;%0Aim
@@ -277,47 +277,8 @@
 w;%0A%0A
-import org.wikipedia.util.StringUtil;%0A%0A
 publ
@@ -395,24 +395,40 @@
 r(context);%0A
+        init();%0A
     %7D%0A%0A    p
@@ -519,24 +519,40 @@
 xt, attrs);%0A
+        init();%0A
     %7D%0A%0A    p
@@ -679,16 +679,32 @@
 eAttr);%0A
+        init();%0A
     %7D%0A%0A 
@@ -918,150 +918,534 @@
     
-%7D%0A%0A    public void setText(@Nullable String text) %7B%0A        super.setText(text);%0A        setVisibility(StringUtil.emptyIfNull(text).equals(%22%22)
+    init();%0A    %7D%0A%0A    private void init() %7B%0A        addTextChangedListener(new EmptyTextWatcher());%0A    %7D%0A%0A    private class EmptyTextWatcher implements TextWatcher %7B%0A        @Override%0A        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) %7B%0A        %7D%0A%0A        @Override%0A        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) %7B%0A        %7D%0A%0A        @Override%0A        public void afterTextChanged(Editable editable) %7B%0A            setVisibility(editable.length() == 0
  ? V
@@ -1470,16 +1470,26 @@
 SIBLE);%0A
+        %7D%0A
     %7D%0A%7D%0A

Remove ambiguity when using GoneIfEmptyTextView.