Search in sources :

Example 1 with Condition

use of com.codename1.rad.attributes.Condition in project CodeRAD by shannah.

the class DefaultActionViewFactory method update.

public static void update(MultiButton btn, Entity entity, ActionNode action) {
    boolean repaint = false;
    boolean revalidate = false;
    Condition cond = action.getCondition();
    if (cond != null) {
        boolean hidden = !cond.getValue().test(entity);
        if (hidden != btn.isHidden()) {
            btn.setHidden(hidden);
            btn.setVisible(!hidden);
            revalidate = true;
        }
    }
    EnabledCondition enabledCond = action.getEnabledCondition();
    if (enabledCond != null) {
        boolean enabled = enabledCond.getValue().test(entity);
        if (enabled != btn.isEnabled()) {
            btn.setEnabled(enabled);
            repaint = true;
        }
    }
    if (action.getLabel() != null) {
        // String currTextVal = btn.getText();
        String newTextVal = action.getLabelText(entity);
        String currTextVal = btn.getTextLines();
        if (!Objects.equals(currTextVal.trim(), newTextVal.trim())) {
            btn.setTextLines(newTextVal.trim());
            repaint = true;
        }
    }
    if (!action.isTextStyle() && !"".equals(btn.getTextLines().trim())) {
        btn.setTextLine1("");
        btn.setTextLine2("");
        btn.setTextLine3("");
        btn.setTextLine4("");
        repaint = true;
    }
    if (action.getUIID() != null) {
        String currUiid = btn.getUIID();
        String newUiid = action.getUIID(entity, "Button");
        if (!Objects.equals(currUiid, newUiid)) {
            btn.setUIID(newUiid);
            repaint = true;
        }
    }
    if (btn.isCheckBox()) {
        SelectedCondition selectedCond = action.getSelectedCondition();
        if (selectedCond != null) {
            boolean selected = selectedCond.getValue().test(entity);
            if (selected != btn.isSelected()) {
                btn.setSelected(selected);
                repaint = true;
                ActionNode newState = selected ? action.getSelected() : action.getUnselected();
                ActionNode oldState = selected ? action.getUnselected() : action.getSelected();
                if (oldState != newState) {
                    String currText = btn.getText();
                    String newText = newState.getLabelText(entity);
                    if (!newState.isTextStyle()) {
                        newText = "";
                    }
                    if (!Objects.equals(newText, currText)) {
                        btn.setText(newText);
                    }
                }
            }
        }
    }
    Badge badge = action.getBadge();
    if (badge != null) {
        btn.setBadgeText(badge.getValue(entity));
        BadgeUIID badgeUiid = action.getBadgeUIID();
        if (badgeUiid != null) {
            btn.setBadgeUIID(badgeUiid.getValue());
        }
    }
    if (revalidate || repaint) {
        Form f = btn.getComponentForm();
        if (f != null) {
            if (revalidate) {
                Component entityView = findEntityViewParent(btn);
                if (entityView instanceof Container) {
                    ((Container) entityView).revalidateLater();
                } else {
                    entityView.repaint();
                }
            } else {
                btn.repaint();
            }
        }
    }
}
Also used : EnabledCondition(com.codename1.rad.nodes.ActionNode.EnabledCondition) Condition(com.codename1.rad.attributes.Condition) SelectedCondition(com.codename1.rad.attributes.SelectedCondition) SelectedCondition(com.codename1.rad.attributes.SelectedCondition) Container(com.codename1.ui.Container) Form(com.codename1.ui.Form) EnabledCondition(com.codename1.rad.nodes.ActionNode.EnabledCondition) ActionNode(com.codename1.rad.nodes.ActionNode) Badge(com.codename1.rad.attributes.Badge) Component(com.codename1.ui.Component) BadgeUIID(com.codename1.rad.attributes.BadgeUIID)

Example 2 with Condition

use of com.codename1.rad.attributes.Condition in project CodenameOne by codenameone.

the class CommonTransitions method paintAlpha.

