Search in sources :

Example 21 with CollapsingToolbarLayout

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());
        }
    }
}
Also used : Bundle(android.os.Bundle) IOException(java.io.IOException) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) ImageView(android.widget.ImageView) View(android.view.View) CardView(android.support.v7.widget.CardView) TextView(android.widget.TextView) FloatingActionButton(android.support.design.widget.FloatingActionButton) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) ArrayList(java.util.ArrayList) List(java.util.List) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 22 with CollapsingToolbarLayout

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));
        }
    }
}
Also used : Context(android.content.Context) SharedPreferences(android.content.SharedPreferences) Drawable(android.graphics.drawable.Drawable) Intent(android.content.Intent) AccountPagerAdapter(com.keylesspalace.tusky.pager.AccountPagerAdapter) ViewPager(android.support.v4.view.ViewPager) AttrRes(android.support.annotation.AttrRes) TabLayout(android.support.design.widget.TabLayout) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) AppBarLayout(android.support.design.widget.AppBarLayout) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 23 with CollapsingToolbarLayout

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);
        }
    }
}
Also used : Activity(android.app.Activity) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout)

Example 24 with CollapsingToolbarLayout

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);
}
Also used : RecyclerCollapseAdapter(com.example.group.adapter.RecyclerCollapseAdapter) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Toolbar(android.support.v7.widget.Toolbar)

Example 25 with CollapsingToolbarLayout

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);
}
Also used : NetworkImageView(com.android.volley.toolbox.NetworkImageView) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) Point(android.graphics.Point) Point(android.graphics.Point) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

CollapsingToolbarLayout (android.support.design.widget.CollapsingToolbarLayout)30 Toolbar (android.support.v7.widget.Toolbar)14 View (android.view.View)11 ImageView (android.widget.ImageView)10 AppBarLayout (android.support.design.widget.AppBarLayout)6 Activity (android.app.Activity)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 TextView (android.widget.TextView)5 Intent (android.content.Intent)4 RecyclerView (android.support.v7.widget.RecyclerView)4 Bundle (android.os.Bundle)3 FloatingActionButton (android.support.design.widget.FloatingActionButton)3 TabLayout (android.support.design.widget.TabLayout)3 ViewPager (android.support.v4.view.ViewPager)3 ArrayList (java.util.ArrayList)3 Context (android.content.Context)2 Drawable (android.graphics.drawable.Drawable)2 AttrRes (android.support.annotation.AttrRes)2 NonNull (android.support.annotation.NonNull)2 NavigationView (android.support.design.widget.NavigationView)2