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

The following examples show how to use android.support.design.widget.FloatingActionButton#setImageDrawable() . 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: CartActivity.java    From android-instant-apps-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_cart);
    viewModel = ViewModelProviders.of(this).get(CartViewModel.class);

    fab = (FloatingActionButton) findViewById(R.id.fab);
    toolbar = (Toolbar) findViewById(R.id.toolbar);

    setupToolbar();
    handleDeepLink();

    fab.setImageDrawable(VectorDrawableCompat.create(getResources(), R.drawable.ic_share_white_24dp, null));
    fab.setOnClickListener(view -> {
        String cartId = viewModel.getCartId().getValue();
        ShareCompat.IntentBuilder.from(this)
                .setText(String.format(Locale.US, "Check out my shopping cart now using Android Instant Apps! \n%s/cart/%s", ROOT_ENDPOINT, cartId))
                .setType("text/plain")
                .setChooserTitle(share_cart)
                .startChooser();
    });
}
 
Example 2
Source File: FloatingActionMenu.java    From MaterialWpp with Apache License 2.0 6 votes vote down vote up
@Override
public void addView(@NonNull View child, int index, LayoutParams params) {
    super.addView(child, index, params);
    if (getChildCount() > 1) {
        if (child instanceof FloatingActionButton) {
            addMenuItem((FloatingActionButton) child);
        }
    } else {
        mMenuButton = (FloatingActionButton) child;
        mIcon.setImageDrawable(mMenuButton.getDrawable());
        addView(mIcon);
        mMenuButton.setImageDrawable(mMenuButton.getDrawable());
        createDefaultIconAnimation();
        mMenuButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                toggle();
            }
        });
    }
}
 
Example 3
Source File: IncDecCircular.java    From IncDec with Apache License 2.0 6 votes vote down vote up
/** Setting up the left button */
private void setupLeftButton(FloatingActionButton leftButton, Drawable leftSrc,
                             int leftButtonTint, int leftDrawableTint) {
    if(leftSrc!=null) {
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            leftSrc.setTintList(new ColorStateList(new int[][]{new int[]{0}},
                    new int[]{leftDrawableTint}));
        }
        else
        {
            final Drawable wrappedDrawable = DrawableCompat.wrap(leftSrc);
            DrawableCompat.setTintList(wrappedDrawable, ColorStateList.valueOf(leftDrawableTint));
        }
        leftButton.setImageDrawable(leftSrc);

    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        leftButton.setBackgroundTintList(new ColorStateList(new int[][]{new int[]{0}},
                new int[]{leftButtonTint}));
    }
    else
    {
        ViewCompat.setBackgroundTintList(leftButton, ColorStateList.valueOf(leftButtonTint));
    }

}
 
Example 4
Source File: IncDecCircular.java    From IncDec with Apache License 2.0 6 votes vote down vote up
/** Setting up the right button */
private void setupRightButton(FloatingActionButton rightButton, Drawable rightSrc,
                              int rightButtonTint, int rightDrawableTint) {
    if(rightSrc!=null) {
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            rightSrc.setTintList(new ColorStateList(new int[][]{new int[]{0}},
                    new int[]{rightDrawableTint}));
        }
        else
        {
            final Drawable wrappedDrawable = DrawableCompat.wrap(rightSrc);
            DrawableCompat.setTintList(wrappedDrawable, ColorStateList.valueOf(rightDrawableTint));
        }
        rightButton.setImageDrawable(rightSrc);
    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        rightButton.setBackgroundTintList(new ColorStateList(new int[][]{new int[]{0}},
                new int[]{rightButtonTint}));
    }
    else
    {
        ViewCompat.setBackgroundTintList(rightButton, ColorStateList.valueOf(rightButtonTint));
    }
}
 
Example 5
Source File: FabOnScroll.java    From ForPDA with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onNestedPreScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dx, int dy, int[] consumed) {
    super.onNestedPreScroll(coordinatorLayout, child, target, dx, dy, consumed);
    //Log.d("SUKA", "FabOnScroll onNestedPreScroll" + consumed[1] + " : " + dy);
    if (child.getAlpha() == 0.0f && Math.abs(dy) > App.px24) {
        child.setImageDrawable(App.getVecDrawable(child.getContext(), dy > 0 ? R.drawable.ic_arrow_down : R.drawable.ic_arrow_up));
        child.clearAnimation();
        child.animate()
                .scaleX(1.0f)
                .scaleY(1.0f)
                .alpha(1.0f)
                .setInterpolator(interpolator)
                .start();
        child.setClickable(true);
    }
}
 
