Java Code Examples for com.github.clans.fab.FloatingActionButton#setOnClickListener()

The following examples show how to use com.github.clans.fab.FloatingActionButton#setOnClickListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From AndroidApp with Mozilla Public License 2.0 6 votes vote down vote up
/**********************************Setup UI elements and their functionality***********************************/
private void viewSetup() {
    fabPoiDetailsAfterRoute = findViewById(R.id.fabPoiDetailsAfterRoute);
    floatingActionButton = findViewById(R.id.mainFab);
    floatingActionButton.setClosedOnTouchOutside(true);

    navigation = findViewById(R.id.navigation);
    //setup bottom navigation
    navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener);
    navigation.setSelectedItemId(R.id.navigation_categories);
    navigation.enableAnimation(false);
    navigation.enableShiftingMode(false);
    navigation.enableItemShiftingMode(false);

    FloatingActionButton fabClearMap = findViewById(R.id.fabClearMap);
    FloatingActionButton fabLocation = findViewById(R.id.fabLocation);
    FloatingActionButton fabAdd = findViewById(R.id.fabAdd);
    FloatingActionButton fabSearch = findViewById(R.id.fabSearch);
    fabClearMap.setOnClickListener(clickListenerFAB);
    fabLocation.setOnClickListener(clickListenerFAB);
    fabAdd.setOnClickListener(clickListenerFAB);
    fabSearch.setOnClickListener(clickListenerFAB);
    fabPoiDetailsAfterRoute.setOnClickListener(clickListenerFAB);
}
 
Example 2
Source File: DeviceActivity.java    From AndroidSDK with MIT License 6 votes vote down vote up
private void initViews() {
    mDeviceItem = (DeviceItem) getIntent().getSerializableExtra(EXTRA_DEVICE_ITEM);

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setTitle(mDeviceItem.getTitle());
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeAsUpIndicator(android.support.v7.appcompat.R.drawable.abc_ic_ab_back_material);

    mRecyclerView = (RecyclerView) findViewById(R.id.recyler_view);
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh_layout);
    mFabAddDataStream = (FloatingActionButton) findViewById(R.id.fab_add_ds);

    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mAdapter = new DSListAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mSwipeRefreshLayout.setColorSchemeColors(0xFFDA4336);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    getDataStreams();
    mSwipeRefreshLayout.setRefreshing(true);

    mFabAddDataStream.setOnClickListener(this);
}
 
Example 3
Source File: ProfileManagerActivity.java    From ShadowsocksRR with Apache License 2.0 5 votes vote down vote up
@SuppressLint("RestrictedApi")
public void initFab() {
    menu = (FloatingActionMenu) findViewById(R.id.menu);
    menu.setClosedOnTouchOutside(true);
    AppCompatDrawableManager dm = AppCompatDrawableManager.get();
    FloatingActionButton manualAddFAB = (FloatingActionButton) findViewById(R.id.fab_manual_add);
    manualAddFAB.setImageDrawable(dm.getDrawable(this, R.drawable.ic_content_create));
    manualAddFAB.setOnClickListener(this);
    final FloatingActionButton qrcodeAddFAB = (FloatingActionButton) findViewById(R.id.fab_qrcode_add);
    qrcodeAddFAB.setImageDrawable(dm.getDrawable(this, R.drawable.ic_image_camera_alt));
    qrcodeAddFAB.setOnClickListener(this);
    FloatingActionButton nfcAddFAB = (FloatingActionButton) findViewById(R.id.fab_nfc_add);
    nfcAddFAB.setImageDrawable(dm.getDrawable(this, R.drawable.ic_device_nfc));
    nfcAddFAB.setOnClickListener(this);
    FloatingActionButton importAddFAB = (FloatingActionButton) findViewById(R.id.fab_import_add);
    importAddFAB.setImageDrawable(dm.getDrawable(this, R.drawable.ic_content_paste));
    importAddFAB.setOnClickListener(this);
    FloatingActionButton ssrsubAddFAB = (FloatingActionButton) findViewById(R.id.fab_ssr_sub);
    ssrsubAddFAB.setImageDrawable(dm.getDrawable(this, R.drawable.ic_rss));
    ssrsubAddFAB.setOnClickListener(this);
    menu.setOnMenuToggleListener(new FloatingActionMenu.OnMenuToggleListener() {
        @Override
        public void onMenuToggle(boolean opened) {
            if (opened) {
                int visible = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA) ? View.VISIBLE : View.GONE;
                qrcodeAddFAB.setVisibility(visible);
            }
        }
    });
}
 
