List of usage examples for android.graphics BitmapFactory decodeResource
public static Bitmap decodeResource(Resources res, int id)
From source file:com.irccloud.android.activity.PastebinsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC));// w w w . ja v a2s . c om cloud.recycle(); } setContentView(R.layout.ignorelist); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R.drawable.abc_ic_ab_back_mtrl_am_alpha); getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar)); getSupportActionBar().setElevation(0); } if (savedInstanceState != null && savedInstanceState.containsKey("adapter")) { try { page = savedInstanceState.getInt("page"); Pastebin[] pastebins = (Pastebin[]) savedInstanceState.getSerializable("adapter"); for (Pastebin p : pastebins) { adapter.addPastebin(p); } adapter.notifyDataSetChanged(); } catch (Exception e) { page = 0; adapter.clear(); } } footer = getLayoutInflater().inflate(R.layout.messageview_header, null); ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(adapter); listView.addFooterView(footer); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (canLoadMore && firstVisibleItem + visibleItemCount > totalItemCount - 4) { canLoadMore = false; new FetchPastebinsTask().execute((Void) null); } } }); listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { final Pastebin p = (Pastebin) adapter.getItem(i); Intent intent = new Intent(PastebinsActivity.this, PastebinViewerActivity.class); intent.setData(Uri.parse(p.url + "?id=" + p.id + "&own_paste=" + (p.own_paste ? "1" : "0"))); startActivity(intent); } }); Toast.makeText(this, "Tap a pastebin to view full text with syntax highlighting", Toast.LENGTH_LONG).show(); }
From source file:com.irccloud.android.activity.UploadsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (ColorFormatter.file_uri_template != null) template = UriTemplate.fromTemplate(ColorFormatter.file_uri_template); super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= 21) { Bitmap cloud = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); setTaskDescription(new ActivityManager.TaskDescription(getResources().getString(R.string.app_name), cloud, 0xFFF2F7FC));/* w ww. ja v a 2 s. co m*/ cloud.recycle(); } if (Build.VERSION.SDK_INT >= 14) { try { java.io.File httpCacheDir = new java.io.File(getCacheDir(), "http"); long httpCacheSize = 10 * 1024 * 1024; // 10 MiB HttpResponseCache.install(httpCacheDir, httpCacheSize); } catch (IOException e) { Log.i("IRCCloud", "HTTP response cache installation failed:" + e); } } setContentView(R.layout.ignorelist); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeAsUpIndicator(R.drawable.abc_ic_ab_back_mtrl_am_alpha); getSupportActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar)); getSupportActionBar().setElevation(0); } if (savedInstanceState != null && savedInstanceState.containsKey("cid")) { cid = savedInstanceState.getInt("cid"); to = savedInstanceState.getString("to"); msg = savedInstanceState.getString("msg"); page = savedInstanceState.getInt("page"); File[] files = (File[]) savedInstanceState.getSerializable("adapter"); for (File f : files) { adapter.addFile(f); } adapter.notifyDataSetChanged(); } footer = getLayoutInflater().inflate(R.layout.messageview_header, null); ListView listView = (ListView) findViewById(android.R.id.list); listView.setAdapter(adapter); listView.addFooterView(footer); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (canLoadMore && firstVisibleItem + visibleItemCount > totalItemCount - 4) { canLoadMore = false; new FetchFilesTask().execute((Void) null); } } }); listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { final File f = (File) adapter.getItem(i); AlertDialog.Builder builder = new AlertDialog.Builder(UploadsActivity.this); builder.setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB); final View v = getLayoutInflater().inflate(R.layout.dialog_upload, null); final EditText messageinput = (EditText) v.findViewById(R.id.message); messageinput.setText(msg); final ImageView thumbnail = (ImageView) v.findViewById(R.id.thumbnail); v.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { if (messageinput.hasFocus()) { v.post(new Runnable() { @Override public void run() { v.scrollTo(0, v.getBottom()); } }); } } }); if (f.mime_type.startsWith("image/")) { try { thumbnail.setImageBitmap(f.image); thumbnail.setVisibility(View.VISIBLE); thumbnail.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(UploadsActivity.this, ImageViewerActivity.class); i.setData(Uri.parse(f.url)); startActivity(i); } }); thumbnail.setClickable(true); } catch (Exception e) { e.printStackTrace(); } } else { thumbnail.setVisibility(View.GONE); } ((TextView) v.findViewById(R.id.filesize)).setText(f.metadata); v.findViewById(R.id.filename).setVisibility(View.GONE); v.findViewById(R.id.filename_heading).setVisibility(View.GONE); builder.setTitle("Send A File To " + to); builder.setView(v); builder.setPositiveButton("Send", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String message = messageinput.getText().toString(); if (message.length() > 0) message += " "; message += f.url; dialog.dismiss(); if (getParent() == null) { setResult(Activity.RESULT_OK); } else { getParent().setResult(Activity.RESULT_OK); } finish(); NetworkConnection.getInstance().say(cid, to, message); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); AlertDialog d = builder.create(); d.setOwnerActivity(UploadsActivity.this); d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); d.show(); } }); }
From source file:com.android.mail.browse.ConversationItemView.java
private static synchronized void getItemViewResources(Context context) { if (sConfigurationChangedReceiver == null) { sConfigurationChangedReceiver = new BroadcastReceiver() { @Override//from ww w .ja v a 2 s. c om public void onReceive(Context context, Intent intent) { STAR_OFF = null; getItemViewResources(context); } }; context.registerReceiver(sConfigurationChangedReceiver, new IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED)); } if (STAR_OFF == null) { final Resources res = context.getResources(); // Initialize static bitmaps. STAR_OFF = BitmapFactory.decodeResource(res, R.drawable.ic_star_outline_20dp); STAR_ON = BitmapFactory.decodeResource(res, R.drawable.ic_star_20dp); ATTACHMENT = BitmapFactory.decodeResource(res, R.drawable.ic_attach_file_18dp); ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double); TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single); IMPORTANT_ONLY_TO_ME = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_double_important_unread); IMPORTANT_TO_ME_AND_OTHERS = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_single_important_unread); IMPORTANT = BitmapFactory.decodeResource(res, R.drawable.ic_email_caret_none_important_unread); STATE_REPLIED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_holo_light); STATE_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_forward_holo_light); STATE_REPLIED_AND_FORWARDED = BitmapFactory.decodeResource(res, R.drawable.ic_badge_reply_forward_holo_light); STATE_CALENDAR_INVITE = BitmapFactory.decodeResource(res, R.drawable.ic_badge_invite_holo_light); FOCUSED_CONVERSATION_HIGHLIGHT = res.getDrawable(R.drawable.visible_conversation_highlight); // Initialize colors. sActivatedTextSpan = CharacterStyle .wrap(new ForegroundColorSpan(res.getColor(R.color.senders_text_color))); sSendersTextColor = res.getColor(R.color.senders_text_color); sSubjectTextUnreadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceUnreadStyle); sSubjectTextReadSpan = new TextAppearanceSpan(context, R.style.SubjectAppearanceReadStyle); sBadgeTextSpan = new TextAppearanceSpan(context, R.style.BadgeTextStyle); sBadgeBackgroundSpan = new BackgroundColorSpan(res.getColor(R.color.badge_background_color)); sDateTextColorRead = res.getColor(R.color.date_text_color_read); sDateTextColorUnread = res.getColor(R.color.date_text_color_unread); sStarTouchSlop = res.getDimensionPixelSize(R.dimen.star_touch_slop); sSenderImageTouchSlop = res.getDimensionPixelSize(R.dimen.sender_image_touch_slop); sShrinkAnimationDuration = res.getInteger(R.integer.shrink_animation_duration); sSlideAnimationDuration = res.getInteger(R.integer.slide_animation_duration); // Initialize static color. sSendersSplitToken = res.getString(R.string.senders_split_token); sElidedPaddingToken = res.getString(R.string.elided_padding_token); sScrollSlop = res.getInteger(R.integer.swipeScrollSlop); sFoldersMaxCount = res.getInteger(R.integer.conversation_list_max_folder_count); sCabAnimationDuration = res.getInteger(R.integer.conv_item_view_cab_anim_duration); sBadgePaddingExtraWidth = res.getDimensionPixelSize(R.dimen.badge_padding_extra_width); sBadgeRoundedCornerRadius = res.getDimensionPixelSize(R.dimen.badge_rounded_corner_radius); sDividerPaint.setColor(res.getColor(R.color.divider_color)); sDividerHeight = res.getDimensionPixelSize(R.dimen.divider_height); } }
From source file:br.com.anteros.vendas.gui.AnexoCadastroActivity.java
private void atribuiImageParaFotoGaleria(File file) { String extension = FilenameUtils.getExtension(file.getAbsolutePath()); TipoConteudoAnexo tipoConteudoAnexo = TipoConteudoAnexo.getTipoConteudoAnexoPorExtensao(extension); switch (tipoConteudoAnexo) { case IMAGEM:/*w w w.ja v a 2s . c o m*/ fotoGaleria = ImageUtils.loadScaledImage(file.getPath(), 640, 480); break; case PDF: fotoGaleria = BitmapFactory.decodeResource(getResources(), R.drawable.ic_file_extension_pdf); break; case PLANILHA: fotoGaleria = BitmapFactory.decodeResource(getResources(), R.drawable.ic_file_extension_xls); break; case TEXTO: fotoGaleria = BitmapFactory.decodeResource(getResources(), R.drawable.ic_file_extension_txt); break; case DOCUMENTO: fotoGaleria = BitmapFactory.decodeResource(getResources(), R.drawable.ic_file_extension_doc); break; case APRESENTACAO: fotoGaleria = BitmapFactory.decodeResource(getResources(), R.drawable.ic_file_extension_ppt); break; case HTML: fotoGaleria = BitmapFactory.decodeResource(getResources(), R.drawable.ic_file_extension_html); break; case RAR: fotoGaleria = BitmapFactory.decodeResource(getResources(), R.drawable.ic_file_extension_rar); break; case ZIP: fotoGaleria = BitmapFactory.decodeResource(getResources(), R.drawable.ic_file_extension_zip); break; case XML: fotoGaleria = BitmapFactory.decodeResource(getResources(), R.drawable.ic_file_extension_xml); break; default: fotoGaleria = BitmapFactory.decodeResource(getResources(), R.drawable.ic_file_extension_unk); break; } }
From source file:com.tutor.fragment.ViewPageFragment.java
private void BuildjfItemsList(String result) { jf_listItems = new ArrayList<Map<String, Object>>(); try {//from w ww .j a v a 2s . c o m JSONArray jsonArray = new JSONArray(result); for (int i = 0; i < jsonArray.length(); i++) { JSONObject json = (JSONObject) jsonArray.get(i); Map<String, Object> map = new LinkedHashMap<String, Object>(); map.put("id", Integer.parseInt(json.get("id").toString())); map.put("imageUrl", json.get("image").toString()); map.put("image", BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)); String titletemp = json.get("name").toString(); if (titletemp.length() > 8) { titletemp = titletemp.substring(0, 8) + "...."; } map.put("short_title", titletemp); map.put("title", json.get("name").toString()); map.put("point", json.get("point").toString()); map.put("danwei", ""); String introuduceTemp = json.get("introudution").toString(); if (introuduceTemp.length() > 12) { introuduceTemp = introuduceTemp.substring(0, 12) + "...."; } map.put("short_description", introuduceTemp); map.put("description", json.get("introudution").toString()); map.put("recommend_Decrible", json.get("recommend_Decrible").toString()); jf_listItems.add(map); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.appdevper.mediaplayer.app.MediaNotificationManager.java
private Bitmap downloadBitmap(String mediaId) { String url = MusicProvider.getInstance().getMusic(mediaId) .getString(MusicProviderSource.CUSTOM_METADATA_TRACK_SOURCE); final MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever(); metaRetriever.setDataSource(url, new HashMap<String, String>()); try {//from w ww. j a v a2 s . c om final byte[] art = metaRetriever.getEmbeddedPicture(); return BitmapFactory.decodeByteArray(art, 0, art.length); } catch (Exception e) { Log.d(TAG, "Couldn't create album art: " + e.getMessage()); return BitmapFactory.decodeResource(mService.getResources(), R.drawable.ic_default_art); } }
From source file:com.uzmap.pkg.uzmodules.UISearchBar.SearchBarActivity.java
@SuppressWarnings("deprecation") private void initData() { DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metric); mPref = getSharedPreferences("text", Context.MODE_PRIVATE); String text = mPref.getString("text", ""); if (!TextUtils.isEmpty(text)) { mEditText.setText(text);/*from w ww. j a v a 2 s .c o m*/ mEditText.setSelection(text.length()); } mNavigationLayout.setBackgroundColor(config.navBgColor); if (TextUtils.isEmpty(config.searchBoxBgImg)) { BitmapDrawable bitmapDrawable = new BitmapDrawable(BitmapFactory.decodeResource(getResources(), UZResourcesIDFinder.getResDrawableID("mo_searchbar_bg"))); mRelativeLayout.setBackgroundDrawable(bitmapDrawable); } else { BitmapDrawable bitmapDrawable = new BitmapDrawable(generateBitmap(config.searchBoxBgImg)); mRelativeLayout.setBackgroundDrawable(bitmapDrawable); } if (config.cancel_bg_bitmap != null) { mTextView.setBackgroundDrawable(new BitmapDrawable(config.cancel_bg_bitmap)); } else { mTextView.setBackgroundColor(config.cancel_bg_color); } mTextView.setTextSize(config.cancel_size); mTextView.setTextColor(config.cancal_color); LayoutParams params = new LayoutParams(UZUtility.dipToPix(config.searchBoxWidth), UZUtility.dipToPix(config.searchBoxHeight)); params.setMargins(UZUtility.dipToPix(10), 0, 0, 0); params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); mEditText.setLayoutParams(params); WindowManager wm = this.getWindowManager(); int width = wm.getDefaultDisplay().getWidth(); double realWidth = width * 0.80; LayoutParams layoutParams = new LayoutParams((int) realWidth, UZUtility.dipToPix(config.searchBoxHeight)); layoutParams.setMargins(UZUtility.dipToPix(5), 0, 0, 0); layoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); layoutParams.topMargin = UZUtility.dipToPix(8); layoutParams.bottomMargin = UZUtility.dipToPix(8); mRelativeLayout.setLayoutParams(layoutParams); double cancelRealWidth = width * 0.15; int space = (width - (int) realWidth - (int) cancelRealWidth - UZUtility.dipToPix(5)) / 2; LayoutParams cancalTxtParam = new LayoutParams((int) cancelRealWidth, UZUtility.dipToPix(config.searchBoxHeight)); cancalTxtParam.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); cancalTxtParam.addRule(RelativeLayout.CENTER_VERTICAL); cancalTxtParam.rightMargin = space; cancalTxtParam.leftMargin = space; mTextView.setLayoutParams(cancalTxtParam); mListView.setBackgroundColor(config.list_bg_color); listSize = config.list_size; mCleanTextColor = config.clear_font_color; mCleanTextSize = config.clear_font_size; recordCount = config.historyCount; /** * add clean list item */ int relativeLayoutCleanId = UZResourcesIDFinder.getResLayoutID("mo_searchbar_clean_item"); relativeLayoutClean = (LinearLayout) View.inflate(getApplicationContext(), relativeLayoutCleanId, null); int tv_cleanId = UZResourcesIDFinder.getResIdID("tv_clean"); mCleanTV = (TextView) relativeLayoutClean.findViewById(tv_cleanId); mCleanTV.setTextSize(mCleanTextSize); mCleanTV.setTextColor(mCleanTextColor); mCleanTV.setText(config.clearText); relativeLayoutClean .setBackgroundDrawable(addStateDrawable(config.clear_bg_color, config.clear_active_bg_color)); list.clear(); list.add(relativeLayoutClean); mPref = getSharedPreferences("history" + config.database, Context.MODE_PRIVATE); editor = mPref.edit(); trimHistroyList(config.historyCount); @SuppressWarnings("unchecked") Map<String, String> map = (Map<String, String>) mPref.getAll(); if (map != null) { if (map.size() != 0) { for (int i = 1; i <= map.size(); i++) { int listview_item = UZResourcesIDFinder.getResLayoutID("mo_searchbar_listview_item"); LinearLayout linearLayout = (LinearLayout) View.inflate(SearchBarActivity.this, listview_item, null); int tv_listId = UZResourcesIDFinder.getResIdID("tv_listview"); TextView tv = (TextView) linearLayout.findViewById(tv_listId); tv.setTextSize(listSize); tv.setTextColor(config.list_color); linearLayout.setBackgroundDrawable( addStateDrawable(config.list_bg_color, config.list_item_active_bg_color)); int itemBorderLineId = UZResourcesIDFinder.getResIdID("item_border_line"); linearLayout.findViewById(itemBorderLineId).setBackgroundColor(config.list_border_color); for (Entry<String, String> iterable_element : map.entrySet()) { String key = iterable_element.getKey(); if ((i + "").equals(key)) { tv.setText(iterable_element.getValue()); } } list.addFirst(linearLayout); } id = map.size(); } } adapter = new MyAdapter(); mListView.setAdapter(adapter); }
From source file:com.mitre.holdshort.MainActivity.java
private void startMainActivity() { // Set screen layout setContentView(R.layout.main);//from w w w . j a va 2s. com imageHelper = new ImageHelper(); summaryGestureDetector = new GestureDetector(new summaryGester()); // Get Reference to Shared Preferences file auralAlerts = settings.getBoolean("auralAlerts", true); settings.edit().putBoolean("auralAlerts", auralAlerts); announceRWY = settings.getBoolean("announceRWY", true); settings.edit().putBoolean("announceRWY", announceRWY); // Airport ID airportID = (TextView) findViewById(R.id.airportID); airportID.setText("K" + airport); // SpeechButton speechBtn = (ImageView) findViewById(R.id.speechBtn); speechBtn.setOnClickListener(speechBtnClickListener); // Get open close button openClose = (TextView) findViewById(R.id.openClose); openClose.setText("close"); // openClose.setTextColor(Color.argb(200, 255, 255, 255)); openClose.setOnClickListener(openCloseListener); // departure runway button depRwyBtn = (TextView) findViewById(R.id.depRwyBtn); depRwyBtn.setOnClickListener(depRwyListener); depRwyBtn.setText("Departure Rwy"); depRwyBtn.setBackgroundResource(R.drawable.hatched_small_bg_layer); depRwyBtn.setPadding(10, 5, 10, 5); // info button - used to start prefs activity infoBtn = (ImageButton) findViewById(R.id.info_btn); // infoBtn.setBackgroundColor(Color.rgb(0,0,0)); infoBtn.setOnClickListener(settingsMenuListener); // taxi button - used to start Taxi instruction activity taxiBtn = (ImageButton) findViewById(R.id.taxi_btn); // taxiBtn.setBackgroundColor(Color.rgb(0,0,0)); taxiBtn.setOnClickListener(taxiBtnListener); // summary info - when drawer is closed summaryBar = (RelativeLayout) findViewById(R.id.summaryBar); summaryBar.setOnTouchListener(summaryTouchListener); runwayContainer = (LinearLayout) findViewById(R.id.holder); innerHolder = (LinearLayout) findViewById(R.id.innerHolder); slidingPanel = (SlidingPanel) findViewById(R.id.slidingDrawer); // header header = (RelativeLayout) findViewById(R.id.header); headerDropShadow = (View) findViewById(R.id.header_drop_shadow); slidingPanel.setHeaderDropShadow(headerDropShadow); slidingPanel.setRunwayContainer(runwayContainer); slidingPanel.setOpenCloseTextView(openClose); slidingPanel.setHandler(this.handler); summaryInfo = (RelativeLayout) findViewById(R.id.summary_info); summary_index = (TextView) findViewById(R.id.summary_index); summary_thumb = (TextView) findViewById(R.id.summary_thumb); summary_thumb.setWidth(90); // Taxi path area taxiClearance = (TextView) findViewById(R.id.taxiClearance); taxiClearance.setTextSize(12); taxiClearance.setPadding(5, 0, 5, 0); taxiClearance.setTextColor(Color.WHITE); // taxiClearance.setBackgroundColor(Color.rgb(0,0,0)); taxiClearance.setOnClickListener(taxiPathListener); // Airport Diagram plateView = (AirportPlateView) findViewById(R.id.plateView); // Set up the nav control for the moving map // this is used when ownship is off screen navControl = (ImageView) findViewById(R.id.showNavBtn); plateView.setNavControls(navControl); navControl.setVisibility(ImageView.INVISIBLE); navControl.setOnClickListener(navControlListener); // // Lat/Lon Ref 1 SFO Point latLon1 = new Point(37.627827, -122.366794); Point latLon2 = new Point(37.606827, -122.380724); XYPoint xy1 = new XYPoint(134, 173); XYPoint xy2 = new XYPoint(340, 281); // Lat/Lon Ref 1 HEF // Point latLon1 = new Point(38.727680,-77.518803); // Point latLon2 = new Point(38.714041,-77.508976); // XYPoint xy1 = new XYPoint(140,187); // XYPoint xy2 = new XYPoint(322,513); plateView.geoReference(latLon1, latLon2, xy1, xy2); Location loc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); plateView.updatePosition(loc.getBearing(), loc.getLatitude(), loc.getLongitude()); // navView.setScroll(plateView); TextView emptyPlate = (TextView) findViewById(R.id.emptyPlate); if (!(plateView.setImage(airport))) { // Place holder if no plate is available emptyPlate.setVisibility(View.VISIBLE); plateView.setVisibility(View.GONE); } else { // Show plate. Hide placeholder plateView.setImage(airport); emptyPlate.setVisibility(View.GONE); } // Create logger for alerts alertLogger = new AlertLogger(airport, MainActivity.this); // Alert Panels alertScreen = (RelativeLayout) findViewById(R.id.alertScreen); betaControls = (LinearLayout) findViewById(R.id.betaControls); goodAlert = (TextView) findViewById(R.id.goodAlert); goodAlert.setOnClickListener(alertResponseListener); badAlert = (TextView) findViewById(R.id.badAlert); badAlert.setOnClickListener(alertResponseListener); lateAlert = (TextView) findViewById(R.id.lateAlert); lateAlert.setOnClickListener(alertResponseListener); earlyAlert = (TextView) findViewById(R.id.earlyAlert); earlyAlert.setOnClickListener(alertResponseListener); miniAlert = (TextView) findViewById(R.id.miniAlertText); miniAlert.setOnClickListener(maximizeAlert); holdShort = (LinearLayout) findViewById(R.id.holdShort); holdShort.getChildAt(0).setBackgroundDrawable(imageHelper .getRoundedCornerBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.alert), 10)); holdShort.setOnClickListener(minimizeAlert); noClearance = (LinearLayout) findViewById(R.id.noClearance); noClearance.setOnClickListener(minimizeAlert); noClearance.getChildAt(0).setBackgroundDrawable(imageHelper .getRoundedCornerBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.alert), 10)); crossingAlert = (LinearLayout) findViewById(R.id.crossingAlert); noTakeoffClearance = (LinearLayout) findViewById(R.id.noTakeoffClearance); noTakeoffClearance.getChildAt(0).setBackgroundDrawable(imageHelper .getRoundedCornerBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.alert), 10)); noTakeoffClearance.setOnClickListener(minimizeAlert); disabled_gps = (LinearLayout) findViewById(R.id.disabled_gps); disabled_gps.getChildAt(0).setBackgroundDrawable(imageHelper .getRoundedCornerBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.disabled), 10)); disabled_gps.setOnClickListener(minimizeAlert); disabled_speed = (LinearLayout) findViewById(R.id.disabled_speed); disabled_speed.getChildAt(0).setBackgroundDrawable(imageHelper .getRoundedCornerBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.disabled), 10)); disabled_speed.setOnClickListener(minimizeAlert); // Instantiate media player & set completion listener mp = new MediaPlayer(); mp.setOnCompletionListener(alertPlaybackListener); // Instruction List instantiation instructionList = new ArrayList<String>(); setUpRunways(); slidingPanel.setOnTouchListener(summaryTouchListener); // Instantiate Alert Manager alertManager = new AlertManager(rwyMgr); allSetUp = true; }
From source file:com.firefly.sample.castcompanionlibrary.cast.player.VideoCastControllerFragment.java
private void showImage(final String url) { if (null != mImageAsyncTask) { mImageAsyncTask.cancel(true);/* w w w .ja v a 2 s . c om*/ } if (null == url) { mCastController.setImage( BitmapFactory.decodeResource(getActivity().getResources(), R.drawable.dummy_album_art_large)); return; } if (null != mUrlAndBitmap && mUrlAndBitmap.isMatch(url)) { // we can reuse mBitmap mCastController.setImage(mUrlAndBitmap.mBitmap); return; } mUrlAndBitmap = null; mImageAsyncTask = new AsyncTask<String, Void, Bitmap>() { @Override protected Bitmap doInBackground(String... params) { String uri = params[0]; try { URL imgUrl = new URL(uri); return BitmapFactory.decodeStream(imgUrl.openStream()); } catch (Exception e) { LOGE(TAG, "Failed to load the image with mUrl: " + uri, e); } return null; } @Override protected void onPostExecute(Bitmap bitmap) { if (null != bitmap) { mUrlAndBitmap = new UrlAndBitmap(); mUrlAndBitmap.mBitmap = bitmap; mUrlAndBitmap.mUrl = url; mCastController.setImage(bitmap); } } }; mImageAsyncTask.execute(url); }
From source file:cc.softwarefactory.lokki.android.fragments.MapViewFragment.java
public Bitmap getMarkerBitmap(String email, Boolean accurate, Boolean recent) { Log.e(TAG, "getMarkerBitmap"); // Add cache checking logic Bitmap markerImage = MainApplication.avatarCache.get(email + ":" + accurate + ":" + recent); if (markerImage != null) { Log.e(TAG, "Marker IN cache: " + email + ":" + accurate + ":" + recent); return markerImage; } else {//from ww w . j a v a 2 s.c o m Log.e(TAG, "Marker NOT in cache. Processing: " + email + ":" + accurate + ":" + recent); } Log.e(TAG, "AvatarLoader not in cache. Fetching it. Email: " + email); // Get avatars Bitmap userImage = Utils.getPhotoFromEmail(context, email); if (userImage == null) { userImage = BitmapFactory.decodeResource(getResources(), R.drawable.default_avatar); } else { userImage = Utils.getRoundedCornerBitmap(userImage, 50); } // Marker colors, etc. Log.e(TAG, "userImage size: " + userImage); View markerView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.map_marker, null); aq = new AQuery(markerView); aq.id(R.id.user_image).image(userImage); Log.e(TAG, "aq in place"); if (email.equals(MainApplication.userAccount)) { aq.id(R.id.marker_frame).image(R.drawable.pointers_android_pointer_green); } else if (!recent || !accurate) { aq.id(R.id.marker_frame).image(R.drawable.pointers_android_pointer_orange); } Log.e(TAG, "Image set. Calling createDrawableFromView"); markerImage = createDrawableFromView(markerView); MainApplication.avatarCache.put(email + ":" + accurate + ":" + recent, markerImage); return markerImage; }