Example 6
Source File: MainActivity.java    From journaldev with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    FloatingActionButton fabSync = findViewById(R.id.fabSync);
    FloatingActionButton fabTickCross = findViewById(R.id.fabTickCross);

    tickToCross = (AnimatedVectorDrawable) getDrawable(R.drawable.avd_tick2cross);
    crossToTick = (AnimatedVectorDrawable) getDrawable(R.drawable.avd_cross2tick);


    ImageView imgSettings = findViewById(R.id.imgSettings);
    ImageView imgJD = findViewById(R.id.imgJD);
    imgSettings.setOnClickListener(this);
    imgJD.setOnClickListener(this);

    AnimatedVectorDrawableCompat animatedVectorDrawableCompat = AnimatedVectorDrawableCompat.create(this, R.drawable.avd_sync);
    fabSync.setImageDrawable(animatedVectorDrawableCompat);
    fabSync.setOnClickListener(this);
    fabTickCross.setOnClickListener(this);

}
 
Example 7
Source File: FloatingActionMenu.java    From belvedere with Apache License 2.0 6 votes vote down vote up
public void addMenuItem(@DrawableRes int iconRes, @IdRes int id, @StringRes int contentDescription, @NonNull View.OnClickListener clickListener) {
    FloatingActionButton menuItem = (FloatingActionButton) layoutInflater.inflate(R.layout.belvedere_floating_action_menu_item, this, false);
    menuItem.setOnClickListener(clickListener);
    menuItem.setImageDrawable(getTintedDrawable(iconRes, R.color.belvedere_floating_action_menu_item_icon_color));
    menuItem.setId(id);
    menuItem.setContentDescription(getResources().getString(contentDescription));

    menuItems.add(Pair.create(menuItem, clickListener));

    if (menuItems.size() == 1) {
        fab.setImageDrawable(getTintedDrawable(iconRes, R.color.belvedere_floating_action_menu_icon_color));
        fab.setContentDescription(getResources().getString(contentDescription));

    } else if (menuItems.size() == 2) {
        addView(menuItems.get(0).first, 0);
        addView(menuItem, 0);

        fab.setImageDrawable(getTintedDrawable(R.drawable.belvedere_fam_icon_add, R.color.belvedere_floating_action_menu_icon_color));
        fab.setContentDescription(getResources().getString(R.string.belvedere_fam_desc_expand_fam));
    } else {
        addView(menuItem, 0);
    }
    setVisibility(VISIBLE);
}
 
Example 8
Source File: FabSpeedDial.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
private void setupFab() {
    // Set up the client's FAB
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setImageDrawable(fabDrawable);
    if (Utils.hasLollipop()) {
        fab.setImageTintList(fabDrawableTint);
    }
    if (fabBackgroundTint != null) {
        fab.setBackgroundTintList(fabBackgroundTint);
    }

    fab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isAnimating) return;

            if (isMenuOpen()) {
                closeMenu();
            } else {
                openMenu();
            }
        }
    });
}
 
Example 9
Source File: FabSpeedDial.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
private void setupFab() {
    // Set up the client's FAB
    fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setImageDrawable(fabDrawable);
    if (Utils.hasLollipop()) {
        fab.setImageTintList(fabDrawableTint);
    }
    if (fabBackgroundTint != null) {
        fab.setBackgroundTintList(fabBackgroundTint);
    }

    fab.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isAnimating) return;

            if (isMenuOpen()) {
                closeMenu();
            } else {
                openMenu();
            }
        }
    });
}
 
Example 10
Source File: ExpandableButtonView.java    From Expandable-Action-Button with MIT License 6 votes vote down vote up
private void init(Context context){

        actionButton=new FloatingActionButton(context);
        toolbarLayout=new LinearLayout(getContext());
        float density = getResources().getDisplayMetrics().density;
        addView(actionButton,(int)(56*density),(int)(56*density));
        FrameLayout.LayoutParams params=
                FrameLayout.LayoutParams.class.cast(actionButton.getLayoutParams());
        params.gravity= Gravity.CENTER;
        actionButton.setLayoutParams(params);
        toolbarLayout.setGravity(Gravity.CENTER);
        actionButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                onButtonClick();
            }
        });

        fabDrawable=actionButton.getDrawable();
        if(fabDrawable!=null) actionButton.setImageDrawable(fabDrawable);
        setToolbarColor(-1);


    }
 
