Search in sources :

Example 16 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.FloatingActionButton in project IITB-App by wncc.

the class UserFragment method populateViews.

private void populateViews() {
    if (getActivity() == null || getView() == null)
        return;
    userProfilePictureImageView = getActivity().findViewById(R.id.user_profile_picture_profile);
    TextView userNameTextView = getActivity().findViewById(R.id.user_name_profile);
    TextView userRollNumberTextView = getActivity().findViewById(R.id.user_rollno_profile);
    final TextView userEmailIDTextView = getActivity().findViewById(R.id.user_email_profile);
    TextView userContactNumberTextView = getActivity().findViewById(R.id.user_contact_no_profile);
    FloatingActionButton userShareFab = getActivity().findViewById(R.id.share_user_button);
    Picasso.get().load(user.getUserProfilePictureUrl()).placeholder(R.drawable.user_placeholder).into(userProfilePictureImageView);
    userProfilePictureImageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            zoomImageFromThumb(userProfilePictureImageView);
        }
    });
    mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
    if (!showingMin) {
        /* Show tabs */
        getActivity().findViewById(R.id.tab_layout).setVisibility(VISIBLE);
        /* Load lists */
        final List<Role> roleList = user.getUserRoles();
        final List<Body> bodyList = user.getUserFollowedBodies();
        final List<Event> eventList = user.getUserGoingEvents();
        final List<Role> formerRoleList = user.getUserFormerRoles();
        /* Construct user profile */
        final List<CardInterface> profile = new ArrayList<>(roleList);
        for (Role role : formerRoleList) {
            Role temp = new Role(role);
            temp.setRoleName("Former " + role.getRoleName() + " " + role.getRoleYear());
            profile.add(temp);
        }
        profile.addAll(user.getUserAchievements());
        List<Event> eventInterestedList = user.getUserInterestedEvents();
        eventList.removeAll(eventInterestedList);
        eventList.addAll(eventInterestedList);
        GenericRecyclerViewFragment frag1 = GenericRecyclerViewFragment.newInstance(profile);
        BodyRecyclerViewFragment frag2 = BodyRecyclerViewFragment.newInstance(bodyList);
        EventRecyclerViewFragment frag3 = EventRecyclerViewFragment.newInstance(eventList);
        frag1.parentFragment = this;
        frag2.parentFragment = this;
        frag3.parentFragment = this;
        TabAdapter tabAdapter = new TabAdapter(getChildFragmentManager());
        tabAdapter.addFragment(frag1, "Profile");
        tabAdapter.addFragment(frag2, "Following");
        tabAdapter.addFragment(frag3, "Events");
        // Set up the ViewPager with the sections adapter.
        ViewPager viewPager = (ViewPager) getActivity().findViewById(R.id.viewPager);
        viewPager.setAdapter(tabAdapter);
        viewPager.setOffscreenPageLimit(2);
        TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.tab_layout);
        tabLayout.setupWithViewPager(viewPager);
        userShareFab.show();
        getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
    }
    userNameTextView.setText(user.getUserName());
    userRollNumberTextView.setText(user.getUserRollNumber());
    if (user.getUserEmail() != null && !user.getUserEmail().equals("N/A")) {
        userEmailIDTextView.setText(user.getUserEmail());
    } else {
        if (user.getUserRollNumber() != null)
            userEmailIDTextView.setText(user.getUserRollNumber() + "@iitb.ac.in");
    }
    userEmailIDTextView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mail((String) userEmailIDTextView.getText());
        }
    });
    if (!"N/A".equals(user.getUserContactNumber())) {
        userContactNumberTextView.setText(user.getUserContactNumber());
        userContactNumberTextView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                call(user.getUserContactNumber());
            }
        });
    } else {
        userContactNumberTextView.setVisibility(View.GONE);
    }
    userShareFab.setOnClickListener(new View.OnClickListener() {

        String shareUrl = ShareURLMaker.getUserURL(user);

        @Override
        public void onClick(View view) {
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_SUBJECT, "Sharing URL");
            i.putExtra(Intent.EXTRA_TEXT, shareUrl);
            startActivity(Intent.createChooser(i, "Share URL"));
        }
    });
}
Also used : CardInterface(app.insti.interfaces.CardInterface) TabAdapter(app.insti.adapter.TabAdapter) ArrayList(java.util.ArrayList) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ViewPager(androidx.viewpager.widget.ViewPager) Role(app.insti.api.model.Role) TabLayout(com.google.android.material.tabs.TabLayout) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Event(app.insti.api.model.Event) TextView(android.widget.TextView) Body(app.insti.api.model.Body)

Example 17 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.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());
    setHasOptionsMenu(true);
    setListAdapter(adapter);
    FloatingActionButton fab = view.findViewById(R.id.fab);
    fab.setOnClickListener(v -> {
        String path = preferences.getString(PREF_LAST_PATH, null);
        if (path == null) {
            File dir = Environment.getExternalStorageDirectory();
            if (dir.canRead()) {
                path = dir.getAbsolutePath();
            }
        }
        openFileLauncher.launch(path);
    });
}
Also used : FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) File(java.io.File)

