android.support.design.widget.FloatingActionButton Java Examples

The following examples show how to use android.support.design.widget.FloatingActionButton. 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 AndroidKeyValueStore with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
    testKVStore();
}
 
Example #2
Source File: MainActivity.java    From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
}
 
Example #3
Source File: CreateActivity.java    From materialup with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_create);

    ButterKnife.bind(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            fabClick(view);
        }
    });
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
 
Example #4
Source File: MainActivity.java    From TwoStageRate with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    initTwoStage();

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(MainActivity.this, EventActivity.class));
        }
    });
}
 
Example #5
Source File: MainActivity.java    From Material-Color-Picker with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    final Context ctx = this;
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View view) {
            ColorChooserDialog dialog = new ColorChooserDialog(ctx);
            dialog.setColorListener(new ColorListener() {
                @Override
                public void OnColorClick(View v, int color) {
                    Snackbar.make(view, "Color: "+color, Snackbar.LENGTH_LONG)
                            .setAction("Action", null).show();
                }
            });
            dialog.show();
        }
    });
}
 
Example #6
Source File: ScrollAwareFABBehavior.java    From MaoWanAndoidClient with Apache License 2.0 6 votes vote down vote up
@SuppressLint("RestrictedApi")
private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);

    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(1.0F).scaleY(1.0F).alpha(1.0F)
                .setInterpolator(INTERPOLATOR).withLayer().setListener(null)
                .start();

    }
    else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);

    }
}
 
Example #7
Source File: FanMenuButtons1Activity.java    From android-widget-fanmenu with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fan_menu_buttons1);
    final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.myFAB);
    final FanMenuButtons sub = (FanMenuButtons) findViewById(R.id.myFABSubmenu);
    if (sub != null) {
        sub.setOnFanButtonClickListener(new FanMenuButtons.OnFanClickListener() {
            @Override
            public void onFanButtonClicked(int index) {
                Toast.makeText(FanMenuButtons1Activity.this, "Button Clicked = " + index, Toast.LENGTH_SHORT).show();
                //sub.setButtonSelected(index);
            }
        });

        if (fab != null) {
            fab.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    sub.toggleShow();
                }
            });
        }
    }
}
 
Example #8
Source File: TasksFragment.java    From mobius-android-sample with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(
    LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

  FloatingActionButton fab = getActivity().findViewById(R.id.fab_add_task);
  mViews = new TasksViews(inflater, container, fab, mMenuEvents);

  mController =
      TasksInjector.createController(
          createEffectHandler(getContext(), mViews, this::showAddTask, this::showTaskDetailsUi),
          mEventSource,
          resolveDefaultModel(savedInstanceState));

  mController.connect(contramap(TasksListViewDataMapper::tasksListModelToViewData, mViews));
  setHasOptionsMenu(true);
  return mViews.getRootView();
}
 
Example #9
Source File: SongDetailActivity.java    From Musicoco with Apache License 2.0 6 votes vote down vote up
private void initViews() {

        container = findViewById(R.id.song_detail_container);

        mClose = (ImageButton) findViewById(R.id.song_detail_close);
        mSaveImage = (FloatingActionButton) findViewById(R.id.song_detail_save_image);

        mImage = (ImageView) findViewById(R.id.song_detail_image);
        mName = (TextView) findViewById(R.id.song_detail_name);
        mArts = (TextView) findViewById(R.id.song_detail_arts);
        mLine = findViewById(R.id.song_detail_ni_line);
        mInfos = (TextView) findViewById(R.id.song_detail_infos);

        mImage.setOnClickListener(this);
        mClose.setOnClickListener(this);
        mSaveImage.setOnClickListener(this);

    }
 
