Example usage for android.widget LinearLayout requestLayout

List of usage examples for android.widget LinearLayout requestLayout

Introduction

In this page you can find the example usage for android.widget LinearLayout requestLayout.

Prototype

@CallSuper
public void requestLayout() 

Source Link

Document

Call this when something has changed which has invalidated the layout of this view.

Usage

From source file:com.brq.wallet.activity.modern.AccountsFragment.java

private LinearLayout createActiveAccountBalanceSumView(CurrencySum spendableBalance) {
    LinearLayout outer = new LinearLayout(getActivity());
    outer.setOrientation(LinearLayout.VERTICAL);
    outer.setLayoutParams(_outerLayoutParameters);

    LinearLayout inner = new LinearLayout(getActivity());
    inner.setOrientation(LinearLayout.VERTICAL);
    inner.setLayoutParams(_innerLayoutParameters);
    inner.requestLayout();

    // Add records
    RecordRowBuilder builder = new RecordRowBuilder(_mbwManager, getResources(), _layoutInflater);

    // Add item//from  w ww.j ava2s.  c  o  m
    View item = builder.buildTotalView(outer, spendableBalance);
    inner.addView(item);

    // Add separator
    inner.addView(createSeparator());

    outer.addView(inner);
    return outer;
}

From source file:com.brq.wallet.activity.modern.AccountsFragment.java

private LinearLayout createAccountViewList(String title, List<WalletAccount> accounts,
        WalletAccount selectedAccount, CurrencySum spendableBalance) {
    LinearLayout outer = new LinearLayout(getActivity());
    outer.setOrientation(LinearLayout.VERTICAL);
    outer.setLayoutParams(_outerLayoutParameters);

    // Add title/*w  w w .ja  v  a2s. c  om*/
    createTitle(outer, title, spendableBalance);

    if (accounts.isEmpty()) {
        return outer;
    }

    LinearLayout inner = new LinearLayout(getActivity());
    inner.setOrientation(LinearLayout.VERTICAL);
    inner.setLayoutParams(_innerLayoutParameters);
    inner.requestLayout();

    //      // Add records
    RecordRowBuilder builder = new RecordRowBuilder(_mbwManager, getResources(), _layoutInflater);
    for (WalletAccount account : accounts) {
        // Add separator
        inner.addView(createSeparator());

        // Add item
        boolean isSelected = account.equals(selectedAccount);
        View item = createAccountView(outer, account, isSelected, builder);
        inner.addView(item);
    }

    if (accounts.size() > 0) {
        // Add separator
        inner.addView(createSeparator());
    }

    outer.addView(inner);
    return outer;
}

From source file:universe.constellation.orion.viewer.OrionViewerActivity.java

public void initZoomScreen() {
    //zoom screen

    final Spinner sp = (Spinner) findMyViewById(R.id.zoom_spinner);

    final EditText zoomText = (EditText) findMyViewById(R.id.zoom_picker_message);

    final SeekBar zoomSeek = (SeekBar) findMyViewById(R.id.zoom_picker_seeker);

    if (zoomSeek != null) {
        zoomSeek.setMax(300);/*  ww w .  j ava  2 s . co m*/
        zoomSeek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                if (zoomInternal != 1) {
                    zoomText.setText("" + progress);
                    if (sp.getSelectedItemPosition() != 0) {
                        int oldInternal = zoomInternal;
                        zoomInternal = 2;
                        sp.setSelection(0);
                        zoomInternal = oldInternal;
                    }
                }
            }

            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            public void onStopTrackingTouch(SeekBar seekBar) {
            }
        });
    }

    getSubscriptionManager().addDocListeners(new DocumentViewAdapter() {
        @Override
        public void documentOpened(Controller controller) {
            updateZoom();
        }
    });

    final ImageButton zplus = (ImageButton) findMyViewById(R.id.zoom_picker_plus);
    zplus.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            zoomSeek.incrementProgressBy(1);
        }
    });

    final ImageButton zminus = (ImageButton) findMyViewById(R.id.zoom_picker_minus);
    zminus.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (zoomSeek.getProgress() != 0) {
                zoomSeek.incrementProgressBy(-1);
            }
        }
    });

    ImageButton closeZoomPeeker = (ImageButton) findMyViewById(R.id.zoom_picker_close);
    closeZoomPeeker.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            //main menu
            onAnimatorCancel();
            //updateZoom();
        }
    });

    ImageButton zoom_preview = (ImageButton) findMyViewById(R.id.zoom_preview);
    zoom_preview.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onApplyAction();
            int index = sp.getSelectedItemPosition();
            controller.changeZoom(index == 0 ? (int) (Float.parseFloat(zoomText.getText().toString()) * 100)
                    : -1 * (index - 1));
            updateZoom();
        }
    });

    sp.setAdapter(new MyArrayAdapter());
    sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            boolean disable = position != 0;
            int oldZoomInternal = zoomInternal;
            if (zoomInternal != 2) {
                zoomInternal = 1;
                if (disable) {
                    zoomText.setText((String) parent.getAdapter().getItem(position));
                } else {
                    zoomText.setText("" + ((int) (controller.getCurrentPageZoom() * 10000)) / 100f);
                    zoomSeek.setProgress((int) (controller.getCurrentPageZoom() * 100));
                }
                zoomInternal = oldZoomInternal;
            }

            zminus.setVisibility(disable ? View.GONE : View.VISIBLE);
            zplus.setVisibility(disable ? View.GONE : View.VISIBLE);

            zoomText.setFocusable(!disable);
            zoomText.setFocusableInTouchMode(!disable);

            final LinearLayout parent1 = (LinearLayout) zoomText.getParent();

            parent1.post(new Runnable() {
                @Override
                public void run() {
                    parent1.requestLayout();
                }
            });
        }

        public void onNothingSelected(AdapterView<?> parent) {
            //To change body of implemented methods use File | Settings | File Templates.
        }
    });

    //by width
    sp.setSelection(1);

}

