Search in sources :

Example 1 with OnUnblockNumberListener

use of com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnUnblockNumberListener in project android_packages_apps_Dialer by MoKee.

the class BlockNumberDialogFragment method blockNumber.

private void blockNumber() {
    final CharSequence message = getBlockedMessage();
    final CharSequence undoMessage = getUnblockedMessage();
    final Callback callback = mCallback;
    final int actionTextColor = getActionTextColor();
    final Context context = getContext();
    final OnUnblockNumberListener onUndoListener = new OnUnblockNumberListener() {

        @Override
        public void onUnblockComplete(int rows, ContentValues values) {
            if (mParentView != null) {
                Snackbar.make(mParentView, undoMessage, Snackbar.LENGTH_LONG).show();
            }
            if (callback != null) {
                callback.onChangeFilteredNumberUndo();
            }
        }
    };
    final OnBlockNumberListener onBlockNumberListener = new OnBlockNumberListener() {

        @Override
        public void onBlockComplete(final Uri uri) {
            final View.OnClickListener undoListener = new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    // Delete the newly created row on 'undo'.
                    Logger.logInteraction(InteractionEvent.UNDO_BLOCK_NUMBER);
                    mHandler.unblock(onUndoListener, uri);
                }
            };
            if (mParentView != null) {
                Snackbar.make(mParentView, message, Snackbar.LENGTH_LONG).setAction(R.string.block_number_undo, undoListener).setActionTextColor(actionTextColor).show();
            }
            if (callback != null) {
                callback.onFilterNumberSuccess();
            }
            if (context != null && FilteredNumbersUtil.hasRecentEmergencyCall(context)) {
                FilteredNumbersUtil.maybeNotifyCallBlockingDisabled(context);
            }
        }
    };
    mHandler.blockNumber(onBlockNumberListener, mNumber, mCountryIso);
}
Also used : Context(android.content.Context) ContentValues(android.content.ContentValues) OnBlockNumberListener(com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnBlockNumberListener) OnUnblockNumberListener(com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnUnblockNumberListener) Uri(android.net.Uri) View(android.view.View)

Example 2 with OnUnblockNumberListener

use of com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnUnblockNumberListener in project android_packages_apps_Dialer by MoKee.

the class BlockNumberDialogFragment method unblockNumber.

private void unblockNumber() {
    final CharSequence message = getUnblockedMessage();
    final CharSequence undoMessage = getBlockedMessage();
    final Callback callback = mCallback;
    final int actionTextColor = getActionTextColor();
    final OnBlockNumberListener onUndoListener = new OnBlockNumberListener() {

        @Override
        public void onBlockComplete(final Uri uri) {
            if (mParentView != null) {
                Snackbar.make(mParentView, undoMessage, Snackbar.LENGTH_LONG).show();
            }
            if (callback != null) {
                callback.onChangeFilteredNumberUndo();
            }
        }
    };
    mHandler.unblock(new OnUnblockNumberListener() {

        @Override
        public void onUnblockComplete(int rows, final ContentValues values) {
            final View.OnClickListener undoListener = new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    // Re-insert the row on 'undo', with a new ID.
                    Logger.logInteraction(InteractionEvent.UNDO_UNBLOCK_NUMBER);
                    mHandler.blockNumber(onUndoListener, values);
                }
            };
            if (mParentView != null) {
                Snackbar.make(mParentView, message, Snackbar.LENGTH_LONG).setAction(R.string.block_number_undo, undoListener).setActionTextColor(actionTextColor).show();
            }
            if (callback != null) {
                callback.onUnfilterNumberSuccess();
            }
        }
    }, getArguments().getInt(ARG_BLOCK_ID));
}
Also used : OnBlockNumberListener(com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnBlockNumberListener) ContentValues(android.content.ContentValues) OnUnblockNumberListener(com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnUnblockNumberListener) Uri(android.net.Uri) View(android.view.View)

Aggregations

ContentValues (android.content.ContentValues)2 Uri (android.net.Uri)2 View (android.view.View)2 OnBlockNumberListener (com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnBlockNumberListener)2 OnUnblockNumberListener (com.android.dialer.database.FilteredNumberAsyncQueryHandler.OnUnblockNumberListener)2 Context (android.content.Context)1