Search in sources :

Example 11 with Toolbar

use of android.support.v7.widget.Toolbar in project cheesesquare by chrisbanes.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final ActionBar ab = getSupportActionBar();
    ab.setHomeAsUpIndicator(R.drawable.ic_menu);
    ab.setDisplayHomeAsUpEnabled(true);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    if (navigationView != null) {
        setupDrawerContent(navigationView);
    }
    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Here's a Snackbar", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
    TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
}
Also used : NavigationView(android.support.design.widget.NavigationView) TabLayout(android.support.design.widget.TabLayout) FloatingActionButton(android.support.design.widget.FloatingActionButton) ViewPager(android.support.v4.view.ViewPager) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) AdapterView(android.widget.AdapterView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 12 with Toolbar

use of android.support.v7.widget.Toolbar in project cheesesquare by chrisbanes.

the class CheeseDetailActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_detail);
    Intent intent = getIntent();
    final String cheeseName = intent.getStringExtra(EXTRA_NAME);
    final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle(cheeseName);
    loadBackdrop();
}
Also used : CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout) Intent(android.content.Intent) Toolbar(android.support.v7.widget.Toolbar)

Example 13 with Toolbar

use of android.support.v7.widget.Toolbar in project GeekNews by codeestX.

the class GoldManagerActivity method initEventAndData.

@Override
protected void initEventAndData() {
    setToolBar(toolBar, "首页特别展示");
    mList = ((GoldManagerBean) getIntent().getParcelableExtra(Constants.IT_GOLD_MANAGER)).getManagerList();
    mAdapter = new GoldManagerAdapter(mContext, mList);
    rvGoldManagerList.setLayoutManager(new LinearLayoutManager(mContext));
    rvGoldManagerList.setAdapter(mAdapter);
    mCallback = new DefaultItemTouchHelpCallback(new DefaultItemTouchHelpCallback.OnItemTouchCallbackListener() {

        @Override
        public void onSwiped(int adapterPosition) {
        }

        @Override
        public boolean onMove(int srcPosition, int targetPosition) {
            if (mList != null) {
                Collections.swap(mList, srcPosition, targetPosition);
                mAdapter.notifyItemMoved(srcPosition, targetPosition);
                return true;
            }
            return false;
        }
    });
    mCallback.setDragEnable(true);
    mCallback.setSwipeEnable(false);
    ItemTouchHelper itemTouchHelper = new ItemTouchHelper(mCallback);
    itemTouchHelper.attachToRecyclerView(rvGoldManagerList);
}
Also used : DefaultItemTouchHelpCallback(com.codeest.geeknews.widget.DefaultItemTouchHelpCallback) ItemTouchHelper(android.support.v7.widget.helper.ItemTouchHelper) GoldManagerAdapter(com.codeest.geeknews.ui.gold.adapter.GoldManagerAdapter) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 14 with Toolbar

use of android.support.v7.widget.Toolbar in project UltimateAndroid by cymcsg.

