private void restoreComplexPreferences() {
    SharedPreferences sharedPreferences = getPreferences(Context.MODE_PRIVATE);
    Gson gson = new Gson();
    String json = sharedPreferences.getString(MAIN_ACTIVITY_SAVE, "");
    MainActivitySave save = gson.fromJson(json, MainActivitySave.class);

    if (save != null) {
      Log.i(TAG, "drawer final state is ------ " + save.isDrawerOpen());
      if (!save.isDrawerOpen()) mPagerTitleStrip.setBackgroundColor(Color.parseColor("#01579B"));
      else mPagerTitleStrip.setBackgroundColor(Color.parseColor("#039BE5"));
    }
  }
  private void initialViewPager() {
    addFriend = AddFriends_Fragment.newInstance("a", "n");
    createEvents = CreateEvents_Fragment.newInstance("a", "n");
    viewEvents = ViewEvents_Fragment.newInstance("a", "n");

    fAdapter = new FragmentAdapter(getSupportFragmentManager());

    vPager = (ViewPager) findViewById(R.id.pager);
    vPager.setAdapter(fAdapter);
    PagerTitleStrip titleStrip = (PagerTitleStrip) findViewById(R.id.pager_tab_strip);
    titleStrip.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 24);
  }
 @Override
 public void setBackgroundDrawable(Drawable d) {
   super.setBackgroundDrawable(d);
   if (!mDrawFullUnderlineSet) {
     mDrawFullUnderline = d == null;
   }
 }
 @Override
 public void setTextSpacing(int textSpacing) {
   if (textSpacing < mMinTextSpacing) {
     textSpacing = mMinTextSpacing;
   }
   super.setTextSpacing(textSpacing);
 }
 @Override
 public void setPadding(int left, int top, int right, int bottom) {
   if (bottom < mMinPaddingBottom) {
     bottom = mMinPaddingBottom;
   }
   super.setPadding(left, top, right, bottom);
 }
 public void setTextSpacing(int paramInt) {
   int i = paramInt;
   if (paramInt < mMinTextSpacing) {
     i = mMinTextSpacing;
   }
   super.setTextSpacing(i);
 }
 @Override
 public void setBackgroundResource(int resId) {
   super.setBackgroundResource(resId);
   if (!mDrawFullUnderlineSet) {
     mDrawFullUnderline = resId == 0;
   }
 }
 public void setPadding(int paramInt1, int paramInt2, int paramInt3, int paramInt4) {
   int i = paramInt4;
   if (paramInt4 < mMinPaddingBottom) {
     i = mMinPaddingBottom;
   }
   super.setPadding(paramInt1, paramInt2, paramInt3, i);
 }
 @Override
 public void setBackgroundColor(int color) {
   super.setBackgroundColor(color);
   if (!mDrawFullUnderlineSet) {
     mDrawFullUnderline = (color & 0xFF000000) == 0;
   }
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    setTheme(android.R.style.Theme_Light);
    m_vp = (ViewPager) findViewById(R.id.viewpager);
    pagerTabStrip = (PagerTabStrip) findViewById(R.id.pagertab);
    // 设置下划线的颜色
    pagerTabStrip.setTabIndicatorColor(getResources().getColor(android.R.color.holo_green_dark));
    // 设置背景的颜色
    pagerTabStrip.setBackgroundColor(getResources().getColor(android.R.color.holo_blue_dark));

    pagerTitleStrip = (PagerTitleStrip) findViewById(R.id.pagertab);
    // 设置背景的颜色
    pagerTitleStrip.setBackgroundColor(getResources().getColor(android.R.color.holo_blue_dark));

    mfragment1 = new fragment1();
    mfragment2 = new fragment2();
    mfragment3 = new fragment3();

    fragmentList = new ArrayList<Fragment>();
    fragmentList.add(mfragment1);
    fragmentList.add(mfragment2);
    fragmentList.add(mfragment3);

    titleList.add("第一页 ");
    titleList.add("第二页");
    titleList.add("第三页 ");

    m_vp.setAdapter(new MyViewPagerAdapter(getSupportFragmentManager()));
    m_vp.setOffscreenPageLimit(1);
  }
 public void setBackgroundResource(int paramInt) {
   super.setBackgroundResource(paramInt);
   if (!mDrawFullUnderlineSet) {
     if (paramInt != 0) {
       break label24;
     }
   }
   label24:
   for (boolean bool = true; ; bool = false) {
     mDrawFullUnderline = bool;
     return;
   }
 }
 public void setBackgroundDrawable(Drawable paramDrawable) {
   super.setBackgroundDrawable(paramDrawable);
   if (!mDrawFullUnderlineSet) {
     if (paramDrawable != null) {
       break label24;
     }
   }
   label24:
   for (boolean bool = true; ; bool = false) {
     mDrawFullUnderline = bool;
     return;
   }
 }
 public void setBackgroundColor(int paramInt) {
   super.setBackgroundColor(paramInt);
   if (!mDrawFullUnderlineSet) {
     if ((0xFF000000 & paramInt) != 0) {
       break label27;
     }
   }
   label27:
   for (boolean bool = true; ; bool = false) {
     mDrawFullUnderline = bool;
     return;
   }
 }
 @Override
 public void onMainFragmentInteraction(int task) {
   switch (task) {
     case FragmentActivityInterfaceConstants.START_LOCATION_UPDATES:
       startLocationUpdates();
       break;
     case FragmentActivityInterfaceConstants.STOP_LOCATION_UPDATES_AND_DISCONNECT_GOOGLE_API:
       if (mGoogleApiClient.isConnected()) {
         // Just like we have to disconnect our client, we also need to explicitly
         // remove location updates after requesting them. We do this with the opposite method,
         // which we can call in onPause() when we disconnect our Google API client:
         LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
         mGoogleApiClient.disconnect();
       }
       break;
     case FragmentActivityInterfaceConstants.DISABLE_PAGER_TITLESTRIP:
       mPagerTitleStrip.setBackgroundColor(Color.parseColor("#039BE5"));
       break;
     case FragmentActivityInterfaceConstants.ENABLE_PAGER_TITLESTRIP:
       mPagerTitleStrip.setBackgroundColor(Color.parseColor("#01579B"));
       break;
   }
 }
 final void updateTextPositions(int paramInt, float paramFloat, boolean paramBoolean) {
   Rect localRect = mTempRect;
   int i = getHeight();
   int j = mCurrText.getLeft();
   int k = mTabPadding;
   int m = mCurrText.getRight();
   int n = mTabPadding;
   int i1 = i - mIndicatorHeight;
   localRect.set(j - k, i1, m + n, i);
   super.updateTextPositions(paramInt, paramFloat, paramBoolean);
   mTabAlpha = ((int) (Math.abs(paramFloat - 0.5F) * 2.0F * 255.0F));
   localRect.union(mCurrText.getLeft() - mTabPadding, i1, mCurrText.getRight() + mTabPadding, i);
   invalidate(localRect);
 }
 protected void onDraw(Canvas paramCanvas) {
   super.onDraw(paramCanvas);
   int i = getHeight();
   int j = mCurrText.getLeft();
   int k = mTabPadding;
   int m = mCurrText.getRight();
   int n = mTabPadding;
   int i1 = mIndicatorHeight;
   mTabPaint.setColor(mTabAlpha << 24 | mIndicatorColor & 0xFFFFFF);
   paramCanvas.drawRect(j - k, i - i1, m + n, i, mTabPaint);
   if (mDrawFullUnderline) {
     mTabPaint.setColor(0xFF000000 | mIndicatorColor & 0xFFFFFF);
     paramCanvas.drawRect(
         getPaddingLeft(), i - mFullUnderlineHeight, getWidth() - getPaddingRight(), i, mTabPaint);
   }
 }
  @Override
  void updateTextPositions(int position, float positionOffset, boolean force) {
    final Rect r = mTempRect;
    int bottom = getHeight();
    int left = mCurrText.getLeft() - mTabPadding;
    int right = mCurrText.getRight() + mTabPadding;
    int top = bottom - mIndicatorHeight;

    r.set(left, top, right, bottom);

    super.updateTextPositions(position, positionOffset, force);
    mTabAlpha = (int) (Math.abs(positionOffset - 0.5f) * 2 * 0xFF);

    left = mCurrText.getLeft() - mTabPadding;
    right = mCurrText.getRight() + mTabPadding;
    r.union(left, top, right, bottom);

    invalidate(r);
  }
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    final int height = getHeight();
    final int bottom = height;
    final int left = mCurrText.getLeft() - mTabPadding;
    final int right = mCurrText.getRight() + mTabPadding;
    final int top = bottom - mIndicatorHeight;

    mTabPaint.setColor(mTabAlpha << 24 | (mIndicatorColor & 0xFFFFFF));
    canvas.drawRect(left, top, right, bottom, mTabPaint);

    if (mDrawFullUnderline) {
      mTabPaint.setColor(0xFF << 24 | (mIndicatorColor & 0xFFFFFF));
      canvas.drawRect(
          getPaddingLeft(),
          height - mFullUnderlineHeight,
          getWidth() - getPaddingRight(),
          height,
          mTabPaint);
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    overridePendingTransition(R.anim.slide_in_left, R.anim.activity_zoom_exit);

    try {
      ViewConfiguration config = ViewConfiguration.get(this);
      Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
      if (menuKeyField != null) {
        menuKeyField.setAccessible(true);
        menuKeyField.setBoolean(config, false);
      }
    } catch (Exception ex) {
      // Ignore
    }

    context = this;
    sharedPrefs =
        context.getSharedPreferences(
            "com.klinker.android.twitter_world_preferences",
            Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE);
    settings = AppSettings.getInstance(this);

    try {
      searchQuery = getIntent().getStringExtra(SearchManager.QUERY);
    } catch (Exception e) {
      searchQuery = "";
    }

    if (searchQuery == null) {
      searchQuery = "";
    }

    handleIntent(getIntent());

    if (Build.VERSION.SDK_INT > 18
        && settings.uiExtras
        && (getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE
            || getResources().getBoolean(R.bool.isTablet))) {
      translucent = true;
      getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

      try {
        int immersive =
            android.provider.Settings.System.getInt(getContentResolver(), "immersive_mode");

        if (immersive == 1) {
          translucent = false;
        }
      } catch (Exception e) {
      }
    } else {
      translucent = false;
    }

    Utils.setUpTheme(context, settings);
    setContentView(R.layout.search_pager);

    actionBar = getActionBar();
    actionBar.setTitle(getResources().getString(R.string.search));
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent)));

    View statusBar = findViewById(R.id.activity_status_bar);

    mViewPager = (ViewPager) findViewById(R.id.pager);

    if (translucent) {
      statusBar.setVisibility(View.VISIBLE);

      int statusBarHeight = Utils.getStatusBarHeight(context);

      LinearLayout.LayoutParams statusParams =
          (LinearLayout.LayoutParams) statusBar.getLayoutParams();
      statusParams.height = statusBarHeight;
      statusBar.setLayoutParams(statusParams);
    } else {
      mViewPager.setPadding(0, 0, 0, 0);
    }

    mSectionsPagerAdapter =
        new SearchPagerAdapter(
            getFragmentManager(), context, onlyStatus, onlyProfile, searchQuery, translucent);

    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.setOffscreenPageLimit(3);

    if (settings.addonTheme) {
      PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
      strip.setBackgroundColor(settings.pagerTitleInt);
    }

    mViewPager.setCurrentItem(1);

    Utils.setActionBar(context, true);

    if (onlyProfile) {
      mViewPager.setCurrentItem(2);
    }
  }