Program: 26281
Project: 26281
Buggy source:
private void initPreferences(){
  final ListPreference prefHomeGdgList=(ListPreference)findPreference(Const.SETTINGS_HOME_GDG);
  if (prefHomeGdgList != null) {
    App.getInstance().getModelCache().getAsync("String_Node_Str",false,new ModelCache.CacheListener(){
      @Override public void onGet(      Object item){
        Directory directory=(Directory)item;
        CharSequence entries[]=new String[directory.getGroups().size()];
        CharSequence entryValues[]=new String[directory.getGroups().size()];
        int i=0;
        for (        Chapter chapter : directory.getGroups()) {
          entries[i]=chapter.getName();
          entryValues[i]=chapter.getGplusId();
          i++;
        }
        prefHomeGdgList.setEntries(entries);
        prefHomeGdgList.setEntryValues(entryValues);
      }
      @Override public void onNotFound(      String key){
      }
    }
);
    prefHomeGdgList.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
      @Override public boolean onPreferenceChange(      Preference preference,      Object o){
        final String homeGdg=(String)o;
        if (mPlayServicesHelper.isSignedIn() && mPreferences.getBoolean("String_Node_Str",true)) {
          setHomeGdg(homeGdg);
        }
        return true;
      }
    }
);
  }
  CheckBoxPreference prefGcm=(CheckBoxPreference)findPreference(Const.SETTINGS_GCM);
  if (prefGcm != null) {
    prefGcm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
      @Override public boolean onPreferenceChange(      Preference preference,      Object o){
        final boolean enableGcm=(Boolean)o;
        if (mPlayServicesHelper.isSignedIn()) {
          mLoading.setVisibility(View.VISIBLE);
          mLoading.startAnimation(AnimationUtils.loadAnimation(SettingsActivity.this,R.anim.fade_in));
          new AsyncTask<Void,Void,Void>(){
            @Override protected Void doInBackground(            Void... voids){
              try {
                String token=GoogleAuthUtil.getToken(SettingsActivity.this,mPlayServicesHelper.getPlusClient().getAccountName(),"String_Node_Str" + Scopes.PLUS_LOGIN);
                mXClient.setToken(token);
                if (!enableGcm) {
                  ApiRequest req=mXClient.unregisterGcm(mPreferences.getString(Const.SETTINGS_GCM_REG_ID,"String_Node_Str"),new Response.Listener<GcmRegistrationResponse>(){
                    @Override public void onResponse(                    GcmRegistrationResponse messageResponse){
                      mPreferences.edit().putBoolean(Const.SETTINGS_GCM,false).remove(Const.SETTINGS_GCM_REG_ID).apply();
                    }
                  }
,new Response.ErrorListener(){
                    @Override public void onErrorResponse(                    VolleyError volleyError){
                      Log.e(LOG_TAG,"String_Node_Str",volleyError);
                    }
                  }
);
                  req.execute();
                }
 else {
                  final String regid=mGcm.register(getString(R.string.gcm_sender_id));
                  ApiRequest req=mXClient.registerGcm(regid,new Response.Listener<GcmRegistrationResponse>(){
                    @Override public void onResponse(                    GcmRegistrationResponse messageResponse){
                      mPreferences.edit().putBoolean(Const.SETTINGS_GCM,true).putString(Const.SETTINGS_GCM_REG_ID,regid).putString(Const.SETTINGS_GCM_NOTIFICATION_KEY,messageResponse.getNotificationKey()).apply();
                    }
                  }
,new Response.ErrorListener(){
                    @Override public void onErrorResponse(                    VolleyError volleyError){
                      Log.e(LOG_TAG,"String_Node_Str",volleyError);
                    }
                  }
);
                  req.execute();
                  setHomeGdg(mPreferences.getString(Const.SETTINGS_HOME_GDG,"String_Node_Str"));
                }
              }
 catch (              IOException e) {
                Log.e(LOG_TAG,"String_Node_Str",e);
                e.printStackTrace();
              }
catch (              GoogleAuthException e) {
                Log.e(LOG_TAG,"String_Node_Str",e);
                e.printStackTrace();
              }
              return null;
            }
            @Override protected void onPostExecute(            Void o){
              super.onPostExecute(o);
              Animation fadeOut=AnimationUtils.loadAnimation(SettingsActivity.this,R.anim.fade_out);
              fadeOut.setAnimationListener(new Animation.AnimationListener(){
                @Override public void onAnimationStart(                Animation animation){
                }
                @Override public void onAnimationEnd(                Animation animation){
                  mLoading.setVisibility(View.GONE);
                }
                @Override public void onAnimationRepeat(                Animation animation){
                }
              }
);
              mLoading.startAnimation(fadeOut);
            }
          }
.execute();
        }
        return true;
      }
    }
);
  }
  CheckBoxPreference prefGoogleSignIn=(CheckBoxPreference)findPreference("String_Node_Str");
  if (prefGoogleSignIn != null) {
    prefGoogleSignIn.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
      @Override public boolean onPreferenceChange(      Preference preference,      Object o){
        boolean signedIn=(Boolean)o;
        if (!signedIn) {
          if (mPlayServicesHelper.isSignedIn()) {
            mPlayServicesHelper.signOut();
          }
        }
 else {
          if (!mPlayServicesHelper.isSignedIn()) {
            mPlayServicesHelper.beginUserInitiatedSignIn();
          }
        }
        return true;
      }
    }
);
  }
  CheckBoxPreference prefAnalytics=(CheckBoxPreference)findPreference("String_Node_Str");
  if (prefAnalytics != null) {
    prefAnalytics.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
      @Override public boolean onPreferenceChange(      Preference preference,      Object o){
        boolean analytics=(Boolean)o;
        GoogleAnalytics.getInstance(SettingsActivity.this).setAppOptOut(!analytics);
        return true;
      }
    }
);
  }
}

