Ejemplo n.º 1
0
 public java.util.List <T> getSystemListeners()
 {
     lock (this)
     {
         if (systemList == null || systemList.isEmpty())
         {
             return(java.util.Collections <T> .emptyList());
         }
         return(new java.util.ArrayList <T>(systemList));
     }
 }
Ejemplo n.º 2
0
        private android.view.View findNextFocus(android.view.ViewGroup root, android.view.View
                                                focused, android.graphics.Rect focusedRect, int direction)
        {
            java.util.ArrayList <android.view.View> focusables = root.getFocusables(direction);
            if (focusables.isEmpty())
            {
                // The focus cannot change.
                return(null);
            }
            if (direction == android.view.View.FOCUS_FORWARD || direction == android.view.View
                .FOCUS_BACKWARD)
            {
                if (focused != null && !focusables.contains(focused))
                {
                    // Add the currently focused view to the list to have it sorted
                    // along with the other views.
                    focusables.add(focused);
                }
                try
                {
                    // Note: This sort is stable.
                    mSequentialFocusComparator.setRoot(root);
                    java.util.Collections.sort(focusables, mSequentialFocusComparator);
                }
                finally
                {
                    mSequentialFocusComparator.recycle();
                }
                int count = focusables.size();
                switch (direction)
                {
                case android.view.View.FOCUS_FORWARD:
                {
                    if (focused != null)
                    {
                        int position = focusables.lastIndexOf(focused);
                        if (position >= 0 && position + 1 < count)
                        {
                            return(focusables.get(position + 1));
                        }
                    }
                    return(focusables.get(0));
                }

                case android.view.View.FOCUS_BACKWARD:
                {
                    if (focused != null)
                    {
                        int position = focusables.indexOf(focused);
                        if (position > 0)
                        {
                            return(focusables.get(position - 1));
                        }
                    }
                    return(focusables.get(count - 1));
                }
                }
                return(null);
            }
            // initialize the best candidate to something impossible
            // (so the first plausible view will become the best choice)
            mBestCandidateRect.set(focusedRect);
            switch (direction)
            {
            case android.view.View.FOCUS_LEFT:
            {
                mBestCandidateRect.offset(focusedRect.width() + 1, 0);
                break;
            }

            case android.view.View.FOCUS_RIGHT:
            {
                mBestCandidateRect.offset(-(focusedRect.width() + 1), 0);
                break;
            }

            case android.view.View.FOCUS_UP:
            {
                mBestCandidateRect.offset(0, focusedRect.height() + 1);
                break;
            }

            case android.view.View.FOCUS_DOWN:
            {
                mBestCandidateRect.offset(0, -(focusedRect.height() + 1));
                break;
            }
            }
            android.view.View closest = null;
            int numFocusables         = focusables.size();

            {
                for (int i = 0; i < numFocusables; i++)
                {
                    android.view.View focusable = focusables.get(i);
                    // only interested in other non-root views
                    if (focusable == focused || focusable == root)
                    {
                        continue;
                    }
                    // get visible bounds of other view in same coordinate system
                    focusable.getDrawingRect(mOtherRect);
                    root.offsetDescendantRectToMyCoords(focusable, mOtherRect);
                    if (isBetterCandidate(direction, focusedRect, mOtherRect, mBestCandidateRect))
                    {
                        mBestCandidateRect.set(mOtherRect);
                        closest = focusable;
                    }
                }
            }
            return(closest);
        }
Ejemplo n.º 3
0
            //UPGRADE_TODO: The equivalent of method 'java.lang.Thread.run' is not an override method. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1143"'
            //UPGRADE_NOTE: Synchronized keyword was removed from method 'run'. Lock expression was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1027"'
            /// <summary> Simply runs the ChannelListener and lets it process Events.
            /// </summary>
            public override void Run()
            {
                lock (this)
                {
                    List msgEvents = new ArrayList();
                    bool printPrompt = false;

                    while (Enclosing_Instance.running)
                    {
                        Enclosing_Instance.channel.fillEventList(msgEvents);
                        if (!msgEvents.isEmpty())
                        {
                            Enclosing_Instance.stopTimer();
                            System.Text.StringBuilder buffer = new System.Text.StringBuilder();
                            for (int idx = 0; idx < msgEvents.size(); idx++)
                            {
                                MessageEvent event_Renamed = (MessageEvent) msgEvents.get(idx);
                                if (event_Renamed.Type == MessageEvent.PARSE_ERROR || event_Renamed.Type == MessageEvent.ERROR || event_Renamed.Type == MessageEvent.RESULT)
                                {

                                    printPrompt = true;
                                    Enclosing_Instance.lastIncompleteCommand = new System.Text.StringBuilder();
                                }
                                if (event_Renamed.Type == MessageEvent.ERROR)
                                {
                                    //UPGRADE_ISSUE: Method 'java.lang.System.getProperty' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javalangSystemgetProperty_javalangString"'
                                    buffer.Append(exceptionToString((System.Exception) event_Renamed.Message).Trim() + System.getProperty("line.separator"));
                                }
                                //UPGRADE_TODO: The equivalent in .NET for method 'java.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
                                if (event_Renamed.Type != MessageEvent.COMMAND && !event_Renamed.Message.ToString().Equals("") && !event_Renamed.Message.Equals(Constants.NIL_SYMBOL))
                                {
                                    //UPGRADE_TODO: The equivalent in .NET for method 'java.Object.toString' may return a different value. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1043"'
                                    //UPGRADE_ISSUE: Method 'java.lang.System.getProperty' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javalangSystemgetProperty_javalangString"'
                                    buffer.Append(event_Renamed.Message.ToString().Trim() + System.getProperty("line.separator"));
                                }
                            }
                            msgEvents.clear();
                            Enclosing_Instance.hideCursor();
                            Enclosing_Instance.printMessage(buffer.ToString().Trim(), true);
                            if (printPrompt)
                            {
                                Enclosing_Instance.printPrompt();
                                Enclosing_Instance.moveCursorTo(Enclosing_Instance.lastPromptIndex);
                            }
                            Enclosing_Instance.showCursor();
                            printPrompt = false;
                            Enclosing_Instance.startTimer();
                        }
                        else
                        {
                            try
                            {
                                System.Threading.Thread.Sleep(new System.TimeSpan(10000 * 10));
                            }
                            catch (System.Threading.ThreadInterruptedException e)
                            {
                                // Can be ignored
                            }
                        }
                    }
                    try
                    {
                        Enclosing_Instance.outWriter.Close();
                    }
                    catch (System.IO.IOException e)
                    {
                        // we silently ignore it
                        SupportClass.WriteStackTrace(e, Console.Error);
                    }
                    Enclosing_Instance.gui.Engine.MessageRouter.closeChannel(Enclosing_Instance.channel);
                }
            }
Ejemplo n.º 4
0
 public override void addTab(android.app.ActionBar.Tab tab)
 {
     addTab(tab, mTabs.isEmpty());
 }