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

The following examples show how to use android.support.design.widget.FloatingActionButton#setVisibility() . 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: 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 2
Source File: TranslateUpDownBehavior.java    From okhttp-OkGo with Apache License 2.0 6 votes vote down vote up
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
    if (((dyConsumed > 0 && dyUnconsumed == 0) || (dyConsumed == 0 && dyUnconsumed > 0)) && !isAnimating && child.getVisibility() == View.VISIBLE) {
        if (listener != null) listener.onChange(true);
        AnimHelper.translateDown(child, new MyViewPropertyAnimatorListener() {
            @Override
            public void onAnimationEnd(View view) {
                super.onAnimationEnd(view);
                view.setVisibility(View.INVISIBLE);
            }
        });
    } else if ((dyConsumed < 0 && dyUnconsumed == 0) || (dyConsumed == 0 && dyUnconsumed < 0) && !isAnimating && child.getVisibility() == View.INVISIBLE) {
        if (listener != null) listener.onChange(false);
        child.setVisibility(View.VISIBLE);
        AnimHelper.translateUp(child, null);
    }
}
 
Example 3
Source File: ScrollAwareFABBehavior.java    From PowerSwitch_Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Same animation that FloatingActionButton.Behavior
 * uses to show the FAB when the AppBarLayout enters
 *
 * @param floatingActionButton FAB
 */
//
private void animateIn(FloatingActionButton floatingActionButton) {
    if (SmartphonePreferencesHandler.getUseOptionsMenuInsteadOfFAB()) {
        return;
    }
    floatingActionButton.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(floatingActionButton).scaleX(1.0F).scaleY(1.0F).alpha(1.0F)
                .setInterpolator(INTERPOLATOR).withLayer().setListener(null)
                .start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(floatingActionButton.getContext(), android.R.anim.fade_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        floatingActionButton.startAnimation(anim);
    }
}
 
Example 4
Source File: NearbyGroupWithRedPocketMapViewActivity.java    From Social with Apache License 2.0 5 votes vote down vote up
private void initView(){
    infos = new ArrayList<RedPocketGroup>();

    fab_home = (FloatingActionButton)this.findViewById(R.id.id_nearby_group_with_redpocket_mapview_activity_fab_home);
    fab_home.setOnClickListener(this);

    if (is_first_page==1){
        fab_home.setVisibility(View.GONE);
    }else{
        fab_home.setVisibility(View.VISIBLE);
    }

    mapView = (MapView)this.findViewById(R.id.id_nearby_group_with_redpocket_mapview_activity_mapview);
    mBaiduMap  = mapView.getMap();

    rl_mark_info_container = (RelativeLayout)this.findViewById(R.id.id_nearby_group_with_redpocket_mapview_activity_mark_info_windows);
    rl_mark_info_container.setVisibility(View.INVISIBLE);

    mBaiduMap.setOnMapClickListener(new BaiduMap.OnMapClickListener() {
        @Override
        public void onMapClick(LatLng latLng) {
            rl_mark_info_container.setVisibility(View.INVISIBLE);
        }

        @Override
        public boolean onMapPoiClick(MapPoi mapPoi) {
            return false;
        }
    });
}
 
Example 5
Source File: ScrollAwareFABBehavior.java    From AndroidBleManager with Apache License 2.0 5 votes vote down vote up
private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).translationY(0)
                .setInterpolator(INTERPOLATOR).withLayer().setListener(null)
                .start();
    } else {

    }
}
 
Example 6
Source File: ScrollAwareFabBehavior.java    From gank.io-unofficial-android-client with Apache License 2.0 5 votes vote down vote up
private void animateIn(FloatingActionButton button) {

    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
      ViewCompat.animate(button).translationY(0)
          .setInterpolator(INTERPOLATOR)
          .withLayer().setListener(null)
          .start();
    } else {

    }
  }
 
Example 7
Source File: ScrollAwareFABBehavior.java    From yahnac with Apache License 2.0 5 votes vote down vote up
private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    button.setScaleX(0);
    button.setScaleY(0);
    button.animate()
            .scaleX(1)
            .scaleY(1)
            .setInterpolator(new FastOutSlowInInterpolator())
            .setListener(null)
            .start();
}
 