private void paintAlpha(Graphics graphics) {
    Component src = getSource();
    int w = src.getWidth();
    int h = src.getHeight();
    int position = this.position;
    if (position > 255) {
        position = 255;
    } else {
        if (position < 0) {
            position = 0;
        }
    }
    // for slow mutable images
    if (buffer == null) {
        Component dest = getDestination();
        Component srcCmp = src;
        Component destCmp = dest;
        int alpha = position;
        if (src instanceof Dialog && dest instanceof Form) {
            srcCmp = dest;
            destCmp = src;
            alpha = 255 - position;
        }
        paint(graphics, srcCmp, 0, 0);
        destCmp.setX(srcCmp.getX());
        destCmp.setY(srcCmp.getY());
        destCmp.setWidth(srcCmp.getWidth());
        destCmp.setHeight(srcCmp.getHeight());
        graphics.setAlpha(alpha);
        paint(graphics, destCmp, 0, 0);
        graphics.setAlpha(255);
        return;
    }
    // this will always be invoked on the EDT so there is no race condition risk
    if (rgbBuffer != null || secondaryBuffer != null) {
        if (secondaryBuffer != null) {
            Component dest = getDestination();
            int x = dest.getAbsoluteX();
            int y = dest.getAbsoluteY();
            graphics.drawImage(buffer, x, y);
            graphics.setAlpha(position);
            graphics.drawImage(secondaryBuffer, x, y);
            graphics.setAlpha(0xff);
        } else {
            int alpha = position << 24;
            int[] bufferArray = rgbBuffer.getRGB();
            int size = bufferArray.length;
            for (int iter = 0; iter < size; iter++) {
                bufferArray[iter] = ((bufferArray[iter] & 0xFFFFFF) | alpha);
            }
            Component dest = getDestination();
            int x = dest.getAbsoluteX();
            int y = dest.getAbsoluteY();
            graphics.drawImage(buffer, x, y);
            graphics.drawImage(rgbBuffer, x, y);
        }
    }
}
Also used : Form(com.codename1.ui.Form) Dialog(com.codename1.ui.Dialog) Component(com.codename1.ui.Component)

Example 3 with Condition

use of com.codename1.rad.attributes.Condition in project CodenameOne by codenameone.

the class LazyValueC method showContainerImpl.

