use of android.support.design.widget.CollapsingToolbarLayout in project LeMondeRssReader by MBach.
the class ArticleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initActivityTransitions();
setContentView(R.layout.activity_article);
appBarLayout = (AppBarLayout) findViewById(R.id.app_bar_layout);
toolbar = (Toolbar) findViewById(R.id.toolbar);
articleActivityRecyclerView = (ScrollFeedbackRecyclerView) findViewById(R.id.articleActivityRecyclerView);
articleActivityRecyclerView.setLayoutManager(new LinearLayoutManager(this));
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fabProgressCircle = (FABProgressCircle) findViewById(R.id.fabProgressCircle);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
fabProgressCircle.show();
List<Model> comments = loadMoreComments();
fabProgressCircle.hide();
if (comments.isEmpty()) {
Snackbar.make(findViewById(R.id.coordinatorArticle), "Pas de nouveau commentaire", Snackbar.LENGTH_LONG).show();
} else {
ArticleAdapter adapter = (ArticleAdapter) articleActivityRecyclerView.getAdapter();
adapter.insertItems(comments);
}
}
});
//ViewCompat.setTransitionName(appBarLayout, Constants.EXTRA_RSS_IMAGE);
//supportPostponeEnterTransition();
Bundle extras = getIntent().getExtras();
if (extras != null) {
CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
collapsingToolbar.setTitle(extras.getString(Constants.EXTRA_NEWS_CATEGORY));
final ImageView imageView = (ImageView) findViewById(R.id.imageArticle);
Picasso.with(getBaseContext()).load(extras.getString(Constants.EXTRA_RSS_IMAGE)).into(imageView);
try {
Document doc = Jsoup.connect(extras.getString(Constants.EXTRA_RSS_LINK)).get();
if (doc.getElementById("teaser_article") != null) {
TextView paidArticle = (TextView) findViewById(R.id.paidArticle);
paidArticle.setVisibility(View.VISIBLE);
}
Elements articles = doc.getElementsByTag("article");
List<Model> items = null;
if (!articles.isEmpty()) {
Elements category = doc.select("div.tt_rubrique_ombrelle");
if (atLeastOneChild(category)) {
getSupportActionBar().setTitle(category.text());
}
items = extractStandardArticle(articles);
items.addAll(loadAndExtractCommentPreview(doc.getElementById("liste_reactions")));
} else if (doc.getElementById("content") != null) {
items = extractBlogArticle(doc);
}
if (items != null && !items.isEmpty()) {
articleActivityRecyclerView.setAdapter(new ArticleAdapter(items));
}
} catch (IOException e) {
Log.d(TAG, e.getMessage());
}
}
}
use of android.support.design.widget.CollapsingToolbarLayout 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.CollapsingToolbarLayout in project Synthese_2BIN by TheYoungSensei.
the class ItemDetailFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments().containsKey(ARG_ITEM_ID)) {
// Load the dummy content specified by the fragment
// arguments. In a real-world scenario, use a Loader
// to load content from a content provider.
//TODO mItem = Artist.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
Activity activity = this.getActivity();
CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
if (appBarLayout != null) {
appBarLayout.setTitle(mItem.content);
}
}
}
Aggregations