Example usage for android.widget RemoteViews setFloat

List of usage examples for android.widget RemoteViews setFloat

Introduction

In this page you can find the example usage for android.widget RemoteViews setFloat.

Prototype

public void setFloat(int viewId, String methodName, float value) 

Source Link

Document

Call a method taking one float on a view in the layout for this RemoteViews.

Usage

From source file:com.freshplanet.nativeExtensions.C2DMBroadcastReceiver.java

/**
 * Get the parameters from the message and create a notification from it.
 * @param context//from  ww  w .  j  a va 2s.c  om
 * @param intent
 */
public void handleMessage(Context context, Intent intent) {
    try {
        registerResources(context);
        extractColors(context);

        FREContext ctxt = C2DMExtension.context;

        NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

        // icon is required for notification.
        // @see http://developer.android.com/guide/practices/ui_guidelines/icon_design_status_bar.html

        int icon = notificationIcon;
        long when = System.currentTimeMillis();

        // json string

        String parameters = intent.getStringExtra("parameters");
        String facebookId = null;
        JSONObject object = null;
        if (parameters != null) {
            try {
                object = (JSONObject) new JSONTokener(parameters).nextValue();
            } catch (Exception e) {
                Log.d(TAG, "cannot parse the object");
            }
        }
        if (object != null && object.has("facebookId")) {
            facebookId = object.getString("facebookId");
        }

        CharSequence tickerText = intent.getStringExtra("tickerText");
        CharSequence contentTitle = intent.getStringExtra("contentTitle");
        CharSequence contentText = intent.getStringExtra("contentText");

        Intent notificationIntent = new Intent(context, Class.forName(context.getPackageName() + ".AppEntry"));

        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);

        Notification notification = new Notification(icon, tickerText, when);
        notification.flags |= Notification.FLAG_AUTO_CANCEL;
        notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

        RemoteViews contentView = new RemoteViews(context.getPackageName(), customLayout);

        contentView.setTextViewText(customLayoutTitle, contentTitle);
        contentView.setTextViewText(customLayoutDescription, contentText);

        contentView.setTextColor(customLayoutTitle, notification_text_color);
        contentView.setFloat(customLayoutTitle, "setTextSize",
                notification_title_size_factor * notification_text_size);
        contentView.setTextColor(customLayoutDescription, notification_text_color);
        contentView.setFloat(customLayoutDescription, "setTextSize",
                notification_description_size_factor * notification_text_size);

        if (facebookId != null) {
            Log.d(TAG, "bitmap not null");
            CreateNotificationTask cNT = new CreateNotificationTask();
            cNT.setParams(customLayoutImageContainer, NotifId, nm, notification, contentView);
            String src = "http://graph.facebook.com/" + facebookId + "/picture?type=normal";
            URL url = new URL(src);
            cNT.execute(url);
        } else {
            Log.d(TAG, "bitmap null");
            contentView.setImageViewResource(customLayoutImageContainer, customLayoutImage);
            notification.contentView = contentView;
            nm.notify(NotifId, notification);
        }
        NotifId++;

        if (ctxt != null) {
            parameters = parameters == null ? "" : parameters;
            ctxt.dispatchStatusEventAsync("COMING_FROM_NOTIFICATION", parameters);
        }

    } catch (Exception e) {
        Log.e(TAG, "Error activating application:", e);
    }
}

From source file:au.com.wallaceit.reddinator.Rservice.java