Example #10
Source File: MainActivity.java    From RxBus with Apache License 2.0 6 votes vote down vote up
/**
 * Init view and bus provider.
 *
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Mouse mouse = mouseMam.birth();
            mouse.squeak();
            Snackbar.make(view, "Birth a mouse and squeak ! " + mouse, Snackbar.LENGTH_SHORT)
                    .setAction("Action", null).show();
            Timber.e("Haha, i am " + mouse);
        }
    });

    RxBus.get().register(mouseMam);
    RxBus.get().register(catMam.birth());

    Timber.e("Moust Mam has registed? " + RxBus.get().hasRegistered(mouseMam));
}
 
Example #11
Source File: ScrollAwareFABBehavior.java    From MarkdownEditors with Apache License 2.0 6 votes vote down vote up
private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button)
                .scaleX(1.0F)
                .scaleY(1.0F)
                .alpha(1.0F)
                .setInterpolator(INTERPOLATOR)
                .withLayer()
                .setListener(null)
                .start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(),
                android.support.design.R.anim.design_fab_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}
 
Example #12
Source File: MainActivity.java    From Android-Developer-Fundamentals-Version-2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    Boolean switchPref = sharedPref.getBoolean(SettingsActivity.KEY_PREF_EXAMPLE_SWITCH, false);
    Toast.makeText(this, switchPref.toString(), Toast.LENGTH_SHORT).show();
}
 
Example #13
Source File: ComposeFabFragment.java    From actor-platform with GNU Affero General Public License v3.0 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View res = inflater.inflate(R.layout.fragment_fab, container, false);
    FloatingActionButton fabRoot = (FloatingActionButton) res.findViewById(R.id.fab);
    fabRoot.setImageResource(R.drawable.ic_edit_white_24dp);
    fabRoot.setBackgroundTintList(new ColorStateList(new int[][]{
            new int[]{android.R.attr.state_pressed},
            StateSet.WILD_CARD,

    }, new int[]{
            ActorSDK.sharedActor().style.getFabPressedColor(),
            ActorSDK.sharedActor().style.getFabColor(),
    }));
    fabRoot.setRippleColor(ActorSDK.sharedActor().style.getFabPressedColor());
    fabRoot.setOnClickListener(v -> startActivity(new Intent(getActivity(), ComposeActivity.class)));
    return res;
}
 
Example #14
Source File: MainActivity.java    From Android-Tutorials with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    final FloatingActionButton button = findViewById(R.id.fab);

    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startActivity(new Intent(MainActivity.this, NextActivity.class));
        }

    });

}
 
Example #15
Source File: ScrollAwareFABBehavior2.java    From MaoWanAndoidClient with Apache License 2.0 6 votes vote down vote up
@Override
public void onStopNestedScroll(@NonNull CoordinatorLayout coordinatorLayout, @NonNull final FloatingActionButton child, @NonNull View target, int type) {

    // If animation didn't start, we don't need to care about running the restore animation.
    // i.e.: when the user swipes to another tab in a viewpager. The onNestedPreScroll is never called.
    if (!fabAnimationStarted) {
        return;
    }

    // Animate back when the fling ended (TYPE_NON_TOUCH:非手指触碰手势输入类型,通常是手指离开屏幕后的惯性滑动事件)
    // or if the user made the touch up (TYPE_TOUCH:正常的屏幕触控驱动事件) but the fling didn't happen.
    if (type == ViewCompat.TYPE_NON_TOUCH || (type == ViewCompat.TYPE_TOUCH && !flingHappened)) {
        //ViewCompat.animate(child).translationY(0).start();
        fabAnimationStarted = false;
    }
}
 
Example #16
Source File: MainActivity.java    From AnimatedPullToRefresh-master with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    RecyclerView recyclerView = findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
    recyclerView.setAdapter(new ListAdapter(this));

    mPullToRefreshLayout = findViewById(R.id.pullToRefreshLayout);
    mPullToRefreshLayout.setColorAnimationArray(new int[]{Color.CYAN, Color.RED, Color.YELLOW, Color.MAGENTA});
    mPullToRefreshLayout.setOnRefreshListener(this);

    /*
    For FABRevealMenu checkout here:
    https://github.com/HarinTrivedi/FABRevealMenu-master
    */

    FloatingActionButton fab = findViewById(R.id.fab);
    fabMenu = findViewById(R.id.fabMenu);
    fabMenu.bindAncherView(fab);
    fabMenu.setCustomView(addCustomView());
}
 
Example #17
Source File: ActivtyA.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_activty);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
}
 
Example #18
Source File: MainActivity.java    From MeiZiNews with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_wd_ad);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.addDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
}
 
