0% found this document useful (0 votes)
63 views

Com - Github.Clans - Fab.Floatingactionmenu: Todo Something When Floating Action Menu First Item Clicked

The document defines a FloatingActionMenu layout with two FloatingActionButton children for social media icons. It finds the menu and button views by ID and sets click listeners to open Facebook and Twitter intents, either launching their apps or opening URLs if they are not installed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Com - Github.Clans - Fab.Floatingactionmenu: Todo Something When Floating Action Menu First Item Clicked

The document defines a FloatingActionMenu layout with two FloatingActionButton children for social media icons. It finds the menu and button views by ID and sets click listeners to open Facebook and Twitter intents, either launching their apps or opening URLs if they are not installed.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

<com.github.clans.fab.

FloatingActionMenu
android:id="@+id/social_floating_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="11dp"
android:layout_marginLeft="11dp"
android:layout_marginRight="11dp"
fab:menu_animationDelayPerItem="55"
fab:menu_backgroundColor="@android:color/transparent"
fab:menu_buttonSpacing="0dp"
fab:menu_colorNormal="#da3c2f"
fab:menu_colorPressed="#dc4b3f"
fab:menu_colorRipple="#99d4d4d4"
fab:menu_fab_label="Floating Social Icons"
fab:menu_fab_size="normal"
fab:menu_icon="@drawable/fab_add"
fab:menu_labels_colorNormal="#333"
fab:menu_labels_colorPressed="#444"
fab:menu_labels_colorRipple="#66efecec"
fab:menu_labels_cornerRadius="3dp"
fab:menu_labels_ellipsize="none"
fab:menu_labels_hideAnimation="@anim/fab_slide_out_to_right"
fab:menu_labels_margin="0dp"
fab:menu_labels_maxLines="-1"
fab:menu_labels_padding="8dp"
fab:menu_labels_position="left"
fab:menu_labels_showAnimation="@anim/fab_slide_in_from_right"
fab:menu_labels_showShadow="true"
fab:menu_labels_singleLine="false"
fab:menu_labels_textColor="#f2f1f1"
fab:menu_labels_textSize="15sp"
fab:menu_openDirection="up"
fab:menu_shadowColor="#66aff198"
fab:menu_shadowRadius="4dp"
fab:menu_shadowXOffset="1dp"
fab:menu_shadowYOffset="4dp"
fab:menu_showShadow="true">

<com.github.clans.fab.FloatingActionButton
android:id="@+id/floating_help"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/help"
fab:fab_size="mini" />

<com.github.clans.fab.FloatingActionButton
android:id="@+id/floating_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/info"
fab:fab_size="mini" />

</com.github.clans.fab.FloatingActionMenu>

materialDesignFAM = (FloatingActionMenu) findViewById(R.id.social_floating_menu);


floatingActionButton1 = (FloatingActionButton) findViewById(R.id.floating_help);
floatingActionButton2 = (FloatingActionButton) findViewById(R.id.floating_info);

floatingActionButton1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//TODO something when floating action menu first item clicked
Intent facebookIntent = getOpenFacebookIntent(MainActivity.this);
startActivity(facebookIntent);

}
});
floatingActionButton2.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//TODO something when floating action menu second item clicked
Intent twitterIntent = getOpenTwitterIntent(MainActivity.this);
startActivity(twitterIntent);

}
});

public static Intent getOpenFacebookIntent(Context context) {

try {
context.getPackageManager()
.getPackageInfo("com.facebook.katana", 0); //Checks if FB is even
installed.
return new Intent(Intent.ACTION_VIEW,
Uri.parse("fb://page/376227335860239")); //Trys to make intent with
FB's URI
} catch (Exception e) {
return new Intent(Intent.ACTION_VIEW,
Uri.parse("https://www.facebook.com/karthikofficialpage"));
//catches and opens a url to the desired page
}
}

public static Intent getOpenTwitterIntent(Context context) {

try {
context.getPackageManager()
.getPackageInfo("com.twitter.android", 0); //Checks if Twitter is
even installed.
return new Intent(Intent.ACTION_VIEW,
Uri.parse("https://twitter.com/drkarthiik")); //Trys to make intent
with Twitter's's URI
} catch (Exception e) {
return new Intent(Intent.ACTION_VIEW,
Uri.parse("https://twitter.com/drkarthiik")); //catches and opens a
url to the desired page
}
}

FloatingActionMenu materialDesignFAM;
FloatingActionButton floatingActionButton1, floatingActionButton2;

You might also like