Example usage for android.appwidget AppWidgetManager EXTRA_APPWIDGET_ID

List of usage examples for android.appwidget AppWidgetManager EXTRA_APPWIDGET_ID

Introduction

In this page you can find the example usage for android.appwidget AppWidgetManager EXTRA_APPWIDGET_ID.

Prototype

String EXTRA_APPWIDGET_ID

To view the source code for android.appwidget AppWidgetManager EXTRA_APPWIDGET_ID.

Click Source Link

Document

An intent extra that contains one appWidgetId.

Usage

From source file:xyz.klinker.blur.launcher3.Launcher.java

/**
 * Process a widget drop./*w  w w . j  av  a2s .  c o m*/
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param screenId The ID of the screen where it should be added
 * @param cell The cell it should be added to, optional
 */
private void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, long screenId, int[] cell,
        int[] span) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.screenId = info.screenId = screenId;
    mPendingAddInfo.dropPos = null;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        // In the case where we've prebound the widget, we remove it from the DragLayer
        if (LOGD) {
            Log.d(TAG, "Removing widget view from drag layer and setting boundWidget to null");
        }
        getDragLayer().removeView(hostView);

        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetFromDropImpl(appWidgetId, info, hostView, info.info);

        // Clear the boundWidget so that it doesn't get destroyed.
        info.boundWidget = null;
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.info, options);
        if (success) {
            addAppWidgetFromDropImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            mAppWidgetManager.getUser(mPendingAddWidgetInfo).addToIntent(intent,
                    AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}

From source file:com.android.launcher3.Launcher.java

/**
 * Process a widget drop.//www  .java  2 s .c  o m
 */
private void addAppWidgetFromDrop(PendingAddWidgetInfo info) {
    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        // In the case where we've prebound the widget, we remove it from the DragLayer
        if (LOGD) {
            Log.d(TAG, "Removing widget view from drag layer and setting boundWidget to null");
        }
        getDragLayer().removeView(hostView);

        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetFromDropImpl(appWidgetId, info, hostView, info.info);

        // Clear the boundWidget so that it doesn't get destroyed.
        info.boundWidget = null;
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.info, options);
        if (success) {
            addAppWidgetFromDropImpl(appWidgetId, info, null, info.info);
        } else {
            setWaitingForResult(PendingRequestArgs.forWidgetInfo(appWidgetId, info.info, info));
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            mAppWidgetManager.getUser(info.info).addToIntent(intent,
                    AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}

From source file:g7.bluesky.launcher3.Launcher.java

/**
 * Process a widget drop./*from  ww  w.  j av  a2  s  .  c om*/
 *
 * @param info The PendingAppWidgetInfo of the widget being added.
 * @param screenId The ID of the screen where it should be added
 * @param cell The cell it should be added to, optional
 * @param position The location on the screen where it was dropped, optional
 */
void addAppWidgetFromDrop(PendingAddWidgetInfo info, long container, long screenId, int[] cell, int[] span,
        int[] loc) {
    resetAddInfo();
    mPendingAddInfo.container = info.container = container;
    mPendingAddInfo.screenId = info.screenId = screenId;
    mPendingAddInfo.dropPos = loc;
    mPendingAddInfo.minSpanX = info.minSpanX;
    mPendingAddInfo.minSpanY = info.minSpanY;

    if (cell != null) {
        mPendingAddInfo.cellX = cell[0];
        mPendingAddInfo.cellY = cell[1];
    }
    if (span != null) {
        mPendingAddInfo.spanX = span[0];
        mPendingAddInfo.spanY = span[1];
    }

    AppWidgetHostView hostView = info.boundWidget;
    int appWidgetId;
    if (hostView != null) {
        appWidgetId = hostView.getAppWidgetId();
        addAppWidgetImpl(appWidgetId, info, hostView, info.info);
    } else {
        // In this case, we either need to start an activity to get permission to bind
        // the widget, or we need to start an activity to configure the widget, or both.
        appWidgetId = getAppWidgetHost().allocateAppWidgetId();
        Bundle options = info.bindOptions;

        boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(appWidgetId, info.info, options);
        if (success) {
            addAppWidgetImpl(appWidgetId, info, null, info.info);
        } else {
            mPendingAddWidgetInfo = info.info;
            Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, info.componentName);
            mAppWidgetManager.getUser(mPendingAddWidgetInfo).addToIntent(intent,
                    AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
            // TODO: we need to make sure that this accounts for the options bundle.
            // intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_OPTIONS, options);
            startActivityForResult(intent, REQUEST_BIND_APPWIDGET);
        }
    }
}

From source file:com.android.launcher3.Launcher.java

/**
 * Event handler for the app widget view which has not fully restored.
 *///from w w w  .  j  a va  2s  . c o  m
public void onClickPendingWidget(final PendingAppWidgetHostView v) {
    if (mIsSafeModeEnabled) {
        Toast.makeText(this, R.string.safemode_widget_error, Toast.LENGTH_SHORT).show();
        return;
    }

    final LauncherAppWidgetInfo info = (LauncherAppWidgetInfo) v.getTag();
    if (v.isReadyForClickSetup()) {
        if (info.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_NOT_VALID)) {
            if (!info.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_ALLOCATED)) {
                // This should not happen, as we make sure that an Id is allocated during bind.
                return;
            }
            LauncherAppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.findProvider(info.providerName,
                    info.user);
            if (appWidgetInfo != null) {
                setWaitingForResult(PendingRequestArgs.forWidgetInfo(info.appWidgetId, appWidgetInfo, info));

                Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
                intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, info.appWidgetId);
                intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER, appWidgetInfo.provider);
                mAppWidgetManager.getUser(appWidgetInfo).addToIntent(intent,
                        AppWidgetManager.EXTRA_APPWIDGET_PROVIDER_PROFILE);
                startActivityForResult(intent, REQUEST_BIND_PENDING_APPWIDGET);
            }
        } else {
            LauncherAppWidgetProviderInfo appWidgetInfo = mAppWidgetManager
                    .getLauncherAppWidgetInfo(info.appWidgetId);
            if (appWidgetInfo != null) {
                startRestoredWidgetReconfigActivity(appWidgetInfo, info);
            }
        }
    } else if (info.installProgress < 0) {
        // The install has not been queued
        final String packageName = info.providerName.getPackageName();
        showBrokenAppInstallDialog(packageName, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                startActivitySafely(v, LauncherModel.getMarketIntent(packageName), info);
            }
        });
    } else {
        // Download has started.
        final String packageName = info.providerName.getPackageName();
        startActivitySafely(v, LauncherModel.getMarketIntent(packageName), info);
    }
}

From source file:com.piusvelte.sonet.core.SonetService.java