@Override
public RemoteViews getViewAt(int position) {
    RemoteViews row;
    if (position > data.length()) {
        return null; //  prevent errornous views
    }/* w w w . j  a va  2  s. c o  m*/
    // check if its the last view and return loading view instead of normal row
    if (position == data.length()) {
        // build load more item
        //System.out.println("load more getViewAt("+position+") firing");
        RemoteViews loadmorerow = new RemoteViews(mContext.getPackageName(), R.layout.listrowloadmore);
        if (endOfFeed) {
            loadmorerow.setTextViewText(R.id.loadmoretxt, "There's nothing more here");
        } else {
            loadmorerow.setTextViewText(R.id.loadmoretxt, "Load more...");
        }
        loadmorerow.setTextColor(R.id.loadmoretxt, themeColors[0]);
        Intent i = new Intent();
        Bundle extras = new Bundle();
        extras.putString(WidgetProvider.ITEM_ID, "0"); // zero will be an indicator in the onreceive function of widget provider if its not present it forces a reload
        i.putExtras(extras);
        loadmorerow.setOnClickFillInIntent(R.id.listrowloadmore, i);
        return loadmorerow;
    } else {
        // build normal item
        String title = "";
        String url = "";
        String permalink = "";
        String thumbnail = "";
        String domain = "";
        String id = "";
        int score = 0;
        int numcomments = 0;
        boolean nsfw = false;
        try {
            JSONObject tempobj = data.getJSONObject(position).getJSONObject("data");
            title = tempobj.getString("title");
            //userlikes = tempobj.getString("likes");
            domain = tempobj.getString("domain");
            id = tempobj.getString("name");
            url = tempobj.getString("url");
            permalink = tempobj.getString("permalink");
            thumbnail = (String) tempobj.get("thumbnail"); // we have to call get and cast cause its not in quotes
            score = tempobj.getInt("score");
            numcomments = tempobj.getInt("num_comments");
            nsfw = tempobj.getBoolean("over_18");
        } catch (JSONException e) {
            e.printStackTrace();
            // return null; // The view is invalid;
        }
        // create remote view from specified layout
        if (bigThumbs) {
            row = new RemoteViews(mContext.getPackageName(), R.layout.listrowbigthumb);
        } else {
            row = new RemoteViews(mContext.getPackageName(), R.layout.listrow);
        }
        // build view
        row.setTextViewText(R.id.listheading, Html.fromHtml(title).toString());
        row.setFloat(R.id.listheading, "setTextSize", Integer.valueOf(titleFontSize)); // use for compatibility setTextViewTextSize only introduced in API 16
        row.setTextColor(R.id.listheading, themeColors[0]);
        row.setTextViewText(R.id.sourcetxt, domain);
        row.setTextColor(R.id.sourcetxt, themeColors[3]);
        row.setTextColor(R.id.votestxt, themeColors[4]);
        row.setTextColor(R.id.commentstxt, themeColors[4]);
        row.setTextViewText(R.id.votestxt, String.valueOf(score));
        row.setTextViewText(R.id.commentstxt, String.valueOf(numcomments));
        row.setInt(R.id.listdivider, "setBackgroundColor", themeColors[2]);
        row.setViewVisibility(R.id.nsfwflag, nsfw ? TextView.VISIBLE : TextView.GONE);
        // add extras and set click intent
        Intent i = new Intent();
        Bundle extras = new Bundle();
        extras.putString(WidgetProvider.ITEM_ID, id);
        extras.putInt("itemposition", position);
        extras.putString(WidgetProvider.ITEM_URL, url);
        extras.putString(WidgetProvider.ITEM_PERMALINK, permalink);
        i.putExtras(extras);
        row.setOnClickFillInIntent(R.id.listrow, i);
        // load thumbnail if they are enabled for this widget
        if (loadThumbnails) {
            // load big image if preference is set
            if (!thumbnail.equals("")) { // check for thumbnail; self is used to display the thinking logo on the reddit site, we'll just show nothing for now
                if (thumbnail.equals("nsfw") || thumbnail.equals("self") || thumbnail.equals("default")) {
                    int resource = 0;
                    switch (thumbnail) {
                    case "nsfw":
                        resource = R.drawable.nsfw;
                        break;
                    case "default":
                    case "self":
                        resource = R.drawable.self_default;
                        break;
                    }
                    row.setImageViewResource(R.id.thumbnail, resource);
                    row.setViewVisibility(R.id.thumbnail, View.VISIBLE);
                    //System.out.println("Loading default image: "+thumbnail);
                } else {
                    Bitmap bitmap;
                    String fileurl = mContext.getCacheDir() + "/thumbcache-" + appWidgetId + "/" + id + ".png";
                    // check if the image is in cache
                    if (new File(fileurl).exists()) {
                        bitmap = BitmapFactory.decodeFile(fileurl);
                        saveImageToStorage(bitmap, id);
                    } else {
                        // download the image
                        bitmap = loadImage(thumbnail);
                    }
                    if (bitmap != null) {
                        row.setImageViewBitmap(R.id.thumbnail, bitmap);
                        row.setViewVisibility(R.id.thumbnail, View.VISIBLE);
                    } else {
                        // row.setImageViewResource(R.id.thumbnail, android.R.drawable.stat_notify_error); for later
                        row.setViewVisibility(R.id.thumbnail, View.GONE);
                    }
                }
            } else {
                row.setViewVisibility(R.id.thumbnail, View.GONE);
            }
        } else {
            row.setViewVisibility(R.id.thumbnail, View.GONE);
        }
        // hide info bar if options set
        if (hideInf) {
            row.setViewVisibility(R.id.infbox, View.GONE);
        } else {
            row.setViewVisibility(R.id.infbox, View.VISIBLE);
        }
    }
    //System.out.println("getViewAt("+position+");");
    return row;
}

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;//w w w .  ja  v a  2  s .  co  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(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;//from w  ww  . j a  v  a2s  . 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);
    }
}