Example 11
Source File: MultiFloatingActionButton.java    From ReadMark with Apache License 2.0 5 votes vote down vote up
private void setBaseViews(Context context){
    mBackgroundView = new View(context);
    mBackgroundView.setBackgroundColor(mBackgroundColor);
    mBackgroundView.setAlpha(0);
    addView(mBackgroundView);

    mFloatingActionButton = new FloatingActionButton(context);
    mFloatingActionButton.setBackgroundTintList(mFabColor);
    mFloatingActionButton.setImageDrawable(mFabIcon);
    addView(mFloatingActionButton);
}
 
Example 12
Source File: FabSpeedDial.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
private View createFabMenuItem(MenuItem menuItem) {
    ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
            .inflate(getMenuItemLayoutId(), this, false);

    FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
    FrameLayout cardView = (FrameLayout) fabMenuItem.findViewById(R.id.card_view);
    TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);

    fabMenuItemMap.put(miniFab, menuItem);
    cardViewMenuItemMap.put(cardView, menuItem);

    miniFab.setImageDrawable(menuItem.getIcon());
    miniFab.setOnClickListener(this);
    cardView.setOnClickListener(this);

    ViewCompat.setAlpha(miniFab, 0f);
    ViewCompat.setAlpha(cardView, 0f);

    final CharSequence title = menuItem.getTitle();
    if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
        //cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
        titleView.setText(title);
        titleView.setTypeface(null, Typeface.BOLD);
        titleView.setTextColor(miniFabTitleTextColor);
    } else {
        fabMenuItem.removeView(cardView);
    }

    miniFab.setBackgroundTintList(miniFabBackgroundTint);
    if (Utils.hasLollipop()) {
        miniFab.setImageTintList(miniFabDrawableTint);
    }

    return fabMenuItem;
}
 
Example 13
Source File: MultiFloatingActionButton.java    From ReadMark with Apache License 2.0 5 votes vote down vote up
private void setBaseViews(Context context){
    mBackgroundView = new View(context);
    mBackgroundView.setBackgroundColor(mBackgroundColor);
    mBackgroundView.setAlpha(0);
    addView(mBackgroundView);

    mFloatingActionButton = new FloatingActionButton(context);
    mFloatingActionButton.setBackgroundTintList(mFabColor);
    mFloatingActionButton.setImageDrawable(mFabIcon);
    addView(mFloatingActionButton);
}
 
Example 14
Source File: FabSpeedDial.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
private View createFabMenuItem(MenuItem menuItem) {
    ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
            .inflate(getMenuItemLayoutId(), this, false);

    FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
    FrameLayout cardView = (FrameLayout) fabMenuItem.findViewById(R.id.card_view);
    TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);

    fabMenuItemMap.put(miniFab, menuItem);
    cardViewMenuItemMap.put(cardView, menuItem);

    miniFab.setImageDrawable(menuItem.getIcon());
    miniFab.setOnClickListener(this);
    cardView.setOnClickListener(this);

    ViewCompat.setAlpha(miniFab, 0f);
    ViewCompat.setAlpha(cardView, 0f);

    final CharSequence title = menuItem.getTitle();
    if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
        //cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
        titleView.setText(title);
        titleView.setTypeface(null, Typeface.BOLD);
        titleView.setTextColor(miniFabTitleTextColor);
    } else {
        fabMenuItem.removeView(cardView);
    }

    miniFab.setBackgroundTintList(miniFabBackgroundTint);
    if (Utils.hasLollipop()) {
        miniFab.setImageTintList(miniFabDrawableTint);
    }

    return fabMenuItem;
}
 
Example 15
Source File: FabSpeedDial.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
private View createFabMenuItem(MenuItem menuItem) {
    ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
            .inflate(getMenuItemLayoutId(), this, false);

    FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
    FrameLayout cardView = (FrameLayout) fabMenuItem.findViewById(R.id.card_view);
    TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);

    fabMenuItemMap.put(miniFab, menuItem);
    cardViewMenuItemMap.put(cardView, menuItem);

    miniFab.setImageDrawable(menuItem.getIcon());
    miniFab.setOnClickListener(this);
    cardView.setOnClickListener(this);

    ViewCompat.setAlpha(miniFab, 0f);
    ViewCompat.setAlpha(cardView, 0f);

    final CharSequence title = menuItem.getTitle();
    if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
        //cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
        titleView.setText(title);
        titleView.setTypeface(null, Typeface.BOLD);
        titleView.setTextColor(miniFabTitleTextColor);
    } else {
        fabMenuItem.removeView(cardView);
    }

    miniFab.setBackgroundTintList(miniFabBackgroundTint);
    if (Utils.hasLollipop()) {
        miniFab.setImageTintList(miniFabDrawableTint);
    }

    return fabMenuItem;
}
 
