當前位置: 首頁>>代碼示例>>Java>>正文


Java RemoteViews.removeAllViews方法代碼示例

本文整理匯總了Java中android.widget.RemoteViews.removeAllViews方法的典型用法代碼示例。如果您正苦於以下問題:Java RemoteViews.removeAllViews方法的具體用法?Java RemoteViews.removeAllViews怎麽用?Java RemoteViews.removeAllViews使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.RemoteViews的用法示例。


在下文中一共展示了RemoteViews.removeAllViews方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: generateBigContentView

import android.widget.RemoteViews; //導入方法依賴的package包/類
private static <T extends Action> RemoteViews generateBigContentView(Context context, CharSequence contentTitle, CharSequence contentText, CharSequence contentInfo, int number, Bitmap largeIcon, CharSequence subText, boolean useChronometer, long when, List<T> actions, boolean showCancelButton, PendingIntent cancelButtonIntent) {
    int actionCount = Math.min(actions.size(), 5);
    RemoteViews big = applyStandardTemplate(context, contentTitle, contentText, contentInfo, number, largeIcon, subText, useChronometer, when, getBigLayoutResource(actionCount), false);
    big.removeAllViews(R.id.media_actions);
    if (actionCount > 0) {
        for (int i = 0; i < actionCount; i++) {
            big.addView(R.id.media_actions, generateMediaActionButton(context, (Action) actions.get(i)));
        }
    }
    if (showCancelButton) {
        big.setViewVisibility(R.id.cancel_action, 0);
        big.setInt(R.id.cancel_action, "setAlpha", context.getResources().getInteger(R.integer.cancel_button_image_alpha));
        big.setOnClickPendingIntent(R.id.cancel_action, cancelButtonIntent);
    } else {
        big.setViewVisibility(R.id.cancel_action, 8);
    }
    return big;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:19,代碼來源:NotificationCompatImplBase.java

示例2: updateAppWidget

import android.widget.RemoteViews; //導入方法依賴的package包/類
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            Recipe recipe, int appWidgetId) {

    Intent intent = RecipeDetailActivity.newIntent(context, recipe);
    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.recipe_widget);
    views.removeAllViews(R.id.ll_recipe_widget_ingredient_list);
    views.setTextViewText(R.id.recipe_widget_title, recipe.getName());
    views.setOnClickPendingIntent(R.id.recipe_widget_holder, pendingIntent);

    for(Ingredient ingredient : recipe.getIngredients()) {
        RemoteViews rvIngredient = new RemoteViews(context.getPackageName(),
                R.layout.recipe_widget_list_item);
        rvIngredient.setTextViewText(R.id.tv_recipe_widget_ingredient_item,
                String.valueOf(ingredient.getQuantity()) +
                String.valueOf(ingredient.getMeasure()) + " " + ingredient.getIngredient());
        views.addView(R.id.ll_recipe_widget_ingredient_list, rvIngredient);
    }

    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
開發者ID:twisstosin,項目名稱:UdacityBakingAndroid,代碼行數:23,代碼來源:RecipeWidgetProvider.java

示例3: onDeleted

import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public void onDeleted(Context context, int[] appWidgetIds) {
    super.onDeleted(context, appWidgetIds);
    for (int appWidgetId : appWidgetIds) {
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget);
        rv.removeAllViews(appWidgetId);
    }
}
 
開發者ID:mvescovo,項目名稱:item-reaper,代碼行數:9,代碼來源:ItemWidgetProvider.java

示例4: generateContentView

