use of android.support.v4.widget.DrawerLayout.LayoutParams in project qualitymatters by artem-zinnatullin.
the class MainActivityViewModifier method modify.
@NonNull
@Override
public <T extends View> T modify(@NonNull T view) {
// Basically, what we do here is adding a Developer Setting Fragment to a DrawerLayout!
DrawerLayout drawerLayout = (DrawerLayout) view.findViewById(R.id.main_drawer_layout);
DrawerLayout.LayoutParams layoutParams = new DrawerLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
layoutParams.gravity = Gravity.END;
drawerLayout.addView(LayoutInflater.from(view.getContext()).inflate(R.layout.developer_settings_view, drawerLayout, false), layoutParams);
return view;
}
use of android.support.v4.widget.DrawerLayout.LayoutParams in project smooth-app-bar-layout by henrytao-me.
the class SmoothAppBarLayout method onLayout.
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
int i = 0;
for (int z = this.getChildCount(); i < z; ++i) {
View child = this.getChildAt(i);
LayoutParams childLp = (LayoutParams) child.getLayoutParams();
Interpolator interpolator = childLp.getScrollInterpolator();
if (interpolator != null) {
mHaveChildWithInterpolator = true;
break;
}
}
}
use of android.support.v4.widget.DrawerLayout.LayoutParams in project RxBinding by JakeWharton.
the class RxSwipeRefreshLayoutTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
swipeRefreshLayout = new SwipeRefreshLayout(this);
swipeRefreshLayout.setId(R.id.swipe_refresh_layout);
swipeRefreshLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (MotionEventCompat.getActionMasked(event) == MotionEvent.ACTION_UP) {
handler.removeCallbacks(stopRefreshing);
handler.postDelayed(stopRefreshing, 300);
}
return false;
}
});
ScrollView scrollView = new ScrollView(this);
LayoutParams scrollParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
swipeRefreshLayout.addView(scrollView, scrollParams);
FrameLayout emptyView = new FrameLayout(this);
LayoutParams emptyParams = new LayoutParams(MATCH_PARENT, 100000);
scrollView.addView(emptyView, emptyParams);
setContentView(swipeRefreshLayout);
}
use of android.support.v4.widget.DrawerLayout.LayoutParams in project Lightning-Browser by anthonycr.
the class BrowserActivity method initialize.
private synchronized void initialize(Bundle savedInstanceState) {
initializeToolbarHeight(getResources().getConfiguration());
setSupportActionBar(mToolbar);
ActionBar actionBar = getSupportActionBar();
//TODO make sure dark theme flag gets set correctly
mDarkTheme = mPreferences.getUseTheme() != 0 || isIncognito();
mIconColor = mDarkTheme ? ThemeUtils.getIconDarkThemeColor(this) : ThemeUtils.getIconLightThemeColor(this);
mDisabledIconColor = mDarkTheme ? ContextCompat.getColor(this, R.color.icon_dark_theme_disabled) : ContextCompat.getColor(this, R.color.icon_light_theme_disabled);
mShowTabsInDrawer = mPreferences.getShowTabsInDrawer(!isTablet());
mSwapBookmarksAndTabs = mPreferences.getBookmarksAndTabsSwapped();
// initialize background ColorDrawable
int primaryColor = ThemeUtils.getPrimaryColor(this);
mBackground.setColor(primaryColor);
// Drawer stutters otherwise
mDrawerLeft.setLayerType(View.LAYER_TYPE_NONE, null);
mDrawerRight.setLayerType(View.LAYER_TYPE_NONE, null);
mDrawerLayout.addDrawerListener(new DrawerListener() {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
}
@Override
public void onDrawerOpened(View drawerView) {
}
@Override
public void onDrawerClosed(View drawerView) {
}
@Override
public void onDrawerStateChanged(int newState) {
if (newState == DrawerLayout.STATE_DRAGGING) {
mDrawerLeft.setLayerType(View.LAYER_TYPE_HARDWARE, null);
mDrawerRight.setLayerType(View.LAYER_TYPE_HARDWARE, null);
} else if (newState == DrawerLayout.STATE_IDLE) {
mDrawerLeft.setLayerType(View.LAYER_TYPE_NONE, null);
mDrawerRight.setLayerType(View.LAYER_TYPE_NONE, null);
}
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !mShowTabsInDrawer) {
getWindow().setStatusBarColor(Color.BLACK);
}
setNavigationDrawerWidth();
mDrawerLayout.addDrawerListener(new DrawerLocker());
mWebpageBitmap = ThemeUtils.getThemedBitmap(this, R.drawable.ic_webpage, mDarkTheme);
final FragmentManager fragmentManager = getSupportFragmentManager();
TabsFragment tabsFragment = (TabsFragment) fragmentManager.findFragmentByTag(TAG_TABS_FRAGMENT);
BookmarksFragment bookmarksFragment = (BookmarksFragment) fragmentManager.findFragmentByTag(TAG_BOOKMARK_FRAGMENT);
if (tabsFragment != null) {
fragmentManager.beginTransaction().remove(tabsFragment).commit();
}
tabsFragment = TabsFragment.createTabsFragment(isIncognito(), mShowTabsInDrawer);
mTabsView = tabsFragment;
if (bookmarksFragment != null) {
fragmentManager.beginTransaction().remove(bookmarksFragment).commit();
}
bookmarksFragment = BookmarksFragment.createFragment(isIncognito());
mBookmarksView = bookmarksFragment;
fragmentManager.executePendingTransactions();
fragmentManager.beginTransaction().replace(getTabsFragmentViewId(), tabsFragment, TAG_TABS_FRAGMENT).replace(getBookmarksFragmentViewId(), bookmarksFragment, TAG_BOOKMARK_FRAGMENT).commit();
if (mShowTabsInDrawer) {
mToolbarLayout.removeView(findViewById(R.id.tabs_toolbar_container));
}
Preconditions.checkNonNull(actionBar);
// set display options of the ActionBar
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(R.layout.toolbar_content);
View customView = actionBar.getCustomView();
LayoutParams lp = customView.getLayoutParams();
lp.width = LayoutParams.MATCH_PARENT;
lp.height = LayoutParams.MATCH_PARENT;
customView.setLayoutParams(lp);
mArrowImage = (ImageView) customView.findViewById(R.id.arrow);
FrameLayout arrowButton = (FrameLayout) customView.findViewById(R.id.arrow_button);
if (mShowTabsInDrawer) {
if (mArrowImage.getWidth() <= 0) {
mArrowImage.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
}
updateTabNumber(0);
// Post drawer locking in case the activity is being recreated
Handlers.MAIN.post(new Runnable() {
@Override
public void run() {
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, getTabDrawer());
}
});
} else {
// Post drawer locking in case the activity is being recreated
Handlers.MAIN.post(new Runnable() {
@Override
public void run() {
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, getTabDrawer());
}
});
mArrowImage.setImageResource(R.drawable.ic_action_home);
mArrowImage.setColorFilter(mIconColor, PorterDuff.Mode.SRC_IN);
}
// Post drawer locking in case the activity is being recreated
Handlers.MAIN.post(new Runnable() {
@Override
public void run() {
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, getBookmarkDrawer());
}
});
arrowButton.setOnClickListener(this);
// create the search EditText in the ToolBar
mSearch = (SearchView) customView.findViewById(R.id.search);
mSearchBackground = customView.findViewById(R.id.search_container);
// initialize search background color
mSearchBackground.getBackground().setColorFilter(getSearchBarColor(primaryColor, primaryColor), PorterDuff.Mode.SRC_IN);
mSearch.setHintTextColor(ThemeUtils.getThemedTextHintColor(mDarkTheme));
mSearch.setTextColor(mDarkTheme ? Color.WHITE : Color.BLACK);
mUntitledTitle = getString(R.string.untitled);
mBackgroundColor = ThemeUtils.getPrimaryColor(this);
mDeleteIcon = ThemeUtils.getThemedDrawable(this, R.drawable.ic_action_delete, mDarkTheme);
mRefreshIcon = ThemeUtils.getThemedDrawable(this, R.drawable.ic_action_refresh, mDarkTheme);
mClearIcon = ThemeUtils.getThemedDrawable(this, R.drawable.ic_action_delete, mDarkTheme);
int iconBounds = Utils.dpToPx(24);
mDeleteIcon.setBounds(0, 0, iconBounds, iconBounds);
mRefreshIcon.setBounds(0, 0, iconBounds, iconBounds);
mClearIcon.setBounds(0, 0, iconBounds, iconBounds);
mIcon = mRefreshIcon;
SearchListenerClass search = new SearchListenerClass();
mSearch.setCompoundDrawablePadding(Utils.dpToPx(3));
mSearch.setCompoundDrawables(null, null, mRefreshIcon, null);
mSearch.setOnKeyListener(search);
mSearch.setOnFocusChangeListener(search);
mSearch.setOnEditorActionListener(search);
mSearch.setOnTouchListener(search);
mSearch.setOnPreFocusListener(search);
initializeSearchSuggestions(mSearch);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_right_shadow, GravityCompat.END);
mDrawerLayout.setDrawerShadow(R.drawable.drawer_left_shadow, GravityCompat.START);
if (API <= Build.VERSION_CODES.JELLY_BEAN_MR2) {
//noinspection deprecation
WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());
}
@SuppressWarnings("VariableNotUsedInsideIf") Intent intent = savedInstanceState == null ? getIntent() : null;
boolean launchedFromHistory = intent != null && (intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0;
if (isPanicTrigger(intent)) {
setIntent(null);
panicClean();
} else {
if (launchedFromHistory) {
intent = null;
}
mPresenter.setupTabs(intent);
setIntent(null);
mProxyUtils.checkForProxy(this);
}
}
use of android.support.v4.widget.DrawerLayout.LayoutParams in project bdcodehelper by boredream.
the class IndicatorRadioGroup method setViewPager.
public void setViewPager(ViewPager vp, final int count) {
if (vp == null || vp.getAdapter() == null) {
return;
}
if (count <= 1) {
setVisibility(View.GONE);
return;
}
setVisibility(View.VISIBLE);
vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
if (getChildCount() > 1) {
View child = getChildAt(position % count);
if (child != null && child instanceof RadioButton) {
((RadioButton) child).setChecked(true);
}
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
removeAllViews();
for (int i = 0; i < count; i++) {
RadioButton rb = new RadioButton(getContext());
LayoutParams params = new LayoutParams(DisplayUtils.dp2px(getContext(), 6), DisplayUtils.dp2px(getContext(), 6));
if (i > 0) {
params.setMargins(DisplayUtils.dp2px(getContext(), 10), 0, 0, 0);
}
rb.setLayoutParams(params);
rb.setButtonDrawable(new ColorDrawable());
rb.setBackgroundResource(indicatorRes);
rb.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
// do nothing
return true;
}
});
addView(rb);
}
((RadioButton) getChildAt(0)).setChecked(true);
}
Aggregations