Example 16
Source File: FabSpeedDial.java    From fab-speed-dial with Apache License 2.0 4 votes vote down vote up
private View createFabMenuItem(MenuItem menuItem) {
    ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
            .inflate(getMenuItemLayoutId(), this, false);

    FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
    CardView cardView = (CardView) fabMenuItem.findViewById(R.id.card_view);
    TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);

    fabMenuItemMap.put(miniFab, menuItem);
    cardViewMenuItemMap.put(cardView, menuItem);

    miniFab.setImageDrawable(menuItem.getIcon());
    miniFab.setOnClickListener(this);
    cardView.setOnClickListener(this);

    ViewCompat.setAlpha(miniFab, 0f);
    ViewCompat.setAlpha(cardView, 0f);

    final CharSequence title = menuItem.getTitle();
    if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
        cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
        titleView.setText(title);
        titleView.setTypeface(null, Typeface.BOLD);
        titleView.setTextColor(miniFabTitleTextColor);

        if (miniFabTitleTextColorArray != null) {
            titleView.setTextColor(ContextCompat.getColorStateList(getContext(),
                    miniFabTitleTextColorArray[menuItem.getOrder()]));
        }
    } else {
        fabMenuItem.removeView(cardView);
    }

    miniFab.setBackgroundTintList(miniFabBackgroundTint);

    if (miniFabBackgroundTintArray != null) {
        miniFab.setBackgroundTintList(ContextCompat.getColorStateList(getContext(),
                miniFabBackgroundTintArray[menuItem.getOrder()]));
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        miniFab.setImageTintList(miniFabDrawableTint);
    }

    return fabMenuItem;
}
 
Example 17
Source File: RoomsFragment.java    From PowerSwitch_Android with GNU General Public License v3.0 4 votes vote down vote up
@Override
    public void onCreateViewEvent(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_rooms, container, false);

        setHasOptionsMenu(true);

        rooms = new ArrayList<>();
        recyclerViewRooms = (RecyclerView) rootView.findViewById(R.id.recyclerView);
        roomsRecyclerViewAdapter = new RoomRecyclerViewAdapter(this, getActivity(), rooms);
        recyclerViewRooms.setAdapter(roomsRecyclerViewAdapter);
        layoutManager = new StaggeredGridLayoutManager(
                getSpanCount(), StaggeredGridLayoutManager.VERTICAL);
        recyclerViewRooms.setLayoutManager(layoutManager);

        addReceiverFAB = (FloatingActionButton) rootView.findViewById(R.id.add_fab);
        addReceiverFAB.setImageDrawable(IconicsHelper.getAddIcon(getActivity(), ContextCompat.getColor(getActivity(), android.R.color.white)));
        final RecyclerViewFragment recyclerViewFragment = this;
        addReceiverFAB.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (AnimationHandler.checkTargetApi()) {
//                    Intent intent = new Intent();
//
//                    ActivityOptionsCompat options =
//                            ActivityOptionsCompat.makeSceneTransitionAnimation(getActivity(),
//                                    addReceiverFAB,   // The view which starts the transition
//                                    "configureReceiverTransition"    // The transitionName of the view we’re transitioning to
//                            );
//                    ActivityCompat.startActivity(getActivity(), intent, options.toBundle());
                } else {

                }

                if (SettingsConstants.INVALID_APARTMENT_ID == SmartphonePreferencesHandler.getCurrentApartmentId()) {
                    new AlertDialog.Builder(getContext())
                            .setMessage(R.string.please_create_or_activate_apartment_first)
                            .setNeutralButton(android.R.string.ok, null)
                            .show();
                    return;
                }

                ConfigureReceiverDialog configureReceiverDialog = new ConfigureReceiverDialog();
                configureReceiverDialog.setTargetFragment(recyclerViewFragment, 0);
                configureReceiverDialog.show(getFragmentManager(), null);
            }
        });

        // BroadcastReceiver to get notifications from background service if room data has changed
        broadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                Log.d("RoomsFragment", "received intent: " + intent.getAction());
                updateUI();
            }
        };
    }
 
