Search in sources :

Example 31 with Toolbar

use of android.support.v7.widget.Toolbar in project flexbox-layout by google.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initializeStringResources();
    mFlexboxLayout = (FlexboxLayout) findViewById(R.id.flexbox_layout);
    mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    if (drawer != null) {
        drawer.addDrawerListener(toggle);
    }
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        navigationView.setNavigationItemSelectedListener(this);
        Menu navigationMenu = navigationView.getMenu();
        initializeFlexDirectionSpinner(navigationMenu);
        initializeFlexWrapSpinner(navigationMenu);
        initializeJustifyContentSpinner(navigationMenu);
        initializeAlignItemsSpinner(navigationMenu);
        initializeAlignContentSpinner(navigationMenu);
    }
    if (savedInstanceState != null) {
        ArrayList<FlexItem> flexItems = savedInstanceState.getParcelableArrayList(FLEX_ITEMS_KEY);
        assert flexItems != null;
        mFlexboxLayout.removeAllViews();
        for (int i = 0; i < flexItems.size(); i++) {
            FlexItem flexItem = flexItems.get(i);
            FlexboxLayout.LayoutParams lp = flexItem.toLayoutParams(this);
            TextView textView = createBaseFlexItemTextView(i);
            ViewCompat.setPaddingRelative(textView, flexItem.paddingStart, flexItem.paddingTop, flexItem.paddingEnd, flexItem.paddingBottom);
            textView.setLayoutParams(lp);
            mFlexboxLayout.addView(textView);
        }
    }
    for (int i = 0; i < mFlexboxLayout.getChildCount(); i++) {
        mFlexboxLayout.getChildAt(i).setOnClickListener(new FlexItemClickListener(i));
    }
    FloatingActionButton addFab = (FloatingActionButton) findViewById(R.id.add_fab);
    if (addFab != null) {
        addFab.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                int viewIndex = mFlexboxLayout.getChildCount();
                // index starts from 0. New View's index is N if N views ([0, 1, 2, ... N-1])
                // exist.
                TextView textView = createBaseFlexItemTextView(viewIndex);
                textView.setLayoutParams(createDefaultLayoutParams());
                textView.setOnClickListener(new FlexItemClickListener(viewIndex));
                mFlexboxLayout.addView(textView);
            }
        });
    }
    FloatingActionButton removeFab = (FloatingActionButton) findViewById(R.id.remove_fab);
    if (removeFab != null) {
        removeFab.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (mFlexboxLayout.getChildCount() == 0) {
                    return;
                }
                mFlexboxLayout.removeViewAt(mFlexboxLayout.getChildCount() - 1);
            }
        });
    }
}
Also used : NavigationView(android.support.design.widget.NavigationView) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) NavigationView(android.support.design.widget.NavigationView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) FlexboxLayout(com.google.android.flexbox.FlexboxLayout) FloatingActionButton(android.support.design.widget.FloatingActionButton) TextView(android.widget.TextView) Menu(android.view.Menu) DrawerLayout(android.support.v4.widget.DrawerLayout) Toolbar(android.support.v7.widget.Toolbar)

Example 32 with Toolbar

use of android.support.v7.widget.Toolbar in project material-components-android by material-components.

the class AppBarLayoutBaseTest method configureContent.

