Exemple #1
0
  public void processConnection(HttpConnection connection, Object e) {
    BrowserContent browserContent = null;

    try {
      if (connection.getResponseCode() != HttpConnection.HTTP_NOT_MODIFIED)
        browserContent = _renderingSession.getBrowserContent(connection, this, (Event) e);

      if (browserContent != null) {
        browserContent.finishLoading();

        Field field = browserContent.getDisplayableContent();
        if (field != null) {

          synchronized (Application.getEventLock()) {
            m_oMainScreen.deleteAll();
            m_oMainScreen.add(field);

            /*if ( m_oMainScreen.getFieldCount() > 0 )
            {
            	Field old = m_oMainScreen.getField(0);
            	m_oMainScreen.add(field);
            	m_oMainScreen.delete(old);
            }else
            	m_oMainScreen.add(field);*/
            /*
            _mainScreen.doPaint();
            if ( e == null )
            {//This should awake screen in case of long network response
             KeyCodeEvent inject1 = 	new KeyCodeEvent( KeyCodeEvent.KEY_DOWN, (char)Keypad.KEY_ESCAPE, 0);
             KeyCodeEvent inject2 =  new KeyCodeEvent( KeyCodeEvent.KEY_UP, (char)Keypad.KEY_ESCAPE, 0);
             inject1.post();
             inject2.post();
             m_bSkipKeyPress = true;
            }*/
          }
        }
      }
    } catch (Exception re) {
      LOG.ERROR("processConnection failed.", re);
    } finally {
      SecondaryResourceFetchThread.doneAddingImages();
    }
  }
 /**
  * Processes a new HttpConnection object to instantiate a new browser Field (aka WebView) object,
  * and then resets the screen to the newly-created Field.
  *
  * @param connection
  * @param e
  */
 public void processConnection(HttpConnection connection, Event e) {
   // Cancel previous request.
   if (_currentConnection != null) {
     try {
       _currentConnection.close();
     } catch (IOException e1) {
     }
   }
   // Clear out pending responses.
   synchronized (pendingResponses) {
     pendingResponses.removeAllElements();
   }
   // Cancel any XHRs happening.
   commandManager.stopXHR();
   _currentConnection = connection;
   BrowserContent browserContent = null;
   Field field = null;
   try {
     browserContent = _renderingSession.getBrowserContent(connection, this, e);
     if (browserContent != null) {
       field = browserContent.getDisplayableContent();
       if (field != null) {
         synchronized (Application.getEventLock()) {
           _mainScreen.deleteAll();
           _mainScreen.add(field);
         }
       }
       browserContent.finishLoading();
     }
   } catch (RenderingException re) {
   } finally {
     browserContent = null;
     field = null;
     // Manually call the garbage collector to clean up all of leftover objects and free up the
     // nulled object handles.
     System.gc();
   }
 }