use of android.support.v4.widget.SlidingPaneLayout.LayoutParams in project Klyph by jonathangerbaud.
the class MainActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
* if (KlyphSession.getSessionUserName() != null)
* {
* loggedIn = true;
* setTitle(KlyphSession.getSessionUserName());
* }
* else
* {
* if (KlyphFlags.IS_PRO_VERSION == true)
* setTitle(R.string.app_pro_name);
* else
* setTitle(R.string.app_name);
* }
*/
setTitle("");
if (Session.getActiveSession() == null || KlyphSession.getSessionUserId() == null || (Session.getActiveSession() != null && Session.getActiveSession().isOpened() == false)) {
getActionBar().hide();
getFragmentManager().beginTransaction().add(R.id.main, new LoginFragment(), FRAGMENT_TAG).commit();
}
// notificationsFragment.setHasOptionsMenu(false);
adContainer = (ViewGroup) findViewById(R.id.ad);
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
drawerToggle = new ActionBarDrawerToggle(this, drawer, AttrUtil.getResourceId(this, R.attr.drawerIcon), R.string.open, R.string.close) {
@Override
public void onDrawerOpened(View view) {
Log.d("MainActivity.onCreate(...).new ActionBarDrawerToggle() {...}", "onDrawerOpened: ");
super.onDrawerOpened(view);
Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG);
if (drawer.isDrawerOpen(Gravity.RIGHT)) {
if (notificationsFragment != null) {
notificationsFragment.setHasOptionsMenu(true);
notificationsFragment.onOpenPane();
}
if (fragment != null)
fragment.setHasOptionsMenu(false);
} else if (drawer.isDrawerOpen(Gravity.LEFT)) {
if (notificationsFragment != null) {
notificationsFragment.setHasOptionsMenu(false);
}
if (fragment != null)
fragment.setHasOptionsMenu(true);
}
invalidateOptionsMenu();
}
@Override
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
if (!drawer.isDrawerOpen(Gravity.RIGHT)) {
if (notificationsFragment != null)
notificationsFragment.setHasOptionsMenu(false);
Fragment fragment = getFragmentManager().findFragmentByTag(FRAGMENT_TAG);
if (fragment != null)
fragment.setHasOptionsMenu(true);
}
invalidateOptionsMenu();
}
};
drawer.setDrawerListener(drawerToggle);
final List<String> labels = KlyphPreferences.getLeftDrawerMenuLabels();
classes = new ArrayList<String>(KlyphPreferences.getLeftDrawerMenuClasses());
classes.add("com.abewy.android.apps.klyph.fragment.UserTimeline");
navAdapter = new DrawerLayoutAdapter(getActionBar().getThemedContext(), R.layout.item_drawer_layout, labels);
final ListView navList = (ListView) findViewById(R.id.drawer);
// Setting drawers max width
int maxWidth = getResources().getDimensionPixelSize(R.dimen.max_drawer_layout_width);
int w = Math.min(KlyphDevice.getDeviceWidth(), KlyphDevice.getDeviceHeight()) - getResources().getDimensionPixelSize(R.dimen.dip_64);
int finalWidth = Math.min(maxWidth, w);
LayoutParams params = ((View) navList.getParent()).getLayoutParams();
params.width = finalWidth;
((View) navList.getParent()).setLayoutParams(params);
final View notificationContainer = findViewById(R.id.notifications_container);
params = notificationContainer.getLayoutParams();
params.width = finalWidth;
notificationContainer.setLayoutParams(params);
// End max width
navList.setFadingEdgeLength(0);
navList.setVerticalFadingEdgeEnabled(false);
navList.setAdapter(navAdapter);
navList.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, final int pos, long id) {
updateContent(pos);
drawer.closeDrawer(Gravity.LEFT);
}
});
// Facebook HashKey
if (KlyphFlags.LOG_FACEBOOK_HASH)
FacebookUtil.logHash(this);
// Hierarchy View Connector
if (KlyphFlags.ENABLE_HIERACHY_VIEW_CONNECTOR)
HierachyViewUtil.connectHierarchyView(this);
}
use of android.support.v4.widget.SlidingPaneLayout.LayoutParams in project FlexibleAdapter by davideas.
the class MainActivity method onNavigationItemSelected.
/* =======================================
* NAVIGATION DRAWER & FRAGMENT MANAGEMENT
* ======================================= */
/**
* IMPORTANT!! READ THE COMMENT FOR THE FRAGMENT REPLACE
*/
@SuppressWarnings("StatementWithEmptyBody")
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
hideFabSilently();
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) mFab.getLayoutParams();
ScrollAwareFABBehavior fabBehavior = ((ScrollAwareFABBehavior) layoutParams.getBehavior());
fabBehavior.setEnabled(false);
// Handle navigation view item clicks
int id = item.getItemId();
if (id == R.id.nav_overall) {
mFragment = FragmentOverall.newInstance(2);
} else if (id == R.id.nav_selection_modes) {
mFragment = FragmentSelectionModes.newInstance(2);
} else if (id == R.id.nav_filter) {
mFragment = FragmentAsyncFilter.newInstance(true);
} else if (id == R.id.nav_animator) {
mFragment = FragmentAnimators.newInstance();
} else if (id == R.id.nav_endless_scrolling) {
mFragment = FragmentEndlessScrolling.newInstance(2);
} else if (id == R.id.nav_instagram_headers) {
mFragment = FragmentInstagramHeaders.newInstance();
} else if (id == R.id.nav_headers_and_sections) {
mFragment = FragmentHeadersSections.newInstance(2);
fabBehavior.setEnabled(true);
} else if (id == R.id.nav_multi_level_expandable) {
mFragment = FragmentExpandableMultiLevel.newInstance(2);
} else if (id == R.id.nav_expandable_sections) {
mFragment = FragmentExpandableSections.newInstance(3);
} else if (id == R.id.nav_staggered) {
mFragment = FragmentStaggeredLayout.newInstance(2);
} else if (id == R.id.nav_model_holders) {
mFragment = FragmentHolderSections.newInstance();
} else if (id == R.id.nav_viewpager) {
Intent intent = new Intent(this, ViewPagerActivity.class);
ActivityOptionsCompat activityOptionsCompat = ActivityOptionsCompat.makeBasic();
ActivityCompat.startActivity(this, intent, activityOptionsCompat.toBundle());
// Close drawer
mRecyclerView.post(new Runnable() {
@Override
public void run() {
mDrawer.closeDrawer(GravityCompat.START);
}
});
return true;
} else if (id == R.id.nav_about) {
MessageDialog.newInstance(R.drawable.ic_info_grey600_24dp, getString(R.string.about_title), getString(R.string.about_body, Utils.getVersionName(this), Integer.toString(Utils.getVersionCode(this)))).show(getFragmentManager(), MessageDialog.TAG);
return true;
} else if (id == R.id.nav_github) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://github.com/davideas/FlexibleAdapter"));
startActivity(Intent.createChooser(intent, getString(R.string.intent_chooser)));
return true;
}
// Insert the fragment by replacing any existing fragment
if (mFragment != null) {
// Highlight the selected item has been done by NavigationView
item.setChecked(true);
// THIS IS VERY IMPORTANT. Because you are going to inflate a new RecyclerView, its
// Adapter will be null, therefore the following method cannot be called automatically!
// If your StickyHeaderContainer is in the main view, you must call this method to clean
// the previous sticky view. Alternatively you can move the <include> of StickyHeaderLayout
// in the Fragment view.
mAdapter.onDetachedFromRecyclerView(mRecyclerView);
// Inflate the new Fragment with the new RecyclerView and a new Adapter
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.recycler_view_container, mFragment).commit();
// Close drawer
mRecyclerView.post(new Runnable() {
@Override
public void run() {
mDrawer.closeDrawer(GravityCompat.START);
}
});
//mToolbar.setSubtitle(item.getTitle());
mHeaderView.bindTo(getString(R.string.app_name), item.getTitle());
return true;
}
return false;
}
use of android.support.v4.widget.SlidingPaneLayout.LayoutParams in project vlayout by alibaba.
the class OnePlusNLayoutActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
mFirstText = (TextView) findViewById(R.id.first);
mLastText = (TextView) findViewById(R.id.last);
mCountText = (TextView) findViewById(R.id.count);
mTotalOffsetText = (TextView) findViewById(R.id.total_offset);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.main_view);
findViewById(R.id.jump).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText position = (EditText) findViewById(R.id.position);
if (!TextUtils.isEmpty(position.getText())) {
try {
int pos = Integer.parseInt(position.getText().toString());
recyclerView.scrollToPosition(pos);
} catch (Exception e) {
Log.e("VlayoutActivity", e.getMessage(), e);
}
} else {
recyclerView.requestLayout();
}
}
});
final VirtualLayoutManager layoutManager = new VirtualLayoutManager(this);
recyclerView.setOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int scrollState) {
}
@Override
public void onScrolled(RecyclerView recyclerView, int i, int i2) {
mFirstText.setText("First: " + layoutManager.findFirstVisibleItemPosition());
mLastText.setText("Existing: " + MainViewHolder.existing + " Created: " + MainViewHolder.createdTimes);
mCountText.setText("Count: " + recyclerView.getChildCount());
mTotalOffsetText.setText("Total Offset: " + layoutManager.getOffsetToStart());
}
});
recyclerView.setLayoutManager(layoutManager);
// layoutManager.setReverseLayout(true);
RecyclerView.ItemDecoration itemDecoration = new RecyclerView.ItemDecoration() {
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
int position = ((LayoutParams) view.getLayoutParams()).getViewPosition();
outRect.set(4, 4, 4, 4);
}
};
final RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
recyclerView.setRecycledViewPool(viewPool);
// recyclerView.addItemDecoration(itemDecoration);
viewPool.setMaxRecycledViews(0, 20);
final DelegateAdapter delegateAdapter = new DelegateAdapter(layoutManager, true);
recyclerView.setAdapter(delegateAdapter);
List<DelegateAdapter.Adapter> adapters = new LinkedList<>();
if (BANNER_LAYOUT) {
adapters.add(new SubAdapter(this, new LinearLayoutHelper(), 1) {
@Override
public void onViewRecycled(MainViewHolder holder) {
if (holder.itemView instanceof ViewPager) {
((ViewPager) holder.itemView).setAdapter(null);
}
}
@Override
public MainViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == 1)
return new MainViewHolder(LayoutInflater.from(OnePlusNLayoutActivity.this).inflate(R.layout.view_pager, parent, false));
return super.onCreateViewHolder(parent, viewType);
}
@Override
public int getItemViewType(int position) {
return 1;
}
@Override
protected void onBindViewHolderWithOffset(MainViewHolder holder, int position, int offsetTotal) {
}
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
if (holder.itemView instanceof ViewPager) {
ViewPager viewPager = (ViewPager) holder.itemView;
viewPager.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 200));
// from position to get adapter
viewPager.setAdapter(new PagerAdapter(this, viewPool));
}
}
});
}
if (GRID_LAYOUT) {
GridLayoutHelper layoutHelper;
layoutHelper = new GridLayoutHelper(4);
layoutHelper.setMargin(0, 10, 0, 10);
layoutHelper.setHGap(3);
layoutHelper.setAspectRatio(4f);
adapters.add(new SubAdapter(this, layoutHelper, 8));
}
if (HORIZONTAL_SCROLL_LAYOUT) {
}
if (GRID_LAYOUT) {
GridLayoutHelper layoutHelper;
layoutHelper = new GridLayoutHelper(2);
layoutHelper.setMargin(0, 10, 0, 10);
layoutHelper.setHGap(3);
layoutHelper.setAspectRatio(3f);
adapters.add(new SubAdapter(this, layoutHelper, 2));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper();
helper.setBgColor(0xff876384);
helper.setMargin(10, 10, 10, 10);
helper.setPadding(10, 10, 10, 10);
adapters.add(new SubAdapter(this, helper, 3) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
// LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
// layoutParams.leftMargin = 10;
// layoutParams.topMargin = 10;
// layoutParams.rightMargin = 10;
// layoutParams.bottomMargin = 10;
// holder.itemView.setLayoutParams(layoutParams);
}
});
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
adapters.add(new SubAdapter(this, helper, 4));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelper helper = new OnePlusNLayoutHelper();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
adapters.add(new SubAdapter(this, helper, 5));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
adapters.add(new SubAdapter(this, helper, 5));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
helper.setColWeights(new float[] { 40f, 45f, 15f, 60f, 0f });
adapters.add(new SubAdapter(this, helper, 5));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
helper.setColWeights(new float[] { 20f, 80f, 0f, 60f, 20f });
helper.setAspectRatio(4);
adapters.add(new SubAdapter(this, helper, 5));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
adapters.add(new SubAdapter(this, helper, 6));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
adapters.add(new SubAdapter(this, helper, 7));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xff876384);
helper.setMargin(0, 10, 0, 10);
helper.setColWeights(new float[] { 40f, 45f, 15f, 60f, 0f, 30f, 30f });
adapters.add(new SubAdapter(this, helper, 7));
}
if (ONEN_LAYOUT) {
OnePlusNLayoutHelperEx helper = new OnePlusNLayoutHelperEx();
helper.setBgColor(0xffed7612);
// helper.setMargin(10, 10, 10, 10);
// helper.setPadding(10, 10, 10, 10);
helper.setColWeights(new float[] { 30f, 20f, 50f, 40f, 30f, 35f, 35f });
adapters.add(new SubAdapter(this, helper, 7) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
// LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 300);
// layoutParams.leftMargin = 10;
// layoutParams.topMargin = 10;
// layoutParams.rightMargin = 10;
// layoutParams.bottomMargin = 10;
// holder.itemView.setLayoutParams(layoutParams);
}
});
}
if (STICKY_LAYOUT) {
StickyLayoutHelper layoutHelper = new StickyLayoutHelper();
layoutHelper.setAspectRatio(4);
adapters.add(new SubAdapter(this, layoutHelper, 1, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 100)));
}
if (SCROLL_FIX_LAYOUT) {
ScrollFixLayoutHelper layoutHelper = new ScrollFixLayoutHelper(FixLayoutHelper.BOTTOM_RIGHT, 20, 20);
layoutHelper.setShowType(ScrollFixLayoutHelper.SHOW_ON_LEAVE);
adapters.add(new SubAdapter(this, layoutHelper, 1) {
@Override
public void onBindViewHolder(MainViewHolder holder, int position) {
super.onBindViewHolder(holder, position);
LayoutParams layoutParams = new LayoutParams(50, 50);
holder.itemView.setLayoutParams(layoutParams);
}
});
}
if (LINEAR_LAYOUT)
adapters.add(new SubAdapter(this, new LinearLayoutHelper(), 100));
delegateAdapter.setAdapters(adapters);
final Handler mainHandler = new Handler(Looper.getMainLooper());
trigger = new Runnable() {
@Override
public void run() {
// recyclerView.scrollToPosition(22);
// recyclerView.getAdapter().notifyDataSetChanged();
recyclerView.requestLayout();
// mainHandler.postDelayed(trigger, 1000);
}
};
mainHandler.postDelayed(trigger, 1000);
}
use of android.support.v4.widget.SlidingPaneLayout.LayoutParams in project RxBinding by JakeWharton.
the class RxDrawerLayoutTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
drawerLayout = new DrawerLayout(this);
drawerLayout.setId(android.R.id.primary);
FrameLayout main = new FrameLayout(this);
LayoutParams mainParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
drawerLayout.addView(main, mainParams);
FrameLayout drawer = new FrameLayout(this);
drawer.setBackgroundColor(Color.WHITE);
LayoutParams drawerParams = new LayoutParams(300, MATCH_PARENT, RIGHT);
drawerLayout.addView(drawer, drawerParams);
setContentView(drawerLayout);
}
use of android.support.v4.widget.SlidingPaneLayout.LayoutParams in project RxBinding by JakeWharton.
the class RxNestedScrollViewTestActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ScrollView scrollView = new ScrollView(this);
nestedScrollView = new NestedScrollView(this);
emptyView = new FrameLayout(this);
LayoutParams scrollParams = new LayoutParams(MATCH_PARENT, MATCH_PARENT);
LayoutParams emptyParams = new LayoutParams(50000, 50000);
nestedScrollView.addView(emptyView, emptyParams);
scrollView.addView(nestedScrollView, scrollParams);
setContentView(scrollView, scrollParams);
}
Aggregations