Example 8
Source File: ScrollAwareFABBehavior.java    From Loop with Apache License 2.0 5 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(), R.anim.design_fab_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}
 
Example 9
Source File: ScrollAwareFABBehavior2.java    From MarkdownEditors with Apache License 2.0 5 votes vote down vote up
private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).translationY(0)
                .setInterpolator(INTERPOLATOR).withLayer().setListener(null)
                .start();
    } else {

    }
}
 
Example 10
Source File: ApiaryHivesFragment.java    From go-bees with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.apiary_hives_frag, container, false);

    // Set up hives list view
    RecyclerView recyclerView = (RecyclerView) root.findViewById(R.id.hives_list);
    LinearLayoutManager llm = new LinearLayoutManager(getActivity());
    recyclerView.setLayoutManager(llm);
    recyclerView.setAdapter(listAdapter);
    hivesView = (LinearLayout) root.findViewById(R.id.hivesLL);

    // Set up  no apiaries view
    noHivesView = root.findViewById(R.id.no_hives);

    // Set up floating action button
    fab = (FloatingActionButton) getActivity().findViewById(R.id.fab_add_hive);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            presenter.addEditHive(AddEditHiveActivity.NEW_HIVE);
        }
    });
    fab.setVisibility(View.VISIBLE);

    // Configure progress indicator
    AndroidUtils.setUpProgressIndicator(root, getContext(), recyclerView, presenter);
    return root;
}
 
Example 11
Source File: ScrollAwareFABBehaviour.java    From ankihelper with GNU General Public License v3.0 5 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(), R.anim.design_fab_out);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}
 
Example 12
Source File: ScaleDownShowBehavior.java    From CoordinatorLayoutExample with Apache License 2.0 5 votes vote down vote up
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
    if ((dyConsumed > 0 || dyUnconsumed > 0) && !isAnimatingOut && child.getVisibility() == View.VISIBLE) {//往下滑
        child.setVisibility(View.INVISIBLE);
        AnimatorUtil.scaleHide(child, viewPropertyAnimatorListener);
        if (mOnStateChangedListener != null) {
            mOnStateChangedListener.onChanged(false);
        }
    } else if ((dyConsumed < 0 || dyUnconsumed < 0) && child.getVisibility() != View.VISIBLE) {
        AnimatorUtil.scaleShow(child, null);
        if (mOnStateChangedListener != null) {
            mOnStateChangedListener.onChanged(true);
        }
    }
}
 
Example 13
Source File: SheetDetailActivity.java    From Musicoco with Apache License 2.0 5 votes vote down vote up
private void initSelfView() {
    toolbar = (Toolbar) findViewById(R.id.sheet_detail_toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    toTop = (FloatingActionButton) findViewById(R.id.sheet_detail_top);
    initToTopPos();

    songList = (RecyclerView) findViewById(R.id.sheet_detail_songs_list);
    appBarLayout = (AppBarLayout) findViewById(R.id.sheet_detail_app_bar);
    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.sheet_detail_toolbar_layout);
    barStateChangeListener = new AppBarStateChangeListener() {
        @Override
        public void onStateChanged(AppBarLayout appBarLayout, State state) {
            switch (state) {
                case EXPANDED:
                    collapsingToolbarLayout.setTitle(" ");
                    songList.setNestedScrollingEnabled(false);
                    transToTopBt(true);
                    break;
                case COLLAPSED:
                    collapsingToolbarLayout.setTitle(infoController.getTitle());
                    songList.setNestedScrollingEnabled(true);
                    toTop.setVisibility(View.VISIBLE);
                    transToTopBt(false);
                    break;
                case IDLE:
                    collapsingToolbarLayout.setTitle(" ");
                    break;
            }
        }
    };
    appBarLayout.addOnOffsetChangedListener(barStateChangeListener);

}
 
Example 14
Source File: ScrollAwareFABBehavior2.java    From MaoWanAndoidClient with Apache License 2.0 5 votes vote down vote up
@SuppressLint("RestrictedApi")
private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);

    ViewCompat.animate(button).scaleX(1.0F).scaleY(1.0F).alpha(1.0F)
            .setInterpolator(INTERPOLATOR).withLayer().setListener(null)
            .start();

}
 