Example 4
Source File: ProfileManagerActivity.java    From Maying with Apache License 2.0 5 votes vote down vote up
@SuppressLint("RestrictedApi")
public void initFab() {
    menu = findViewById(R.id.menu);
    menu.setClosedOnTouchOutside(true);
    AppCompatDrawableManager dm = AppCompatDrawableManager.get();
    FloatingActionButton manualAddFAB = findViewById(R.id.fab_manual_add);
    manualAddFAB.setImageDrawable(dm.getDrawable(this, R.drawable.ic_content_create));
    manualAddFAB.setOnClickListener(this);
    final FloatingActionButton qrcodeAddFAB = findViewById(R.id.fab_qrcode_add);
    qrcodeAddFAB.setImageDrawable(dm.getDrawable(this, R.drawable.ic_image_camera_alt));
    qrcodeAddFAB.setOnClickListener(this);
    FloatingActionButton nfcAddFAB = findViewById(R.id.fab_nfc_add);
    nfcAddFAB.setImageDrawable(dm.getDrawable(this, R.drawable.ic_device_nfc));
    nfcAddFAB.setOnClickListener(this);
    FloatingActionButton importAddFAB = findViewById(R.id.fab_import_add);
    importAddFAB.setImageDrawable(dm.getDrawable(this, R.drawable.ic_content_paste));
    importAddFAB.setOnClickListener(this);
    FloatingActionButton ssrsubAddFAB = findViewById(R.id.fab_ssr_sub);
    ssrsubAddFAB.setImageDrawable(dm.getDrawable(this, R.drawable.ic_rss));
    ssrsubAddFAB.setOnClickListener(this);
    menu.setOnMenuToggleListener(opened -> {
        if (opened) {
            int visible = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA) ? View.VISIBLE : View.GONE;
            qrcodeAddFAB.setVisibility(visible);
        }
    });
}
 
Example 5
Source File: MainActivity.java    From QuickNote with Apache License 2.0 5 votes vote down vote up
private void initFabMenu() {
    mFabMenu = findViewById(R.id.floating_action_menu);
    FloatingActionButton fabBtnCamera = findViewById(R.id.fab_menu_item_camera);
    FloatingActionButton fabBtnAttachment = findViewById(R.id.fab_menu_item_attachment);
    FloatingActionButton fabBtnRecord = findViewById(R.id.fab_menu_item_record);
    FloatingActionButton fabBtnFreehand = findViewById(R.id.fab_menu_item_freehand);
    FloatingActionButton fabBtnText = findViewById(R.id.fab_menu_item_text);
    fabBtnCamera.setOnClickListener(this);
    fabBtnAttachment.setOnClickListener(this);
    fabBtnRecord.setOnClickListener(this);
    fabBtnFreehand.setOnClickListener(this);
    fabBtnText.setOnClickListener(this);
}
 