Example 18
Source File: BaseNowplayingFragment.java    From Muzesto with GNU General Public License v3.0 4 votes vote down vote up
public void setSongDetails(View view) {

        albumart = (ImageView) view.findViewById(R.id.album_art);
        shuffle = (ImageView) view.findViewById(R.id.shuffle);
        repeat = (ImageView) view.findViewById(R.id.repeat);
        next = (MaterialIconView) view.findViewById(R.id.next);
        previous = (MaterialIconView) view.findViewById(R.id.previous);
        fabNext = (FloatingActionButton) view.findViewById(R.id.next_fab);
        fabPrevious = (FloatingActionButton) view.findViewById(R.id.previous_fab);
        mPlayPause = (PlayPauseButton) view.findViewById(R.id.playpause);
        playPauseFloating = (FloatingActionButton) view.findViewById(R.id.playpausefloating);
        playPauseWrapper = view.findViewById(R.id.playpausewrapper);

        songtitle = (TextView) view.findViewById(R.id.song_title);
        songtitle.setSelected(true);
        songalbum = (TextView) view.findViewById(R.id.song_album);
        songartist = (TextView) view.findViewById(R.id.song_artist);
        songduration = (TextView) view.findViewById(R.id.song_duration);
        elapsedtime = (TextView) view.findViewById(R.id.song_elapsed_time);

        timelyView11 = (TimelyView) view.findViewById(R.id.timelyView11);
        timelyView12 = (TimelyView) view.findViewById(R.id.timelyView12);
        timelyView13 = (TimelyView) view.findViewById(R.id.timelyView13);
        timelyView14 = (TimelyView) view.findViewById(R.id.timelyView14);
        timelyView15 = (TimelyView) view.findViewById(R.id.timelyView15);
        hourColon = (TextView) view.findViewById(R.id.hour_colon);

        mProgress = (SeekBar) view.findViewById(R.id.song_progress);
        mCircularProgress = (CircularSeekBar) view.findViewById(R.id.song_progress_circular);

        recyclerView = (RecyclerView) view.findViewById(R.id.queue_recyclerview);

        Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
        if (toolbar != null) {
            ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
            final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
            ab.setDisplayHomeAsUpEnabled(true);
            ab.setTitle("");
        }
        if (mPlayPause != null && getActivity() != null) {
            mPlayPause.setColor(ContextCompat.getColor(getContext(), android.R.color.white));
        }

        if (playPauseFloating != null) {
            playPauseDrawable.setColorFilter(TimberUtils.getBlackWhiteColor(accentColor), PorterDuff.Mode.MULTIPLY);
            playPauseFloating.setImageDrawable(playPauseDrawable);
            if (MusicPlayer.isPlaying())
                playPauseDrawable.transformToPause(false);
            else playPauseDrawable.transformToPlay(false);
        }

        if (mCircularProgress != null) {
            mCircularProgress.setCircleProgressColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));
            mCircularProgress.setPointerColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));
            mCircularProgress.setPointerHaloColor(ContextCompat.getColor(getActivity(), R.color.colorAccent));
        }

        if (timelyView11 != null) {
            String time = TimberUtils.makeShortTimeString(getActivity(), MusicPlayer.position() / 1000);
            if (time.length() < 5) {
                timelyView11.setVisibility(View.GONE);
                timelyView12.setVisibility(View.GONE);
                hourColon.setVisibility(View.GONE);

                changeDigit(timelyView13, time.charAt(0) - '0');
                changeDigit(timelyView14, time.charAt(2) - '0');
                changeDigit(timelyView15, time.charAt(3) - '0');

            } else if (time.length() == 5) {
                timelyView12.setVisibility(View.VISIBLE);
                changeDigit(timelyView12, time.charAt(0) - '0');
                changeDigit(timelyView13, time.charAt(1) - '0');
                changeDigit(timelyView14, time.charAt(3) - '0');
                changeDigit(timelyView15, time.charAt(4) - '0');
            } else {
                timelyView11.setVisibility(View.VISIBLE);
                hourColon.setVisibility(View.VISIBLE);
                changeDigit(timelyView11, time.charAt(0) - '0');
                changeDigit(timelyView12, time.charAt(2) - '0');
                changeDigit(timelyView13, time.charAt(3) - '0');
                changeDigit(timelyView14, time.charAt(5) - '0');
                changeDigit(timelyView15, time.charAt(6) - '0');
            }
        }

        setSongDetails();

    }
 