private Container showContainerImpl(String resourceName, Command sourceCommand, Component sourceComponent, boolean forceBack) {
    if (sourceComponent != null) {
        Form currentForm = sourceComponent.getComponentForm();
        // avoid the overhead of searching if no embedding is used
        if (currentForm.getClientProperty(EMBEDDED_FORM_FLAG) != null) {
            Container destContainer = sourceComponent.getParent();
            while (!(destContainer instanceof EmbeddedContainer || destContainer instanceof Form)) {
                // race condition, container was already removed by someone else
                if (destContainer == null) {
                    return null;
                }
                destContainer = destContainer.getParent();
            }
            if (destContainer instanceof EmbeddedContainer) {
                Container cnt = createContainer(fetchResourceFile(), resourceName, (EmbeddedContainer) destContainer);
                if (cnt instanceof Form) {
                    // Form f = (Form)cnt;
                    // cnt = formToContainer(f);
                    showForm((Form) cnt, sourceCommand, sourceComponent);
                    return cnt;
                }
                Component fromCmp = destContainer.getComponentAt(0);
                // This seems to be no longer necessary now that we have the replaceAndWait version that drops events
                // block the user from the ability to press the button twice by mistake
                // fromCmp.setEnabled(false);
                boolean isBack = forceBack;
                Transition t = fromCmp.getUIManager().getLookAndFeel().getDefaultFormTransitionOut();
                if (forceBack) {
                    initBackContainer(cnt, destContainer.getComponentForm(), getFormNavigationStackForComponent(sourceComponent));
                    t = t.copy(true);
                } else {
                    if (sourceCommand != null) {
                        if (t != null && backCommands != null && backCommands.contains(sourceCommand) || Display.getInstance().getCurrent().getBackCommand() == sourceCommand) {
                            isBack = true;
                            t = t.copy(true);
                        }
                    }
                }
                // create a back command if supported
                String commandAction = cnt.getName();
                Vector formNavigationStack = getFormNavigationStackForComponent(fromCmp);
                if (formNavigationStack != null && !isBack && allowBackTo(commandAction) && !isSameBackDestination((Container) fromCmp, cnt)) {
                    // trigger listener creation if this is the only command in the form
                    getFormListenerInstance(destContainer.getComponentForm(), null);
                    formNavigationStack.addElement(getContainerState((com.codename1.ui.Container) fromCmp));
                }
                beforeShowContainer(cnt);
                destContainer.replaceAndWait(fromCmp, cnt, t, true);
                postShowContainer(cnt);
                return cnt;
            } else {
                Container cnt = createContainer(fetchResourceFile(), resourceName);
                showForm((Form) cnt, sourceCommand, sourceComponent);
                return cnt;
            }
        }
    }
    Container cnt = createContainer(fetchResourceFile(), resourceName);
    if (cnt instanceof Form) {
        showForm((Form) cnt, sourceCommand, sourceComponent);
    } else {
        Form f = new Form();
        f.setLayout(new BorderLayout());
        f.addComponent(BorderLayout.CENTER, cnt);
        f.setName("Form" + cnt.getName());
        showForm(f, sourceCommand, sourceComponent);
    }
    return cnt;
}
Also used : Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) Form(com.codename1.ui.Form) Transition(com.codename1.ui.animations.Transition) Component(com.codename1.ui.Component) Vector(java.util.Vector)

Example 4 with Condition

use of com.codename1.rad.attributes.Condition in project CodenameOne by codenameone.

the class ResetableTextWatcher method startEditing.

/**
 * Start editing the given text-area
 * This method is executed on the UI thread, so UI manipulation is safe here.
 * @param activity Current running activity
 * @param textArea The TextAreaData instance that wraps the CN1 TextArea that our internal EditText needs to overlap.  We use
 *                 a TextAreaData so that the text area properties can be accessed off the EDT safely.
 * @param codenameOneInputType One of the input type constants in com.codename1.ui.TextArea
 * @param initialText The text that appears in the Codename One text are before the call to startEditing
 * @param isEditedFieldSwitch if true, then special case for async edit mode - the native editing is already active, no need to show
 *                            native field, just change the connected field
 */
