Skip to content
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.

Commit

Permalink
Position fabs properly
Browse files Browse the repository at this point in the history
  • Loading branch information
jahirfiquitiva committed Aug 1, 2017
1 parent 6c2b9c0 commit 495ba96
Show file tree
Hide file tree
Showing 2 changed files with 249 additions and 235 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,79 +16,79 @@

package jahirfiquitiva.apps.fabsmenu.demo;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDelegate;
import android.view.View;
import android.widget.Toast;

import jahirfiquitiva.libs.fabsmenu.FABsMenu;
import jahirfiquitiva.libs.fabsmenu.TitleFAB;

public class MainActivity extends Activity {

public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);

setContentView(R.layout.activity_main);

final FABsMenu menu = findViewById(R.id.fabs_menu);
menu.setMenuUpdateListener(new FABsMenu.OnFABsMenuUpdateListener() {
@Override
public void onMenuClicked() {
showToast("You pressed the menu!");
menu.toggle();
}

@Override
public void onMenuExpanded() {
showToast("The menu has been expanded!");
}

@Override
public void onMenuCollapsed() {
showToast("The menu has been collapsed!");
}
});

TitleFAB clickableTitle = findViewById(R.id.clickable_title);
clickableTitle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showToast("You pressed the red fab or its title");
}
});

TitleFAB mini = findViewById(R.id.mini_fab);
mini.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showToast("You pressed the mini fab!");
}
});

TitleFAB green = findViewById(R.id.green_fab);
green.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showToast("You pressed the green fab");
}
});

// Removes a button
TitleFAB toRemove = findViewById(R.id.to_remove);
menu.removeButton(toRemove);

// Adds a button to the bottom
TitleFAB toAdd = new TitleFAB(this);
toAdd.setTitle("A new added fab");
toAdd.setBackgroundColor(Color.parseColor("#ff5722"));
menu.addButton(toAdd);
}

private void showToast(String text) {
Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
}
Expand Down
Loading

0 comments on commit 495ba96

Please sign in to comment.