private void buildWidgetButtons(Integer appWidgetId, boolean updatesReady, int page, boolean hasbuttons,
        int scrollable, int buttons_bg_color, int buttons_color, int buttons_textsize, boolean display_profile,
        int margin) {
    final String widget = Integer.toString(appWidgetId);
    // Push update for this widget to the home screen
    int layout;//from   w  w  w  .j av  a  2  s.c om
    if (hasbuttons) {
        if (sNativeScrollingSupported) {
            if (margin > 0)
                layout = R.layout.widget_margin_scrollable;
            else
                layout = R.layout.widget_scrollable;
        } else if (display_profile) {
            if (margin > 0)
                layout = R.layout.widget_margin;
            else
                layout = R.layout.widget;
        } else {
            if (margin > 0)
                layout = R.layout.widget_noprofile_margin;
            else
                layout = R.layout.widget_noprofile;
        }
    } else {
        if (sNativeScrollingSupported) {
            if (margin > 0)
                layout = R.layout.widget_nobuttons_margin_scrollable;
            else
                layout = R.layout.widget_nobuttons_scrollable;
        } else if (display_profile) {
            if (margin > 0)
                layout = R.layout.widget_nobuttons_margin;
            else
                layout = R.layout.widget_nobuttons;
        } else {
            if (margin > 0)
                layout = R.layout.widget_nobuttons_noprofile_margin;
            else
                layout = R.layout.widget_nobuttons_noprofile;
        }
    }
    // wrap RemoteViews for backward compatibility
    RemoteViews views = new RemoteViews(getPackageName(), layout);
    if (hasbuttons) {
        Bitmap buttons_bg = Bitmap.createBitmap(1, 1, Config.ARGB_8888);
        Canvas buttons_bg_canvas = new Canvas(buttons_bg);
        buttons_bg_canvas.drawColor(buttons_bg_color);
        views.setImageViewBitmap(R.id.buttons_bg, buttons_bg);
        views.setTextColor(R.id.buttons_bg_clear, buttons_bg_color);
        views.setFloat(R.id.buttons_bg_clear, "setTextSize", buttons_textsize);
        views.setOnClickPendingIntent(R.id.button_post, PendingIntent.getActivity(SonetService.this, 0,
                Sonet.getPackageIntent(SonetService.this, SonetCreatePost.class)
                        .setAction(LauncherIntent.Action.ACTION_VIEW_CLICK)
                        .setData(Uri.withAppendedPath(Widgets.getContentUri(SonetService.this), widget)),
                0));
        views.setTextColor(R.id.button_post, buttons_color);
        views.setFloat(R.id.button_post, "setTextSize", buttons_textsize);
        views.setOnClickPendingIntent(R.id.button_configure, PendingIntent.getActivity(SonetService.this, 0,
                Sonet.getPackageIntent(SonetService.this, ManageAccounts.class).setAction(widget), 0));
        views.setTextColor(R.id.button_configure, buttons_color);
        views.setFloat(R.id.button_configure, "setTextSize", buttons_textsize);
        views.setOnClickPendingIntent(R.id.button_refresh, PendingIntent.getService(SonetService.this, 0,
                Sonet.getPackageIntent(SonetService.this, SonetService.class).setAction(widget), 0));
        views.setTextColor(R.id.button_refresh, buttons_color);
        views.setFloat(R.id.button_refresh, "setTextSize", buttons_textsize);
        views.setTextColor(R.id.page_up, buttons_color);
        views.setFloat(R.id.page_up, "setTextSize", buttons_textsize);
        views.setTextColor(R.id.page_down, buttons_color);
        views.setFloat(R.id.page_down, "setTextSize", buttons_textsize);
    }
    // set margin
    if (scrollable == 0) {
        final AppWidgetManager mgr = AppWidgetManager.getInstance(SonetService.this);
        // check if native scrolling is supported
        if (sNativeScrollingSupported) {
            // native scrolling
            try {
                final Intent intent = SonetRemoteViewsServiceWrapper.getRemoteAdapterIntent(SonetService.this);
                if (intent != null) {
                    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
                    intent.putExtra(Widgets.DISPLAY_PROFILE, display_profile);
                    intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
                    sSetRemoteAdapter.invoke(views, appWidgetId, R.id.messages, intent);
                    // empty
                    sSetEmptyView.invoke(views, R.id.messages, R.id.empty_messages);
                    // onclick
                    // Bind a click listener template for the contents of the message list
                    final Intent onClickIntent = Sonet.getPackageIntent(SonetService.this, SonetWidget.class);
                    onClickIntent.setAction(ACTION_ON_CLICK);
                    onClickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
                    onClickIntent.setData(Uri.parse(onClickIntent.toUri(Intent.URI_INTENT_SCHEME)));
                    final PendingIntent onClickPendingIntent = PendingIntent.getBroadcast(SonetService.this, 0,
                            onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
                    sSetPendingIntentTemplate.invoke(views, R.id.messages, onClickPendingIntent);
                } else {
                    // fallback on non-scrolling widget
                    sNativeScrollingSupported = false;
                }
            } catch (NumberFormatException e) {
                Log.e(TAG, e.toString());
            } catch (IllegalArgumentException e) {
                Log.e(TAG, e.toString());
            } catch (IllegalAccessException e) {
                Log.e(TAG, e.toString());
            } catch (InvocationTargetException e) {
                Log.e(TAG, e.toString());
            }

        }
        if (!sNativeScrollingSupported) {
            Cursor statuses_styles = getContentResolver().query(
                    Uri.withAppendedPath(Statuses_styles.getContentUri(SonetService.this), widget),
                    new String[] { Statuses_styles._ID, Statuses_styles.FRIEND, Statuses_styles.PROFILE,
                            Statuses_styles.MESSAGE, Statuses_styles.CREATEDTEXT,
                            Statuses_styles.MESSAGES_COLOR, Statuses_styles.FRIEND_COLOR,
                            Statuses_styles.CREATED_COLOR, Statuses_styles.MESSAGES_TEXTSIZE,
                            Statuses_styles.FRIEND_TEXTSIZE, Statuses_styles.CREATED_TEXTSIZE,
                            Statuses_styles.STATUS_BG, Statuses_styles.ICON, Statuses_styles.PROFILE_BG,
                            Statuses_styles.FRIEND_BG, Statuses_styles.IMAGE_BG, Statuses_styles.IMAGE },
                    null, null, Statuses_styles.CREATED + " DESC LIMIT " + page + ",-1");
            if (statuses_styles.moveToFirst()) {
                int count_status = 0;
                views.removeAllViews(R.id.messages);
                while (!statuses_styles.isAfterLast() && (count_status < 16)) {
                    int friend_color = statuses_styles.getInt(6), created_color = statuses_styles.getInt(7),
                            friend_textsize = statuses_styles.getInt(9),
                            created_textsize = statuses_styles.getInt(10),
                            messages_color = statuses_styles.getInt(5),
                            messages_textsize = statuses_styles.getInt(8);
                    // get the item wrapper
                    RemoteViews itemView;
                    if (display_profile) {
                        itemView = new RemoteViews(getPackageName(), R.layout.widget_item);
                        // set profiles background
                        byte[] profile_bg = statuses_styles.getBlob(13);
                        if (profile_bg != null) {
                            Bitmap profile_bgbmp = BitmapFactory.decodeByteArray(profile_bg, 0,
                                    profile_bg.length, sBFOptions);
                            if (profile_bgbmp != null)
                                itemView.setImageViewBitmap(R.id.profile_bg, profile_bgbmp);
                        }
                        byte[] profile = statuses_styles.getBlob(2);
                        if (profile != null) {
                            Bitmap profilebmp = BitmapFactory.decodeByteArray(profile, 0, profile.length,
                                    sBFOptions);
                            if (profilebmp != null)
                                itemView.setImageViewBitmap(R.id.profile, profilebmp);
                        }
                    } else
                        itemView = new RemoteViews(getPackageName(), R.layout.widget_item_noprofile);
                    itemView.setTextViewText(R.id.friend_bg_clear, statuses_styles.getString(1));
                    itemView.setFloat(R.id.friend_bg_clear, "setTextSize", friend_textsize);
                    itemView.setTextViewText(R.id.message_bg_clear, statuses_styles.getString(3));
                    itemView.setFloat(R.id.message_bg_clear, "setTextSize", messages_textsize);
                    // set friends background
                    byte[] friend_bg = statuses_styles.getBlob(14);
                    if (friend_bg != null) {
                        Bitmap friend_bgbmp = BitmapFactory.decodeByteArray(friend_bg, 0, friend_bg.length,
                                sBFOptions);
                        if (friend_bgbmp != null)
                            itemView.setImageViewBitmap(R.id.friend_bg, friend_bgbmp);
                    }
                    // set messages background
                    byte[] status_bg = statuses_styles.getBlob(11);
                    if (status_bg != null) {
                        Bitmap status_bgbmp = BitmapFactory.decodeByteArray(status_bg, 0, status_bg.length,
                                sBFOptions);
                        if (status_bgbmp != null)
                            itemView.setImageViewBitmap(R.id.status_bg, status_bgbmp);
                    }
                    // set an image
                    byte[] image_bg = statuses_styles.getBlob(15);
                    byte[] image = statuses_styles.getBlob(16);
                    if ((image_bg != null) && (image != null)) {
                        Bitmap image_bgBmp = BitmapFactory.decodeByteArray(image_bg, 0, image_bg.length,
                                sBFOptions);
                        if (image_bgBmp != null) {
                            Bitmap imageBmp = BitmapFactory.decodeByteArray(image, 0, image.length, sBFOptions);
                            itemView.setImageViewBitmap(R.id.image_clear, image_bgBmp);
                            itemView.setImageViewBitmap(R.id.image, imageBmp);
                        }
                    }
                    itemView.setTextViewText(R.id.message, statuses_styles.getString(3));
                    itemView.setTextColor(R.id.message, messages_color);
                    itemView.setFloat(R.id.message, "setTextSize", messages_textsize);
                    itemView.setOnClickPendingIntent(R.id.item,
                            PendingIntent.getActivity(SonetService.this, 0,
                                    Sonet.getPackageIntent(SonetService.this, StatusDialog.class)
                                            .setData(Uri.withAppendedPath(
                                                    Statuses_styles.getContentUri(SonetService.this),
                                                    Long.toString(statuses_styles.getLong(0)))),
                                    0));
                    itemView.setTextViewText(R.id.friend, statuses_styles.getString(1));
                    itemView.setTextColor(R.id.friend, friend_color);
                    itemView.setFloat(R.id.friend, "setTextSize", friend_textsize);
                    itemView.setTextViewText(R.id.created, statuses_styles.getString(4));
                    itemView.setTextColor(R.id.created, created_color);
                    itemView.setFloat(R.id.created, "setTextSize", created_textsize);
                    // set icons
                    byte[] icon = statuses_styles.getBlob(12);
                    if (icon != null) {
                        Bitmap iconbmp = BitmapFactory.decodeByteArray(icon, 0, icon.length, sBFOptions);
                        if (iconbmp != null)
                            itemView.setImageViewBitmap(R.id.icon, iconbmp);
                    }
                    views.addView(R.id.messages, itemView);
                    count_status++;
                    statuses_styles.moveToNext();
                }
                if (hasbuttons && (page < statuses_styles.getCount())) {
                    // there are more statuses to show, allow paging down
                    views.setOnClickPendingIntent(R.id.page_down, PendingIntent.getService(SonetService.this, 0,
                            Sonet.getPackageIntent(SonetService.this, SonetService.class)
                                    .setAction(ACTION_PAGE_DOWN)
                                    .setData(Uri.withAppendedPath(Widgets.getContentUri(SonetService.this),
                                            widget))
                                    .putExtra(ACTION_PAGE_DOWN, page + 1),
                            PendingIntent.FLAG_UPDATE_CURRENT));
                }
            }
            statuses_styles.close();
            if (hasbuttons && (page > 0))
                views.setOnClickPendingIntent(R.id.page_up, PendingIntent.getService(SonetService.this, 0,
                        Sonet.getPackageIntent(SonetService.this, SonetService.class).setAction(ACTION_PAGE_UP)
                                .setData(Uri.withAppendedPath(Widgets.getContentUri(SonetService.this), widget))
                                .putExtra(ACTION_PAGE_UP, page - 1),
                        PendingIntent.FLAG_UPDATE_CURRENT));
        }
        Log.d(TAG, "update native widget: " + appWidgetId);
        mgr.updateAppWidget(appWidgetId, views);
        if (sNativeScrollingSupported) {
            Log.d(TAG, "trigger widget query: " + appWidgetId);
            try {
                // trigger query
                sNotifyAppWidgetViewDataChanged.invoke(mgr, appWidgetId, R.id.messages);
            } catch (NumberFormatException e) {
                Log.e(TAG, e.toString());
            } catch (IllegalArgumentException e) {
                Log.e(TAG, e.toString());
            } catch (IllegalAccessException e) {
                Log.e(TAG, e.toString());
            } catch (InvocationTargetException e) {
                Log.e(TAG, e.toString());
            }
        }
    } else if (updatesReady) {
        //         Log.d(TAG, "notify updatesReady");
        getContentResolver().notifyChange(Statuses_styles.getContentUri(SonetService.this), null);
    } else {
        AppWidgetManager.getInstance(SonetService.this).updateAppWidget(Integer.parseInt(widget), views);
        buildScrollableWidget(appWidgetId, scrollable, display_profile);
    }
}

From source file:com.shafiq.myfeedle.core.MyfeedleService.java

private void buildWidgetButtons(Integer appWidgetId, boolean updatesReady, int page, boolean hasbuttons,
        int scrollable, int buttons_bg_color, int buttons_color, int buttons_textsize, boolean display_profile,
        int margin) {
    final String widget = Integer.toString(appWidgetId);
    // Push update for this widget to the home screen
    int layout;// w w w. j ava 2 s  .c  o  m
    if (hasbuttons) {
        if (sNativeScrollingSupported) {
            if (margin > 0)
                layout = R.layout.widget_margin_scrollable;
            else
                layout = R.layout.widget_scrollable;
        } else if (display_profile) {
            if (margin > 0)
                layout = R.layout.widget_margin;
            else
                layout = R.layout.widget;
        } else {
            if (margin > 0)
                layout = R.layout.widget_noprofile_margin;
            else
                layout = R.layout.widget_noprofile;
        }
    } else {
        if (sNativeScrollingSupported) {
            if (margin > 0)
                layout = R.layout.widget_nobuttons_margin_scrollable;
            else
                layout = R.layout.widget_nobuttons_scrollable;
        } else if (display_profile) {
            if (margin > 0)
                layout = R.layout.widget_nobuttons_margin;
            else
                layout = R.layout.widget_nobuttons;
        } else {
            if (margin > 0)
                layout = R.layout.widget_nobuttons_noprofile_margin;
            else
                layout = R.layout.widget_nobuttons_noprofile;
        }
    }
    // wrap RemoteViews for backward compatibility
    RemoteViews views = new RemoteViews(getPackageName(), layout);
    if (hasbuttons) {
        Bitmap buttons_bg = Bitmap.createBitmap(1, 1, Config.ARGB_8888);
        Canvas buttons_bg_canvas = new Canvas(buttons_bg);
        buttons_bg_canvas.drawColor(buttons_bg_color);
        views.setImageViewBitmap(R.id.buttons_bg, buttons_bg);
        views.setTextColor(R.id.buttons_bg_clear, buttons_bg_color);
        views.setFloat(R.id.buttons_bg_clear, "setTextSize", buttons_textsize);
        views.setOnClickPendingIntent(R.id.button_post,
                PendingIntent.getActivity(MyfeedleService.this, 0,
                        Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleCreatePost.class)
                                .setAction(LauncherIntent.Action.ACTION_VIEW_CLICK).setData(Uri
                                        .withAppendedPath(Widgets.getContentUri(MyfeedleService.this), widget)),
                        0));
        views.setTextColor(R.id.button_post, buttons_color);
        views.setFloat(R.id.button_post, "setTextSize", buttons_textsize);
        views.setOnClickPendingIntent(R.id.button_configure, PendingIntent.getActivity(MyfeedleService.this, 0,
                Myfeedle.getPackageIntent(MyfeedleService.this, ManageAccounts.class).setAction(widget), 0));
        views.setTextColor(R.id.button_configure, buttons_color);
        views.setFloat(R.id.button_configure, "setTextSize", buttons_textsize);
        views.setOnClickPendingIntent(R.id.button_refresh, PendingIntent.getService(MyfeedleService.this, 0,
                Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleService.class).setAction(widget), 0));
        views.setTextColor(R.id.button_refresh, buttons_color);
        views.setFloat(R.id.button_refresh, "setTextSize", buttons_textsize);
        views.setTextColor(R.id.page_up, buttons_color);
        views.setFloat(R.id.page_up, "setTextSize", buttons_textsize);
        views.setTextColor(R.id.page_down, buttons_color);
        views.setFloat(R.id.page_down, "setTextSize", buttons_textsize);
    }
    // set margin
    if (scrollable == 0) {
        final AppWidgetManager mgr = AppWidgetManager.getInstance(MyfeedleService.this);
        // check if native scrolling is supported
        if (sNativeScrollingSupported) {
            // native scrolling
            try {
                final Intent intent = MyfeedleRemoteViewsServiceWrapper
                        .getRemoteAdapterIntent(MyfeedleService.this);
                if (intent != null) {
                    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
                    intent.putExtra(Widgets.DISPLAY_PROFILE, display_profile);
                    intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
                    sSetRemoteAdapter.invoke(views, appWidgetId, R.id.messages, intent);
                    // empty
                    sSetEmptyView.invoke(views, R.id.messages, R.id.empty_messages);
                    // onclick
                    // Bind a click listener template for the contents of the message list
                    final Intent onClickIntent = Myfeedle.getPackageIntent(MyfeedleService.this,
                            MyfeedleWidget.class);
                    onClickIntent.setAction(ACTION_ON_CLICK);
                    onClickIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
                    onClickIntent.setData(Uri.parse(onClickIntent.toUri(Intent.URI_INTENT_SCHEME)));
                    final PendingIntent onClickPendingIntent = PendingIntent.getBroadcast(MyfeedleService.this,
                            0, onClickIntent, PendingIntent.FLAG_UPDATE_CURRENT);
                    sSetPendingIntentTemplate.invoke(views, R.id.messages, onClickPendingIntent);
                } else {
                    // fallback on non-scrolling widget
                    sNativeScrollingSupported = false;
                }
            } catch (NumberFormatException e) {
                Log.e(TAG, e.toString());
            } catch (IllegalArgumentException e) {
                Log.e(TAG, e.toString());
            } catch (IllegalAccessException e) {
                Log.e(TAG, e.toString());
            } catch (InvocationTargetException e) {
                Log.e(TAG, e.toString());
            }

        }
        if (!sNativeScrollingSupported) {
            Cursor statuses_styles = getContentResolver().query(
                    Uri.withAppendedPath(Statuses_styles.getContentUri(MyfeedleService.this), widget),
                    new String[] { Statuses_styles._ID, Statuses_styles.FRIEND, Statuses_styles.PROFILE,
                            Statuses_styles.MESSAGE, Statuses_styles.CREATEDTEXT,
                            Statuses_styles.MESSAGES_COLOR, Statuses_styles.FRIEND_COLOR,
                            Statuses_styles.CREATED_COLOR, Statuses_styles.MESSAGES_TEXTSIZE,
                            Statuses_styles.FRIEND_TEXTSIZE, Statuses_styles.CREATED_TEXTSIZE,
                            Statuses_styles.STATUS_BG, Statuses_styles.ICON, Statuses_styles.PROFILE_BG,
                            Statuses_styles.FRIEND_BG, Statuses_styles.IMAGE_BG, Statuses_styles.IMAGE },
                    null, null, Statuses_styles.CREATED + " DESC LIMIT " + page + ",-1");
            if (statuses_styles.moveToFirst()) {
                int count_status = 0;
                views.removeAllViews(R.id.messages);
                while (!statuses_styles.isAfterLast() && (count_status < 16)) {
                    int friend_color = statuses_styles.getInt(6), created_color = statuses_styles.getInt(7),
                            friend_textsize = statuses_styles.getInt(9),
                            created_textsize = statuses_styles.getInt(10),
                            messages_color = statuses_styles.getInt(5),
                            messages_textsize = statuses_styles.getInt(8);
                    // get the item wrapper
                    RemoteViews itemView;
                    if (display_profile) {
                        itemView = new RemoteViews(getPackageName(), R.layout.widget_item);
                        // set profiles background
                        byte[] profile_bg = statuses_styles.getBlob(13);
                        if (profile_bg != null) {
                            Bitmap profile_bgbmp = BitmapFactory.decodeByteArray(profile_bg, 0,
                                    profile_bg.length, sBFOptions);
                            if (profile_bgbmp != null)
                                itemView.setImageViewBitmap(R.id.profile_bg, profile_bgbmp);
                        }
                        byte[] profile = statuses_styles.getBlob(2);
                        if (profile != null) {
                            Bitmap profilebmp = BitmapFactory.decodeByteArray(profile, 0, profile.length,
                                    sBFOptions);
                            if (profilebmp != null)
                                itemView.setImageViewBitmap(R.id.profile, profilebmp);
                        }
                    } else
                        itemView = new RemoteViews(getPackageName(), R.layout.widget_item_noprofile);
                    itemView.setTextViewText(R.id.friend_bg_clear, statuses_styles.getString(1));
                    itemView.setFloat(R.id.friend_bg_clear, "setTextSize", friend_textsize);
                    itemView.setTextViewText(R.id.message_bg_clear, statuses_styles.getString(3));
                    itemView.setFloat(R.id.message_bg_clear, "setTextSize", messages_textsize);
                    // set friends background
                    byte[] friend_bg = statuses_styles.getBlob(14);
                    if (friend_bg != null) {
                        Bitmap friend_bgbmp = BitmapFactory.decodeByteArray(friend_bg, 0, friend_bg.length,
                                sBFOptions);
                        if (friend_bgbmp != null)
                            itemView.setImageViewBitmap(R.id.friend_bg, friend_bgbmp);
                    }
                    // set messages background
                    byte[] status_bg = statuses_styles.getBlob(11);
                    if (status_bg != null) {
                        Bitmap status_bgbmp = BitmapFactory.decodeByteArray(status_bg, 0, status_bg.length,
                                sBFOptions);
                        if (status_bgbmp != null)
                            itemView.setImageViewBitmap(R.id.status_bg, status_bgbmp);
                    }
                    // set an image
                    byte[] image_bg = statuses_styles.getBlob(15);
                    byte[] image = statuses_styles.getBlob(16);
                    if ((image_bg != null) && (image != null)) {
                        Bitmap image_bgBmp = BitmapFactory.decodeByteArray(image_bg, 0, image_bg.length,
                                sBFOptions);
                        if (image_bgBmp != null) {
                            Bitmap imageBmp = BitmapFactory.decodeByteArray(image, 0, image.length, sBFOptions);
                            itemView.setImageViewBitmap(R.id.image_clear, image_bgBmp);
                            itemView.setImageViewBitmap(R.id.image, imageBmp);
                        }
                    }
                    itemView.setTextViewText(R.id.message, statuses_styles.getString(3));
                    itemView.setTextColor(R.id.message, messages_color);
                    itemView.setFloat(R.id.message, "setTextSize", messages_textsize);
                    itemView.setOnClickPendingIntent(R.id.item,
                            PendingIntent.getActivity(MyfeedleService.this, 0,
                                    Myfeedle.getPackageIntent(MyfeedleService.this, StatusDialog.class)
                                            .setData(Uri.withAppendedPath(
                                                    Statuses_styles.getContentUri(MyfeedleService.this),
                                                    Long.toString(statuses_styles.getLong(0)))),
                                    0));
                    itemView.setTextViewText(R.id.friend, statuses_styles.getString(1));
                    itemView.setTextColor(R.id.friend, friend_color);
                    itemView.setFloat(R.id.friend, "setTextSize", friend_textsize);
                    itemView.setTextViewText(R.id.created, statuses_styles.getString(4));
                    itemView.setTextColor(R.id.created, created_color);
                    itemView.setFloat(R.id.created, "setTextSize", created_textsize);
                    // set icons
                    byte[] icon = statuses_styles.getBlob(12);
                    if (icon != null) {
                        Bitmap iconbmp = BitmapFactory.decodeByteArray(icon, 0, icon.length, sBFOptions);
                        if (iconbmp != null)
                            itemView.setImageViewBitmap(R.id.icon, iconbmp);
                    }
                    views.addView(R.id.messages, itemView);
                    count_status++;
                    statuses_styles.moveToNext();
                }
                if (hasbuttons && (page < statuses_styles.getCount())) {
                    // there are more statuses to show, allow paging down
                    views.setOnClickPendingIntent(R.id.page_down, PendingIntent.getService(MyfeedleService.this,
                            0,
                            Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleService.class)
                                    .setAction(ACTION_PAGE_DOWN)
                                    .setData(Uri.withAppendedPath(Widgets.getContentUri(MyfeedleService.this),
                                            widget))
                                    .putExtra(ACTION_PAGE_DOWN, page + 1),
                            PendingIntent.FLAG_UPDATE_CURRENT));
                }
            }
            statuses_styles.close();
            if (hasbuttons && (page > 0))
                views.setOnClickPendingIntent(R.id.page_up, PendingIntent.getService(MyfeedleService.this, 0,
                        Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleService.class)
                                .setAction(ACTION_PAGE_UP)
                                .setData(Uri.withAppendedPath(Widgets.getContentUri(MyfeedleService.this),
                                        widget))
                                .putExtra(ACTION_PAGE_UP, page - 1),
                        PendingIntent.FLAG_UPDATE_CURRENT));
        }
        Log.d(TAG, "update native widget: " + appWidgetId);
        mgr.updateAppWidget(appWidgetId, views);
        if (sNativeScrollingSupported) {
            Log.d(TAG, "trigger widget query: " + appWidgetId);
            try {
                // trigger query
                sNotifyAppWidgetViewDataChanged.invoke(mgr, appWidgetId, R.id.messages);
            } catch (NumberFormatException e) {
                Log.e(TAG, e.toString());
            } catch (IllegalArgumentException e) {
                Log.e(TAG, e.toString());
            } catch (IllegalAccessException e) {
                Log.e(TAG, e.toString());
            } catch (InvocationTargetException e) {
                Log.e(TAG, e.toString());
            }
        }
    } else if (updatesReady) {
        //         Log.d(TAG, "notify updatesReady");
        getContentResolver().notifyChange(Statuses_styles.getContentUri(MyfeedleService.this), null);
    } else {
        AppWidgetManager.getInstance(MyfeedleService.this).updateAppWidget(Integer.parseInt(widget), views);
        buildScrollableWidget(appWidgetId, scrollable, display_profile);
    }
}