@CallSuper
protected void configureContent(@LayoutRes final int layoutResId, @StringRes final int titleResId) throws Throwable {
    onView(withId(R.id.coordinator_stub)).perform(inflateViewStub(layoutResId));
    mAppBar = (AppBarLayout) mCoordinatorLayout.findViewById(R.id.app_bar);
    mCollapsingToolbar = (CollapsingToolbarLayout) mAppBar.findViewById(R.id.collapsing_app_bar);
    mToolbar = (Toolbar) mAppBar.findViewById(R.id.toolbar);
    final AppCompatActivity activity = activityTestRule.getActivity();
    activityTestRule.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            activity.setSupportActionBar(mToolbar);
        }
    });
    final CharSequence activityTitle = activity.getString(titleResId);
    activityTestRule.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            activity.setTitle(activityTitle);
        }
    });
    getInstrumentation().waitForIdleSync();
    if (mCollapsingToolbar != null) {
        onView(withId(R.id.collapsing_app_bar)).perform(setTitle(activityTitle)).perform(setContentScrimColor(Color.MAGENTA));
    }
    TextView dialog = (TextView) mCoordinatorLayout.findViewById(R.id.textview_dialogue);
    if (dialog != null) {
        onView(withId(R.id.textview_dialogue)).perform(setText(TextUtils.concat(Shakespeare.DIALOGUE)));
    }
    mDefaultElevationValue = mAppBar.getResources().getDimension(R.dimen.design_appbar_elevation);
}
Also used : AppCompatActivity(android.support.v7.app.AppCompatActivity) TextView(android.widget.TextView) CallSuper(android.support.annotation.CallSuper)

Example 33 with Toolbar

use of android.support.v7.widget.Toolbar in project material-components-android by material-components.

the class AppBarLayoutCollapsePinActivity method onContentViewSet.

@Override
protected void onContentViewSet() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
}
Also used : Toolbar(android.support.v7.widget.Toolbar)

Example 34 with Toolbar

use of android.support.v7.widget.Toolbar in project AdvancedMaterialDrawer by madcyph3r.

the class HeadItemTypesFragment method createAdapter.