the class UltimateRecyclerViewActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ultimate_recyclerview_activity);
    toolbar = (Toolbar) findViewById(R.id.tool_bar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    ultimateRecyclerView = (UltimateRecyclerView) findViewById(R.id.ultimate_recycler_view);
    ultimateRecyclerView.setHasFixedSize(false);
    final List<String> stringList = new ArrayList<>();
    stringList.add("111");
    stringList.add("aaa");
    stringList.add("222");
    stringList.add("33");
    stringList.add("44");
    stringList.add("55");
    stringList.add("66");
    stringList.add("11771");
    simpleRecyclerViewAdapter = new SimpleAdapter(stringList);
    linearLayoutManager = new LinearLayoutManager(this);
    ultimateRecyclerView.setLayoutManager(linearLayoutManager);
    ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
    StickyRecyclerHeadersDecoration headersDecor = new StickyRecyclerHeadersDecoration(simpleRecyclerViewAdapter);
    ultimateRecyclerView.addItemDecoration(headersDecor);
    ultimateRecyclerView.enableLoadmore();
    simpleRecyclerViewAdapter.setCustomLoadMoreView(LayoutInflater.from(this).inflate(R.layout.custom_bottom_progressbar, null));
    ultimateRecyclerView.setParallaxHeader(getLayoutInflater().inflate(R.layout.parallax_recyclerview_header, ultimateRecyclerView.mRecyclerView, false));
    ultimateRecyclerView.setOnParallaxScroll(new UltimateRecyclerView.OnParallaxScroll() {

        @Override
        public void onParallaxScroll(float percentage, float offset, View parallax) {
            Drawable c = toolbar.getBackground();
            c.setAlpha(Math.round(127 + percentage * 128));
            toolbar.setBackgroundDrawable(c);
        }
    });
    ultimateRecyclerView.setRecylerViewBackgroundColor(Color.parseColor("#ffffff"));
    ultimateRecyclerView.setDefaultOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    simpleRecyclerViewAdapter.insert(moreNum++ + "  Refresh things", 0);
                    ultimateRecyclerView.setRefreshing(false);
                    //   ultimateRecyclerView.scrollBy(0, -50);
                    linearLayoutManager.scrollToPosition(0);
                //                        ultimateRecyclerView.setAdapter(simpleRecyclerViewAdapter);
                //                        simpleRecyclerViewAdapter.notifyDataSetChanged();
                }
            }, 1000);
        }
    });
    ultimateRecyclerView.setOnLoadMoreListener(new UltimateRecyclerView.OnLoadMoreListener() {

        @Override
        public void loadMore(int itemsCount, final int maxLastVisiblePosition) {
            Handler handler = new Handler();
            handler.postDelayed(new Runnable() {

                public void run() {
                    simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
                    simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
                    simpleRecyclerViewAdapter.insert("More " + moreNum++, simpleRecyclerViewAdapter.getAdapterItemCount());
                // linearLayoutManager.scrollToPositionWithOffset(maxLastVisiblePosition,-1);
                //   linearLayoutManager.scrollToPosition(maxLastVisiblePosition);
                }
            }, 1000);
        }
    });
    //        ultimateRecyclerView.setDefaultSwipeToRefreshColorScheme(getResources().getColor(android.R.color.holo_blue_bright),
    //                getResources().getColor(android.R.color.holo_green_light),
    //                getResources().getColor(android.R.color.holo_orange_light),
    //                getResources().getColor(android.R.color.holo_red_light));
    ultimateRecyclerView.setScrollViewCallbacks(new ObservableScrollViewCallbacks() {

        @Override
        public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
        }

        @Override
        public void onDownMotionEvent() {
        }

        @Override
        public void onUpOrCancelMotionEvent(ObservableScrollState observableScrollState) {
            if (observableScrollState == ObservableScrollState.DOWN) {
                ultimateRecyclerView.showToolbar(toolbar, ultimateRecyclerView, getScreenHeight());
                ultimateRecyclerView.showFloatingActionMenu();
            } else if (observableScrollState == ObservableScrollState.UP) {
                ultimateRecyclerView.hideToolbar(toolbar, ultimateRecyclerView, getScreenHeight());
                ultimateRecyclerView.hideFloatingActionMenu();
            } else if (observableScrollState == ObservableScrollState.STOP) {
            }
        }
    });
    ultimateRecyclerView.showFloatingButtonView();
    ultimateRecyclerView.addOnItemTouchListener(new SwipeableRecyclerViewTouchListener(ultimateRecyclerView.mRecyclerView, new SwipeableRecyclerViewTouchListener.SwipeListener() {

        @Override
        public boolean canSwipe(int position) {
            if (position > 0)
                return true;
            else
                return false;
        }

        @Override
        public void onDismissedBySwipeLeft(RecyclerView recyclerView, int[] reverseSortedPositions) {
            for (int position : reverseSortedPositions) {
                simpleRecyclerViewAdapter.remove(position);
            }
            simpleRecyclerViewAdapter.notifyDataSetChanged();
        }

        @Override
        public void onDismissedBySwipeRight(RecyclerView recyclerView, int[] reverseSortedPositions) {
            for (int position : reverseSortedPositions) {
                simpleRecyclerViewAdapter.remove(position);
            }
            simpleRecyclerViewAdapter.notifyDataSetChanged();
        }
    }));
    ItemTouchListenerAdapter itemTouchListenerAdapter = new ItemTouchListenerAdapter(ultimateRecyclerView.mRecyclerView, new ItemTouchListenerAdapter.RecyclerViewOnItemClickListener() {

        @Override
        public void onItemClick(RecyclerView parent, View clickedView, int position) {
        }

        @Override
        public void onItemLongClick(RecyclerView parent, View clickedView, int position) {
            URLogs.d("onItemLongClick()" + isDrag);
            if (isDrag) {
                URLogs.d("onItemLongClick()" + isDrag);
                dragDropTouchListener.startDrag();
                ultimateRecyclerView.enableDefaultSwipeRefresh(false);
            }
        }
    });
    ultimateRecyclerView.mRecyclerView.addOnItemTouchListener(itemTouchListenerAdapter);
    dragDropTouchListener = new DragDropTouchListener(ultimateRecyclerView.mRecyclerView, this) {

        @Override
        public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
        }

        @Override
        protected void onItemSwitch(RecyclerView recyclerView, int from, int to) {
            if (from > 0 && to > 0) {
                simpleRecyclerViewAdapter.swapPositions(from, to);
                //                    //simpleRecyclerViewAdapter.clearSelection(from);
                //                    simpleRecyclerViewAdapter.notifyItemChanged(to);
                //simpleRecyclerViewAdapter.remove(position);
                //  simpleRecyclerViewAdapter.notifyDataSetChanged();
                URLogs.d("switch----");
            //    simpleRecyclerViewAdapter.insert(simpleRecyclerViewAdapter.remove(););
            }
        }

        @Override
        protected void onItemDrop(RecyclerView recyclerView, int position) {
            URLogs.d("drop----");
            ultimateRecyclerView.enableDefaultSwipeRefresh(true);
            simpleRecyclerViewAdapter.notifyDataSetChanged();
        }
    };
    dragDropTouchListener.setCustomDragHighlight(getResources().getDrawable(R.drawable.custom_drag_frame));
    ultimateRecyclerView.mRecyclerView.addOnItemTouchListener(dragDropTouchListener);
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
    for (Type type : Type.values()) {
        spinnerAdapter.add(type.name());
    }
    spinner.setAdapter(spinnerAdapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            ultimateRecyclerView.setItemAnimator(Type.values()[position].getAnimator());
            ultimateRecyclerView.getItemAnimator().setAddDuration(300);
            ultimateRecyclerView.getItemAnimator().setRemoveDuration(300);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            simpleRecyclerViewAdapter.insert("newly added item", 1);
        }
    });
    findViewById(R.id.del).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            simpleRecyclerViewAdapter.remove(1);
        }
    });
