Search in sources :

Example 81 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project Synthese_2BIN by TheYoungSensei.

the class ItemDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_item_detail);
    Toolbar toolbar = (Toolbar) findViewById(R.id.detail_toolbar);
    setSupportActionBar(toolbar);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own detail action", Snackbar.LENGTH_LONG).setAction("Action", null).show();
        }
    });
    // Show the Up button in the action bar.
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    //
    if (savedInstanceState == null) {
        // Create the detail fragment and add it to the activity
        // using a fragment transaction.
        Bundle arguments = new Bundle();
        arguments.putString(ItemDetailFragment.ARG_ITEM_ID, getIntent().getStringExtra(ItemDetailFragment.ARG_ITEM_ID));
        ItemDetailFragment fragment = new ItemDetailFragment();
        fragment.setArguments(arguments);
        getSupportFragmentManager().beginTransaction().add(R.id.item_detail_container, fragment).commit();
    }
}
Also used : Bundle(android.os.Bundle) FloatingActionButton(android.support.design.widget.FloatingActionButton) View(android.view.View) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 82 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project MadMax by deviz92.

the class DetailFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // create the view to return
    View mainView = null;
    // get the bundle
    Bundle bundle = this.getArguments();
    // the listener will be the GroupDetailActivity or the FriendDetailActivity
    setInterface((OnItemClickInterface) getActivity());
    databaseReference = FirebaseDatabase.getInstance().getReference();
    // when an item in the list will be clicked the onListItemClicked will be called
    groupsViewAdapter = new GroupsViewAdapter(this.getContext(), this, groups, DetailFragment.TAG);
    if (activityName.equals("FriendDetailActivity")) {
        Log.d(TAG, "FriendDetailActivity per RecylerView");
        // Inflate the layout for this fragment
        mainView = inflater.inflate(R.layout.skeleton_list_friend, container, false);
        RecyclerView.ItemDecoration divider = new InsetDivider.Builder(getContext()).orientation(InsetDivider.VERTICAL_LIST).dividerHeight(getResources().getDimensionPixelSize(R.dimen.divider_height)).color(ContextCompat.getColor(getContext(), R.color.colorDivider)).insets(getResources().getDimensionPixelSize(R.dimen.divider_inset), 0).overlay(true).build();
        recyclerView = (RecyclerView) mainView.findViewById(R.id.rv_skeleton);
        layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.addItemDecoration(divider);
        recyclerView.setAdapter(groupsViewAdapter);
        // Extract data from bundle
        friendID = bundle.getString("friendID");
        // Show shared groups
        databaseReference.child("users").child(MainActivity.getCurrentUser().getID()).child("friends").child(friendID).child("sharedGroups").addListenerForSingleValueEvent(new ValueEventListener() {

            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                for (DataSnapshot sharedGroupSnapshot : dataSnapshot.getChildren()) {
                    FirebaseUtils.getInstance().getGroup(sharedGroupSnapshot.getKey(), groups, groupsViewAdapter);
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        });
    } else if (activityName.equals("GroupDetailActivity")) {
        groupID = bundle.getString("groupID");
        mainView = inflater.inflate(R.layout.fragment_group_detail, container, false);
        fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
        fab.setImageResource(android.R.drawable.ic_input_add);
        TabLayout tabLayout = (TabLayout) mainView.findViewById(R.id.tab_layout);
        tabLayout.addTab(tabLayout.newTab().setText(R.string.expenses));
        tabLayout.addTab(tabLayout.newTab().setText(R.string.members));
        tabLayout.addTab(tabLayout.newTab().setText(R.string.activities));
        tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
        updateFab(0);
        final ViewPager viewPager = (ViewPager) mainView.findViewById(R.id.main_view_pager);
        final DetailFragment.PagerAdapter adapter = new DetailFragment.PagerAdapter(getActivity().getSupportFragmentManager(), tabLayout.getTabCount());
        viewPager.setAdapter(adapter);
        viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
        tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                Log.d(TAG, "selected tab " + tab.getPosition());
                updateFab(tab.getPosition());
                viewPager.setCurrentItem(tab.getPosition());
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {
            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {
            }
        });
    }
    return mainView;
}
Also used : GroupsViewAdapter(com.polito.mad17.madmax.activities.groups.GroupsViewAdapter) Bundle(android.os.Bundle) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DataSnapshot(com.google.firebase.database.DataSnapshot) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) ViewPager(android.support.v4.view.ViewPager) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) DatabaseError(com.google.firebase.database.DatabaseError) TabLayout(android.support.design.widget.TabLayout) FloatingActionButton(android.support.design.widget.FloatingActionButton) RecyclerView(android.support.v7.widget.RecyclerView) ValueEventListener(com.google.firebase.database.ValueEventListener)

