@SuppressWarnings("unchecked") @Override public void onRestoreInstanceState(Parcelable state){
  if (state instanceof Bundle) {
    Bundle bundle=(Bundle)state;
    AutoLabelUISettings autoLabelUISettings=bundle.getParcelable(KEY_INSTANCE_STATE_SETTINGS);
    if (autoLabelUISettings != null) {
      setSettings(autoLabelUISettings);
    }
    resetLabelsCounter();
    List<LabelValues> labelsAdded=(List<LabelValues>)bundle.getSerializable(KEY_INSTANCE_STATE_LABELS);
    if (labelsAdded != null) {
      for (int i=0; i < labelsAdded.size(); i++) {
        LabelValues labelValues=labelsAdded.get(i);
        if (labelValues.getKey() == -1) {
          addLabel(labelValues.getValue());
        }
 else {
          addLabel(labelValues.getValue(),labelValues.getKey());
        }
      }
    }
    state=bundle.getParcelable(KEY_INSTANCE_STATE_GENERAL);
  }
  super.onRestoreInstanceState(state);
}

@ SuppressWarnings ( "unchecked" ) @ Override public void onRestoreInstanceState ( Parcelable state ) { if ( state instanceof Bundle ) { Bundle bundle = ( Bundle ) state ; AutoLabelUISettings autoLabelUISettings = bundle . getParcelable ( KEY_INSTANCE_STATE_SETTINGS ) ; if ( autoLabelUISettings != null ) { setSettings ( autoLabelUISettings ) ; } resetLabelsCounter ( ) ; List < LabelValues > labelsAdded = ( List < LabelValues > ) bundle . getSerializable ( KEY_INSTANCE_STATE_LABELS ) ; if ( labelsAdded != null ) { for ( int i = 0 ; i < labelsAdded . size ( ) ; i ++ ) { LabelValues labelValues = labelsAdded . get ( i ) ; if ( labelValues . getKey ( ) == - 1 ) { addLabel ( labelValues . getValue ( ) ) ; } else { addLabel ( labelValues . getValue ( ) , labelValues . getKey ( ) ) ; } } } state = bundle . getParcelable ( KEY_INSTANCE_STATE_GENERAL ) ; } super . onRestoreInstanceState ( state ) ; }
retrieve the state of the labels when orientation screen changed .
