use of android.support.design.widget.AppBarLayout in project Tusky by Vavassor.
the class AccountActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_account);
ButterKnife.bind(this);
if (savedInstanceState != null) {
accountId = savedInstanceState.getString("accountId");
followState = (FollowState) savedInstanceState.getSerializable("followState");
blocking = savedInstanceState.getBoolean("blocking");
muting = savedInstanceState.getBoolean("muting");
} else {
Intent intent = getIntent();
accountId = intent.getStringExtra("id");
followState = FollowState.NOT_FOLLOWING;
blocking = false;
muting = false;
}
loadedAccount = null;
SharedPreferences preferences = getPrivatePreferences();
String loggedInAccountId = preferences.getString("loggedInAccountId", null);
// Setup the toolbar.
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(null);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
}
// Add a listener to change the toolbar icon color when it enters/exits its collapsed state.
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.account_app_bar_layout);
final CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
@AttrRes
int priorAttribute = R.attr.account_toolbar_icon_tint_uncollapsed;
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
@AttrRes int attribute;
if (collapsingToolbar.getHeight() + verticalOffset < 2 * ViewCompat.getMinimumHeight(collapsingToolbar)) {
toolbar.setTitleTextColor(ThemeUtils.getColor(AccountActivity.this, android.R.attr.textColorPrimary));
toolbar.setSubtitleTextColor(ThemeUtils.getColor(AccountActivity.this, android.R.attr.textColorSecondary));
attribute = R.attr.account_toolbar_icon_tint_collapsed;
} else {
toolbar.setTitleTextColor(Color.TRANSPARENT);
toolbar.setSubtitleTextColor(Color.TRANSPARENT);
attribute = R.attr.account_toolbar_icon_tint_uncollapsed;
}
if (attribute != priorAttribute) {
priorAttribute = attribute;
Context context = toolbar.getContext();
ThemeUtils.setDrawableTint(context, toolbar.getNavigationIcon(), attribute);
ThemeUtils.setDrawableTint(context, toolbar.getOverflowIcon(), attribute);
}
}
});
// Initialise the default UI states.
floatingBtn.hide();
// Obtain information to fill out the profile.
obtainAccount();
if (!accountId.equals(loggedInAccountId)) {
isSelf = false;
obtainRelationships();
} else {
/* Cause the options menu to update and instead show an options menu for when the
* account being shown is their own account. */
isSelf = true;
invalidateOptionsMenu();
}
// Setup the tabs and timeline pager.
AccountPagerAdapter adapter = new AccountPagerAdapter(getSupportFragmentManager(), this, accountId);
pagerAdapter = adapter;
String[] pageTitles = { getString(R.string.title_statuses), getString(R.string.title_follows), getString(R.string.title_followers) };
adapter.setPageTitles(pageTitles);
ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
int pageMargin = getResources().getDimensionPixelSize(R.dimen.tab_page_margin);
viewPager.setPageMargin(pageMargin);
Drawable pageMarginDrawable = ThemeUtils.getDrawable(this, R.attr.tab_page_margin_drawable, R.drawable.tab_page_margin_dark);
viewPager.setPageMarginDrawable(pageMarginDrawable);
viewPager.setAdapter(adapter);
tabLayout.setupWithViewPager(viewPager);
for (int i = 0; i < tabLayout.getTabCount(); i++) {
TabLayout.Tab tab = tabLayout.getTabAt(i);
if (tab != null) {
tab.setCustomView(adapter.getTabView(i, tabLayout));
}
}
}
use of android.support.design.widget.AppBarLayout in project MadMax by deviz92.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i(TAG, "onCreate");
FirebaseUtils.getInstance().setUp();
firebaseDatabase = FirebaseUtils.getFirebaseDatabase();
databaseReference = FirebaseUtils.getDatabaseReference();
usersRef = databaseReference.child("users");
groupRef = databaseReference.child("groups");
auth = FirebaseAuth.getInstance();
/*
// getting Intent from invitation
Intent intent = getIntent();
String action = intent.getAction();
Log.d(TAG, "action " + action);
// retrieving data from the intent inviterUID & groupToBeAddedID as the group ID where to add the current user
Uri data = intent.getData();
if(data != null) {
// to be used to set the current user as friend of the inviter
Log.d(TAG, "there is an invite");
inviterUID = data.getQueryParameter("inviterUID");
groupToBeAddedID = data.getQueryParameter("groupToBeAddedID");
}
else {
inviterUID = null;
groupToBeAddedID = null;
Log.d(TAG, "there is not an invite");
}*/
// getting currentUID from Intent (from LoginSignUpActivity or EmailVerificationActivity)
startingIntent = getIntent();
Uri data = startingIntent.getData();
if (data != null) {
inviterID = data.getQueryParameter("inviterID");
groupToBeAddedID = data.getQueryParameter("groupToBeAddedID");
} else {
// retrieving data from the intent inviterID & groupToBeAddedID as the group ID where to add the current user
if (startingIntent.hasExtra("inviterID")) {
// to be used to set the current user as friend of the inviter
Log.d(TAG, "there is an invite");
inviterID = startingIntent.getStringExtra("inviterID");
startingIntent.removeExtra("inviterID");
} else
inviterID = null;
if (startingIntent.hasExtra("groupToBeAddedID")) {
groupToBeAddedID = startingIntent.getStringExtra("groupToBeAddedID");
startingIntent.removeExtra("groupToBeAddedID");
} else
groupToBeAddedID = null;
}
//todo a cosa serve?
currentFragment = startingIntent.getIntExtra("currentFragment", 1);
if ((auth.getCurrentUser() == null) || (!auth.getCurrentUser().isEmailVerified())) {
if (auth.getCurrentUser() != null) {
auth.signOut();
}
Intent doLogin = new Intent(getApplicationContext(), LoginSignUpActivity.class).setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
if (inviterID != null)
doLogin.putExtra("inviterID", inviterID);
if (groupToBeAddedID != null)
doLogin.putExtra("groupToBeAddedID", groupToBeAddedID);
startActivity(doLogin);
//0 for no animation
overridePendingTransition(0, 0);
finish();
}
// insert tabs and current fragment in the main layout
mainView.addView(getLayoutInflater().inflate(R.layout.skeleton_tab, null));
tabLayout = (TabLayout) findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText(friends));
tabLayout.addTab(tabLayout.newTab().setText(R.string.groups));
tabLayout.addTab(tabLayout.newTab().setText(R.string.pending));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
viewPager = (ViewPager) findViewById(R.id.main_view_pager);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
Log.d(TAG, String.valueOf(tab.getPosition()));
updateFab(tab.getPosition());
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
// in the main we don't want an expansible bar
AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.app_bar);
appBarLayout.setExpanded(false);
//todo: capire come bloccare la barra nel main
progressDialog = new ProgressDialog(this);
}
Aggregations