private void createAdapter(RecyclerView recyclerView) {
    final List<ExampleData> content = new ArrayList<>();
    content.add(new ExampleData("One Item Example", HeadItemOneActivity.class));
    content.add(new ExampleData("(One Item) Below Toolbar", HeadItemOneBelowToolbarActivity.class));
    content.add(new ExampleData("(One Item) Black Theme", HeadItemOneBlackThemeActivity.class));
    content.add(new ExampleData("(Three Item)", HeadItemThreeActivity.class));
    content.add(new ExampleData("(Five Item)", HeadItemFiveActivity.class));
    content.add(new ExampleData("(Five Item) With Extra Menu", HeadItemFiveExtraMenuActivity.class));
    content.add(new ExampleData("(Two Items) With Extra Menu", HeadItemTwoExtraMenuActivity.class));
    content.add(new ExampleData("(Three Items) Don't Close Drawer On Change", HeadItemThreeDontCloseOnChangeActivity.class));
    content.add(new ExampleData("(Five Items) Don't Close Drawer On Change", HeadItemFiveDontCloseOnChangeActivity.class));
    content.add(new ExampleData("Add And Remove Menu Items At Runtime", AddRemoveMenuItemsActivity.class));
    content.add(new ExampleData("(Two Items) Only First Item Has a Menu", HeadItemTwoOnlyOneHasMenuActivity.class));
    content.add(new ExampleData("(Two Items) Fragment Doesn't Change On HeadItem Change", HeadItemTwoNoFragmentLoadOnChangeActivity.class));
    content.add(new ExampleData("100 Head Items With Static Background", HeadItem100StaticBackgroundActivity.class));
    final ParallaxRecyclerAdapter<ExampleData> adapter = new ParallaxRecyclerAdapter<>(content);
    View header = getActivity().getLayoutInflater().inflate(R.layout.recycleview_header, recyclerView, false);
    ImageView headerImage = (ImageView) header.findViewById(R.id.imageViewHeader);
    headerImage.setImageResource(R.drawable.l_5);
    adapter.setParallaxHeader(header, recyclerView);
    adapter.setData(content);
    adapter.implementRecyclerAdapterMethods(new ParallaxRecyclerAdapter.RecyclerAdapterMethods() {

        @Override
        public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
            ((ViewHolder) viewHolder).textView.setText(adapter.getData().get(i).getTitle());
        }

        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, final int i) {
            final ViewHolder holder = new ViewHolder(getActivity().getLayoutInflater().inflate(R.layout.recycleview_row, viewGroup, false));
            return holder;
        }

        @Override
        public int getItemCount() {
            return content.size();
        }
    });
    adapter.setOnParallaxScroll(new ParallaxRecyclerAdapter.OnParallaxScroll() {

        @Override
        public void onParallaxScroll(float percentage, float offset, View view) {
            ((MainActivity) getActivity()).setActionBarAlpha(percentage);
        }
    });
    adapter.setOnClickEvent(new ParallaxRecyclerAdapter.OnClickEvent() {

        @Override
        public void onClick(View view, int i) {
            if (i >= 0) {
                Intent intent = new Intent(getActivity(), adapter.getData().get(i).getClazz());
                startActivity(intent);
            }
        }
    });
    recyclerView.setAdapter(adapter);
}
Also used : ExampleData(de.madcyph3r.example.data.ExampleData) HeadItemOneBelowToolbarActivity(de.madcyph3r.example.example.headerTypes.HeadItemOneBelowToolbarActivity) HeadItem100StaticBackgroundActivity(de.madcyph3r.example.example.headItemTypes.HeadItem100StaticBackgroundActivity) ArrayList(java.util.ArrayList) HeadItemThreeDontCloseOnChangeActivity(de.madcyph3r.example.example.headItemTypes.HeadItemThreeDontCloseOnChangeActivity) HeadItemThreeActivity(de.madcyph3r.example.example.headerTypes.HeadItemThreeActivity) HeadItemFiveExtraMenuActivity(de.madcyph3r.example.example.headItemTypes.HeadItemFiveExtraMenuActivity) HeadItemTwoNoFragmentLoadOnChangeActivity(de.madcyph3r.example.example.headItemTypes.HeadItemTwoNoFragmentLoadOnChangeActivity) AddRemoveMenuItemsActivity(de.madcyph3r.example.example.menu.AddRemoveMenuItemsActivity) ParallaxRecyclerAdapter(com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter) HeadItemTwoOnlyOneHasMenuActivity(de.madcyph3r.example.example.headItemTypes.HeadItemTwoOnlyOneHasMenuActivity) HeadItemTwoExtraMenuActivity(de.madcyph3r.example.example.headItemTypes.HeadItemTwoExtraMenuActivity) ImageView(android.widget.ImageView) HeadItemOneActivity(de.madcyph3r.example.example.headerTypes.HeadItemOneActivity) ViewGroup(android.view.ViewGroup) HeadItemOneBlackThemeActivity(de.madcyph3r.example.example.headItemTypes.HeadItemOneBlackThemeActivity) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) HeadItemFiveActivity(de.madcyph3r.example.example.headerTypes.HeadItemFiveActivity) HeadItemFiveDontCloseOnChangeActivity(de.madcyph3r.example.example.headItemTypes.HeadItemFiveDontCloseOnChangeActivity) RecyclerView(android.support.v7.widget.RecyclerView)

Example 35 with Toolbar

use of android.support.v7.widget.Toolbar in project AdvancedMaterialDrawer by madcyph3r.

the class ThemeFragment method createAdapter.