Example 18 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.FloatingActionButton in project FlexibleAdapter by davideas.

the class FragmentStaggeredLayout method addItem.

private int addItem(StaggeredItemStatus status, StaggeredHeaderItem headerItem) {
    StaggeredItem staggeredItem = DatabaseService.newStaggeredItem(DatabaseService.getInstance().getMaxStaggeredId(), headerItem);
    // !!!
    staggeredItem.setStatus(status);
    // The section object is known
    mAdapter.addItemToSection(staggeredItem, staggeredItem.getHeader(), new DatabaseService.ItemComparatorByGroup());
    // Add Item to the Database as well for next refresh
    DatabaseService.getInstance().addItem(staggeredItem, new DatabaseService.ItemComparatorById());
    // Change fab action (MOVE ITEM)
    if (mAdapter.getItemCountOfTypes(R.layout.recycler_staggered_item) >= 15) {
        FloatingActionButton fab = getActivity().findViewById(R.id.fab);
        fab.setImageResource(R.drawable.ic_sort_white_24dp);
    }
    // Retrieve the final position due to a possible hidden header became now visible!
    int scrollTo = mAdapter.getGlobalPositionOf(staggeredItem);
    Log.d(TAG, "Creating New Item " + staggeredItem + " at position " + scrollTo);
    return scrollTo;
}
Also used : FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) DatabaseService(eu.davidea.samples.flexibleadapter.services.DatabaseService) StaggeredItem(eu.davidea.samples.flexibleadapter.items.StaggeredItem)

Example 19 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.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(androidx.recyclerview.widget.SimpleItemAnimator) ArrayList(java.util.ArrayList) SelectorCard(xyz.zpayh.myadapter.data.SelectorCard) StaggeredGridLayoutManager(androidx.recyclerview.widget.StaggeredGridLayoutManager) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) NoSelectCard(xyz.zpayh.myadapter.data.NoSelectCard) OnItemCheckedChangeListener(xyz.zpayh.adapter.OnItemCheckedChangeListener) MyMultiSelectAdapter(xyz.zpayh.myadapter.adapter.MyMultiSelectAdapter) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) RecyclerView(androidx.recyclerview.widget.RecyclerView) Toolbar(androidx.appcompat.widget.Toolbar) IMultiSelectItem(xyz.zpayh.adapter.IMultiSelectItem)

Example 20 with FloatingActionButton

use of com.google.android.material.floatingactionbutton.FloatingActionButton in project EhViewer by seven332.

the class HostsActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    hosts = EhApplication.getHosts(this);
    data = hosts.getAll();
    setContentView(R.layout.activity_hosts);
    setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
    recyclerView = findViewById(R.id.recycler_view);
    tip = findViewById(R.id.tip);
    FloatingActionButton fab = findViewById(R.id.fab);
    adapter = new HostsAdapter();
    recyclerView.setAdapter(adapter);
    recyclerView.setLayoutManager(new LinearLayoutManager(this, RecyclerView.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(LinearDividerItemDecoration.VERTICAL, AttrResources.getAttrColor(this, R.attr.dividerColor), LayoutUtils.dp2pix(this, 1));
    decoration.setShowLastDivider(true);
    recyclerView.addItemDecoration(decoration);
    recyclerView.setSelector(Ripple.generateRippleDrawable(this, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
    recyclerView.setHasFixedSize(true);
    recyclerView.setOnItemClickListener(this);
    recyclerView.setPadding(recyclerView.getPaddingLeft(), recyclerView.getPaddingTop(), recyclerView.getPaddingRight(), recyclerView.getPaddingBottom() + getResources().getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab));
    fab.setOnClickListener(this);
    recyclerView.setVisibility(data.isEmpty() ? View.GONE : View.VISIBLE);
    tip.setVisibility(data.isEmpty() ? View.VISIBLE : View.GONE);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) LinearDividerItemDecoration(com.hippo.easyrecyclerview.LinearDividerItemDecoration)

Aggregations

FloatingActionButton (com.google.android.material.floatingactionbutton.FloatingActionButton)29 View (android.view.View)19 RecyclerView (androidx.recyclerview.widget.RecyclerView)8 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)7 TextView (android.widget.TextView)6 Toolbar (androidx.appcompat.widget.Toolbar)6 Bundle (android.os.Bundle)5 ImageView (android.widget.ImageView)5 Intent (android.content.Intent)4 AdapterView (android.widget.AdapterView)4 ListView (android.widget.ListView)4 ArrayList (java.util.ArrayList)4 MainActivity (app.insti.activity.MainActivity)3 CardInterface (app.insti.interfaces.CardInterface)3 DialogInterface (android.content.DialogInterface)2 SharedPreferences (android.content.SharedPreferences)2 Point (android.graphics.Point)2 Uri (android.net.Uri)2 TextPaint (android.text.TextPaint)2 GenericAdapter (app.insti.adapter.GenericAdapter)2