Java Code Examples for android.support.design.widget.FloatingActionButton#setOnLongClickListener()

The following examples show how to use android.support.design.widget.FloatingActionButton#setOnLongClickListener() . 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: GraphActivity.java    From GraphView with Apache License 2.0 6 votes vote down vote up
private void setupFab(final Graph graph) {
    FloatingActionButton addButton = findViewById(R.id.addNode);
    addButton.setOnClickListener(v -> {
        final Node newNode = new Node(getNodeText());
        if (currentNode != null) {
            graph.addEdge(currentNode, newNode);
        } else {
            graph.addNode(newNode);
            adapter.notifyInvalidated();
        }
    });

    addButton.setOnLongClickListener(v -> {
        if (currentNode != null) {
            graph.removeNode(currentNode);
            currentNode = null;
        }
        return true;
    });
}
 
Example 2
Source File: MainActivity.java    From IdeaTrackerPlus with MIT License 6 votes vote down vote up
private void setUpUI() {

        //Default colors
        defaultPrimaryColor = ContextCompat.getColor(this, R.color.md_blue_grey_800);
        defaultSecondaryColor = ContextCompat.getColor(this, R.color.md_teal_a400);
        defaultTextColor = ContextCompat.getColor(this, R.color.md_white);

        // Toolbar
        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(mToolbar);
        mToolbar.setOnClickListener(this);

        // Wire the floating button
        mFab = (FloatingActionButton) findViewById(R.id.fab);
        mFab.setOnClickListener(this);
        mFab.setOnLongClickListener(this);
    }
 
Example 3
Source File: WhatsNewViewBinder.java    From fdroidclient with GNU General Public License v3.0 4 votes vote down vote up
WhatsNewViewBinder(final AppCompatActivity activity, FrameLayout parent) {
    this.activity = activity;

    View whatsNewView = activity.getLayoutInflater().inflate(R.layout.main_tab_whats_new, parent, true);

    whatsNewAdapter = new WhatsNewAdapter(activity);

    GridLayoutManager layoutManager = new GridLayoutManager(activity, 2);
    layoutManager.setSpanSizeLookup(new WhatsNewAdapter.SpanSizeLookup());

    emptyState = (TextView) whatsNewView.findViewById(R.id.empty_state);

    appList = (RecyclerView) whatsNewView.findViewById(R.id.app_list);
    appList.setHasFixedSize(true);
    appList.setLayoutManager(layoutManager);
    appList.setAdapter(whatsNewAdapter);

    final SwipeRefreshLayout swipeToRefresh = (SwipeRefreshLayout) whatsNewView
            .findViewById(R.id.swipe_to_refresh);
    Utils.applySwipeLayoutColors(swipeToRefresh);
    swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            swipeToRefresh.setRefreshing(false);
            UpdateService.updateNow(activity);
        }
    });

    FloatingActionButton searchFab = (FloatingActionButton) whatsNewView.findViewById(R.id.fab_search);
    searchFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            activity.startActivity(new Intent(activity, AppListActivity.class));
        }
    });
    searchFab.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            if (Preferences.get().hideOnLongPressSearch()) {
                HidingManager.showHideDialog(activity);
                return true;
            } else {
                return false;
            }
        }
    });

    activity.getSupportLoaderManager().initLoader(LOADER_ID, null, this);
}
 
Example 4
Source File: CategoriesViewBinder.java    From fdroidclient with GNU General Public License v3.0 4 votes vote down vote up
CategoriesViewBinder(final AppCompatActivity activity, FrameLayout parent) {
    this.activity = activity;

    View categoriesView = activity.getLayoutInflater().inflate(R.layout.main_tab_categories, parent, true);

    categoryAdapter = new CategoryAdapter(activity, activity.getSupportLoaderManager());

    emptyState = (TextView) categoriesView.findViewById(R.id.empty_state);

    categoriesList = (RecyclerView) categoriesView.findViewById(R.id.category_list);
    categoriesList.setHasFixedSize(true);
    categoriesList.setLayoutManager(new LinearLayoutManager(activity));
    categoriesList.setAdapter(categoryAdapter);

    final SwipeRefreshLayout swipeToRefresh =
            (SwipeRefreshLayout) categoriesView.findViewById(R.id.swipe_to_refresh);
    Utils.applySwipeLayoutColors(swipeToRefresh);
    swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            swipeToRefresh.setRefreshing(false);
            UpdateService.updateNow(activity);
        }
    });

    FloatingActionButton searchFab = (FloatingActionButton) categoriesView.findViewById(R.id.fab_search);
    searchFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            activity.startActivity(new Intent(activity, AppListActivity.class));
        }
    });
    searchFab.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View view) {
            if (Preferences.get().hideOnLongPressSearch()) {
                HidingManager.showHideDialog(activity);
                return true;
            } else {
                return false;
            }
        }
    });

    activity.getSupportLoaderManager().restartLoader(LOADER_ID, null, this);
}