当前位置: 首页>>代码示例>>Java>>正文


Java Snackbar.addCallback方法代码示例

本文整理汇总了Java中android.support.design.widget.Snackbar.addCallback方法的典型用法代码示例。如果您正苦于以下问题:Java Snackbar.addCallback方法的具体用法?Java Snackbar.addCallback怎么用?Java Snackbar.addCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.design.widget.Snackbar的用法示例。


在下文中一共展示了Snackbar.addCallback方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DoubleClickCloseSnackBar

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public static void DoubleClickCloseSnackBar(final Activity mActivity, boolean isDoubleClick) {
    if (isDoubleClick && waitDoubleClick) {
        mActivity.finish();
    } else {
        Snackbar snackbar = Snackbar.make(mActivity.findViewById(R.id.main_layout_content), R.string.action_warn_double_click_close_application, Snackbar.LENGTH_SHORT);
        snackbar.addCallback(new BaseTransientBottomBar.BaseCallback<Snackbar>() {
            @Override
            public void onDismissed(Snackbar transientBottomBar, int event) {
                waitDoubleClick = false;
                super.onDismissed(transientBottomBar, event);
            }
        });
        waitDoubleClick = true;
        snackbar.show();
    }
}
 
开发者ID:XFY9326,项目名称:CatchSpy,代码行数:17,代码来源:ApplicationMethod.java

示例2: remove

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
/**
 * Performs the action on the specified positions and displays a SnackBar to Undo
 * the operation. To customize the UPDATE event, please set a custom listener with
 * {@link #withAction(int, OnActionListener)} method.
 * <p>By default the DELETE action will be performed.</p>
 *
 * @param positions  the position to delete or update
 * @param mainView   the view to find a parent from
 * @param message    the text to show. Can be formatted text
 * @param actionText the action text to display
 * @param undoTime   How long to display the message. Either {@link Snackbar#LENGTH_SHORT} or
 *                   {@link Snackbar#LENGTH_LONG} or any custom Integer.
 * @return The SnackBar instance
 * @see #remove(List, View, int, int, int)
 */
@SuppressWarnings("WrongConstant")
public Snackbar remove(List<Integer> positions, @NonNull View mainView,
				   CharSequence message, CharSequence actionText,
				   @IntRange(from = -1) int undoTime) {
	this.mPositions = positions;
	Snackbar snackbar;
	if (!mAdapter.isPermanentDelete()) {
		snackbar = Snackbar.make(mainView, message, undoTime > 0 ? undoTime + 400 : undoTime)
				.setAction(actionText, new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						if (mUndoListener != null)
							mUndoListener.onUndoConfirmed(mAction);
					}
				});
	} else {
		snackbar = Snackbar.make(mainView, message, undoTime);
	}
	if (mActionTextColor != Color.TRANSPARENT) {
		snackbar.setActionTextColor(mActionTextColor);
	}
	snackbar.addCallback(this);
	snackbar.show();
	return snackbar;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:41,代码来源:UndoHelper.java

示例3: showSnackbar

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public static void showSnackbar(View container, @NonNull SnackbarType snackbarType,
                                @StringRes int textStringRes, @Nullable SnackbarDuration duration,
                                @Nullable BaseTransientBottomBar.BaseCallback<Snackbar> callback) {

    duration = (duration == null ? SnackbarDuration.LONG : duration);

    Snackbar snackbar = Snackbar.make(container, textStringRes, duration.getDuration());
    snackbar.getView().setBackgroundResource(snackbarType.getColorRes());
    TextView snackbarText = (TextView) snackbar.getView().findViewById(android.support.design.R.id.snackbar_text);
    snackbarText.setCompoundDrawablesWithIntrinsicBounds(0, 0,snackbarType.getIconRes(), 0);
    snackbarText.setGravity(Gravity.CENTER);
    if(callback != null)
        snackbar.addCallback(callback);
    snackbar.show();
}
 
开发者ID:abicelis,项目名称:Remindy,代码行数:16,代码来源:SnackbarUtil.java

示例4: removeItemWithSnackbar

import android.support.design.widget.Snackbar; //导入方法依赖的package包/类
public void removeItemWithSnackbar(Activity activity, final int position, final SnackbarListener listener)
{
    getSwipeManager().performFakeSwipe(mVHs.get(position), SwipeableItemConstants.RESULT_SWIPED_LEFT);

    if (mChatroomObjects.get(position) != null)
    {
        final ChatroomRecyclerObject huehuehue = removeItem(position);

        if (huehuehue != null)
        {
            final SharedPreferences mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(activity);

            huehuehue.setIsPinned(false);
            String chatroomName = huehuehue.getName();
            String snackTextDel = "Deleted " + chatroomName;
            final String snackTextRestore = "Chatroom restored!";

            final SpannableStringBuilder snackTextDelSSB = new SpannableStringBuilder().append(snackTextDel);
            final SpannableStringBuilder snackTextRestoreSSB = new SpannableStringBuilder().append(snackTextRestore);


            if (mSharedPrefs.getBoolean("darkTheme", false))
            {
                snackTextDelSSB.setSpan(new ForegroundColorSpan(activity.getResources().getColor(R.color.colorDark)), 0, snackTextDel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                snackTextRestoreSSB.setSpan(new ForegroundColorSpan(activity.getResources().getColor(R.color.colorDark)), 0, snackTextRestore.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            else
            {
                snackTextDelSSB.setSpan(new ForegroundColorSpan(activity.getResources().getColor(R.color.white)), 0, snackTextDel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                snackTextRestoreSSB.setSpan(new ForegroundColorSpan(activity.getResources().getColor(R.color.white)), 0, snackTextRestore.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }

            final View parentLayout = activity.findViewById(android.R.id.content);
            Snackbar snackbar = Snackbar
                    .make(parentLayout, snackTextDelSSB, Snackbar.LENGTH_LONG)
                    .setAction("UNDO", new View.OnClickListener()
                    {
                        @Override
                        public void onClick(View view)
                        {
                            Snackbar hue = Snackbar.make(parentLayout, snackTextRestoreSSB, Snackbar.LENGTH_SHORT);

                            if (mSharedPrefs.getBoolean("darkTheme", false))
                            {
                                hue.getView().setBackgroundColor(Color.WHITE);
                            }

                            hue.show();
                            addItem(huehuehue);
                            listener.onUndo();
                        }
                    });

            if (mSharedPrefs.getBoolean("darkTheme", false))
            {
                snackbar.getView().setBackgroundColor(activity.getResources().getColor(R.color.white));
            }

            snackbar.show();
            snackbar.addCallback(new BaseTransientBottomBar.BaseCallback<Snackbar>()
            {
                @Override
                public void onDismissed(Snackbar transientBottomBar, int event)
                {
                    switch (event)
                    {
                        case DISMISS_EVENT_TIMEOUT:
                            listener.onUndoExpire(huehuehue.getUrl());
                            break;
                    }
                }
            });
        }
    }
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:77,代码来源:RecyclerAdapter.java


注:本文中的android.support.design.widget.Snackbar.addCallback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。