import android.widget.RemoteViews; //導入方法依賴的package包/類
private static <T extends Action> RemoteViews generateContentView(Context context, CharSequence contentTitle, CharSequence contentText, CharSequence contentInfo, int number, Bitmap largeIcon, CharSequence subText, boolean useChronometer, long when, List<T> actions, int[] actionsToShowInCompact, boolean showCancelButton, PendingIntent cancelButtonIntent) {
    int N;
    RemoteViews view = applyStandardTemplate(context, contentTitle, contentText, contentInfo, number, largeIcon, subText, useChronometer, when, R.layout.notification_template_media, true);
    int numActions = actions.size();
    if (actionsToShowInCompact == null) {
        N = 0;
    } else {
        N = Math.min(actionsToShowInCompact.length, 3);
    }
    view.removeAllViews(R.id.media_actions);
    if (N > 0) {
        for (int i = 0; i < N; i++) {
            if (i >= numActions) {
                throw new IllegalArgumentException(String.format("setShowActionsInCompactView: action %d out of bounds (max %d)", new Object[]{Integer.valueOf(i), Integer.valueOf(numActions - 1)}));
            }
            Context context2 = context;
            RemoteViews button = generateMediaActionButton(context2, (Action) actions.get(actionsToShowInCompact[i]));
            view.addView(R.id.media_actions, button);
        }
    }
    if (showCancelButton) {
        view.setViewVisibility(R.id.end_padder, 8);
        view.setViewVisibility(R.id.cancel_action, 0);
        view.setOnClickPendingIntent(R.id.cancel_action, cancelButtonIntent);
        view.setInt(R.id.cancel_action, "setAlpha", context.getResources().getInteger(R.integer.cancel_button_image_alpha));
    } else {
        view.setViewVisibility(R.id.end_padder, 0);
        view.setViewVisibility(R.id.cancel_action, 8);
    }
    return view;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:32,代碼來源:NotificationCompatImplBase.java

示例5: onReceive

import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getBooleanExtra(ArcadeCommon.STATUS_RESET_SCORE, false)) {
        score = 0;
    } else {
        score += intent.getIntExtra(ArcadeCommon.STATUS_INCREMENT_SCORE, 0);
    }

    RemoteViews notifViews = new RemoteViews(context.getPackageName(),
            R.layout.status_notification);
    notifViews.setTextViewText(R.id.title, getString(titleResID));
    notifViews.setImageViewResource(R.id.notif_icon, notifIconResID);

    NotificationManager notifMgr =
            (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
    notifViews.setTextViewText(R.id.score, getString(R.string.score, score));

    int newLevel = intent.getIntExtra(ArcadeCommon.STATUS_LEVEL, level);
    if (newLevel != level) {
        setLevel(newLevel);
    }
    if (level >= 0) {
        notifViews.setTextViewText(R.id.level, getString(R.string.level, level));
    }

    setLives(intent.getIntExtra(ArcadeCommon.STATUS_LIVES, lives));
    if (previewActive) {
        return;
    }
    
    notifViews.removeAllViews(R.id.lives_area);
    if (lives < 0) {
        // Game over, man
        RemoteViews gameOver = new RemoteViews(getPackageName(), R.layout.status_text);
        gameOver.setTextViewText(R.id.status_text, "Game Over");
        notifViews.addView(R.id.lives_area, gameOver);
        if (!isPaused) {
            onPause();
        }
    } else {
        Bitmap lifeBitmap = BitmapFactory.decodeResource(getResources(), lifeIconResId);
        for (int i = 0; i < lives; i++) {
            RemoteViews thisLife = new RemoteViews(getPackageName(), R.layout.status_life_icon);
            thisLife.setBitmap(R.id.life_icon, "setImageBitmap", lifeBitmap);
            notifViews.addView(R.id.lives_area, thisLife);
        }
    }

    Bitmap pauseBtn = BitmapFactory.decodeResource(getResources(),
            isPaused || (readyTime > 0) 
                    ? R.drawable.ic_play_circle_outline_white_48dp
                    : R.drawable.ic_pause_circle_outline_white_48dp);
    notifViews.setBitmap(R.id.play_pause, "setImageBitmap", pauseBtn);
    notifViews.setOnClickPendingIntent(R.id.play_pause,
            PendingIntent.getBroadcast(context, 0, 
                    new Intent(ArcadeCommon.ACTION_PAUSE), 0));
    
    final NotificationCompat.Builder notif = new NotificationCompat.Builder(context)
            .setSmallIcon(notifIconResID)
            .setContent(notifViews)
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .setVisibility(VISIBILITY_SECRET); // keep the scroreboard off the lock screen
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        // This forces a heads-up notification
        notif.setVibrate(new long[0]);
    }

    notifMgr.notify(0, notif.build());
}
 
開發者ID:StringMon,項目名稱:homescreenarcade,代碼行數:70,代碼來源:GameWallpaperService.java

示例6: addActionButtons

import android.widget.RemoteViews; //導入方法依賴的package包/類
/**
 * If there are actions, shows the button related views, and adds a button for each action.
 */
private void addActionButtons(RemoteViews bigView) {
    // Remove the existing buttons in case an existing notification is being updated.
    bigView.removeAllViews(R.id.buttons);

    // Always set the visibility of the views associated with the action buttons. The current
    // visibility state is not known as perhaps an existing notification is being updated.
    int visibility = mActions.isEmpty() ? View.GONE : View.VISIBLE;
    bigView.setViewVisibility(R.id.button_divider, visibility);
    bigView.setViewVisibility(R.id.buttons, visibility);

    Resources resources = mContext.getResources();
    DisplayMetrics metrics = resources.getDisplayMetrics();
    for (Action action : mActions) {
        RemoteViews view =
                new RemoteViews(mContext.getPackageName(), R.layout.web_notification_button);

        // If there is an icon then set it and add some padding.
        if (action.iconBitmap != null || action.iconId != 0) {
            if (useMaterial()) {
                view.setInt(R.id.button_icon, "setColorFilter", BUTTON_ICON_COLOR_MATERIAL);
            }

            int iconWidth = 0;
            if (action.iconBitmap != null) {
                view.setImageViewBitmap(R.id.button_icon, action.iconBitmap);
                iconWidth = action.iconBitmap.getWidth();
            } else if (action.iconId != 0) {
                view.setImageViewResource(R.id.button_icon, action.iconId);
                BitmapFactory.Options options = new BitmapFactory.Options();
                options.inJustDecodeBounds = true;
                BitmapFactory.decodeResource(resources, action.iconId, options);
                iconWidth = options.outWidth;
            }
            iconWidth = dpToPx(
                    Math.min(pxToDp(iconWidth, metrics), MAX_ACTION_ICON_WIDTH_DP), metrics);

            // Set the padding of the button so the text does not overlap with the icon. Flip
            // between left and right manually as RemoteViews does not expose a method that sets
            // padding in a writing-direction independent way.
            int buttonPadding =
                    dpToPx(BUTTON_PADDING_START_DP + BUTTON_ICON_PADDING_DP, metrics)
                    + iconWidth;
            int buttonPaddingLeft = LocalizationUtils.isLayoutRtl() ? 0 : buttonPadding;
            int buttonPaddingRight = LocalizationUtils.isLayoutRtl() ? buttonPadding : 0;
            view.setViewPadding(R.id.button, buttonPaddingLeft, 0, buttonPaddingRight, 0);
        }

        view.setTextViewText(R.id.button, action.title);
        view.setOnClickPendingIntent(R.id.button, action.intent);
        bigView.addView(R.id.buttons, view);
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:56,代碼來源:CustomNotificationBuilder.java


注:本文中的android.widget.RemoteViews.removeAllViews方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。