From source file:com.nextgis.maplibui.activity.FormBuilderModifyAttributesActivity.java

protected void fillTabControls(LinearLayout layout, Bundle savedState, JSONArray elements)
        throws JSONException {
    Cursor featureCursor = null;//w  w  w  .  j  av  a 2 s.  c o m

    if (mFeatureId != NOT_FOUND) {
        featureCursor = mLayer.query(null, FIELD_ID + " = " + mFeatureId, null, null, null);
        if (!featureCursor.moveToFirst()) {
            featureCursor = null;
        }
    }

    List<Field> fields = mLayer.getFields();

    for (int i = 0; i < elements.length(); i++) {
        JSONObject element = elements.getJSONObject(i);
        String type = element.getString(JSON_TYPE_KEY);

        IFormControl control = null;

        switch (type) {

        case JSON_TEXT_LABEL_VALUE:
            control = (TextLabel) getLayoutInflater().inflate(R.layout.formtemplate_textlabel, layout, false);
            break;

        case JSON_TEXT_EDIT_VALUE:
            control = (TextEdit) getLayoutInflater().inflate(R.layout.formtemplate_edittext, layout, false);
            break;

        case JSON_DATE_TIME_VALUE:
            control = (DateTime) getLayoutInflater().inflate(R.layout.formtemplate_datetime, layout, false);
            break;

        case JSON_RADIO_GROUP_VALUE:
            control = (RadioGroup) getLayoutInflater().inflate(R.layout.formtemplate_radiogroup, layout, false);
            break;

        case JSON_COMBOBOX_VALUE:
            if (ControlHelper.isAutoComplete(element.getJSONObject(JSON_ATTRIBUTES_KEY)))
                control = (AutoTextEdit) getLayoutInflater().inflate(R.layout.formtemplate_autoedittext, layout,
                        false);
            else
                control = (Combobox) getLayoutInflater().inflate(R.layout.formtemplate_combobox, layout, false);
            break;

        case JSON_DOUBLE_COMBOBOX_VALUE:
            control = (DoubleCombobox) getLayoutInflater().inflate(R.layout.formtemplate_doublecombobox, layout,
                    false);
            break;

        case JSON_SPACE_VALUE:
            control = (Space) getLayoutInflater().inflate(R.layout.formtemplate_space, layout, false);
            break;

        case JSON_CHECKBOX_VALUE:
            control = (Checkbox) getLayoutInflater().inflate(R.layout.formtemplate_checkbox, layout, false);
            break;

        case JSON_PHOTO_VALUE:
            control = (PhotoGallery) getLayoutInflater().inflate(R.layout.formtemplate_photo, layout, false);
            ((PhotoGallery) control).init(mLayer, mFeatureId);
            break;

        case JSON_SIGN_VALUE:
            control = (Sign) getLayoutInflater().inflate(R.layout.formtemplate_sign, layout, false);
            ((Sign) control).setPath(mLayer.getPath().getPath() + File.separator + mFeatureId);
            break;

        case JSON_COUNTER_VALUE:
            control = (Counter) getLayoutInflater().inflate(R.layout.formtemplate_counter, layout, false);
            break;

        case JSON_COORDINATES_VALUE:
            Double x, y;
            x = y = null;
            if (mGeometry != null && mGeometry instanceof GeoPoint) {
                GeoPoint point = (GeoPoint) mGeometry.copy();
                point.setCRS(GeoConstants.CRS_WEB_MERCATOR);
                point.project(GeoConstants.CRS_WGS84);
                y = point.getY();
                x = point.getX();
            }

            JSONObject attributes = element.getJSONObject(JSON_ATTRIBUTES_KEY);
            String field = attributes.optString(JSON_FIELD_NAME_KEY + "_lat");
            attributes.put(JSON_FIELD_NAME_KEY, field);
            control = (Coordinates) getLayoutInflater().inflate(R.layout.formtemplate_coordinates, layout,
                    false);
            if (control != null) {
                ((Coordinates) control).setIsLat();
                if (y != null)
                    ((Coordinates) control).setValue(y);
            }

            addToLayout(control, element, fields, savedState, featureCursor, layout);

            field = attributes.optString(JSON_FIELD_NAME_KEY + "_long");
            attributes.put(JSON_FIELD_NAME_KEY, field);
            control = (Coordinates) getLayoutInflater().inflate(R.layout.formtemplate_coordinates, layout,
                    false);
            if (control != null && x != null)
                ((Coordinates) control).setValue(x);
            break;

        //TODO: add controls
        //button
        //group
        //orientation
        //tabs
        //compass

        default:
            break;
        }

        addToLayout(control, element, fields, savedState, featureCursor, layout);
    }

    if (null != featureCursor) {
        featureCursor.close();
    }

    layout.requestLayout();
}