Fixed version (ground truth):
private void initPreferences(){
  final ListPreference prefHomeGdgList=(ListPreference)findPreference(Const.SETTINGS_HOME_GDG);
  if (prefHomeGdgList != null) {
    App.getInstance().getModelCache().getAsync("String_Node_Str",false,new ModelCache.CacheListener(){
      @Override public void onGet(      Object item){
        Directory directory=(Directory)item;
        CharSequence entries[]=new String[directory.getGroups().size()];
        CharSequence entryValues[]=new String[directory.getGroups().size()];
        int i=0;
        for (        Chapter chapter : directory.getGroups()) {
          entries[i]=chapter.getName();
          entryValues[i]=chapter.getGplusId();
          i++;
        }
        prefHomeGdgList.setEntries(entries);
        prefHomeGdgList.setEntryValues(entryValues);
      }
      @Override public void onNotFound(      String key){
      }
    }
);
    prefHomeGdgList.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
      @Override public boolean onPreferenceChange(      Preference preference,      Object o){
        final String homeGdg=(String)o;
        if (mPlayServicesHelper.isSignedIn() && mPreferences.getBoolean("String_Node_Str",true)) {
          setHomeGdg(homeGdg);
        }
        App.getInstance().startService(new Intent(App.getInstance(),UpcomingEventWidgetProvider.UpdateService.class));
        return true;
      }
    }
);
  }
  CheckBoxPreference prefGcm=(CheckBoxPreference)findPreference(Const.SETTINGS_GCM);
  if (prefGcm != null) {
    prefGcm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
      @Override public boolean onPreferenceChange(      Preference preference,      Object o){
        final boolean enableGcm=(Boolean)o;
        if (mPlayServicesHelper.isSignedIn()) {
          mLoading.setVisibility(View.VISIBLE);
          mLoading.startAnimation(AnimationUtils.loadAnimation(SettingsActivity.this,R.anim.fade_in));
          new AsyncTask<Void,Void,Void>(){
            @Override protected Void doInBackground(            Void... voids){
              try {
                String token=GoogleAuthUtil.getToken(SettingsActivity.this,mPlayServicesHelper.getPlusClient().getAccountName(),"String_Node_Str" + Scopes.PLUS_LOGIN);
                mXClient.setToken(token);
                if (!enableGcm) {
                  ApiRequest req=mXClient.unregisterGcm(mPreferences.getString(Const.SETTINGS_GCM_REG_ID,"String_Node_Str"),new Response.Listener<GcmRegistrationResponse>(){
                    @Override public void onResponse(                    GcmRegistrationResponse messageResponse){
                      mPreferences.edit().putBoolean(Const.SETTINGS_GCM,false).remove(Const.SETTINGS_GCM_REG_ID).apply();
                    }
                  }
,new Response.ErrorListener(){
                    @Override public void onErrorResponse(                    VolleyError volleyError){
                      Log.e(LOG_TAG,"String_Node_Str",volleyError);
                    }
                  }
);
                  req.execute();
                }
 else {
                  final String regid=mGcm.register(getString(R.string.gcm_sender_id));
                  ApiRequest req=mXClient.registerGcm(regid,new Response.Listener<GcmRegistrationResponse>(){
                    @Override public void onResponse(                    GcmRegistrationResponse messageResponse){
                      mPreferences.edit().putBoolean(Const.SETTINGS_GCM,true).putString(Const.SETTINGS_GCM_REG_ID,regid).putString(Const.SETTINGS_GCM_NOTIFICATION_KEY,messageResponse.getNotificationKey()).apply();
                    }
                  }
,new Response.ErrorListener(){
                    @Override public void onErrorResponse(                    VolleyError volleyError){
                      Log.e(LOG_TAG,"String_Node_Str",volleyError);
                    }
                  }
);
                  req.execute();
                  setHomeGdg(mPreferences.getString(Const.SETTINGS_HOME_GDG,"String_Node_Str"));
                }
              }
 catch (              IOException e) {
                Log.e(LOG_TAG,"String_Node_Str",e);
                e.printStackTrace();
              }
catch (              GoogleAuthException e) {
                Log.e(LOG_TAG,"String_Node_Str",e);
                e.printStackTrace();
              }
              return null;
            }
            @Override protected void onPostExecute(            Void o){
              super.onPostExecute(o);
              Animation fadeOut=AnimationUtils.loadAnimation(SettingsActivity.this,R.anim.fade_out);
              fadeOut.setAnimationListener(new Animation.AnimationListener(){
                @Override public void onAnimationStart(                Animation animation){
                }
                @Override public void onAnimationEnd(                Animation animation){
                  mLoading.setVisibility(View.GONE);
                }
                @Override public void onAnimationRepeat(                Animation animation){
                }
              }
);
              mLoading.startAnimation(fadeOut);
            }
          }
.execute();
        }
        return true;
      }
    }
);
  }
  CheckBoxPreference prefGoogleSignIn=(CheckBoxPreference)findPreference("String_Node_Str");
  if (prefGoogleSignIn != null) {
    prefGoogleSignIn.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
      @Override public boolean onPreferenceChange(      Preference preference,      Object o){
        boolean signedIn=(Boolean)o;
        if (!signedIn) {
          if (mPlayServicesHelper.isSignedIn()) {
            mPlayServicesHelper.signOut();
          }
        }
 else {
          if (!mPlayServicesHelper.isSignedIn()) {
            mPlayServicesHelper.beginUserInitiatedSignIn();
          }
        }
        return true;
      }
    }
);
  }
  CheckBoxPreference prefAnalytics=(CheckBoxPreference)findPreference("String_Node_Str");
  if (prefAnalytics != null) {
    prefAnalytics.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener(){
      @Override public boolean onPreferenceChange(      Preference preference,      Object o){
        boolean analytics=(Boolean)o;
        GoogleAnalytics.getInstance(SettingsActivity.this).setAppOptOut(!analytics);
        return true;
      }
    }
);
  }
}