Example 15
Source File: TopicActivity.java    From Android-Carbon-Forum with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //注册一个广播用于回复成功时,刷新主题
    IntentFilter intentFilter = new IntentFilter();
    intentFilter.addAction("action.refreshTopic");
    LocalBroadcastManager.getInstance(this).registerReceiver(mRefreshTopicBroadcastReceiver, intentFilter);
    //取得启动该Activity的Intent对象
    Intent mIntent = getIntent();
    //取出Intent中附加的数据
    mTopic = mIntent.getStringExtra("Topic");
    mTopicID = mIntent.getStringExtra("TopicID");
    mTopicPage = mIntent.getStringExtra("TargetPage");
    setContentView(R.layout.activity_topic);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    if(mTopic != null) {
        getSupportActionBar().setTitle(mTopic);
    }
    mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.activity_topic_swipe_refresh_layout);
    mSwipeRefreshLayout.setColorSchemeResources(
            R.color.material_light_blue_700,
            R.color.material_red_700,
            R.color.material_orange_700,
            R.color.material_light_green_700
    );
    mSwipeRefreshLayout.setOnRefreshListener(this);
    /*
    if(Integer.parseInt(mTopicPage) == 1) {
        mTopicTitle = (TextView) findViewById(R.id.title);
        mTopicTitle.setText(mTopic);
    }
    */
    //RecyclerView
    mRecyclerView = (RecyclerView) findViewById(R.id.post_list);
    mRecyclerView.setHasFixedSize(true);
    final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                int lastVisibleItem = layoutManager.findLastCompletelyVisibleItemPosition();
                int totalItemCount = layoutManager.getItemCount();
                if (lastVisibleItem >= (totalItemCount - 5) && enableScrollListener && currentPage < totalPage) {
                    loadPost(currentPage + 1);
                }
            }
        }
    });
    mRecyclerView.setLayoutManager(layoutManager);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mAdapter = new PostAdapter(this, false);
    mAdapter.setData(postList);
    mRecyclerView.setAdapter(mAdapter);

    mFloatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
    mFloatingActionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(TopicActivity.this, ReplyActivity.class);
            intent.putExtra("TopicID", mTopicID);
            intent.putExtra("PostID", "0");
            intent.putExtra("PostFloor", "0");
            intent.putExtra("UserName", "0");
            intent.putExtra("DefaultContent", "");
            startActivity(intent);
        }
    });
    if(!CarbonForumApplication.isLoggedIn()){
        mFloatingActionButton.setVisibility(View.INVISIBLE);
    }
    loadPost(Integer.parseInt(mTopicPage));
}
 
Example 16
Source File: NumberPadTimePickerBottomSheetComponent.java    From NumberPadTimePicker with Apache License 2.0 4 votes vote down vote up
@Override
public void onHidden(FloatingActionButton fab) {
    fab.setVisibility(INVISIBLE);
}
 
Example 17
Source File: ScrollAwareFABBehavior.java    From GracefulMovies with Apache License 2.0 4 votes vote down vote up
private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    ViewCompat.animate(button).translationY(0)
            .setInterpolator(INTERPOLATOR).withLayer().setListener(null)
            .start();
}
 
Example 18
Source File: ScrollAwareFABBehavior.java    From HHComicViewer with Apache License 2.0 4 votes vote down vote up
private void animateIn(FloatingActionButton child) {
    child.setVisibility(View.VISIBLE);
    //属性动画
    ViewCompat.animate(child).translationX(0).setInterpolator(folistener).setListener(null).start();
}
 