//        ultimateRecyclerView.addItemDecoration(
//                new HorizontalDividerItemDecoration.Builder(this).build());
//        ultimateRecyclerView.setCustomSwipeToRefresh();
//        final StoreHouseHeader header = new StoreHouseHeader(this);
//        //   header.setPadding(0, 15, 0, 0);
//
//        header.initWithString("Marshal Chen");
//        //  header.initWithStringArray(R.array.akta);
//        ultimateRecyclerView.mPtrFrameLayout.setHeaderView(header);
//        ultimateRecyclerView.mPtrFrameLayout.addPtrUIHandler(header);
//
//        ultimateRecyclerView.mPtrFrameLayout.setPtrHandler(new PtrHandler() {
//            @Override
//            public boolean checkCanDoRefresh(PtrFrameLayout ptrFrameLayout, View view, View view2) {
//                boolean canbePullDown = PtrDefaultHandler.checkContentCanBePulledDown(ptrFrameLayout, view, view2);
//                return canbePullDown;
//            }
//
//            @Override
//            public void onRefreshBegin(PtrFrameLayout ptrFrameLayout) {
//                ptrFrameLayout.postDelayed(new Runnable() {
//                    @Override
//                    public void run() {
//                        simpleRecyclerViewAdapter.insert("Refresh things", 0);
//                        //   ultimateRecyclerView.scrollBy(0, -50);
//                        linearLayoutManager.scrollToPosition(0);
//                        ultimateRecyclerView.mPtrFrameLayout.refreshComplete();
//                    }
//                }, 1800);
//            }
//        });
}
Also used : ObservableScrollState(com.marshalchen.ultimaterecyclerview.ObservableScrollState) Spinner(android.widget.Spinner) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) SwipeableRecyclerViewTouchListener(com.marshalchen.ultimaterecyclerview.SwipeableRecyclerViewTouchListener) ItemTouchListenerAdapter(com.marshalchen.ultimaterecyclerview.ItemTouchListenerAdapter) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) Drawable(android.graphics.drawable.Drawable) Handler(android.os.Handler) ObservableScrollViewCallbacks(com.marshalchen.ultimaterecyclerview.ObservableScrollViewCallbacks) StickyRecyclerHeadersDecoration(com.marshalchen.ultimaterecyclerview.stickyheadersrecyclerview.StickyRecyclerHeadersDecoration) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) DragDropTouchListener(com.marshalchen.ultimaterecyclerview.DragDropTouchListener) UltimateRecyclerView(com.marshalchen.ultimaterecyclerview.UltimateRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter)

Example 15 with Toolbar

use of android.support.v7.widget.Toolbar in project PhotoPicker by donglua.

the class PhotoPagerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.__picker_activity_photo_pager);
    int currentItem = getIntent().getIntExtra(EXTRA_CURRENT_ITEM, 0);
    List<String> paths = getIntent().getStringArrayListExtra(EXTRA_PHOTOS);
    showDelete = getIntent().getBooleanExtra(EXTRA_SHOW_DELETE, true);
    if (pagerFragment == null) {
        pagerFragment = (ImagePagerFragment) getSupportFragmentManager().findFragmentById(R.id.photoPagerFragment);
    }
    pagerFragment.setPhotos(paths, currentItem);
    Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        updateActionBarTitle();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            actionBar.setElevation(25);
        }
    }
    pagerFragment.getViewPager().addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            updateActionBarTitle();
        }
    });
}
Also used : ViewPager(android.support.v4.view.ViewPager) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Toolbar (android.support.v7.widget.Toolbar)442 View (android.view.View)316 ActionBar (android.support.v7.app.ActionBar)155 TextView (android.widget.TextView)149 RecyclerView (android.support.v7.widget.RecyclerView)120 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)112 ImageView (android.widget.ImageView)77 Intent (android.content.Intent)65 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)49 ArrayList (java.util.ArrayList)46 AdapterView (android.widget.AdapterView)38 AppCompatActivity (android.support.v7.app.AppCompatActivity)35 NavigationView (android.support.design.widget.NavigationView)34 FloatingActionButton (android.support.design.widget.FloatingActionButton)29 ViewPager (android.support.v4.view.ViewPager)29 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)28 BindView (butterknife.BindView)28 MenuItem (android.view.MenuItem)24 ViewGroup (android.view.ViewGroup)24 Handler (android.os.Handler)23