Example #19
Source File: CropAndRotate.java    From text-scanner with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.crop_and_rotate);
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ViewCompat.setElevation(toolbar,10);
    toolbar.setOnMenuItemClickListener(this);
    Intent intent = getIntent();
    message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
    cropImageView = (CropImageView) findViewById(R.id.cropImageView);

    cropImageView.setImageUriAsync(Uri.parse(message));
    mFab = (FloatingActionButton) findViewById(R.id.nextStep);
    mFab.setOnClickListener(this);

}
 
Example #20
Source File: MainActivity.java    From RxFile with Apache License 2.0 6 votes vote down vote up
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  Toolbar toolbar = findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);

  mBitmap = findViewById(R.id.iv_bitmap);

  RxFile.setLoggingEnabled(true);

  FloatingActionButton fab = findViewById(R.id.fab);
  fab.setOnClickListener(new View.OnClickListener() {
    @Override public void onClick(View view) {
      pickFile();
    }
  });
}
 
Example #21
Source File: SsoAllActivity.java    From ESSocialSDK with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sso_all);
    ButterKnife.bind(this);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    /**************************************************/
    BusProvider.getInstance().register(this);
    /**************************************************/
}
 
Example #22
Source File: MainActivity.java    From FeedFire with MIT License 5 votes vote down vote up
/**
 * Bind views XML with JavaAPI
 */
private void initViews(){
    mProgressBar = (ProgressBar)findViewById(R.id.pb);
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(this);
    recyclerView = (RecyclerView)findViewById(R.id.rv_list_feed);
    recyclerView.setHasFixedSize(true);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
 
Example #23
Source File: BottomNavBarFabBehaviour.java    From JD-Test with Apache License 2.0 5 votes vote down vote up
private void updateFabTranslationForBottomNavigationBar(CoordinatorLayout parent, FloatingActionButton fab, View dependency) {

        float snackBarTranslation = getFabTranslationYForSnackBar(parent, fab);
        float[] bottomBarParameters = getFabTranslationYForBottomNavigationBar(parent, fab);
        float bottomBarTranslation = bottomBarParameters[0];
        float bottomBarHeight = bottomBarParameters[1];

        float targetTransY = 0;
        if (snackBarTranslation >= bottomBarTranslation) {
            // when snackBar is below BottomBar in translation present.
            targetTransY = bottomBarTranslation;
        } else {
            targetTransY = snackBarTranslation;
        }

//        if (mFabBehaviour == BottomNavigationBar.FAB_BEHAVIOUR_DISAPPEAR) {
//            if (targetTransY == 0) {
//                fab.hide();
//            } else {
//                fab.show();
//            }
//        }

        final float currentTransY = ViewCompat.getTranslationY(fab);

        // Make sure that any current animation is cancelled
        ensureOrCancelAnimator(fab);


        if (fab.isShown()
                && Math.abs(currentTransY - targetTransY) > (fab.getHeight() * 0.667f)) {
            // If the FAB will be travelling by more than 2/3 of it's height, let's animate it instead
            mFabTranslationYAnimator.translationY(targetTransY).start();
        } else {
            // Now update the translation Y
            ViewCompat.setTranslationY(fab, targetTransY);
        }
    }
 
Example #24
Source File: StepByStepTestActivity.java    From CVScanner with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_step_by_step);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    if(getIntent().getExtras() != null) scanType = (CVCommand) getIntent().getExtras().getSerializable(EXTRA_SCAN_TYPE);

    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("image/*");
            startActivityForResult(intent, REQ_PICK_IMAGE);
        }
    });

    contentView = (RecyclerView) findViewById(R.id.image_list);

    contentView.setLayoutManager(new LinearLayoutManager(this));
    //contentView.setHasFixedSize(true);

    mAdapter = new ImageAdapter();
    contentView.setAdapter(mAdapter);

    int result = ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
    if(result != PackageManager.PERMISSION_GRANTED){
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, REQ_STORAGE_PERM);
    }
}
 