Example 19
Source File: FragmentStatusList.java    From Rumble with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    Bundle args = getArguments();
    if(args != null) {
        this.filter_gid = args.getString("GroupID");
        this.filter_uid = args.getString("ContactID");
        this.filter_hashtag = args.getString("Hashtag");
        this.noCoordinatorLayout = args.getBoolean("noCoordinatorLayout");
    }

    /*
     * This fragment is shown in three activities: the HomeActivity, the GroupDetail activity
     * and the ContactDetail activity. For HomeActivity and GroupDetail, I need the floating
     * action button to compose message and I need it to disappear when I scroll down so I need
     * this fragment to embeds it in a CoordinatorLayout to enable this effect.
     *
     * However for ContactDetail activity, I need a CoordinatorLayout for the whole activity
     * in order to hide the collapsingtoolbar whenever I scroll down. Unfortunately it conflicts
     * with the coordinatorlayout I use for this very fragmentStatusList. Because I don't need
     * the compose button to display the status to a specific contact, I created two different
     * layout to avoid conflicts and use the argument noCoordinatorLayout to decide which one.
     */
    if(noCoordinatorLayout) {
        mView = inflater.inflate(R.layout.fragment_status_list_no_coordinatorlayout, container, false);
    } else {
        mView = inflater.inflate(R.layout.fragment_status_list, container, false);
    }

    // the filters
    filters = (ListView) (mView.findViewById(R.id.filter_list));
    filterListAdapter = new FilterListAdapter(getActivity(), this);
    filters.setAdapter(filterListAdapter);
    filters.setClickable(false);
    filters.setVisibility(View.GONE);

    // refreshing the list of status by pulling down, disabled for ContactDetail
    swipeLayout = (SwipeRefreshLayout) mView.findViewById(R.id.swipe_container);
    if(noCoordinatorLayout)
        swipeLayout.setEnabled(false);
    else
        swipeLayout.setOnRefreshListener(this);


    /*
    final float density = getResources().getDisplayMetrics().density;
    final int swipeDistance = Math.round(64 * density);
    swipeLayout.setProgressViewOffset(true, 10, 10+swipeDistance);
    */

    // the compose button, disabled for ContactDetail
    composeFAB = (FloatingActionButton) mView.findViewById(R.id.compose_fab);
    if(noCoordinatorLayout)
        composeFAB.setVisibility(View.GONE);
    else
        composeFAB.setOnClickListener(onFabClicked);

    // the list of status
    mRecyclerView = (RecyclerView) mView.findViewById(R.id.status_list);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    statusRecyclerAdapter = new StatusRecyclerAdapter(getActivity(), this);
    mRecyclerView.setAdapter(statusRecyclerAdapter);
    mRecyclerView.addOnScrollListener(loadMore);

    // now get the latest status
    loadingMore = false;
    noMoreStatusToLoad = false;
    refreshStatuses();

    EventBus.getDefault().register(this);

    return mView;
}
 
Example 20
Source File: SetQuickPasswordActivity.java    From Puff-Android with MIT License 4 votes vote down vote up
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_set_quick_password);
        EventBus.getDefault().register(this);
        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

        hintStrSet = getString(R.string.set_gesture_password);
        hintStrVerify = getString(R.string.verify_gesture_password);

        patternView = (PatternView) findViewById(R.id.lock_view);
        hintTextView = (AppCompatTextView) findViewById(R.id.hint_view);
        type = getIntent().getLongExtra("type", ShowTypeSet);

//        findViewById(R.id.content_setpassword).getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
//            @Override
//            public boolean onPreDraw() {
//
//                Blurry.with(SetQuickPasswordActivity.this)
//                        .radius(0)
//                        .sampling(2)
//                        .onto((ViewGroup) findViewById(R.id.content_setpassword));
//                return true;
//            }
//        });

        patternView.setOnPatternDetectedListener(new PatternView.OnPatternDetectedListener() {
            @Override
            public void onPatternDetected() {
                quickCode = patternView.getPatternString();
                if (type == ShowTypeVerify) {
                    checkQuickPass();
                }
            }
        });

        if (type == ShowTypeVerify) {
            masterPassword = getIntent().getStringExtra("masterPassword");
            fab.setVisibility(View.INVISIBLE);
            hintTextView.setText(hintStrVerify);
        } else {
            fab.setVisibility(View.VISIBLE);
            hintTextView.setText(hintStrSet);
        }


        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!validateInput())
                    return;
                startActivity(new Intent(SetQuickPasswordActivity.this, AuthorizeActivity.class));
            }
        });
    }