Java 类android.view.View.OnApplyWindowInsetsListener 实例源码

项目:FMTech    文件:PlayDrawerLayout.java   
@TargetApi(20)
protected void onFinishInflate()
{
  super.onFinishInflate();
  this.mDrawerRoot = ((ViewGroup)findViewById(R.id.play_drawer_root));
  this.mDrawerList = ((ListView)findViewById(R.id.play_drawer_list));
  this.mDockedActionView = ((TextView)findViewById(R.id.play_drawer_docked_action));
  this.mDockedActionView.setVisibility(8);
  if (Build.VERSION.SDK_INT >= 21) {
    this.mDrawerRoot.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener()
    {
      @TargetApi(20)
      public final WindowInsets onApplyWindowInsets(View paramAnonymousView, WindowInsets paramAnonymousWindowInsets)
      {
        return paramAnonymousWindowInsets.consumeSystemWindowInsets();
      }
    });
  }
}
项目:ComedoresUGR    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Resources res = getResources();
    final GridViewPager pager = (GridViewPager) findViewById(R.id.pager);
    pager.setOnApplyWindowInsetsListener(new OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            final boolean round = insets.isRound();
            int rowMargin = res.getDimensionPixelOffset(R.dimen.page_row_margin);
            int colMargin = res.getDimensionPixelOffset(round ?
                    R.dimen.page_column_margin_round : R.dimen.page_column_margin);
            pager.setPageMargins(rowMargin, colMargin);
            return insets;
        }
    });

    menu = new com.iblancasa.comedoresUGR.Menu(this,pager,getFragmentManager());

}
项目:AndroidWearable-Samples    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final Resources res = getResources();
    final GridViewPager pager = (GridViewPager) findViewById(R.id.pager);
    pager.setOnApplyWindowInsetsListener(new OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            // Adjust page margins:
            //   A little extra horizontal spacing between pages looks a bit
            //   less crowded on a round display.
            final boolean round = insets.isRound();
            int rowMargin = res.getDimensionPixelOffset(R.dimen.page_row_margin);
            int colMargin = res.getDimensionPixelOffset(round ?
                    R.dimen.page_column_margin_round : R.dimen.page_column_margin);
            pager.setPageMargins(rowMargin, colMargin);
            return insets;
        }
    });
    pager.setAdapter(new SampleGridPagerAdapter(this, getFragmentManager()));
}