content: /*
   *     Copyright (C) 2016  Merbin J Anselm <merbinjanselm@gmail.com>
   *
   *     This program is free software; you can redistribute it and/or modify
   *     it under the terms of the GNU General Public License as published by
   *     the Free Software Foundation; either version 2 of the License, or
   *     (at your option) any later version.
   *
   *     This program is distributed in the hope that it will be useful,
   *     but WITHOUT ANY WARRANTY; without even the implied warranty of
   *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *     GNU General Public License for more details.
   *
   *     You should have received a copy of the GNU General Public License along
   *     with this program; if not, write to the Free Software Foundation, Inc.,
   *     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   */
  
  package in.blogspot.anselmbros.torchie.ui.widget.settings;
  
  import android.content.Context;
  import android.util.AttributeSet;
  import android.view.View;
  import android.widget.CheckBox;
  
  import in.blogspot.anselmbros.torchie.R;
  
  /**
   * Created by Merbin J Anselm on 27-Jan-17.
   */
  
  public class CheckBoxDialogPreference extends TimeoutListPreference {
  
      public CheckBoxDialogPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
          super(context, attrs, defStyleAttr, defStyleRes);
      }
  
      public CheckBoxDialogPreference(Context context, AttributeSet attrs, int defStyleAttr) {
          super(context, attrs, defStyleAttr);
      }
  
      public CheckBoxDialogPreference(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      public CheckBoxDialogPreference(Context context) {
          super(context);
      }
  
      @Override
      protected void onBindView(View view) {
          super.onBindView(view);
          int value = Integer.parseInt(this.getValue());
          CheckBox checkBox = view.findViewById(R.id.chkbx_pref);
          checkBox.setChecked((value == -1 || value > 0) && isEnabled());
      }
  }
  