PreferenceFragment.java 5.35 KB
package android.support.v4.preference;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;
import android.support.v4.app.Fragment;
import android.support.v4.preferencefragment.R.layout;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnKeyListener;
import android.view.ViewGroup;
import android.widget.ListView;

public abstract class PreferenceFragment
  extends Fragment
{
  private PreferenceManager a;
  private ListView b;
  private boolean c;
  private boolean d;
  private Handler e = new Handler()
  {
    public final void handleMessage(Message paramAnonymousMessage)
    {
      switch (paramAnonymousMessage.what)
      {
      default: 
        return;
      }
      PreferenceFragment.a(PreferenceFragment.this);
    }
  };
  private final Runnable f = new Runnable()
  {
    public final void run()
    {
      PreferenceFragment.b(PreferenceFragment.this).focusableViewAvailable(PreferenceFragment.b(PreferenceFragment.this));
    }
  };
  private View.OnKeyListener g = new View.OnKeyListener()
  {
    public final boolean onKey(View paramAnonymousView, int paramAnonymousInt, KeyEvent paramAnonymousKeyEvent)
    {
      if ((PreferenceFragment.b(PreferenceFragment.this).getSelectedItem() instanceof Preference)) {
        PreferenceFragment.b(PreferenceFragment.this).getSelectedView();
      }
      return false;
    }
  };
  
  private void a()
  {
    PreferenceScreen localPreferenceScreen = getPreferenceScreen();
    if (localPreferenceScreen != null) {
      localPreferenceScreen.bind(getListView());
    }
  }
  
  public void addPreferencesFromResource(int paramInt)
  {
    if (this.a == null) {
      throw new RuntimeException("This should be called after super.onCreate.");
    }
    setPreferenceScreen(PreferenceManagerCompat.a(this.a, getActivity(), paramInt, getPreferenceScreen()));
  }
  
  public Preference findPreference(CharSequence paramCharSequence)
  {
    if (this.a == null) {
      return null;
    }
    return this.a.findPreference(paramCharSequence);
  }
  
  public ListView getListView()
  {
    if (this.b == null)
    {
      View localView = getView();
      if (localView == null) {
        throw new IllegalStateException("Content view not yet created");
      }
      localView = localView.findViewById(16908298);
      if (!(localView instanceof ListView)) {
        throw new RuntimeException("Content has view with id attribute 'android.R.id.list' that is not a ListView class");
      }
      this.b = ((ListView)localView);
      if (this.b == null) {
        throw new RuntimeException("Your content must have a ListView whose id attribute is 'android.R.id.list'");
      }
      this.b.setOnKeyListener(this.g);
      this.e.post(this.f);
    }
    return this.b;
  }
  
  public PreferenceManager getPreferenceManager()
  {
    return this.a;
  }
  
  public PreferenceScreen getPreferenceScreen()
  {
    return PreferenceManagerCompat.a(this.a);
  }
  
  public void onActivityCreated(Bundle paramBundle)
  {
    super.onActivityCreated(paramBundle);
    if (this.c) {
      a();
    }
    this.d = true;
    if (paramBundle != null)
    {
      paramBundle = paramBundle.getBundle("android:preferences");
      if (paramBundle != null)
      {
        PreferenceScreen localPreferenceScreen = getPreferenceScreen();
        if (localPreferenceScreen != null) {
          localPreferenceScreen.restoreHierarchyState(paramBundle);
        }
      }
    }
  }
  
  public void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    super.onActivityResult(paramInt1, paramInt2, paramIntent);
    PreferenceManagerCompat.a(this.a, paramInt1, paramInt2, paramIntent);
  }
  
  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.a = PreferenceManagerCompat.a(getActivity());
    PreferenceManagerCompat.a();
  }
  
  public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
  {
    return paramLayoutInflater.inflate(R.layout.preference_list_fragment, paramViewGroup, false);
  }
  
  public void onDestroy()
  {
    super.onDestroy();
    PreferenceManagerCompat.b(this.a);
  }
  
  public void onDestroyView()
  {
    this.b = null;
    this.e.removeCallbacks(this.f);
    this.e.removeMessages(1);
    super.onDestroyView();
  }
  
  public void onSaveInstanceState(Bundle paramBundle)
  {
    super.onSaveInstanceState(paramBundle);
    PreferenceScreen localPreferenceScreen = getPreferenceScreen();
    if (localPreferenceScreen != null)
    {
      Bundle localBundle = new Bundle();
      localPreferenceScreen.saveHierarchyState(localBundle);
      paramBundle.putBundle("android:preferences", localBundle);
    }
  }
  
  public void setPreferenceScreen(PreferenceScreen paramPreferenceScreen)
  {
    if ((PreferenceManagerCompat.a(this.a, paramPreferenceScreen)) && (paramPreferenceScreen != null))
    {
      this.c = true;
      if ((this.d) && (!this.e.hasMessages(1))) {
        this.e.obtainMessage(1).sendToTarget();
      }
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/android/support/v4/preference/PreferenceFragment.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */