@Override protected void onDestroy() { Log.e("SDL", "onDestroy()"); if (toastShot != null) toastShot.cancel(); if (player != null) player.onDestroy(); stopProgressTask(); System.gc(); if (multicastLock != null) { multicastLock.release(); multicastLock = null; } super.onDestroy(); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); articleFeed = new ArticleFeed(this.getBaseContext()); setFeed(articleFeed); articleFeed.loadCache(); ThumbnailCache.getInstance().setContext(getBaseContext()); setContentView(R.layout.articles_list); rubricsList = (LinearLayout) findViewById(R.id.articles_list); emptyMessage = (TextView) findViewById(R.id.empty); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); String fontSize = preferences.getString("font_list_size", "medium"); float imageSize = 12; if (fontSize.equalsIgnoreCase("small")) { imageSize = getResources().getDimension(R.dimen.image_size_small); } else if (fontSize.equalsIgnoreCase("medium")) { imageSize = getResources().getDimension(R.dimen.image_size_medium); } else if (fontSize.equalsIgnoreCase("large")) { imageSize = getResources().getDimension(R.dimen.image_size_large); } Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int width = display.getWidth(); int maxImageCount = (int) (width / imageSize + 1); Rubric.setDefaultViewCount(maxImageCount); System.gc(); listArticlesViews = new LinkedList<View>(); generateRubricsList(); }
@Override public void handleMessage(Message msg) { PlayerNotifyCodes status = (PlayerNotifyCodes) msg.obj; switch (status) { case CP_CONNECT_STARTING: if (reconnect_type == PlayerConnectType.Reconnecting) strText = "Reconnecting"; else strText = "Connecting"; startProgressTask(strText); player_state = PlayerStates.Busy; showStatusView(); reconnect_type = PlayerConnectType.Normal; setHideControls(); break; case VRP_NEED_SURFACE: player_state = PlayerStates.Busy; showVideoView(); break; case PLP_PLAY_SUCCESSFUL: player_state = PlayerStates.ReadyForUse; stopProgressTask(); playerStatusText.setText(""); setTitle(R.string.app_name); break; case PLP_CLOSE_STARTING: player_state = PlayerStates.Busy; stopProgressTask(); playerStatusText.setText("Disconnected"); showStatusView(); setUIDisconnected(); break; case PLP_CLOSE_SUCCESSFUL: player_state = PlayerStates.ReadyForUse; stopProgressTask(); playerStatusText.setText("Disconnected"); showStatusView(); System.gc(); setShowControls(); setUIDisconnected(); break; case PLP_CLOSE_FAILED: player_state = PlayerStates.ReadyForUse; stopProgressTask(); playerStatusText.setText("Disconnected"); showStatusView(); setShowControls(); setUIDisconnected(); break; case CP_CONNECT_FAILED: player_state = PlayerStates.ReadyForUse; stopProgressTask(); playerStatusText.setText("Disconnected"); showStatusView(); setShowControls(); setUIDisconnected(); break; case PLP_BUILD_FAILED: player_state = PlayerStates.ReadyForUse; stopProgressTask(); playerStatusText.setText("Disconnected"); showStatusView(); setShowControls(); setUIDisconnected(); break; case PLP_PLAY_FAILED: player_state = PlayerStates.ReadyForUse; stopProgressTask(); playerStatusText.setText("Disconnected"); showStatusView(); setShowControls(); setUIDisconnected(); break; case PLP_ERROR: player_state = PlayerStates.ReadyForUse; stopProgressTask(); playerStatusText.setText("Disconnected"); showStatusView(); setShowControls(); setUIDisconnected(); break; case CP_INTERRUPTED: player_state = PlayerStates.ReadyForUse; stopProgressTask(); playerStatusText.setText("Disconnected"); showStatusView(); setShowControls(); setUIDisconnected(); break; case CP_RECORD_STARTED: Log.v(TAG, "=handleMessage CP_RECORD_STARTED"); { String sFile = player.RecordGetFileName(1); Toast.makeText( getApplicationContext(), "Record Started. File " + sFile, Toast.LENGTH_LONG) .show(); } break; case CP_RECORD_STOPPED: Log.v(TAG, "=handleMessage CP_RECORD_STOPPED"); { String sFile = player.RecordGetFileName(0); Toast.makeText( getApplicationContext(), "Record Stopped. File " + sFile, Toast.LENGTH_LONG) .show(); } break; // case CONTENT_PROVIDER_ERROR_DISCONNECTED: case CP_STOPPED: case VDP_STOPPED: case VRP_STOPPED: case ADP_STOPPED: case ARP_STOPPED: if (player_state != PlayerStates.Busy) { stopProgressTask(); player_state = PlayerStates.Busy; if (toastShot != null) toastShot.cancel(); player.Close(); playerStatusText.setText("Disconnected"); showStatusView(); player_state = PlayerStates.ReadyForUse; setShowControls(); setUIDisconnected(); } break; case CP_ERROR_DISCONNECTED: if (player_state != PlayerStates.Busy) { player_state = PlayerStates.Busy; if (toastShot != null) toastShot.cancel(); player.Close(); playerStatusText.setText("Disconnected"); showStatusView(); player_state = PlayerStates.ReadyForUse; setUIDisconnected(); Toast.makeText(getApplicationContext(), "Demo Version!", Toast.LENGTH_SHORT).show(); } break; default: player_state = PlayerStates.Busy; } }
@Override public void onDestroy() { super.onDestroy(); System.gc(); }
public void run() { int x, y; Bitmap locTile; Canvas canvas; float useLon, useLat, useLonMax, useLatMax; System.gc(); if ((useOverlay.tileX == 0) && (useOverlay.tileY == 0)) return; mapThreadRunning = true; try { if (locMap == null) locMap = Bitmap.createBitmap(tileWidth * 256, tileHeight * 256, Bitmap.Config.ARGB_8888); } catch (OutOfMemoryError oome) { return; } locMap.eraseColor(Color.BLACK); canvas = new Canvas(locMap); useLon = (GeoUtils.tilex2long(useOverlay.tileX, useOverlay.m_zoom) + GeoUtils.tilex2long(useOverlay.tileX + 1, useOverlay.m_zoom)) / 2.0f; useLat = (GeoUtils.tiley2lat(useOverlay.tileY, useOverlay.m_zoom) + GeoUtils.tiley2lat(useOverlay.tileY + 1, useOverlay.m_zoom)) / 2.0f; while (mScaleFactor >= 2.0) { mScaleFactor /= 2.0f; useOverlay.m_zoom++; if (useOverlay.m_zoom > 17) { useOverlay.m_zoom = 17; imgOffsetX -= (scrWidth - (scrWidth * 2.0)) / 2.0; imgOffsetY -= (scrHeight - (scrHeight * 2.0)) / 2.0; } } while (mScaleFactor <= 0.5) { mScaleFactor *= 2.0f; useOverlay.m_zoom--; if (useOverlay.m_zoom < 3) { useOverlay.m_zoom = 3; imgOffsetX -= (scrWidth - (scrWidth * 2.0)) / 2.0; imgOffsetY -= (scrHeight - (scrHeight * 2.0)) / 2.0; } } mScaleFactor = 1.0f; /* if ((wasScaleOp) && (lonCenter!=0.0f) && (latCenter!=0.0f)) { tileX=GeoUtils.long2tilex(lonCenter,m_zoom); tileY=GeoUtils.lat2tiley(latCenter,m_zoom); tileX-=(scrWidth / 256); tileY-=(scrWidth / 256); } else*/ { useOverlay.tileX = GeoUtils.long2tilex(useLon, useOverlay.m_zoom); useOverlay.tileY = GeoUtils.lat2tiley(useLat, useOverlay.m_zoom); } useLon = GeoUtils.tilex2long(useOverlay.tileX - 1, useOverlay.m_zoom); useLat = GeoUtils.tiley2lat(useOverlay.tileY - 1, useOverlay.m_zoom); useLonMax = GeoUtils.tilex2long(useOverlay.tileX + tileWidth + 1, useOverlay.m_zoom); useLatMax = GeoUtils.tiley2lat(useOverlay.tileY + tileHeight + 1, useOverlay.m_zoom); /* if (imgOffsetX>scrWidth) { imgOffsetX=scrWidth/2; } if (imgOffsetX<=-scrWidth) { imgOffsetX=-scrWidth/2; } if (imgOffsetY>scrHeight) { imgOffsetY=scrHeight/2; } if (imgOffsetY<=-scrHeight) { imgOffsetY=-scrHeight/2; }*/ while (imgOffsetX > 0) { imgOffsetX -= 256.0f; useOverlay.tileX--; } while (imgOffsetX <= -256.0) { imgOffsetX += 256.0f; useOverlay.tileX++; } while (imgOffsetY > 0) { imgOffsetY -= 256.0f; useOverlay.tileY--; } while (imgOffsetY <= -256.0) { imgOffsetY += 256.0f; useOverlay.tileY++; } // calculate lat/lon of screen center point /* { int useTileX=tileX,useTileY=tileY; x=(int)((scrWidth/2.0f)+imgOffsetX); y=(int)((scrHeight/2.0f)+imgOffsetY); useTileX+=(x / 256); x=x % 256; useTileY+=(y / 256); y=y % 256; float tileLon1=GeoUtils.tilex2long(useTileX,m_zoom); float tileLat1=GeoUtils.tiley2lat(useTileY,m_zoom); float tileLon2=GeoUtils.tilex2long(useTileX+1,m_zoom); float tileLat2=GeoUtils.tiley2lat(useTileY+1,m_zoom); lonCenter=(((tileLon2-tileLon1)/256.0f)*x)+tileLon1; latCenter=(((tileLat2-tileLat1)/256.0f)*y)+tileLat1; }*/ matrix.setTranslate(imgOffsetX, imgOffsetY); breakMapThread = false; mapThreadRunning = false; for (x = 0; x < tileWidth; x++) for (y = 0; y < tileHeight; y++) { if (breakMapThread) return; locTile = geoUtils.loadMapTile( getContext(), useOverlay.tileX + x, useOverlay.tileY + y, useOverlay.m_zoom, allowNetAccess); if (locTile != null) canvas.drawBitmap(locTile, x * 256, y * 256, null); postInvalidate(); } useOverlay.doDraw(canvas, useLon, useLonMax, useLat, useLatMax, locMap); postInvalidate(); System.gc(); }