Home | History | Annotate | Download | only in view
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 package com.android.emergency.view;
     17 
     18 import android.app.Fragment;
     19 import android.content.Context;
     20 import android.content.SharedPreferences;
     21 import android.os.Bundle;
     22 import android.support.v14.preference.PreferenceFragment;
     23 import android.support.v7.preference.PreferenceManager;
     24 import android.widget.ListView;
     25 
     26 import com.android.emergency.PreferenceKeys;
     27 import com.android.emergency.R;
     28 import com.android.emergency.preferences.EmergencyContactsPreference;
     29 
     30 /**
     31  * Fragment that displays emergency contacts.
     32  */
     33 public class ViewEmergencyContactsFragment extends PreferenceFragment {
     34     /** The category that holds the emergency contacts. */
     35     private EmergencyContactsPreference mEmergencyContactsPreference;
     36 
     37     @Override
     38     public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
     39         addPreferencesFromResource(R.xml.view_emergency_contacts);
     40         mEmergencyContactsPreference = (EmergencyContactsPreference)
     41                 findPreference(PreferenceKeys.KEY_EMERGENCY_CONTACTS);
     42     }
     43 
     44     @Override
     45     public void onResume() {
     46         super.onResume();
     47         mEmergencyContactsPreference.reloadFromPreference();
     48     }
     49 
     50     public static Fragment newInstance() {
     51         return new ViewEmergencyContactsFragment();
     52     }
     53 }
     54