From source file:com.piusvelte.sonet.core.SonetService.java

private void buildScrollableWidget(Integer appWidgetId, int scrollableVersion, boolean display_profile) {
    // set widget as scrollable
    Intent replaceDummy = new Intent(LauncherIntent.Action.ACTION_SCROLL_WIDGET_START);
    replaceDummy.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    replaceDummy.putExtra(LauncherIntent.Extra.EXTRA_VIEW_ID, R.id.messages);
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_LISTVIEW_LAYOUT_ID, R.layout.widget_listview);
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_DATA_PROVIDER_ALLOW_REQUERY, true);
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_CHILDREN_CLICKABLE, true);

    //provider//from w ww.  j a va2 s .c o  m
    Uri uri = Uri.withAppendedPath(Statuses_styles.getContentUri(SonetService.this),
            Integer.toString(appWidgetId));
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_DATA_URI, uri.toString());
    String[] projection;
    if (display_profile)
        projection = new String[] { Statuses_styles._ID, Statuses_styles.FRIEND, Statuses_styles.PROFILE,
                Statuses_styles.MESSAGE, Statuses_styles.CREATEDTEXT, Statuses_styles.MESSAGES_COLOR,
                Statuses_styles.FRIEND_COLOR, Statuses_styles.CREATED_COLOR, Statuses_styles.MESSAGES_TEXTSIZE,
                Statuses_styles.FRIEND_TEXTSIZE, Statuses_styles.CREATED_TEXTSIZE, Statuses_styles.STATUS_BG,
                Statuses_styles.ICON, Statuses_styles.PROFILE_BG, Statuses_styles.FRIEND_BG,
                Statuses_styles.IMAGE_BG, Statuses_styles.IMAGE };
    else
        projection = new String[] { Statuses_styles._ID, Statuses_styles.FRIEND, Statuses_styles.PROFILE,
                Statuses_styles.MESSAGE, Statuses_styles.CREATEDTEXT, Statuses_styles.MESSAGES_COLOR,
                Statuses_styles.FRIEND_COLOR, Statuses_styles.CREATED_COLOR, Statuses_styles.MESSAGES_TEXTSIZE,
                Statuses_styles.FRIEND_TEXTSIZE, Statuses_styles.CREATED_TEXTSIZE, Statuses_styles.STATUS_BG,
                Statuses_styles.ICON, Statuses_styles.FRIEND_BG, Statuses_styles.IMAGE_BG,
                Statuses_styles.IMAGE };
    String sortOrder = Statuses_styles.CREATED + " DESC";
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_PROJECTION, projection);
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_SORT_ORDER, sortOrder);
    String whereClause = Statuses_styles.WIDGET + "=?";
    String[] selectionArgs = new String[] { Integer.toString(appWidgetId) };
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_SELECTION, whereClause);
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_SELECTION_ARGUMENTS, selectionArgs);
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_ACTION_VIEW_URI_INDEX,
            SonetProvider.StatusesStylesColumns._id.ordinal());

    switch (scrollableVersion) {
    case 1:
        if (display_profile) {
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_ID, R.layout.widget_item);
            int[] cursorIndices = new int[] { SonetProvider.StatusesStylesColumns.friend.ordinal(),
                    SonetProvider.StatusesStylesColumns.message.ordinal(),
                    SonetProvider.StatusesStylesColumns.status_bg.ordinal(),
                    SonetProvider.StatusesStylesColumns.profile.ordinal(),
                    SonetProvider.StatusesStylesColumns.friend.ordinal(),
                    SonetProvider.StatusesStylesColumns.createdtext.ordinal(),
                    SonetProvider.StatusesStylesColumns.message.ordinal(),
                    SonetProvider.StatusesStylesColumns.icon.ordinal(),
                    SonetProvider.StatusesStylesColumns.profile_bg.ordinal(),
                    SonetProvider.StatusesStylesColumns.friend_bg.ordinal(),
                    SonetProvider.StatusesStylesColumns.image_bg.ordinal(),
                    SonetProvider.StatusesStylesColumns.image.ordinal() };
            int[] viewTypes = new int[] { LauncherIntent.Extra.Scroll.Types.TEXTVIEW,
                    LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB,
                    LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.TEXTVIEW,
                    LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW,
                    LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB,
                    LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB,
                    LauncherIntent.Extra.Scroll.Types.IMAGEBLOB };
            int[] layoutIds = new int[] { R.id.friend_bg_clear, R.id.message_bg_clear, R.id.status_bg,
                    R.id.profile, R.id.friend, R.id.created, R.id.message, R.id.icon, R.id.profile_bg,
                    R.id.friend_bg, R.id.image_clear, R.id.image };
            int[] defaultResource = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            boolean[] clickable = new boolean[] { false, false, true, false, false, false, false, false, false,
                    false, false, false };
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_CURSOR_INDICES, cursorIndices);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_TYPES, viewTypes);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_IDS, layoutIds);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_DEFAULT_RESOURCES, defaultResource);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_CLICKABLE, clickable);
        } else {
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_ID,
                    R.layout.widget_item_noprofile);
            int[] cursorIndices = new int[] { SonetProvider.StatusesStylesColumnsNoProfile.friend.ordinal(),
                    SonetProvider.StatusesStylesColumnsNoProfile.message.ordinal(),
                    SonetProvider.StatusesStylesColumnsNoProfile.status_bg.ordinal(),
                    SonetProvider.StatusesStylesColumnsNoProfile.friend.ordinal(),
                    SonetProvider.StatusesStylesColumnsNoProfile.createdtext.ordinal(),
                    SonetProvider.StatusesStylesColumnsNoProfile.message.ordinal(),
                    SonetProvider.StatusesStylesColumnsNoProfile.icon.ordinal(),
                    SonetProvider.StatusesStylesColumnsNoProfile.friend_bg.ordinal(),
                    SonetProvider.StatusesStylesColumnsNoProfile.image_bg.ordinal(),
                    SonetProvider.StatusesStylesColumnsNoProfile.image.ordinal() };
            int[] viewTypes = new int[] { LauncherIntent.Extra.Scroll.Types.TEXTVIEW,
                    LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB,
                    LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW,
                    LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB,
                    LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB,
                    LauncherIntent.Extra.Scroll.Types.IMAGEBLOB };
            int[] layoutIds = new int[] { R.id.friend_bg_clear, R.id.message_bg_clear, R.id.status_bg,
                    R.id.friend, R.id.created, R.id.message, R.id.icon, R.id.friend_bg, R.id.image_clear,
                    R.id.image };
            int[] defaultResource = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            boolean[] clickable = new boolean[] { false, false, true, false, false, false, false, false, false,
                    false };
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_CURSOR_INDICES, cursorIndices);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_TYPES, viewTypes);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_IDS, layoutIds);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_DEFAULT_RESOURCES, defaultResource);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_CLICKABLE, clickable);
        }
        break;
    case 2:
        if (display_profile) {
            BoundRemoteViews itemViews = new BoundRemoteViews(R.layout.widget_item);

            Intent i = Sonet.getPackageIntent(SonetService.this, SonetWidget.class)
                    .setAction(LauncherIntent.Action.ACTION_VIEW_CLICK).setData(uri)
                    .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            PendingIntent pi = PendingIntent.getBroadcast(SonetService.this, 0, i, 0);

            itemViews.SetBoundOnClickIntent(R.id.item, pi, LauncherIntent.Extra.Scroll.EXTRA_ITEM_POS,
                    SonetProvider.StatusesStylesColumns._id.ordinal());

            itemViews.setBoundCharSequence(R.id.friend_bg_clear, "setText",
                    SonetProvider.StatusesStylesColumns.friend.ordinal(), 0);
            itemViews.setBoundFloat(R.id.friend_bg_clear, "setTextSize",
                    SonetProvider.StatusesStylesColumns.friend_textsize.ordinal());

            itemViews.setBoundCharSequence(R.id.message_bg_clear, "setText",
                    SonetProvider.StatusesStylesColumns.message.ordinal(), 0);
            itemViews.setBoundFloat(R.id.message_bg_clear, "setTextSize",
                    SonetProvider.StatusesStylesColumns.messages_textsize.ordinal());

            itemViews.setBoundBitmap(R.id.status_bg, "setImageBitmap",
                    SonetProvider.StatusesStylesColumns.status_bg.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.image_clear, "setImageBitmap",
                    SonetProvider.StatusesStylesColumns.image_bg.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.image, "setImageBitmap",
                    SonetProvider.StatusesStylesColumns.image.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.profile, "setImageBitmap",
                    SonetProvider.StatusesStylesColumns.profile.ordinal(), 0);
            itemViews.setBoundCharSequence(R.id.friend, "setText",
                    SonetProvider.StatusesStylesColumns.friend.ordinal(), 0);
            itemViews.setBoundCharSequence(R.id.created, "setText",
                    SonetProvider.StatusesStylesColumns.createdtext.ordinal(), 0);
            itemViews.setBoundCharSequence(R.id.message, "setText",
                    SonetProvider.StatusesStylesColumns.message.ordinal(), 0);

            itemViews.setBoundInt(R.id.friend, "setTextColor",
                    SonetProvider.StatusesStylesColumns.friend_color.ordinal());
            itemViews.setBoundInt(R.id.created, "setTextColor",
                    SonetProvider.StatusesStylesColumns.created_color.ordinal());
            itemViews.setBoundInt(R.id.message, "setTextColor",
                    SonetProvider.StatusesStylesColumns.messages_color.ordinal());

            itemViews.setBoundFloat(R.id.friend, "setTextSize",
                    SonetProvider.StatusesStylesColumns.friend_textsize.ordinal());
            itemViews.setBoundFloat(R.id.created, "setTextSize",
                    SonetProvider.StatusesStylesColumns.created_textsize.ordinal());
            itemViews.setBoundFloat(R.id.message, "setTextSize",
                    SonetProvider.StatusesStylesColumns.messages_textsize.ordinal());

            itemViews.setBoundBitmap(R.id.icon, "setImageBitmap",
                    SonetProvider.StatusesStylesColumns.icon.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.profile_bg, "setImageBitmap",
                    SonetProvider.StatusesStylesColumns.profile_bg.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.friend_bg, "setImageBitmap",
                    SonetProvider.StatusesStylesColumns.friend_bg.ordinal(), 0);

            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_REMOTEVIEWS, itemViews);
        } else {
            BoundRemoteViews itemViews = new BoundRemoteViews(R.layout.widget_item_noprofile);

            Intent i = Sonet.getPackageIntent(SonetService.this, SonetWidget.class)
                    .setAction(LauncherIntent.Action.ACTION_VIEW_CLICK).setData(uri)
                    .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            PendingIntent pi = PendingIntent.getBroadcast(SonetService.this, 0, i, 0);

            itemViews.SetBoundOnClickIntent(R.id.item, pi, LauncherIntent.Extra.Scroll.EXTRA_ITEM_POS,
                    SonetProvider.StatusesStylesColumnsNoProfile._id.ordinal());

            itemViews.setBoundCharSequence(R.id.friend_bg_clear, "setText",
                    SonetProvider.StatusesStylesColumnsNoProfile.friend.ordinal(), 0);
            itemViews.setBoundFloat(R.id.friend_bg_clear, "setTextSize",
                    SonetProvider.StatusesStylesColumnsNoProfile.friend_textsize.ordinal());

            itemViews.setBoundCharSequence(R.id.message_bg_clear, "setText",
                    SonetProvider.StatusesStylesColumnsNoProfile.message.ordinal(), 0);
            itemViews.setBoundFloat(R.id.message_bg_clear, "setTextSize",
                    SonetProvider.StatusesStylesColumnsNoProfile.messages_textsize.ordinal());

            itemViews.setBoundBitmap(R.id.status_bg, "setImageBitmap",
                    SonetProvider.StatusesStylesColumnsNoProfile.status_bg.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.image_clear, "setImageBitmap",
                    SonetProvider.StatusesStylesColumnsNoProfile.image_bg.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.image, "setImageBitmap",
                    SonetProvider.StatusesStylesColumnsNoProfile.image.ordinal(), 0);

            itemViews.setBoundCharSequence(R.id.friend, "setText",
                    SonetProvider.StatusesStylesColumnsNoProfile.friend.ordinal(), 0);
            itemViews.setBoundCharSequence(R.id.created, "setText",
                    SonetProvider.StatusesStylesColumnsNoProfile.createdtext.ordinal(), 0);
            itemViews.setBoundCharSequence(R.id.message, "setText",
                    SonetProvider.StatusesStylesColumnsNoProfile.message.ordinal(), 0);

            itemViews.setBoundInt(R.id.friend, "setTextColor",
                    SonetProvider.StatusesStylesColumnsNoProfile.friend_color.ordinal());
            itemViews.setBoundInt(R.id.created, "setTextColor",
                    SonetProvider.StatusesStylesColumnsNoProfile.created_color.ordinal());
            itemViews.setBoundInt(R.id.message, "setTextColor",
                    SonetProvider.StatusesStylesColumnsNoProfile.messages_color.ordinal());

            itemViews.setBoundFloat(R.id.friend, "setTextSize",
                    SonetProvider.StatusesStylesColumnsNoProfile.friend_textsize.ordinal());
            itemViews.setBoundFloat(R.id.created, "setTextSize",
                    SonetProvider.StatusesStylesColumnsNoProfile.created_textsize.ordinal());
            itemViews.setBoundFloat(R.id.message, "setTextSize",
                    SonetProvider.StatusesStylesColumnsNoProfile.messages_textsize.ordinal());

            itemViews.setBoundBitmap(R.id.icon, "setImageBitmap",
                    SonetProvider.StatusesStylesColumnsNoProfile.icon.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.friend_bg, "setImageBitmap",
                    SonetProvider.StatusesStylesColumnsNoProfile.friend_bg.ordinal(), 0);

            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_REMOTEVIEWS, itemViews);
        }
        break;
    }
    sendBroadcast(replaceDummy);
}

