Commit 20b3763c authored by Bartek Fabiszewski's avatar Bartek Fabiszewski
Browse files

Use try-with-resources

parent 30dae4d3
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -62,9 +62,10 @@ class ListWithEditTextPreference extends ListPreference implements Preference.On

    private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        setOnPreferenceChangeListener(this);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ListWithEditTextPreference, defStyleAttr, defStyleRes);
        otherSummary = a.getText(R.styleable.ListWithEditTextPreference_otherSummary);
        a.recycle();
        try (TypedArray attributes = context.obtainStyledAttributes(attrs, R.styleable.ListWithEditTextPreference,
                defStyleAttr, defStyleRes)) {
            otherSummary = attributes.getText(R.styleable.ListWithEditTextPreference_otherSummary);
        }
    }


+4 −4
Original line number Diff line number Diff line
@@ -128,10 +128,10 @@ public class ProviderPreferenceDialogFragment extends ListPreferenceDialogWithMe
        int resId = android.R.layout.select_dialog_singlechoice;
        final Context context = getContext();
        if (context != null) {
            final TypedArray typedArray = context.obtainStyledAttributes(null, R.styleable.AlertDialog,
                    R.attr.alertDialogStyle, 0);
            resId = typedArray.getResourceId(R.styleable.AlertDialog_singleChoiceItemLayout, resId);
            typedArray.recycle();
            try (final TypedArray attributes = context.obtainStyledAttributes(null, R.styleable.AlertDialog,
                    R.attr.alertDialogStyle, 0)) {
                resId = attributes.getResourceId(R.styleable.AlertDialog_singleChoiceItemLayout, resId);
            }
        }
        return resId;
    }