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);
}
}
}
use of android.support.design.widget.CollapsingToolbarLayout in project android2 by aqi00.
the class CollapseParallaxActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_collapse_parallax);
// 从布局文件中获取名叫tl_title的工具栏
Toolbar tl_title = findViewById(R.id.tl_title);
// 设置工具栏的背景
tl_title.setBackgroundColor(Color.RED);
// 使用tl_title替换系统自带的ActionBar
setSupportActionBar(tl_title);
// 从布局文件中获取名叫ctl_title的可折叠布局
CollapsingToolbarLayout ctl_title = findViewById(R.id.ctl_title);
// 设置可折叠布局的标题文字
ctl_title.setTitle(getString(R.string.toolbar_name));
// 从布局文件中获取名叫rv_main的循环视图
RecyclerView rv_main = findViewById(R.id.rv_main);
// 创建一个垂直方向的线性布局管理器
LinearLayoutManager llm = new LinearLayoutManager(this, LinearLayout.VERTICAL, false);
// 设置循环视图的布局管理器
rv_main.setLayoutManager(llm);
// 构建一个十二生肖的线性适配器
RecyclerCollapseAdapter adapter = new RecyclerCollapseAdapter(this, yearArray);
// 给rv_main设置十二生肖线性适配器
rv_main.setAdapter(adapter);
}
use of android.support.design.widget.CollapsingToolbarLayout in project iosched by google.
the class ProductListActivity method initCollapsingToolbar.
private void initCollapsingToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.AppBar);
int collapsingToolbarImageIndex = 6;
int collapsingImageToolbarSize = 1200;
NetworkImageView collapsingToolbarImage = (NetworkImageView) findViewById(R.id.CollapsingToolbarImage);
StringBuilder collapsingToolbarImageUrl = new StringBuilder(productEntryList.get(collapsingToolbarImageIndex).url);
collapsingToolbarImageUrl.append("=s");
collapsingToolbarImageUrl.append(collapsingImageToolbarSize);
setSupportActionBar(toolbar);
CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.CollapsingToolbarLayout);
collapsingToolbarLayout.setTitle(toolbar.getTitle());
collapsingToolbarLayout.setExpandedTitleTextAppearance(R.style.TextAppearance_Shrine_Logo);
collapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.TextAppearance_Shrine_Logo);
imageRequester.setImageFromUrl(collapsingToolbarImage, collapsingToolbarImageUrl.toString());
Point windowSize = new Point();
getWindowManager().getDefaultDisplay().getSize(windowSize);
int windowWidth = windowSize.x;
collapsingToolbarImage.setX(collapsingToolbarImage.getX() - windowWidth / 4);
collapsingToolbarLayout.setScrimVisibleHeightTrigger((int) getResources().getDimension(R.dimen.shrine_tall_toolbar_height) / 2);
}
Aggregations