question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When a second FAB is added, the first one stops working properly

See original GitHub issue

I’m about to finish the first release of a geo-location API and make it public here on github. So, for example purposes, I’m implementing an app that use it too. I have a map fragment where user can save points of interests and see them on the map or on a list. Problem is, I need two different FABs on map screen: one for some functionalities and another to change map type. After I added the second fab, first one does not show the icon anymore neither open the options. Below follows an screenshot of the problem:

image

I have these menu.xml options for each one:

fab_map_add_options.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/ic_save_current_location"
        android:icon="@mipmap/ic_add_poi"
        android:title="@string/nav_add_poi"/>
    <item
        android:id="@+id/ic_goto_my_position"
        android:icon="@mipmap/ic_goto_my_location"
        android:title="@string/fab_goto_my_position" />
</menu>

fab_map_types_options.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/ic_change_map_to_satellite"
        android:icon="@mipmap/ic_add_poi"
        android:title="@string/map_satellite_type"/>
    <item
        android:id="@+id/ic_change_map_to_terrain"
        android:icon="@mipmap/ic_goto_my_location"
        android:title="@string/map_terrain_type" />
    <item
        android:id="@+id/ic_change_map_to_normal"
        android:icon="@mipmap/ic_goto_my_location"
        android:title="@string/map_normal_type" />
</menu>

map_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/map_fragment"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:tools="http://schemas.android.com/tools"
              android:id="@+id/map"
              android:name="com.google.android.gms.maps.SupportMapFragment"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              tools:context="locationmanager.jgeraldo.com.androidlocationmanager.ui.fragments.MapsFragment"/>


    <io.github.yavski.fabspeeddial.FabSpeedDial
        android:id="@+id/fab_map_type_options"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_gravity="bottom|start"
        app:fabDrawable="@mipmap/ic_change_map_type"
        app:fabDrawableTint="@color/icons_n_texts"
        app:fabGravity="bottom_start"
        app:fabMenu="@menu/fab_map_types_options"
        app:miniFabBackgroundTint="@color/colorPrimary"
        app:miniFabDrawableTint="@color/icons_n_texts"
        app:miniFabTitleBackgroundTint="@color/colorPrimary"
        app:miniFabTitleTextColor="@color/icons_n_texts"/>


    <io.github.yavski.fabspeeddial.FabSpeedDial
        android:id="@+id/fab_map_add_options"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_gravity="bottom|end"
        app:fabDrawable="@mipmap/ic_add"
        app:fabDrawableTint="@color/icons_n_texts"
        app:fabGravity="bottom_end"
        app:fabMenu="@menu/fab_map_add_options"
        app:miniFabBackgroundTint="@color/colorPrimary"
        app:miniFabDrawableTint="@color/icons_n_texts"
        app:miniFabTitleBackgroundTint="@color/colorPrimary"
        app:miniFabTitleTextColor="@color/icons_n_texts"/>
</RelativeLayout>

And on MapFragment:

        mFabAdd = (FabSpeedDial) view.findViewById(R.id.fab_map_add_options);
        mFabAdd.setMenuListener(new SimpleMenuListenerAdapter() {
            @Override
            public boolean onMenuItemSelected(MenuItem menuItem) {
                int itemId = menuItem.getItemId();

                if (itemId == R.id.ic_save_current_location) {
                    openNewLocationNameChoosingDialog();
                    return true;
                } else if (itemId == R.id.ic_goto_my_position) {
                    if (!Preferences.getLocationPermissionsGrantFlag(mContext)) {
                        Util.checkLocationPermissions(mActivity);
                    } else {
                        new GetCurrentCoordinates().execute();
                    }
                    return true;
                }
                return false;
            }
        });

        mFabTypes = (FabSpeedDial) view.findViewById(R.id.fab_map_type_options);
        mFabTypes.setMenuListener(new SimpleMenuListenerAdapter() {
            @Override
            public boolean onMenuItemSelected(MenuItem menuItem) {
                int itemId = menuItem.getItemId();

                int map_type
                    ;

                if (itemId == R.id.ic_change_map_to_normal) {
                    map_type = GoogleMap.MAP_TYPE_NORMAL;
                } else if (itemId == R.id.ic_change_map_to_terrain) {
                    map_type = GoogleMap.MAP_TYPE_TERRAIN;
                } else {
                    map_type = GoogleMap.MAP_TYPE_SATELLITE;
                }

                mMap.setMapType(map_type);
                return true;
            }
        });

Any ideia of what can be happening?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
JGeraldoLimacommented, Dec 22, 2016

Hell yeah! I just needed to add

app:touchGuard=“false”

tag and voilà! Thank you again 😃 @yavski can close this issue now 😃

2reactions
ZOlbryscommented, Dec 22, 2016

Not my code - all credit to @yavski, I am just an interested third party/user of the code 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

What to Do When Your Key Fob's Not Working - AutoZone
What should you do when your key fob stops working? Here are some common solutions to a key fob malfuction.
Read more >
Fragment Antigen-Binding - an overview | ScienceDirect Topics
The entire Fab region of an antibody is not essential for binding of the antigen. ... Fabs consist of two polypeptide chains expressed...
Read more >
Overview of Waivers in Fantasy Football | Yahoo Help
Waivers put temporary freezes on unclaimed players, giving everyone a chance to make a claim on them. Learn what waiver modes, claim priorities, ......
Read more >
Digoxin Immune Fab - StatPearls - NCBI Bookshelf - NIH
Digoxin immune fab is a medication used in the management and treatment of digoxin toxicity. Most toxicity cases are seen in patients with...
Read more >
A Tutorial Introduction to the Lambda Calculus
The first function takes two arguments and returns the first one, the second function returns the second of two arguments. 3.1 Logical operations....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found