Example 83 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project J2ME-Loader by nikita36078.

the class AppsListFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    registerForContextMenu(getListView());
    FloatingActionButton fab = getActivity().findViewById(R.id.fab);
    fab.setOnClickListener(v -> {
        Intent i = new Intent(getActivity(), FilteredFilePickerActivity.class);
        i.putExtra(FilePickerActivity.EXTRA_ALLOW_MULTIPLE, false);
        i.putExtra(FilePickerActivity.EXTRA_SINGLE_CLICK, true);
        i.putExtra(FilePickerActivity.EXTRA_ALLOW_CREATE_DIR, false);
        i.putExtra(FilePickerActivity.EXTRA_MODE, FilePickerActivity.MODE_FILE);
        i.putExtra(FilePickerActivity.EXTRA_START_PATH, FilteredFilePickerFragment.getLastPath());
        startActivityForResult(i, FILE_CODE);
    });
}
Also used : FloatingActionButton(android.support.design.widget.FloatingActionButton) Intent(android.content.Intent)

Example 84 with FloatingActionButton

use of android.support.design.widget.FloatingActionButton in project SherlockAdapter by EvilBT.

the class MultiSelectItemActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.act_multi_select_item);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            getSelectedList();
        }
    });
    findViewById(R.id.selectAll).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // 全选
            adapter.selectAll();
        }
    });
    findViewById(R.id.unselectAll).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // 全不选
            adapter.clearSelectAll();
        }
    });
    adapter = new MyMultiSelectAdapter();
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
    recyclerView.setLayoutManager(new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL));
    recyclerView.setAdapter(adapter);
    // 屏障默认的Change动画,默认的Change动画会闪烁一下
    ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
    adapter.setOnItemCheckedChangeListener(new OnItemCheckedChangeListener() {

        @Override
        public void onItemCheck(@NonNull View view, boolean isChecked, int adapterPosition) {
            final int id = view.getId();
            if (id == R.id.checkbox) {
                IMultiSelectItem selectorItem = adapter.getData(adapterPosition);
                if (selectorItem != null) {
                    final int selectedSize = adapter.getSelectedItems().size();
                    if (isChecked && selectedSize > 9) {
                        Toast.makeText(MultiSelectItemActivity.this, "您最多只能选择9个", Toast.LENGTH_SHORT).show();
                        selectorItem.setChecked(false);
                        adapter.notifyItemChanged(adapterPosition);
                    }
                }
            }
        }
    });
    List<IMultiSelectItem> data = new ArrayList<>(20);
    for (int i = 0; i < 40; i++) {
        SelectorCard card = new SelectorCard(i);
        data.add(card);
    }
    // 添加一个不可选中的数据在列表上
    NoSelectCard card = new NoSelectCard("我跟他们不一样");
    data.add(0, card);
    adapter.setData(data);
}
Also used : SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) ArrayList(java.util.ArrayList) SelectorCard(xyz.zpayh.myadapter.data.SelectorCard) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) NoSelectCard(xyz.zpayh.myadapter.data.NoSelectCard) OnItemCheckedChangeListener(xyz.zpayh.adapter.OnItemCheckedChangeListener) MyMultiSelectAdapter(xyz.zpayh.myadapter.adapter.MyMultiSelectAdapter) FloatingActionButton(android.support.design.widget.FloatingActionButton) RecyclerView(android.support.v7.widget.RecyclerView) Toolbar(android.support.v7.widget.Toolbar) IMultiSelectItem(xyz.zpayh.adapter.IMultiSelectItem)

Aggregations

FloatingActionButton (android.support.design.widget.FloatingActionButton)84 View (android.view.View)58 Toolbar (android.support.v7.widget.Toolbar)28 TextView (android.widget.TextView)20 ImageView (android.widget.ImageView)16 Intent (android.content.Intent)13 RecyclerView (android.support.v7.widget.RecyclerView)12 ColorStateList (android.content.res.ColorStateList)9 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 Bundle (android.os.Bundle)7 NavigationView (android.support.design.widget.NavigationView)7 TabLayout (android.support.design.widget.TabLayout)7 ViewPager (android.support.v4.view.ViewPager)7 ActionBar (android.support.v7.app.ActionBar)7 UiController (android.support.test.espresso.UiController)6 ViewAction (android.support.test.espresso.ViewAction)6 AdapterView (android.widget.AdapterView)6 ListView (android.widget.ListView)5 DrawerLayout (android.support.v4.widget.DrawerLayout)4 ActionBarDrawerToggle (android.support.v7.app.ActionBarDrawerToggle)4