public void setItemImage(byte[] image) { try { Bitmap temp = Bitmap.createBitmapFromBytes(image, 0, image.length, 1); int w = TEXT_ANCHOR - 2 * PADDING_TOP; this.newsImage = Utils.resizedImage(temp, w, w); } catch (Exception e) { } synchronized (Application.getEventLock()) { NewsItemButton.super.invalidate(); } }
/* (non-Javadoc) * @see de.enough.polish.ui.NativeDisplay#setCurrent(de.enough.polish.ui.Display) */ public void setCurrent(Display nextDisplayable) { Object lock = Application.getEventLock(); synchronized (lock) { BaseScreen baseScreen; // #if polish.blackberry // # baseScreen = nextDisplayable; // #else baseScreen = (BaseScreen) (Object) nextDisplayable; // #endif this.midlet.pushScreen(baseScreen); } }
public void processConnection(HttpConnection connection, Object e) { try { if (connection.getResponseCode() == HttpConnection.HTTP_NOT_MODIFIED) return; } catch (java.io.IOException exc) { LOG.ERROR("processConnection - getResponseCode failed.", exc); } synchronized (Application.getEventLock()) { createBrowserField(); m_oBrowserField.displayContent(connection, (e != null ? (String) e : "")); } }
public boolean notifyDisplayableChange( Displayable currentDisplayable, Displayable nextDisplayable) { // remove all fields but the dummy field: BaseScreen screen = (BaseScreen) (Object) Display.getInstance(); screen.notifyDisplayableChange(currentDisplayable, nextDisplayable); // #if polish.useNativeAlerts || polish.useNativeGui if (nextDisplayable instanceof Alert) { AlertDialog dialog = new AlertDialog((Alert) nextDisplayable); Object lock = Application.getEventLock(); synchronized (lock) { this.midlet.pushScreen(dialog); } return true; } else // #endif // #if polish.useNativeGui if (nextDisplayable instanceof Form) { Form polishForm = (Form) nextDisplayable; FormScreen bbForm = (FormScreen) polishForm.getNativeScreen(); if (bbForm == null) { bbForm = new FormScreen(polishForm); polishForm.setNativeScreen(bbForm); } Object lock = Application.getEventLock(); synchronized (lock) { if (screen.isDisplayed()) { this.midlet.popScreen(screen); } this.midlet.pushScreen(bbForm); } StyleSheet.currentScreen = polishForm; if (StyleSheet.animationThread == null) { StyleSheet.animationThread = new AnimationThread(); StyleSheet.animationThread.start(); } return true; } // #endif return false; }
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(); } }