Example 19
Source File: ConfigureCallDialogPage2ActionsFragment.java    From PowerSwitch_Android with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.dialog_fragment_configure_call_page_2, container, false);

        broadcastReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                if (LocalBroadcastConstants.INTENT_CALL_ACTION_ADDED.equals(intent.getAction())) {
//                    actions.add((Action) intent.getSerializableExtra("action"));
                    sendActionsChangedBroadcast(getContext(), actions);
                }
            }
        };

        final Fragment fragment = this;
        FloatingActionButton addActionFAB = (FloatingActionButton) rootView.findViewById(R.id.add_action);
        addActionFAB.setImageDrawable(IconicsHelper.getAddIcon(getActivity(), ContextCompat.getColor(getActivity(), android.R.color.white)));
        addActionFAB.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AddCallActionDialog addCallActionDialog = new AddCallActionDialog();
                addCallActionDialog.setTargetFragment(fragment, 0);
                addCallActionDialog.show(getActivity().getSupportFragmentManager(), null);
            }
        });

        actionRecyclerViewAdapter = new ActionRecyclerViewAdapter(getActivity(), actions);
        actionRecyclerViewAdapter.setOnDeleteClickListener(new ActionRecyclerViewAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View itemView, int position) {
                actions.remove(position);
                actionRecyclerViewAdapter.notifyDataSetChanged();
                sendActionsChangedBroadcast(getContext(), actions);
            }
        });
        RecyclerView recyclerViewActions = (RecyclerView) rootView.findViewById(R.id.recyclerview_list_of_actions);
        recyclerViewActions.setAdapter(actionRecyclerViewAdapter);
        StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL);
        recyclerViewActions.setLayoutManager(layoutManager);

        Bundle args = getArguments();
        if (args != null && args.containsKey(ConfigureCallEventDialog.CALL_EVENT_ID_KEY)) {
            callEventId = args.getLong(ConfigureCallEventDialog.CALL_EVENT_ID_KEY);
            initializeCallData(callEventId);
        }

        return rootView;
    }
 
Example 20
Source File: FabSpeedDial.java    From fab-speed-dial with Apache License 2.0 4 votes vote down vote up
private View createFabMenuItem(MenuItem menuItem) {
    ViewGroup fabMenuItem = (ViewGroup) LayoutInflater.from(getContext())
            .inflate(getMenuItemLayoutId(), this, false);

    FloatingActionButton miniFab = (FloatingActionButton) fabMenuItem.findViewById(R.id.mini_fab);
    CardView cardView = (CardView) fabMenuItem.findViewById(R.id.card_view);
    TextView titleView = (TextView) fabMenuItem.findViewById(R.id.title_view);

    fabMenuItemMap.put(miniFab, menuItem);
    cardViewMenuItemMap.put(cardView, menuItem);

    miniFab.setImageDrawable(menuItem.getIcon());
    miniFab.setOnClickListener(this);
    cardView.setOnClickListener(this);

    ViewCompat.setAlpha(miniFab, 0f);
    ViewCompat.setAlpha(cardView, 0f);

    final CharSequence title = menuItem.getTitle();
    if (!TextUtils.isEmpty(title) && miniFabTitlesEnabled) {
        cardView.setCardBackgroundColor(miniFabTitleBackgroundTint.getDefaultColor());
        titleView.setText(title);
        titleView.setTypeface(null, Typeface.BOLD);
        titleView.setTextColor(miniFabTitleTextColor);

        if (miniFabTitleTextColorArray != null) {
            titleView.setTextColor(ContextCompat.getColorStateList(getContext(),
                    miniFabTitleTextColorArray[menuItem.getOrder()]));
        }
    } else {
        fabMenuItem.removeView(cardView);
    }

    miniFab.setBackgroundTintList(miniFabBackgroundTint);

    if (miniFabBackgroundTintArray != null) {
        miniFab.setBackgroundTintList(ContextCompat.getColorStateList(getContext(),
                miniFabBackgroundTintArray[menuItem.getOrder()]));
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        miniFab.setImageTintList(miniFabDrawableTint);
    }

    return fabMenuItem;
}