private void createAdapter(RecyclerView recyclerView) {
    final List<ExampleData> content = new ArrayList<>();
    content.add(new ExampleData("Dark Theme", DarkThemeActivity.class));
    content.add(new ExampleData("Light Theme", LightThemeActivity.class));
    content.add(new ExampleData("My Theme", MyThemeActivity.class));
    content.add(new ExampleData("Unique Toolbar Color", UniqueToolbarColorActivity.class));
    content.add(new ExampleData("Actionbar Overlay", ActionBarOverlayActivity.class));
    content.add(new ExampleData("KitKat Translucent Statusbar", KitKatTranslucentStatusBarActivity.class));
    content.add(new ExampleData("Actionbar Own Font", ActionBarOwnFontActivity.class));
    content.add(new ExampleData("Own Drawer Width", OwnDrawerWidthActivity.class));
    content.add(new ExampleData("Only Icons Menu", OnlyIconsActivity.class));
    final ParallaxRecyclerAdapter<ExampleData> adapter = new ParallaxRecyclerAdapter<>(content);
    View header = getActivity().getLayoutInflater().inflate(R.layout.recycleview_header, recyclerView, false);
    ImageView headerImage = (ImageView) header.findViewById(R.id.imageViewHeader);
    headerImage.setImageResource(R.drawable.l_8);
    adapter.setParallaxHeader(header, recyclerView);
    adapter.setData(content);
    adapter.implementRecyclerAdapterMethods(new ParallaxRecyclerAdapter.RecyclerAdapterMethods() {

        @Override
        public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
            ((ViewHolder) viewHolder).textView.setText(adapter.getData().get(i).getTitle());
        }

        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, final int i) {
            final ViewHolder holder = new ViewHolder(getActivity().getLayoutInflater().inflate(R.layout.recycleview_row, viewGroup, false));
            return holder;
        }

        @Override
        public int getItemCount() {
            return content.size();
        }
    });
    adapter.setOnParallaxScroll(new ParallaxRecyclerAdapter.OnParallaxScroll() {

        @Override
        public void onParallaxScroll(float percentage, float offset, View view) {
            ((MainActivity) getActivity()).setActionBarAlpha(percentage);
        }
    });
    adapter.setOnClickEvent(new ParallaxRecyclerAdapter.OnClickEvent() {

        @Override
        public void onClick(View view, int i) {
            if (i >= 0) {
                Intent intent = new Intent(getActivity(), adapter.getData().get(i).getClazz());
                startActivity(intent);
            }
        }
    });
    recyclerView.setAdapter(adapter);
}
Also used : ExampleData(de.madcyph3r.example.data.ExampleData) KitKatTranslucentStatusBarActivity(de.madcyph3r.example.example.theme.KitKatTranslucentStatusBarActivity) ArrayList(java.util.ArrayList) ActionBarOwnFontActivity(de.madcyph3r.example.example.theme.ActionBarOwnFontActivity) ParallaxRecyclerAdapter(com.poliveira.parallaxrecycleradapter.ParallaxRecyclerAdapter) DarkThemeActivity(de.madcyph3r.example.example.theme.DarkThemeActivity) ImageView(android.widget.ImageView) ActionBarOverlayActivity(de.madcyph3r.example.example.theme.ActionBarOverlayActivity) ViewGroup(android.view.ViewGroup) OwnDrawerWidthActivity(de.madcyph3r.example.example.theme.OwnDrawerWidthActivity) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) MyThemeActivity(de.madcyph3r.example.example.theme.MyThemeActivity) OnlyIconsActivity(de.madcyph3r.example.example.theme.OnlyIconsActivity) UniqueToolbarColorActivity(de.madcyph3r.example.example.theme.UniqueToolbarColorActivity) RecyclerView(android.support.v7.widget.RecyclerView) LightThemeActivity(de.madcyph3r.example.example.theme.LightThemeActivity)

Aggregations

Toolbar (android.support.v7.widget.Toolbar)495 View (android.view.View)357 ActionBar (android.support.v7.app.ActionBar)178 TextView (android.widget.TextView)167 RecyclerView (android.support.v7.widget.RecyclerView)133 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)123 ImageView (android.widget.ImageView)84 Intent (android.content.Intent)75 ArrayList (java.util.ArrayList)56 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)55 BindView (butterknife.BindView)45 AppCompatActivity (android.support.v7.app.AppCompatActivity)41 AdapterView (android.widget.AdapterView)41 NavigationView (android.support.design.widget.NavigationView)39 BarPainter (com.xabber.android.ui.color.BarPainter)36 MenuItem (android.view.MenuItem)35 FloatingActionButton (android.support.design.widget.FloatingActionButton)31 ViewPager (android.support.v4.view.ViewPager)31 ViewGroup (android.view.ViewGroup)31 Bundle (android.os.Bundle)29