From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java

protected void updateMessageDetail(final boolean isUpdate) {
    T.UI();/*from w  w w.j av a2  s.  com*/
    // Set sender avatar
    ImageView avatarImage = (ImageView) findViewById(R.id.avatar);
    String sender = mCurrentMessage.sender;
    setAvatar(avatarImage, sender);
    // Set sender name
    TextView senderView = (TextView) findViewById(R.id.sender);
    final String senderName = mFriendsPlugin.getName(sender);
    senderView.setText(senderName == null ? sender : senderName);
    // Set timestamp
    TextView timestampView = (TextView) findViewById(R.id.timestamp);
    timestampView.setText(TimeUtils.getDayTimeStr(this, mCurrentMessage.timestamp * 1000));

    // Set clickable region on top to go to friends detail
    final RelativeLayout messageHeader = (RelativeLayout) findViewById(R.id.message_header);
    messageHeader.setOnClickListener(getFriendDetailOnClickListener(mCurrentMessage.sender));
    messageHeader.setVisibility(View.VISIBLE);

    // Set message
    TextView messageView = (TextView) findViewById(R.id.message);
    WebView web = (WebView) findViewById(R.id.webview);
    FrameLayout flay = (FrameLayout) findViewById(R.id.message_details);
    Resources resources = getResources();
    flay.setBackgroundColor(resources.getColor(R.color.mc_background));
    boolean showBranded = false;

    int darkSchemeTextColor = resources.getColor(android.R.color.primary_text_dark);
    int lightSchemeTextColor = resources.getColor(android.R.color.primary_text_light);

    senderView.setTextColor(lightSchemeTextColor);
    timestampView.setTextColor(lightSchemeTextColor);

    BrandingResult br = null;
    if (!TextUtils.isEmptyOrWhitespace(mCurrentMessage.branding)) {
        boolean brandingAvailable = false;
        try {
            brandingAvailable = mMessagingPlugin.getBrandingMgr().isBrandingAvailable(mCurrentMessage.branding);
        } catch (BrandingFailureException e1) {
            L.d(e1);
        }
        try {
            if (brandingAvailable) {
                br = mMessagingPlugin.getBrandingMgr().prepareBranding(mCurrentMessage);
                WebSettings settings = web.getSettings();
                settings.setJavaScriptEnabled(false);
                settings.setBlockNetworkImage(false);
                web.loadUrl("file://" + br.file.getAbsolutePath());
                web.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
                if (br.color != null) {
                    flay.setBackgroundColor(br.color);
                }
                if (!br.showHeader) {
                    messageHeader.setVisibility(View.GONE);
                    MarginLayoutParams mlp = (MarginLayoutParams) web.getLayoutParams();
                    mlp.setMargins(0, 0, 0, mlp.bottomMargin);
                } else if (br.scheme == ColorScheme.dark) {
                    senderView.setTextColor(darkSchemeTextColor);
                    timestampView.setTextColor(darkSchemeTextColor);
                }

                showBranded = true;
            } else {
                mMessagingPlugin.getBrandingMgr().queueGenericBranding(mCurrentMessage.branding);
            }
        } catch (BrandingFailureException e) {
            L.bug("Could not display message with branding: branding is available, but prepareBranding failed",
                    e);
        }
    }

    if (showBranded) {
        web.setVisibility(View.VISIBLE);
        messageView.setVisibility(View.GONE);
    } else {
        web.setVisibility(View.GONE);
        messageView.setVisibility(View.VISIBLE);
        messageView.setText(mCurrentMessage.message);
    }

    // Add list of members who did not ack yet
    FlowLayout memberSummary = (FlowLayout) findViewById(R.id.member_summary);
    memberSummary.removeAllViews();
    SortedSet<MemberStatusTO> memberSummarySet = new TreeSet<MemberStatusTO>(getMemberstatusComparator());
    for (MemberStatusTO ms : mCurrentMessage.members) {
        if ((ms.status & MessagingPlugin.STATUS_ACKED) != MessagingPlugin.STATUS_ACKED
                && !ms.member.equals(mCurrentMessage.sender)) {
            memberSummarySet.add(ms);
        }
    }
    FlowLayout.LayoutParams flowLP = new FlowLayout.LayoutParams(2, 0);
    for (MemberStatusTO ms : memberSummarySet) {
        FrameLayout fl = new FrameLayout(this);
        fl.setLayoutParams(flowLP);
        memberSummary.addView(fl);
        fl.addView(createParticipantView(ms));
    }
    memberSummary.setVisibility(memberSummarySet.size() < 2 ? View.GONE : View.VISIBLE);

    // Add members statuses
    final LinearLayout members = (LinearLayout) findViewById(R.id.members);
    members.removeAllViews();
    final String myEmail = mService.getIdentityStore().getIdentity().getEmail();
    boolean isMember = false;
    mSomebodyAnswered = false;
    for (MemberStatusTO ms : mCurrentMessage.members) {
        boolean showMember = true;
        View view = getLayoutInflater().inflate(R.layout.message_member_detail, null);
        // Set receiver avatar
        RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.avatar);
        rl.addView(createParticipantView(ms));
        // Set receiver name
        TextView receiverView = (TextView) view.findViewById(R.id.receiver);
        final String memberName = mFriendsPlugin.getName(ms.member);
        receiverView.setText(memberName == null ? sender : memberName);
        // Set received timestamp
        TextView receivedView = (TextView) view.findViewById(R.id.received_timestamp);
        if ((ms.status & MessagingPlugin.STATUS_RECEIVED) == MessagingPlugin.STATUS_RECEIVED) {
            final String humanTime = TimeUtils.getDayTimeStr(this, ms.received_timestamp * 1000);
            if (ms.member.equals(mCurrentMessage.sender))
                receivedView.setText(getString(R.string.sent_at, humanTime));
            else
                receivedView.setText(getString(R.string.received_at, humanTime));
        } else {
            receivedView.setText(R.string.not_yet_received);
        }
        // Set replied timestamp
        TextView repliedView = (TextView) view.findViewById(R.id.acked_timestamp);
        if ((ms.status & MessagingPlugin.STATUS_ACKED) == MessagingPlugin.STATUS_ACKED) {
            mSomebodyAnswered = true;
            String acked_timestamp = TimeUtils.getDayTimeStr(this, ms.acked_timestamp * 1000);
            if (ms.button_id != null) {

                ButtonTO button = null;
                for (ButtonTO b : mCurrentMessage.buttons) {
                    if (b.id.equals(ms.button_id)) {
                        button = b;
                        break;
                    }
                }
                if (button == null) {
                    repliedView.setText(getString(R.string.dismissed_at, acked_timestamp));
                    // Do not show sender as member if he hasn't clicked a
                    // button
                    showMember = !ms.member.equals(mCurrentMessage.sender);
                } else {
                    repliedView.setText(getString(R.string.replied_at, button.caption, acked_timestamp));
                }
            } else {
                if (ms.custom_reply == null) {
                    // Do not show sender as member if he hasn't clicked a
                    // button
                    showMember = !ms.member.equals(mCurrentMessage.sender);
                    repliedView.setText(getString(R.string.dismissed_at, acked_timestamp));
                } else
                    repliedView.setText(getString(R.string.replied_at, ms.custom_reply, acked_timestamp));
            }
        } else {
            repliedView.setText(R.string.not_yet_replied);
            showMember = !ms.member.equals(mCurrentMessage.sender);
        }
        if (br != null && br.scheme == ColorScheme.dark) {
            receiverView.setTextColor(darkSchemeTextColor);
            receivedView.setTextColor(darkSchemeTextColor);
            repliedView.setTextColor(darkSchemeTextColor);
        } else {
            receiverView.setTextColor(lightSchemeTextColor);
            receivedView.setTextColor(lightSchemeTextColor);
            repliedView.setTextColor(lightSchemeTextColor);
        }

        if (showMember)
            members.addView(view);
        isMember |= ms.member.equals(myEmail);
    }

    boolean isLocked = (mCurrentMessage.flags & MessagingPlugin.FLAG_LOCKED) == MessagingPlugin.FLAG_LOCKED;
    boolean canEdit = isMember && !isLocked;

    // Add attachments
    LinearLayout attachmentLayout = (LinearLayout) findViewById(R.id.attachment_layout);
    attachmentLayout.removeAllViews();
    if (mCurrentMessage.attachments.length > 0) {
        attachmentLayout.setVisibility(View.VISIBLE);

        for (final AttachmentTO attachment : mCurrentMessage.attachments) {
            View v = getLayoutInflater().inflate(R.layout.attachment_item, null);

            ImageView attachment_image = (ImageView) v.findViewById(R.id.attachment_image);
            if (AttachmentViewerActivity.CONTENT_TYPE_JPEG.equalsIgnoreCase(attachment.content_type)
                    || AttachmentViewerActivity.CONTENT_TYPE_PNG.equalsIgnoreCase(attachment.content_type)) {
                attachment_image.setImageResource(R.drawable.attachment_img);
            } else if (AttachmentViewerActivity.CONTENT_TYPE_PDF.equalsIgnoreCase(attachment.content_type)) {
                attachment_image.setImageResource(R.drawable.attachment_pdf);
            } else if (AttachmentViewerActivity.CONTENT_TYPE_VIDEO_MP4
                    .equalsIgnoreCase(attachment.content_type)) {
                attachment_image.setImageResource(R.drawable.attachment_video);
            } else {
                attachment_image.setImageResource(R.drawable.attachment_unknown);
                L.d("attachment.content_type not known: " + attachment.content_type);
            }

            TextView attachment_text = (TextView) v.findViewById(R.id.attachment_text);
            attachment_text.setText(attachment.name);

            v.setOnClickListener(new SafeViewOnClickListener() {

                @Override
                public void safeOnClick(View v) {
                    String downloadUrlHash = mMessagingPlugin
                            .attachmentDownloadUrlHash(attachment.download_url);

                    File attachmentsDir;
                    try {
                        attachmentsDir = mMessagingPlugin.attachmentsDir(mCurrentMessage.getThreadKey(), null);
                    } catch (IOException e) {
                        L.d("Unable to create attachment directory", e);
                        UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "",
                                R.string.unable_to_read_write_sd_card);
                        return;
                    }

                    boolean attachmentAvailable = mMessagingPlugin.attachmentExists(attachmentsDir,
                            downloadUrlHash);

                    if (!attachmentAvailable) {
                        try {
                            attachmentsDir = mMessagingPlugin.attachmentsDir(mCurrentMessage.getThreadKey(),
                                    mCurrentMessage.key);
                        } catch (IOException e) {
                            L.d("Unable to create attachment directory", e);
                            UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "",
                                    R.string.unable_to_read_write_sd_card);
                            return;
                        }

                        attachmentAvailable = mMessagingPlugin.attachmentExists(attachmentsDir,
                                downloadUrlHash);
                    }

                    if (!mService.getNetworkConnectivityManager().isConnected() && !attachmentAvailable) {
                        AlertDialog.Builder builder = new AlertDialog.Builder(
                                ServiceMessageDetailActivity.this);
                        builder.setMessage(R.string.no_internet_connection_try_again);
                        builder.setPositiveButton(R.string.rogerthat, null);
                        AlertDialog dialog = builder.create();
                        dialog.show();
                        return;
                    }
                    if (IOUtils.shouldCheckExternalStorageAvailable()) {
                        String state = Environment.getExternalStorageState();
                        if (Environment.MEDIA_MOUNTED.equals(state)) {
                            // Its all oke
                        } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
                            if (!attachmentAvailable) {
                                L.d("Unable to write to sd-card");
                                UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "",
                                        R.string.unable_to_read_write_sd_card);
                                return;
                            }
                        } else {
                            L.d("Unable to read or write to sd-card");
                            UIUtils.showAlertDialog(ServiceMessageDetailActivity.this, "",
                                    R.string.unable_to_read_write_sd_card);
                            return;
                        }
                    }

                    L.d("attachment.content_type: " + attachment.content_type);
                    L.d("attachment.download_url: " + attachment.download_url);
                    L.d("attachment.name: " + attachment.name);
                    L.d("attachment.size: " + attachment.size);

                    if (AttachmentViewerActivity.supportsContentType(attachment.content_type)) {
                        Intent i = new Intent(ServiceMessageDetailActivity.this,
                                AttachmentViewerActivity.class);
                        i.putExtra("thread_key", mCurrentMessage.getThreadKey());
                        i.putExtra("message", mCurrentMessage.key);
                        i.putExtra("content_type", attachment.content_type);
                        i.putExtra("download_url", attachment.download_url);
                        i.putExtra("name", attachment.name);
                        i.putExtra("download_url_hash", downloadUrlHash);

                        startActivity(i);
                    } else {
                        AlertDialog.Builder builder = new AlertDialog.Builder(
                                ServiceMessageDetailActivity.this);
                        builder.setMessage(getString(R.string.attachment_can_not_be_displayed_in_your_version,
                                getString(R.string.app_name)));
                        builder.setPositiveButton(R.string.rogerthat, null);
                        AlertDialog dialog = builder.create();
                        dialog.show();
                    }
                }

            });

            attachmentLayout.addView(v);
        }

    } else {
        attachmentLayout.setVisibility(View.GONE);
    }

    LinearLayout widgetLayout = (LinearLayout) findViewById(R.id.widget_layout);
    if (mCurrentMessage.form == null) {
        widgetLayout.setVisibility(View.GONE);
    } else {
        widgetLayout.setVisibility(View.VISIBLE);
        widgetLayout.setEnabled(canEdit);
        displayWidget(widgetLayout, br);
    }

    // Add buttons
    TableLayout tableLayout = (TableLayout) findViewById(R.id.buttons);
    tableLayout.removeAllViews();

    for (final ButtonTO button : mCurrentMessage.buttons) {
        addButton(senderName, myEmail, mSomebodyAnswered, canEdit, tableLayout, button);
    }
    if (mCurrentMessage.form == null && (mCurrentMessage.flags
            & MessagingPlugin.FLAG_ALLOW_DISMISS) == MessagingPlugin.FLAG_ALLOW_DISMISS) {
        ButtonTO button = new ButtonTO();
        button.caption = "Roger that!";
        addButton(senderName, myEmail, mSomebodyAnswered, canEdit, tableLayout, button);
    }

    if (mCurrentMessage.broadcast_type != null) {
        L.d("Show broadcast spam control");
        final RelativeLayout broadcastSpamControl = (RelativeLayout) findViewById(R.id.broadcast_spam_control);
        View broadcastSpamControlBorder = findViewById(R.id.broadcast_spam_control_border);
        final View broadcastSpamControlDivider = findViewById(R.id.broadcast_spam_control_divider);

        final LinearLayout broadcastSpamControlTextContainer = (LinearLayout) findViewById(
                R.id.broadcast_spam_control_text_container);
        TextView broadcastSpamControlText = (TextView) findViewById(R.id.broadcast_spam_control_text);

        final LinearLayout broadcastSpamControlSettingsContainer = (LinearLayout) findViewById(
                R.id.broadcast_spam_control_settings_container);
        TextView broadcastSpamControlSettingsText = (TextView) findViewById(
                R.id.broadcast_spam_control_settings_text);
        TextView broadcastSpamControlIcon = (TextView) findViewById(R.id.broadcast_spam_control_icon);
        broadcastSpamControlIcon.setTypeface(mFontAwesomeTypeFace);
        broadcastSpamControlIcon.setText(R.string.fa_bell);

        final FriendBroadcastInfo fbi = mFriendsPlugin.getFriendBroadcastFlowForMfr(mCurrentMessage.sender);
        if (fbi == null) {
            L.bug("BroadcastData was null for: " + mCurrentMessage.sender);
            collapseDetails(DETAIL_SECTIONS);
            return;
        }
        broadcastSpamControl.setVisibility(View.VISIBLE);

        broadcastSpamControlSettingsContainer.setOnClickListener(new SafeViewOnClickListener() {

            @Override
            public void safeOnClick(View v) {
                L.d("goto broadcast settings");

                PressMenuIconRequestTO request = new PressMenuIconRequestTO();
                request.coords = fbi.coords;
                request.static_flow_hash = fbi.staticFlowHash;
                request.hashed_tag = fbi.hashedTag;
                request.generation = fbi.generation;
                request.service = mCurrentMessage.sender;
                mContext = "MENU_" + UUID.randomUUID().toString();
                request.context = mContext;
                request.timestamp = System.currentTimeMillis() / 1000;

                showTransmitting(null);
                Map<String, Object> userInput = new HashMap<String, Object>();
                userInput.put("request", request.toJSONMap());
                userInput.put("func", "com.mobicage.api.services.pressMenuItem");

                MessageFlowRun mfr = new MessageFlowRun();
                mfr.staticFlowHash = fbi.staticFlowHash;
                try {
                    JsMfr.executeMfr(mfr, userInput, mService, true);
                } catch (EmptyStaticFlowException ex) {
                    completeTransmit(null);
                    AlertDialog.Builder builder = new AlertDialog.Builder(ServiceMessageDetailActivity.this);
                    builder.setMessage(ex.getMessage());
                    builder.setPositiveButton(R.string.rogerthat, null);
                    AlertDialog dialog = builder.create();
                    dialog.show();
                    return;
                }
            }

        });

        UIUtils.showHint(this, mService, HINT_BROADCAST, R.string.hint_broadcast,
                mCurrentMessage.broadcast_type, mFriendsPlugin.getName(mCurrentMessage.sender));

        broadcastSpamControlText
                .setText(getString(R.string.broadcast_subscribed_to, mCurrentMessage.broadcast_type));
        broadcastSpamControlSettingsText.setText(fbi.label);
        int ligthAlpha = 180;
        int darkAlpha = 70;
        int alpha = ligthAlpha;
        if (br != null && br.scheme == ColorScheme.dark) {
            broadcastSpamControlIcon.setTextColor(getResources().getColor(android.R.color.black));
            broadcastSpamControlBorder.setBackgroundColor(darkSchemeTextColor);
            broadcastSpamControlDivider.setBackgroundColor(darkSchemeTextColor);
            activity.setBackgroundColor(darkSchemeTextColor);
            broadcastSpamControlText.setTextColor(lightSchemeTextColor);
            broadcastSpamControlSettingsText.setTextColor(lightSchemeTextColor);
            int alpacolor = Color.argb(darkAlpha, Color.red(lightSchemeTextColor),
                    Color.green(lightSchemeTextColor), Color.blue(lightSchemeTextColor));
            broadcastSpamControl.setBackgroundColor(alpacolor);

            alpha = darkAlpha;
        } else {
            broadcastSpamControlIcon.setTextColor(getResources().getColor(android.R.color.white));
            broadcastSpamControlBorder.setBackgroundColor(lightSchemeTextColor);
            broadcastSpamControlDivider.setBackgroundColor(lightSchemeTextColor);
            activity.setBackgroundColor(lightSchemeTextColor);
            broadcastSpamControlText.setTextColor(darkSchemeTextColor);
            broadcastSpamControlSettingsText.setTextColor(darkSchemeTextColor);
            int alpacolor = Color.argb(darkAlpha, Color.red(darkSchemeTextColor),
                    Color.green(darkSchemeTextColor), Color.blue(darkSchemeTextColor));
            broadcastSpamControl.setBackgroundColor(alpacolor);
        }

        if (br != null && br.color != null) {
            int alphaColor = Color.argb(alpha, Color.red(br.color), Color.green(br.color),
                    Color.blue(br.color));
            broadcastSpamControl.setBackgroundColor(alphaColor);
        }

        mService.postOnUIHandler(new SafeRunnable() {

            @Override
            protected void safeRun() throws Exception {
                int maxHeight = broadcastSpamControl.getHeight();
                broadcastSpamControlDivider.getLayoutParams().height = maxHeight;
                broadcastSpamControlDivider.requestLayout();

                broadcastSpamControlSettingsContainer.getLayoutParams().height = maxHeight;
                broadcastSpamControlSettingsContainer.requestLayout();

                broadcastSpamControlTextContainer.getLayoutParams().height = maxHeight;
                broadcastSpamControlTextContainer.requestLayout();

                int broadcastSpamControlWidth = broadcastSpamControl.getWidth();
                android.view.ViewGroup.LayoutParams lp = broadcastSpamControlSettingsContainer
                        .getLayoutParams();
                lp.width = broadcastSpamControlWidth / 4;
                broadcastSpamControlSettingsContainer.setLayoutParams(lp);
            }
        });
    }

    if (!isUpdate)
        collapseDetails(DETAIL_SECTIONS);
}

