Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4e07a9c authored by Yue Liang's avatar Yue Liang Committed by Gerrit - the friendly Code Review server
Browse files

Bug fix: Settings: HotspotPreference.java

Phenomenon:
User leave from TetherSettings after Hotspot activated
and return to it later, HotspotPreference summary will
show empty.

Rootcause:
HotspotPreference.onBindViewHolder will re-hold after
user return to TehterSettings, but summary haven't
latest record, so summary will show empty.

Solution:
Get HotspotPreference to retain the latest summary after
setSummary be called.

Change-Id: Ibc2728e47c938d74819198719087098ea9983ac2
CRs-Fixed: 1088843
parent af150d54
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ public class HotspotPreference extends Preference implements OnCheckedChangeList
    private TextView mSubSummary;
    private Context mContext;
    private boolean mSwitchEnabled;

    private CharSequence mSummary;
    public HotspotPreference(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        mContext = context;
@@ -67,12 +67,21 @@ public class HotspotPreference extends Preference implements OnCheckedChangeList
    @Override
    public void onBindViewHolder(PreferenceViewHolder view) {
        super.onBindViewHolder(view);
        if (mSubSummary == null) {
            mSubSummary = (TextView) view.findViewById(R.id.subsummary);
            if (mSummary != null && !mSummary.toString().isEmpty()) {
                mSubSummary.setVisibility(View.VISIBLE);
            } else {
                mSubSummary.setVisibility(View.GONE);
            }
            mSubSummary.setText(mSummary);
        }
        if (mSwitch == null) {
            mSwitch = (Switch) view.findViewById(R.id.switchWidget);
            mSwitch.setOnCheckedChangeListener(this);
            setChecked(mSwitchEnabled);
        }
    }


    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -81,6 +90,7 @@ public class HotspotPreference extends Preference implements OnCheckedChangeList
    }

    public void setSummary(CharSequence summary) {
        mSummary = summary;
        if (mSubSummary == null) {
            return;
        }