Example #25
Source File: FontPopup.java    From eBook with Apache License 2.0 5 votes vote down vote up
private void initViews() {
    mTextColors = new int[]{
            0xff121111,  //黑
            0x8A000000,  //常规
            0xffa9a8a8,  //夜间
            0xfbe6e3e3,  //白
            0xff486c94,  //蓝
    };


    mTexts = new TextView[]{
            (TextView) mConvertView.findViewById(R.id.text_system),
            (TextView) mConvertView.findViewById(R.id.text_hksn),
            (TextView) mConvertView.findViewById(R.id.text_hwzs),
            (TextView) mConvertView.findViewById(R.id.text_kai),
            (TextView) mConvertView.findViewById(R.id.text_yy)
    };

    mButtons = new Button[]{
            (Button) mConvertView.findViewById(R.id.btn_system),
            (Button) mConvertView.findViewById(R.id.btn_hksn),
            (Button) mConvertView.findViewById(R.id.btn_hwzs),
            (Button) mConvertView.findViewById(R.id.btn_kai),
            (Button) mConvertView.findViewById(R.id.btn_yy)
    };

    mFabs = new FloatingActionButton[]{
            (FloatingActionButton) mConvertView.findViewById(R.id.fab_black),
            (FloatingActionButton) mConvertView.findViewById(R.id.fab_normal),
            (FloatingActionButton) mConvertView.findViewById(R.id.fab_night),
            (FloatingActionButton) mConvertView.findViewById(R.id.fab_white),
            (FloatingActionButton) mConvertView.findViewById(R.id.fab_blue)
    };


}
 
Example #26
Source File: HomeActivity.java    From XposedNavigationBar with GNU General Public License v3.0 5 votes vote down vote up
@Override
void initView() {
    // checkActivated();
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    fabAddFunc = (FloatingActionButton) findViewById(R.id.fab);
    tabLayout = (TabLayout) findViewById(R.id.tabs);
    mViewPager = (ViewPager) findViewById(R.id.container);
}
 
Example #27
Source File: DeleteProductsCache.java    From privacy-friendly-shopping-list with Apache License 2.0 5 votes vote down vote up
public DeleteProductsCache(DeleteProductsActivity activity, String listId, String listName)
{
    this.activity = activity;
    this.listId = listId;
    this.listName = listName;

    deleteProductsAdapter = new DeleteProductsAdapter(new ArrayList<>(), this);

    RecyclerView recyclerView = (RecyclerView) activity.findViewById(R.id.recyclerView);
    recyclerView.setLayoutManager(new LinearLayoutManager(activity));
    recyclerView.setAdapter(deleteProductsAdapter);

    deleteFab = (FloatingActionButton) activity.findViewById(R.id.fab_delete_products);
}
 
Example #28
Source File: FabProgressLayout.java    From Android-Multi-Theme-UI with Apache License 2.0 5 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);

    if (getChildCount() == 0 || getChildCount() > 2) {
        throw new IllegalStateException("Specify only 2 views.");
    }

    for (int i = 0; i < getChildCount(); i++) {
        View view = getChildAt(i);
        if (view instanceof ProgressBar) {
            mProgressBar = (ProgressBar) view;
        } else if (view instanceof FloatingActionButton) {
            mFab = (FloatingActionButton) view;
        } else {
            throw new IllegalStateException("Specify FAB and Progress Bar" +
                    "as view's children in your layout.");
        }
    }

    if (mFab == null) {
        throw new IllegalStateException("Floating Action Button not specified");
    } else if (mProgressBar == null) {
        throw new IllegalStateException("Progress Bar not specified");
    }

    resize();
}
 
Example #29
Source File: ScrollAwareFABBehavior.java    From AndroidBleManager with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child,
                                   final View directTargetChild, final View target, final int nestedScrollAxes) {
    // Ensure we react to vertical scrolling
    return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL
            || super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
}
 
Example #30
Source File: MainActivity.java    From journaldev with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    FloatingActionButton fab = findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivityForResult(getPickImageChooserIntent(), IMAGE_RESULT);
        }
    });


    permissions.add(CAMERA);
    permissions.add(WRITE_EXTERNAL_STORAGE);
    permissions.add(READ_EXTERNAL_STORAGE);
    permissionsToRequest = findUnAskedPermissions(permissions);



    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {


        if (permissionsToRequest.size() > 0)
            requestPermissions(permissionsToRequest.toArray(new String[permissionsToRequest.size()]), ALL_PERMISSIONS_RESULT);
    }

}