From source file:com.zoffcc.applications.zanavi.Navit.java

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    if (last_orientation != newConfig.orientation) {
        // Checks the orientation of the screen
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            // setContentView(R.layout.main_layout);

            // -- bottom bar --
            int h = NavitGraphics.mCanvasHeight;
            try {
                int h001;
                android.view.ViewGroup.LayoutParams lp001;

                View v003 = (View) findViewById(R.id.osd_nextturn_new);
                h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height);
                lp001 = v003.getLayoutParams();
                lp001.height = h001;//from  w ww .  java 2  s. com
                v003.requestLayout();

                v003 = (View) findViewById(R.id.bottom_bar);
                h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
                lp001 = v003.getLayoutParams();
                lp001.height = h001;
                v003.requestLayout();

                LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view);
                h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height);
                lp001 = v002.getLayoutParams();
                lp001.height = h001;
                v002.requestLayout();

                v003 = (View) findViewById(R.id.osd_timetodest_new);
                h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height);
                lp001 = v003.getLayoutParams();
                lp001.height = h001;
                v003.requestLayout();

                v002 = (LinearLayout) findViewById(R.id.bottom_line_container);
                h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height);
                lp001 = v002.getLayoutParams();
                lp001.height = h001;
                v002.requestLayout();

                RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container);
                h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
                lp001 = v001.getLayoutParams();
                lp001.height = h001;
                v001.requestLayout();

                int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding);
                int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding);
                v003 = (View) findViewById(R.id.view_speeding);
                RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003
                        .getLayoutParams();
                relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom
                v003.setLayoutParams(relativeParams_001);
                v003.requestLayout();

                smaller_top_bar(true);

                // Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();

                bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
                bottom_bar_slider_shadow_px = (int) getResources()
                        .getDimension(R.dimen.bottom_slide_view_shadow_compat_height);

                Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px
                        - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
            } catch (Exception e) {
                Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px
                        - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
            }
            Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
            // -- bottom bar --
        } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
            // setContentView(R.layout.main_layout);

            // -- bottom bar --
            int h = NavitGraphics.mCanvasHeight;
            try {
                int h001;
                android.view.ViewGroup.LayoutParams lp001;

                View v003 = (View) findViewById(R.id.osd_nextturn_new);
                h001 = getResources().getDimensionPixelSize(R.dimen.osd_nextturn_new_height);
                lp001 = v003.getLayoutParams();
                lp001.height = h001;
                v003.requestLayout();

                v003 = (View) findViewById(R.id.bottom_bar);
                h001 = getResources().getDimensionPixelSize(R.dimen.bottom_bar_height);
                lp001 = v003.getLayoutParams();
                lp001.height = h001;
                v003.requestLayout();

                LinearLayout v002 = (LinearLayout) findViewById(R.id.bottom_slide_view);
                h001 = getResources().getDimensionPixelSize(R.dimen.bottom_slide_view_height);
                lp001 = v002.getLayoutParams();
                lp001.height = h001;
                v002.requestLayout();

                v003 = (View) findViewById(R.id.osd_timetodest_new);
                h001 = getResources().getDimensionPixelSize(R.dimen.osd_timetodest_new_height);
                lp001 = v003.getLayoutParams();
                lp001.height = h001;
                v003.requestLayout();

                v002 = (LinearLayout) findViewById(R.id.bottom_line_container);
                h001 = getResources().getDimensionPixelSize(R.dimen.bottom_line_container_height);
                lp001 = v002.getLayoutParams();
                lp001.height = h001;
                v002.requestLayout();

                RelativeLayout v001 = (RelativeLayout) findViewById(R.id.gui_top_container);
                h001 = getResources().getDimensionPixelSize(R.dimen.gui_top_container_height);
                lp001 = v001.getLayoutParams();
                lp001.height = h001;
                v001.requestLayout();

                int ml = getResources().getDimensionPixelSize(R.dimen.margin_left_speeding);
                int mb = getResources().getDimensionPixelSize(R.dimen.margin_bottom_speeding);
                v003 = (View) findViewById(R.id.view_speeding);
                RelativeLayout.LayoutParams relativeParams_001 = (RelativeLayout.LayoutParams) v003
                        .getLayoutParams();
                relativeParams_001.setMargins(ml, 0, 0, mb); // left, top, right, bottom
                v003.setLayoutParams(relativeParams_001);
                v003.requestLayout();

                smaller_top_bar(false);

                // Toast.makeText(this, "protrait", Toast.LENGTH_SHORT).show();

                bottom_bar_px = (int) getResources().getDimension(R.dimen.gui_top_container_height);
                bottom_bar_slider_shadow_px = (int) getResources()
                        .getDimension(R.dimen.bottom_slide_view_shadow_compat_height);

                Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px
                        - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
            } catch (Exception e) {
                Navit.cur_y_margin_bottom_bar_touch = h + Navit.actionBarHeight + bottom_bar_px
                        - Navit.bottom_bar_slider_shadow_px; // try to put view at bottom
            }
            Navit.bottom_y_margin_bottom_bar_touch = Navit.cur_y_margin_bottom_bar_touch;
            // -- bottom bar --
        }

        last_orientation = newConfig.orientation;
    }
}