From source file:com.shafiq.myfeedle.core.MyfeedleService.java

private void buildScrollableWidget(Integer appWidgetId, int scrollableVersion, boolean display_profile) {
    // set widget as scrollable
    Intent replaceDummy = new Intent(LauncherIntent.Action.ACTION_SCROLL_WIDGET_START);
    replaceDummy.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    replaceDummy.putExtra(LauncherIntent.Extra.EXTRA_VIEW_ID, R.id.messages);
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_LISTVIEW_LAYOUT_ID, R.layout.widget_listview);
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_DATA_PROVIDER_ALLOW_REQUERY, true);
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_CHILDREN_CLICKABLE, true);

    //provider//from  w  w w .  j ava2  s . com
    Uri uri = Uri.withAppendedPath(Statuses_styles.getContentUri(MyfeedleService.this),
            Integer.toString(appWidgetId));
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_DATA_URI, uri.toString());
    String[] projection;
    if (display_profile)
        projection = new String[] { Statuses_styles._ID, Statuses_styles.FRIEND, Statuses_styles.PROFILE,
                Statuses_styles.MESSAGE, Statuses_styles.CREATEDTEXT, Statuses_styles.MESSAGES_COLOR,
                Statuses_styles.FRIEND_COLOR, Statuses_styles.CREATED_COLOR, Statuses_styles.MESSAGES_TEXTSIZE,
                Statuses_styles.FRIEND_TEXTSIZE, Statuses_styles.CREATED_TEXTSIZE, Statuses_styles.STATUS_BG,
                Statuses_styles.ICON, Statuses_styles.PROFILE_BG, Statuses_styles.FRIEND_BG,
                Statuses_styles.IMAGE_BG, Statuses_styles.IMAGE };
    else
        projection = new String[] { Statuses_styles._ID, Statuses_styles.FRIEND, Statuses_styles.PROFILE,
                Statuses_styles.MESSAGE, Statuses_styles.CREATEDTEXT, Statuses_styles.MESSAGES_COLOR,
                Statuses_styles.FRIEND_COLOR, Statuses_styles.CREATED_COLOR, Statuses_styles.MESSAGES_TEXTSIZE,
                Statuses_styles.FRIEND_TEXTSIZE, Statuses_styles.CREATED_TEXTSIZE, Statuses_styles.STATUS_BG,
                Statuses_styles.ICON, Statuses_styles.FRIEND_BG, Statuses_styles.IMAGE_BG,
                Statuses_styles.IMAGE };
    String sortOrder = Statuses_styles.CREATED + " DESC";
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_PROJECTION, projection);
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_SORT_ORDER, sortOrder);
    String whereClause = Statuses_styles.WIDGET + "=?";
    String[] selectionArgs = new String[] { Integer.toString(appWidgetId) };
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_SELECTION, whereClause);
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_SELECTION_ARGUMENTS, selectionArgs);
    replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_ACTION_VIEW_URI_INDEX,
            MyfeedleProvider.StatusesStylesColumns._id.ordinal());

    switch (scrollableVersion) {
    case 1:
        if (display_profile) {
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_ID, R.layout.widget_item);
            int[] cursorIndices = new int[] { MyfeedleProvider.StatusesStylesColumns.friend.ordinal(),
                    MyfeedleProvider.StatusesStylesColumns.message.ordinal(),
                    MyfeedleProvider.StatusesStylesColumns.status_bg.ordinal(),
                    MyfeedleProvider.StatusesStylesColumns.profile.ordinal(),
                    MyfeedleProvider.StatusesStylesColumns.friend.ordinal(),
                    MyfeedleProvider.StatusesStylesColumns.createdtext.ordinal(),
                    MyfeedleProvider.StatusesStylesColumns.message.ordinal(),
                    MyfeedleProvider.StatusesStylesColumns.icon.ordinal(),
                    MyfeedleProvider.StatusesStylesColumns.profile_bg.ordinal(),
                    MyfeedleProvider.StatusesStylesColumns.friend_bg.ordinal(),
                    MyfeedleProvider.StatusesStylesColumns.image_bg.ordinal(),
                    MyfeedleProvider.StatusesStylesColumns.image.ordinal() };
            int[] viewTypes = new int[] { LauncherIntent.Extra.Scroll.Types.TEXTVIEW,
                    LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB,
                    LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.TEXTVIEW,
                    LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW,
                    LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB,
                    LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB,
                    LauncherIntent.Extra.Scroll.Types.IMAGEBLOB };
            int[] layoutIds = new int[] { R.id.friend_bg_clear, R.id.message_bg_clear, R.id.status_bg,
                    R.id.profile, R.id.friend, R.id.created, R.id.message, R.id.icon, R.id.profile_bg,
                    R.id.friend_bg, R.id.image_clear, R.id.image };
            int[] defaultResource = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            boolean[] clickable = new boolean[] { false, false, true, false, false, false, false, false, false,
                    false, false, false };
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_CURSOR_INDICES, cursorIndices);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_TYPES, viewTypes);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_IDS, layoutIds);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_DEFAULT_RESOURCES, defaultResource);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_CLICKABLE, clickable);
        } else {
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_ID,
                    R.layout.widget_item_noprofile);
            int[] cursorIndices = new int[] { MyfeedleProvider.StatusesStylesColumnsNoProfile.friend.ordinal(),
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.message.ordinal(),
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.status_bg.ordinal(),
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.friend.ordinal(),
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.createdtext.ordinal(),
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.message.ordinal(),
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.icon.ordinal(),
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.friend_bg.ordinal(),
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.image_bg.ordinal(),
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.image.ordinal() };
            int[] viewTypes = new int[] { LauncherIntent.Extra.Scroll.Types.TEXTVIEW,
                    LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB,
                    LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.TEXTVIEW,
                    LauncherIntent.Extra.Scroll.Types.TEXTVIEW, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB,
                    LauncherIntent.Extra.Scroll.Types.IMAGEBLOB, LauncherIntent.Extra.Scroll.Types.IMAGEBLOB,
                    LauncherIntent.Extra.Scroll.Types.IMAGEBLOB };
            int[] layoutIds = new int[] { R.id.friend_bg_clear, R.id.message_bg_clear, R.id.status_bg,
                    R.id.friend, R.id.created, R.id.message, R.id.icon, R.id.friend_bg, R.id.image_clear,
                    R.id.image };
            int[] defaultResource = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            boolean[] clickable = new boolean[] { false, false, true, false, false, false, false, false, false,
                    false };
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_CURSOR_INDICES, cursorIndices);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_TYPES, viewTypes);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_IDS, layoutIds);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_DEFAULT_RESOURCES, defaultResource);
            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.Mapping.EXTRA_VIEW_CLICKABLE, clickable);
        }
        break;
    case 2:
        if (display_profile) {
            BoundRemoteViews itemViews = new BoundRemoteViews(R.layout.widget_item);

            Intent i = Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleWidget.class)
                    .setAction(LauncherIntent.Action.ACTION_VIEW_CLICK).setData(uri)
                    .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            PendingIntent pi = PendingIntent.getBroadcast(MyfeedleService.this, 0, i, 0);

            itemViews.SetBoundOnClickIntent(R.id.item, pi, LauncherIntent.Extra.Scroll.EXTRA_ITEM_POS,
                    MyfeedleProvider.StatusesStylesColumns._id.ordinal());

            itemViews.setBoundCharSequence(R.id.friend_bg_clear, "setText",
                    MyfeedleProvider.StatusesStylesColumns.friend.ordinal(), 0);
            itemViews.setBoundFloat(R.id.friend_bg_clear, "setTextSize",
                    MyfeedleProvider.StatusesStylesColumns.friend_textsize.ordinal());

            itemViews.setBoundCharSequence(R.id.message_bg_clear, "setText",
                    MyfeedleProvider.StatusesStylesColumns.message.ordinal(), 0);
            itemViews.setBoundFloat(R.id.message_bg_clear, "setTextSize",
                    MyfeedleProvider.StatusesStylesColumns.messages_textsize.ordinal());

            itemViews.setBoundBitmap(R.id.status_bg, "setImageBitmap",
                    MyfeedleProvider.StatusesStylesColumns.status_bg.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.image_clear, "setImageBitmap",
                    MyfeedleProvider.StatusesStylesColumns.image_bg.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.image, "setImageBitmap",
                    MyfeedleProvider.StatusesStylesColumns.image.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.profile, "setImageBitmap",
                    MyfeedleProvider.StatusesStylesColumns.profile.ordinal(), 0);
            itemViews.setBoundCharSequence(R.id.friend, "setText",
                    MyfeedleProvider.StatusesStylesColumns.friend.ordinal(), 0);
            itemViews.setBoundCharSequence(R.id.created, "setText",
                    MyfeedleProvider.StatusesStylesColumns.createdtext.ordinal(), 0);
            itemViews.setBoundCharSequence(R.id.message, "setText",
                    MyfeedleProvider.StatusesStylesColumns.message.ordinal(), 0);

            itemViews.setBoundInt(R.id.friend, "setTextColor",
                    MyfeedleProvider.StatusesStylesColumns.friend_color.ordinal());
            itemViews.setBoundInt(R.id.created, "setTextColor",
                    MyfeedleProvider.StatusesStylesColumns.created_color.ordinal());
            itemViews.setBoundInt(R.id.message, "setTextColor",
                    MyfeedleProvider.StatusesStylesColumns.messages_color.ordinal());

            itemViews.setBoundFloat(R.id.friend, "setTextSize",
                    MyfeedleProvider.StatusesStylesColumns.friend_textsize.ordinal());
            itemViews.setBoundFloat(R.id.created, "setTextSize",
                    MyfeedleProvider.StatusesStylesColumns.created_textsize.ordinal());
            itemViews.setBoundFloat(R.id.message, "setTextSize",
                    MyfeedleProvider.StatusesStylesColumns.messages_textsize.ordinal());

            itemViews.setBoundBitmap(R.id.icon, "setImageBitmap",
                    MyfeedleProvider.StatusesStylesColumns.icon.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.profile_bg, "setImageBitmap",
                    MyfeedleProvider.StatusesStylesColumns.profile_bg.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.friend_bg, "setImageBitmap",
                    MyfeedleProvider.StatusesStylesColumns.friend_bg.ordinal(), 0);

            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_REMOTEVIEWS, itemViews);
        } else {
            BoundRemoteViews itemViews = new BoundRemoteViews(R.layout.widget_item_noprofile);

            Intent i = Myfeedle.getPackageIntent(MyfeedleService.this, MyfeedleWidget.class)
                    .setAction(LauncherIntent.Action.ACTION_VIEW_CLICK).setData(uri)
                    .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
            PendingIntent pi = PendingIntent.getBroadcast(MyfeedleService.this, 0, i, 0);

            itemViews.SetBoundOnClickIntent(R.id.item, pi, LauncherIntent.Extra.Scroll.EXTRA_ITEM_POS,
                    MyfeedleProvider.StatusesStylesColumnsNoProfile._id.ordinal());

            itemViews.setBoundCharSequence(R.id.friend_bg_clear, "setText",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.friend.ordinal(), 0);
            itemViews.setBoundFloat(R.id.friend_bg_clear, "setTextSize",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.friend_textsize.ordinal());

            itemViews.setBoundCharSequence(R.id.message_bg_clear, "setText",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.message.ordinal(), 0);
            itemViews.setBoundFloat(R.id.message_bg_clear, "setTextSize",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.messages_textsize.ordinal());

            itemViews.setBoundBitmap(R.id.status_bg, "setImageBitmap",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.status_bg.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.image_clear, "setImageBitmap",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.image_bg.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.image, "setImageBitmap",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.image.ordinal(), 0);

            itemViews.setBoundCharSequence(R.id.friend, "setText",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.friend.ordinal(), 0);
            itemViews.setBoundCharSequence(R.id.created, "setText",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.createdtext.ordinal(), 0);
            itemViews.setBoundCharSequence(R.id.message, "setText",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.message.ordinal(), 0);

            itemViews.setBoundInt(R.id.friend, "setTextColor",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.friend_color.ordinal());
            itemViews.setBoundInt(R.id.created, "setTextColor",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.created_color.ordinal());
            itemViews.setBoundInt(R.id.message, "setTextColor",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.messages_color.ordinal());

            itemViews.setBoundFloat(R.id.friend, "setTextSize",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.friend_textsize.ordinal());
            itemViews.setBoundFloat(R.id.created, "setTextSize",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.created_textsize.ordinal());
            itemViews.setBoundFloat(R.id.message, "setTextSize",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.messages_textsize.ordinal());

            itemViews.setBoundBitmap(R.id.icon, "setImageBitmap",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.icon.ordinal(), 0);

            itemViews.setBoundBitmap(R.id.friend_bg, "setImageBitmap",
                    MyfeedleProvider.StatusesStylesColumnsNoProfile.friend_bg.ordinal(), 0);

            replaceDummy.putExtra(LauncherIntent.Extra.Scroll.EXTRA_ITEM_LAYOUT_REMOTEVIEWS, itemViews);
        }
        break;
    }
    sendBroadcast(replaceDummy);
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

private void appwidgetReadyBroadcast(int appWidgetId, ComponentName cname, int[] widgetSpan) {
    Intent motosize = new Intent("com.motorola.blur.home.ACTION_SET_WIDGET_SIZE");

    motosize.setComponent(cname);//w  ww. j a  va  2  s . c om
    motosize.putExtra("appWidgetId", appWidgetId);
    motosize.putExtra("spanX", widgetSpan[0]);
    motosize.putExtra("spanY", widgetSpan[1]);
    motosize.putExtra("com.motorola.blur.home.EXTRA_NEW_WIDGET", true);
    sendBroadcast(motosize);

    Intent ready = new Intent(PersonaLauncherIntent.Action.ACTION_READY)
            .putExtra(PersonaLauncherIntent.Extra.EXTRA_APPWIDGET_ID, appWidgetId)
            .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
            .putExtra(PersonaLauncherIntent.Extra.EXTRA_API_VERSION, PersonaLauncherMetadata.CurrentAPIVersion)
            .setComponent(cname);
    sendBroadcast(ready);
}