Example 6
Source File: DeviceListFragment.java    From AndroidSDK with MIT License 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View contentView = inflater.inflate(R.layout.fragment_device_list, container, false);
    mRecyclerView = (RecyclerView) contentView.findViewById(R.id.recyler_view);
    mSwipeRefreshLayout = (SwipeRefreshLayout) contentView.findViewById(R.id.swipe_refresh_layout);
    mFabAddDevice = (FloatingActionButton) contentView.findViewById(R.id.fab_add_device);

    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    mAdapter = new DeviceListAdapter();
    mAdapter.setOnLoadMoreListener(mLoadMoreListener, mRecyclerView);
    mRecyclerView.addOnItemTouchListener(new OnItemClickListener() {
        @Override
        public void onSimpleItemClick(BaseQuickAdapter adapter, View view, int position) {
            DeviceActivity.actionDevice(getContext(), mDeviceItems.get(position));
        }
    });
    mRecyclerView.setAdapter(mAdapter);
    mSwipeRefreshLayout.setColorSchemeColors(0xFFDA4336);
    mSwipeRefreshLayout.setOnRefreshListener(this);
    getDevices(false);
    mSwipeRefreshLayout.setRefreshing(true);

    mFabAddDevice.setOnClickListener(this);
    LocalBroadcastManager.getInstance(getContext()).registerReceiver(mUpdateApiKeyReceiver, new IntentFilter(IntentActions.ACTION_UPDATE_APIKEY));
    LocalBroadcastManager.getInstance(getContext()).registerReceiver(mUpdateDeviceListReceiver, new IntentFilter(IntentActions.ACTION_UPDATE_DEVICE_LIST));
    return contentView;
}
 
Example 7
Source File: NewsActivity.java    From SimpleNews with Apache License 2.0 5 votes vote down vote up
private void initNewsTypeIcon() {
    newsTypeButton = (FloatingActionMenu) findViewById(R.id.floating_action_menu);
    subactionButton1 = (FloatingActionButton) findViewById(R.id.menu_item_1);
    subactionButton2 = (FloatingActionButton) findViewById(R.id.menu_item_2);

    subactionButton1.setOnClickListener(new OnSubActionButtonClickListener());
    subactionButton2.setOnClickListener(new OnSubActionButtonClickListener());

    actionButtonIds = new int[]{R.drawable.ic_home, R.drawable.ic_fav, R.drawable.ic_seen};
    updateNewsIcon();
}
 
Example 8
Source File: MenusFragment.java    From FloatingActionButton with Apache License 2.0 4 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    menuRed = (FloatingActionMenu) view.findViewById(R.id.menu_red);
    menuYellow = (FloatingActionMenu) view.findViewById(R.id.menu_yellow);
    menuGreen = (FloatingActionMenu) view.findViewById(R.id.menu_green);
    menuBlue = (FloatingActionMenu) view.findViewById(R.id.menu_blue);
    menuDown = (FloatingActionMenu) view.findViewById(R.id.menu_down);
    menuLabelsRight = (FloatingActionMenu) view.findViewById(R.id.menu_labels_right);

    fab1 = (FloatingActionButton) view.findViewById(R.id.fab1);
    fab2 = (FloatingActionButton) view.findViewById(R.id.fab2);
    fab3 = (FloatingActionButton) view.findViewById(R.id.fab3);

    final FloatingActionButton programFab1 = new FloatingActionButton(getActivity());
    programFab1.setButtonSize(FloatingActionButton.SIZE_MINI);
    programFab1.setLabelText(getString(R.string.lorem_ipsum));
    programFab1.setImageResource(R.drawable.ic_edit);
    menuRed.addMenuButton(programFab1);
    programFab1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            programFab1.setLabelColors(ContextCompat.getColor(getActivity(), R.color.grey),
                    ContextCompat.getColor(getActivity(), R.color.light_grey),
                    ContextCompat.getColor(getActivity(), R.color.white_transparent));
            programFab1.setLabelTextColor(ContextCompat.getColor(getActivity(), R.color.black));
        }
    });

    ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), R.style.MenuButtonsStyle);
    FloatingActionButton programFab2 = new FloatingActionButton(context);
    programFab2.setLabelText("Programmatically added button");
    programFab2.setImageResource(R.drawable.ic_edit);
    menuYellow.addMenuButton(programFab2);

    fab1.setEnabled(false);
    menuRed.setClosedOnTouchOutside(true);
    menuBlue.setIconAnimated(false);

    menuDown.hideMenuButton(false);
    menuRed.hideMenuButton(false);
    menuYellow.hideMenuButton(false);
    menuGreen.hideMenuButton(false);
    menuBlue.hideMenuButton(false);
    menuLabelsRight.hideMenuButton(false);

    fabEdit = (FloatingActionButton) view.findViewById(R.id.fab_edit);
    fabEdit.setShowAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.scale_up));
    fabEdit.setHideAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.scale_down));
}