private synchronized void startEditing(Activity activity, TextAreaData textArea, String initialText, int codenameOneInputType, final boolean isEditedFieldSwitch) {
    int txty = lastTextAreaY = textArea.getAbsoluteY() + textArea.getScrollY();
    int txtx = lastTextAreaX = textArea.getAbsoluteX() + textArea.getScrollX();
    lastTextAreaWidth = textArea.getWidth();
    lastTextAreaHeight = textArea.getHeight();
    int paddingTop = 0;
    int paddingLeft = textArea.paddingLeft;
    int paddingRight = textArea.paddingRight;
    int paddingBottom = textArea.paddingBottom;
    // An ugly hack to smooth over an apparent race condition where
    // the lightweight textarea is not repainted after the native text field
    // becomes visible - resulting in the hint still appearing while typing.
    // https://github.com/codenameone/CodenameOne/issues/2629
    // We just blindly repaint the textfield every 50ms for half a second
    // to make sure it gets a repaint properly.
    final TextArea fTextArea = textArea.textArea;
    new Thread(new Runnable() {

        public void run() {
            for (int i = 0; i < 10; i++) {
                com.codename1.io.Util.sleep(50);
                com.codename1.ui.CN.callSerially(new Runnable() {

                    public void run() {
                        fTextArea.repaint();
                    }
                });
            }
        }
    }).start();
    if (textArea.isTextField) {
        switch(textArea.getVerticalAlignment()) {
            case Component.BOTTOM:
                paddingTop = textArea.getHeight() - textArea.paddingBottom - textArea.fontHeight;
                break;
            case Component.CENTER:
                paddingTop = textArea.getHeight() / 2 - textArea.fontHeight / 2;
                break;
            default:
                paddingTop = textArea.paddingTop;
                break;
        }
    } else {
        paddingTop = textArea.paddingTop;
    }
    int id = activity.getResources().getIdentifier("cn1Style", "attr", activity.getApplicationInfo().packageName);
    if (!isEditedFieldSwitch) {
        mEditText = new EditView(activity, textArea.textArea, this, id);
        defaultInputType = mEditText.getInputType();
        defaultIMEOptions = mEditText.getImeOptions();
    } else {
        mEditText.switchToTextArea(textArea.textArea);
    }
    if (textArea.getClientProperty("blockCopyPaste") != null || Display.getInstance().getProperty("blockCopyPaste", "false").equals("true")) {
        // The code below is taken from this stackoverflow answer: http://stackoverflow.com/a/22756538/756809
        if (android.os.Build.VERSION.SDK_INT < 11) {
            mEditText.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {

                @Override
                public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
                    menu.clear();
                }
            });
        } else {
            mEditText.setCustomSelectionActionModeCallback(new ActionMode.Callback() {

                public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
                    return false;
                }

                public void onDestroyActionMode(ActionMode mode) {
                }

                public boolean onCreateActionMode(ActionMode mode, Menu menu) {
                    return false;
                }

                public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
                    return false;
                }
            });
        }
    } else if (isEditedFieldSwitch) {
        // reset copy-paste protection
        if (android.os.Build.VERSION.SDK_INT < 11) {
            mEditText.setOnCreateContextMenuListener(null);
        } else {
            mEditText.setCustomSelectionActionModeCallback(null);
        }
    }
    if (!isEditedFieldSwitch) {
        mEditText.addTextChangedListener(mEditText.mTextWatcher);
    }
    mEditText.setBackgroundDrawable(null);
    mEditText.setFocusableInTouchMode(true);
    mEditLayoutParams = new FrameLayout.LayoutParams(0, 0);
    // Set the appropriate gravity so that the left and top margins will be
    // taken into account
    mEditLayoutParams.gravity = Gravity.LEFT | Gravity.TOP;
    mEditLayoutParams.setMargins(txtx, txty, 0, 0);
    mEditLayoutParams.width = textArea.getWidth();
    mEditLayoutParams.height = textArea.getHeight();
    mEditText.setLayoutParams(mEditLayoutParams);
    if (textArea.isRTL()) {
        mEditText.setGravity(Gravity.RIGHT | Gravity.TOP);
    } else {
        mEditText.setGravity(Gravity.LEFT | Gravity.TOP);
    }
    mEditText.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
    Component nextDown = textArea.nextDown;
    boolean imeOptionTaken = true;
    int ime = EditorInfo.IME_FLAG_NO_EXTRACT_UI;
    if (textArea.isSingleLineTextArea() || textArea.getDoneListener() != null) {
        if (textArea.getClientProperty("searchField") != null) {
            mEditText.setImeOptions(ime | EditorInfo.IME_ACTION_SEARCH);
        } else {
            if (textArea.getClientProperty("sendButton") != null) {
                mEditText.setImeOptions(ime | EditorInfo.IME_ACTION_SEND);
            } else {
                if (textArea.getClientProperty("goButton") != null) {
                    mEditText.setImeOptions(ime | EditorInfo.IME_ACTION_GO);
                } else {
                    if (textArea.getDoneListener() != null) {
                        mEditText.setImeOptions(ime | EditorInfo.IME_ACTION_DONE);
                    } else if (nextDown != null) {
                        mEditText.setImeOptions(ime | EditorInfo.IME_ACTION_NEXT);
                    } else {
                        mEditText.setImeOptions(ime | EditorInfo.IME_ACTION_DONE);
                        imeOptionTaken = false;
                    }
                }
            }
        }
    }
    mEditText.setSingleLine(textArea.isSingleLineTextArea());
    mEditText.setAdapter((ArrayAdapter<String>) null);
    mEditText.setText(initialText);
    if (!textArea.isSingleLineTextArea() && textArea.textArea.isGrowByContent() && textArea.textArea.getGrowLimit() > -1) {
        defaultMaxLines = mEditText.getMaxLines();
        mEditText.setMaxLines(textArea.textArea.getGrowLimit());
    }
    if (textArea.nativeHintBool && textArea.getHint() != null) {
        mEditText.setHint(textArea.getHint());
    }
    if (!isEditedFieldSwitch) {
        addView(mEditText, mEditLayoutParams);
    }
    invalidate();
    setVisibility(VISIBLE);
    bringToFront();
    mEditText.requestFocus();
    Object nativeFont = textArea.nativeFont;
    if (nativeFont == null) {
        nativeFont = impl.getDefaultFont();
    }
    Paint p = (Paint) ((AndroidImplementation.NativeFont) nativeFont).font;
    mEditText.setTypeface(p.getTypeface());
    mEditText.setTextScaleX(p.getTextScaleX());
    mEditText.setTextSize(TypedValue.COMPLEX_UNIT_PX, p.getTextSize());
    int fgColor = textArea.fgColor;
    mEditText.setTextColor(Color.rgb(fgColor >> 16, (fgColor & 0x00ff00) >> 8, (fgColor & 0x0000ff)));
    boolean password = false;
    if ((codenameOneInputType & TextArea.PASSWORD) == TextArea.PASSWORD) {
        codenameOneInputType = codenameOneInputType ^ TextArea.PASSWORD;
        password = true;
    }
    if (textArea.isSingleLineTextArea()) {
        mEditText.setInputType(getAndroidInputType(codenameOneInputType));
        // if not ime was explicity requested and this is a single line textfield of type ANY add the emoji keyboard.
        if (!imeOptionTaken && codenameOneInputType == TextArea.ANY) {
            mEditText.setInputType(getAndroidInputType(codenameOneInputType) | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
        }
        if (Display.getInstance().getProperty("andAddComma", "false").equals("true") && (codenameOneInputType & TextArea.DECIMAL) == TextArea.DECIMAL) {
            defaultKeyListener = mEditText.getKeyListener();
            mEditText.setKeyListener(DigitsKeyListener.getInstance("0123456789.,"));
        }
    } else {
        if (textArea.getDoneListener() != null) {
            mEditText.setHorizontallyScrolling(false);
            mEditText.setMaxLines(Integer.MAX_VALUE);
            mEditText.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
            mEditText.setMaxWidth(textArea.getWidth());
            mEditText.setMaxHeight(textArea.getHeight());
            mEditText.setHorizontalScrollBarEnabled(false);
            mEditText.getLayoutParams().width = textArea.getWidth();
            mEditText.getLayoutParams().height = textArea.getHeight();
        } else {
            mEditText.setInputType(getAndroidInputType(codenameOneInputType, true));
        }
    }
    if (password) {
        int type = mInputTypeMap.get(codenameOneInputType, InputType.TYPE_CLASS_TEXT);
        if ((type & InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) == InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) {
            type = type ^ InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
        }
        // turn off suggestions for passwords
        mEditText.setInputType(type | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
        mEditText.setTransformationMethod(new MyPasswordTransformationMethod());
    }
    int maxLength = textArea.maxSize;
    InputFilter[] FilterArray = new InputFilter[1];
    FilterArray[0] = new InputFilter.LengthFilter(maxLength);
    mEditText.setFilters(FilterArray);
    mEditText.setSelection(mEditText.getText().length());
    showVirtualKeyboard(true);
    if (Boolean.FALSE.equals(textArea.getClientProperty("android.cursorVisible"))) {
        // This provides an imperfect workaround for this issue:
        // https://github.com/codenameone/CodenameOne/issues/2317
        // Blinking cursor causes text to disappear on some versions of android
        // Can't seem to find how to detect whether device is affected, so
        // just providing a client property to disable the blinking cursor
        // on a particular text field.
        mEditText.setCursorVisible(false);
    }
/*
        // Leaving this hack here for posterity.  It seems that this manually
        // blinking cursor causes the paste menu to disappear
        // https://github.com/codenameone/CodenameOne/issues/2147
        // Removing the hack below, fixes this issue.  And in the test device
        // I'm using the blinking of text doesn't seem to occur, so perhaps
        // it was fixed via other means.  Test device:
        // Name: Samsung Galaxy S3 (T-Mobile)
        //    OS: 4.3
        //    Manufacturer: Samsung
        //    Model: 4.3
        //    Chipset: armeabi-v7a 1512MHz
        //    Memory: 16000000000
        //    Heap: 256000000
        //    Display: 720 x 1280
        //
        // UPDATE Feb. 13, 2018:
        // This issue seems to be still present in some devices, but it isn't clear even
        // how to detect it.
        // Issue reported and reproduced here https://github.com/codenameone/CodenameOne/issues/2317
        // Issue has been observed in a Virtual Box installation with 5.1.1, but
        // cannot be reproduced in a Nexus 5 running 5.1.1.
        // 
        if (Build.VERSION.SDK_INT < 21) {
            // HACK!!!  On Android 4.4, it seems that the natural blinking cursor
            // causes text to disappear when it blinks.  Manually blinking the
            // cursor seems to work around this issue, so that's what we do here.
            // This issue is described here: http://stackoverflow.com/questions/41305052/textfields-content-disappears-during-typing?noredirect=1#comment69977316_41305052
            mEditText.setCursorVisible(false);
            final boolean[] cursorVisible = new boolean[]{false};
            if (cursorTimer != null) {
                cursorTimer.cancel();
            }
            cursorTimer = new Timer();
            cursorTimerTask = new TimerTask() {
                public void run() {
                    AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
                        public void run() {
                            EditView v = mEditText;
                            if (v != null) {
                                cursorVisible[0] = !cursorVisible[0];
                                v.setCursorVisible(cursorVisible[0]);
                            }
                        }
                    });

                }
            };
            cursorTimer.schedule(cursorTimerTask, 100, 500);
        }
        */
}
Also used : TextArea(com.codename1.ui.TextArea) ContextMenu(android.view.ContextMenu) ContextMenu(android.view.ContextMenu) Menu(android.view.Menu) Component(com.codename1.ui.Component) InputFilter(android.text.InputFilter) MenuItem(android.view.MenuItem) Paint(android.graphics.Paint) View(android.view.View) AutoCompleteTextView(android.widget.AutoCompleteTextView) Paint(android.graphics.Paint) ActionMode(android.view.ActionMode) FrameLayout(android.widget.FrameLayout) ContextMenuInfo(android.view.ContextMenu.ContextMenuInfo)

Example 5 with Condition

use of com.codename1.rad.attributes.Condition in project CodenameOne by codenameone.

the class AndroidAsyncView method flushGraphics.

@Override
public void flushGraphics(Rect rect) {
    // Log.d(Display.getInstance().getProperty("AppName", "CodenameOne"), "Flush graphics invoked with pending: " + pendingRenderingOperations.size() + " and current " + renderingOperations.size());
    // we might have pending entries in the rendering queue
    int counter = 0;
    while (!renderingOperations.isEmpty()) {
        try {
            synchronized (RENDERING_OPERATIONS_LOCK) {
                RENDERING_OPERATIONS_LOCK.wait(5);
            }
            // don't let the EDT die here
            counter++;
            if (counter > 10) {
                synchronized (RENDERING_OPERATIONS_LOCK) {
                    pendingRenderingOperations.clear();
                    if (timeoutCounter++ > 10) {
                        renderingOperations.clear();
                    }
                }
                // Log.d(Display.getInstance().getProperty("AppName", "CodenameOne"), "Flush graphics timed out!!!");
                Display.getInstance().callSerially(new Runnable() {

                    @Override
                    public void run() {
                        Form f = Display.getInstance().getCurrent();
                        if (f != null) {
                            f.repaint();
                        }
                    }
                });
                return;
            }
        } catch (InterruptedException err) {
        }
    }
    timeoutCounter = 0;
    ArrayList<AsyncOp> tmp = renderingOperations;
    renderingOperations = pendingRenderingOperations;
    pendingRenderingOperations = tmp;
    try {
        for (AsyncOp o : renderingOperations) {
            o.prepare();
        }
    } catch (java.util.ConcurrentModificationException ex) {
        // This is a race condition that sometimes occurs
        // Rather than add synchronized here (which may have performance implications)
        // we'll just "give up" and issue a repaint.
        Log.p("NOTICE: Hit concurrent modification race condition in flushGraphics.  Skipping flush, and issuing another repaint.");
        Log.e(ex);
        Display.getInstance().callSerially(new Runnable() {

            @Override
            public void run() {
                Form f = Display.getInstance().getCurrent();
                if (f != null) {
                    f.repaint();
                }
            }
        });
        return;
    }
    int children = getChildCount();
    if (children > 0) {
        com.codename1.ui.Form c = Display.getInstance().getCurrent();
        for (int iter = 0; iter < children; iter++) {
            final View v = getChildAt(iter);
            final AndroidAsyncView.LayoutParams lp = (AndroidAsyncView.LayoutParams) v.getLayoutParams();
        // if (lp != null && c == lp.pc.getComponentForm()) {
        // v.postInvalidate();
        /*if(lp.dirty) {
                        lp.dirty = false;
                        v.post(new Runnable() {
                            @Override
                            public void run() {
                                if (v.getVisibility() == View.INVISIBLE) {
                                    v.setVisibility(View.VISIBLE);
                                }
                                v.requestLayout();
                            }
                        });
                    } else {
                        if (v.getVisibility() == View.INVISIBLE) {
                            v.post(new Runnable() {
                                @Override
                                public void run() {
                                    v.setVisibility(View.VISIBLE);
                                }
                            });
                        }
                    }*/
        // } else {
        /*if(v.getVisibility() == View.VISIBLE) {
                        v.post(new Runnable() {
                            @Override
                            public void run() {
                                v.setVisibility(View.INVISIBLE);
                            }
                        });
                    }*/
        // }
        }
    }
    if (rect == null) {
        postInvalidate();
    } else {
        postInvalidate(rect.left, rect.top, rect.right, rect.bottom);
    }
    graphics.setClip(0, 0, cn1View.width, cn1View.height);
    graphics.setAlpha(255);
    graphics.setColor(0);
}
Also used : Form(com.codename1.ui.Form) Form(com.codename1.ui.Form) View(android.view.View) Paint(android.graphics.Paint)

Aggregations

Component (com.codename1.ui.Component)5 Form (com.codename1.ui.Form)5 Container (com.codename1.ui.Container)3 Paint (android.graphics.Paint)2 View (android.view.View)2 Badge (com.codename1.rad.attributes.Badge)2 BadgeUIID (com.codename1.rad.attributes.BadgeUIID)2 Condition (com.codename1.rad.attributes.Condition)2 SelectedCondition (com.codename1.rad.attributes.SelectedCondition)2 ActionNode (com.codename1.rad.nodes.ActionNode)2 EnabledCondition (com.codename1.rad.nodes.ActionNode.EnabledCondition)2 InputFilter (android.text.InputFilter)1 ActionMode (android.view.ActionMode)1 ContextMenu (android.view.ContextMenu)1 ContextMenuInfo (android.view.ContextMenu.ContextMenuInfo)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 AutoCompleteTextView (android.widget.AutoCompleteTextView)1 FrameLayout (android.widget.FrameLayout)1 RAD (com.codename1.rad.annotations.RAD)1