List of usage examples for android.widget LinearLayout removeAllViews
public void removeAllViews()
From source file:com.nadmm.airports.wx.MetarFragment.java
protected void showMetar(Intent intent) { if (getActivity() == null) { // Not ready to do this yet return;//from w ww . j av a 2 s. c om } Metar metar = (Metar) intent.getSerializableExtra(NoaaService.RESULT); if (metar == null) { return; } View detail = findViewById(R.id.wx_detail_layout); LinearLayout layout = (LinearLayout) findViewById(R.id.wx_status_layout); layout.removeAllViews(); TextView tv = (TextView) findViewById(R.id.status_msg); if (!metar.isValid) { tv.setVisibility(View.VISIBLE); layout.setVisibility(View.VISIBLE); tv.setText("Unable to get METAR for this location"); addRow(layout, "This could be due to the following reasons:"); addBulletedRow(layout, "Network connection is not available"); addBulletedRow(layout, "ADDS does not publish METAR for this station"); addBulletedRow(layout, "Station is currently out of service"); addBulletedRow(layout, "Station has not updated the METAR for more than 3 hours"); detail.setVisibility(View.GONE); stopRefreshAnimation(); setFragmentContentShown(true); return; } else { tv.setText(""); tv.setVisibility(View.GONE); layout.setVisibility(View.GONE); detail.setVisibility(View.VISIBLE); } tv = (TextView) findViewById(R.id.wx_station_info2); WxUtils.setFlightCategoryDrawable(tv, metar.flightCategory); tv = (TextView) findViewById(R.id.wx_age); tv.setText(TimeUtils.formatElapsedTime(metar.observationTime)); // Raw Text tv = (TextView) findViewById(R.id.wx_raw_metar); tv.setText(metar.rawText); // Winds tv = (TextView) findViewById(R.id.wx_wind_label); layout = (LinearLayout) findViewById(R.id.wx_wind_layout); layout.removeAllViews(); int visibility = View.GONE; if (metar.windSpeedKnots < Integer.MAX_VALUE) { showWindInfo(layout, metar); visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Visibility tv = (TextView) findViewById(R.id.wx_vis_label); layout = (LinearLayout) findViewById(R.id.wx_vis_layout); layout.removeAllViews(); visibility = View.GONE; if (metar.visibilitySM < Float.MAX_VALUE) { if (metar.flags.contains(Flags.AutoReport) && metar.visibilitySM == 10) { addRow(layout, "10+ statute miles horizontal"); } else { NumberFormat decimal2 = NumberFormat.getNumberInstance(); decimal2.setMaximumFractionDigits(2); decimal2.setMinimumFractionDigits(0); addRow(layout, String.format("%s statute miles horizontal", FormatUtils.formatNumber(metar.visibilitySM))); } if (metar.vertVisibilityFeet < Integer.MAX_VALUE) { addRow(layout, String.format("%s vertical", FormatUtils.formatFeetAgl(metar.vertVisibilityFeet))); } visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Weather layout = (LinearLayout) findViewById(R.id.wx_weather_layout); layout.removeAllViews(); for (WxSymbol wx : metar.wxList) { addWeatherRow(layout, wx, metar.flightCategory); } // Sky Conditions tv = (TextView) findViewById(R.id.wx_sky_cond_label); layout = (LinearLayout) findViewById(R.id.wx_sky_cond_layout); layout.removeAllViews(); visibility = View.GONE; if (!metar.skyConditions.isEmpty()) { for (SkyCondition sky : metar.skyConditions) { addSkyConditionRow(layout, sky, metar.flightCategory); } visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Temperature tv = (TextView) findViewById(R.id.wx_temp_label); layout = (LinearLayout) findViewById(R.id.wx_temp_layout); layout.removeAllViews(); visibility = View.GONE; if (metar.tempCelsius < Float.MAX_VALUE && metar.dewpointCelsius < Float.MAX_VALUE) { addRow(layout, "Temperature", FormatUtils.formatTemperature(metar.tempCelsius)); if (metar.dewpointCelsius < Float.MAX_VALUE) { addRow(layout, "Dew point", FormatUtils.formatTemperature(metar.dewpointCelsius)); addRow(layout, "Relative humidity", String.format("%.0f%%", WxUtils.getRelativeHumidity(metar))); long denAlt = WxUtils.getDensityAltitude(metar); if (denAlt > mElevation) { addRow(layout, "Density altitude", FormatUtils.formatFeet(denAlt)); } } else { addRow(layout, "Dew point", "n/a"); } if (metar.maxTemp6HrCentigrade < Float.MAX_VALUE) { addRow(layout, "6-hour maximum", FormatUtils.formatTemperature(metar.maxTemp6HrCentigrade)); } if (metar.minTemp6HrCentigrade < Float.MAX_VALUE) { addRow(layout, "6-hour minimum", FormatUtils.formatTemperature(metar.minTemp6HrCentigrade)); } if (metar.maxTemp24HrCentigrade < Float.MAX_VALUE) { addRow(layout, "24-hour maximum", FormatUtils.formatTemperature(metar.maxTemp24HrCentigrade)); } if (metar.minTemp24HrCentigrade < Float.MAX_VALUE) { addRow(layout, "24-hour minimum", FormatUtils.formatTemperature(metar.minTemp24HrCentigrade)); } visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Pressure tv = (TextView) findViewById(R.id.wx_pressure_label); layout = (LinearLayout) findViewById(R.id.wx_pressure_layout); layout.removeAllViews(); visibility = View.GONE; if (metar.altimeterHg < Float.MAX_VALUE) { addRow(layout, "Altimeter", FormatUtils.formatAltimeter(metar.altimeterHg)); if (metar.seaLevelPressureMb < Float.MAX_VALUE) { addRow(layout, "Sea level pressure", String.format("%s mb", FormatUtils.formatNumber(metar.seaLevelPressureMb))); } long presAlt = WxUtils.getPressureAltitude(metar); if (presAlt > mElevation) { addRow(layout, "Pressure altitude", FormatUtils.formatFeet(presAlt)); } if (metar.pressureTend3HrMb < Float.MAX_VALUE) { addRow(layout, "3-hour tendency", String.format("%+.2f mb", metar.pressureTend3HrMb)); } if (metar.presfr) { addRow(layout, "Pressure falling rapidly"); } if (metar.presrr) { addRow(layout, "Pressure rising rapidly"); } visibility = View.VISIBLE; } tv.setVisibility(visibility); layout.setVisibility(visibility); // Precipitation tv = (TextView) findViewById(R.id.wx_precip_label); layout = (LinearLayout) findViewById(R.id.wx_precip_layout); layout.removeAllViews(); if (metar.precipInches < Float.MAX_VALUE) { addRow(layout, "1-hour precipitation", String.format("%.2f\"", metar.precipInches)); } if (metar.precip3HrInches < Float.MAX_VALUE) { addRow(layout, "3-hour precipitation", String.format("%.2f\"", metar.precip3HrInches)); } if (metar.precip6HrInches < Float.MAX_VALUE) { addRow(layout, "6-hour precipitation", String.format("%.2f\"", metar.precip6HrInches)); } if (metar.precip24HrInches < Float.MAX_VALUE) { addRow(layout, "24-hour precipitation", String.format("%.2f\"", metar.precip24HrInches)); } if (metar.snowInches < Float.MAX_VALUE) { addRow(layout, "Snow depth", String.format("%.0f\"", metar.snowInches)); } if (metar.snincr) { addRow(layout, "Snow is increasing rapidly"); } visibility = layout.getChildCount() > 0 ? View.VISIBLE : View.GONE; tv.setVisibility(visibility); layout.setVisibility(visibility); // Remarks tv = (TextView) findViewById(R.id.wx_remarks_label); layout = (LinearLayout) findViewById(R.id.wx_remarks_layout); layout.removeAllViews(); for (Flags flag : metar.flags) { addBulletedRow(layout, flag.toString()); } for (String remark : mRemarks) { addBulletedRow(layout, remark); } visibility = layout.getChildCount() > 0 ? View.VISIBLE : View.GONE; tv.setVisibility(visibility); layout.setVisibility(visibility); // Fetch time tv = (TextView) findViewById(R.id.wx_fetch_time); tv.setText("Fetched on " + TimeUtils.formatDateTime(getActivity(), metar.fetchTime)); tv.setVisibility(View.VISIBLE); stopRefreshAnimation(); setFragmentContentShown(true); }
From source file:com.hichinaschool.flashcards.anki.multimediacard.activity.MultimediaCardEditorActivity.java
/** * Creates the UI for editor area inside EditorLayout * //from w w w.j a va 2s. c o m * @param note */ private void createEditorUI(IMultimediaEditableNote note) { try { if (mNote == null) { finishCancel(); return; } else { for (int i = 0; i < mNote.getNumberOfFields(); ++i) { IField f = mNote.getField(i); if (f == null) { finishCancel(); return; } } } LinearLayout linearLayout = mEditorLayout; linearLayout.removeAllViews(); for (int i = 0; i < note.getNumberOfFields(); ++i) { createNewViewer(linearLayout, note.getField(i), i); } mModelButton.setText(gtxt(R.string.multimedia_editor_activity_note_type) + " : " + mEditorNote.model().getString("name")); mDeckButton.setText(gtxt(R.string.multimedia_editor_activity_deck) + " : " + mCol.getDecks().get(mCurrentDid).getString("name")); } catch (JSONException e) { Log.e("Multimedia Editor", e.getMessage()); return; } }
From source file:com.i2max.i2smartwork.common.conference.ConferenceDetailViewFragment.java
public void setFilesLayout(String title, LinearLayout targetLayout, Object object) { final List<LinkedTreeMap<String, String>> filesList = (List<LinkedTreeMap<String, String>>) object; if (filesList == null || (filesList != null && filesList.size() <= 0)) { targetLayout.setVisibility(View.GONE); } else {// w w w .j ava 2s . c o m Log.e(TAG, "fileList size =" + filesList.size()); targetLayout.setVisibility(View.VISIBLE); targetLayout.removeAllViews(); //addTitleView LinearLayout.LayoutParams tvParam = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); tvParam.setMargins(0, DisplayUtil.dip2px(getActivity(), 12), 0, DisplayUtil.dip2px(getActivity(), 10)); TextView tvTitle = new TextView(getActivity()); tvTitle.setLayoutParams(tvParam); if (Build.VERSION.SDK_INT < 23) { tvTitle.setTextAppearance(getActivity(), android.R.style.TextAppearance_Material_Medium); } else { tvTitle.setTextAppearance(android.R.style.TextAppearance_Material_Medium); } tvTitle.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15); tvTitle.setTextColor(getResources().getColor(R.color.text_color_black)); tvTitle.setText(title); targetLayout.addView(tvTitle); //addFilesView for (int i = 0; i < filesList.size(); i++) { final LinkedTreeMap<String, String> fileMap = filesList.get(i); LayoutInflater inflater = (LayoutInflater) getActivity() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View fileView = inflater.inflate(R.layout.view_item_file, null); ImageView ivIcFileExt = (ImageView) fileView.findViewById(R.id.iv_ic_file_ext); TextView tvFileNm = (TextView) fileView.findViewById(R.id.tv_file_nm); //?? ? ivIcFileExt.setImageResource(R.drawable.ic_file_doc); String fileNm = FormatUtil.getStringValidate(fileMap.get("file_nm")); tvFileNm.setText(fileNm); FileUtil.setFileExtIcon(ivIcFileExt, fileNm); final String fileExt = FileUtil.getFileExtsion(fileNm); final String downloadURL = I2UrlHelper.File .getDownloadFile(FormatUtil.getStringValidate(fileMap.get("file_id"))); fileView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { Intent intent = null; if ("Y".equals(FormatUtil.getStringValidate(fileMap.get("conv_yn")))) { //i2viewer ? ( conv_yn='Y') intent = IntentUtil.getI2ViewerIntent( FormatUtil.getStringValidate(fileMap.get("file_id")), FormatUtil.getStringValidate(fileMap.get("file_nm"))); getActivity().startActivity(intent); } else if ("mp4".equalsIgnoreCase(fileExt) || "fla".equalsIgnoreCase(fileExt) || "wmv".equalsIgnoreCase(fileExt) || "avi".equalsIgnoreCase(fileExt)) { //video intent = IntentUtil.getVideoPlayIntent(downloadURL); } else { //? ?? intent = new Intent(Intent.ACTION_VIEW, Uri.parse(downloadURL)); Bundle bundle = new Bundle(); bundle.putString("Authorization", I2UrlHelper.getTokenAuthorization()); intent.putExtra(Browser.EXTRA_HEADERS, bundle); Log.d(TAG, "intent:" + intent.toString()); } getActivity().startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(getActivity(), "I2Viewer? ? .\n ? ?.", Toast.LENGTH_LONG).show(); //TODO ? ? ? URL } } }); targetLayout.addView(fileView); } } }
From source file:github.madmarty.madsonic.util.Util.java
/** * Resolves the default text color for notifications. * * Based on http://stackoverflow.com/questions/4867338/custom-notification-layouts-and-text-colors/7320604#7320604 *//* w w w .ja v a2s .c o m*/ @SuppressWarnings("deprecation") private static Pair<Integer, Integer> getNotificationTextColors(Context context) { if (NOTIFICATION_TEXT_COLORS.getFirst() == null && NOTIFICATION_TEXT_COLORS.getSecond() == null) { try { Notification notification = new Notification(); String title = "title"; String content = "content"; notification.setLatestEventInfo(context, title, content, null); LinearLayout group = new LinearLayout(context); ViewGroup event = (ViewGroup) notification.contentView.apply(context, group); findNotificationTextColors(event, title, content); group.removeAllViews(); } catch (Exception x) { LOG.warn("Failed to resolve notification text colors.", x); } } return NOTIFICATION_TEXT_COLORS; }
From source file:cz.muni.fi.japanesedictionary.fragments.DisplayCharacterInfo.java
/** * Updates Fragment view acording to saved japanese character. * *//* www. java 2 s . c om*/ private void updateCharacter(View view) { Log.i(LOG_TAG, "Setting literal"); if (mJapaneseCharacter == null) { Toast.makeText(getActivity(), R.string.character_unknown_character, Toast.LENGTH_LONG).show(); return; } updateLanguages(); if (view == null || getActivity() == null) { return; } KanjiStrokeLoader kanjiVgLoader = new KanjiStrokeLoader(getActivity().getApplicationContext(), this); kanjiVgLoader.execute(mJapaneseCharacter.getLiteral()); TextView literal = (TextView) view.findViewById(R.id.kanjidict_literal); literal.setText(mJapaneseCharacter.getLiteral()); ((ActionBarActivity) getActivity()).getSupportActionBar().setTitle(mJapaneseCharacter.getLiteral()); if (mJapaneseCharacter.getRadicalClassic() != 0) { Log.i(LOG_TAG, "Setting radical: " + mJapaneseCharacter.getRadicalClassic()); TextView radicalClassical = (TextView) view.findViewById(R.id.kanjidict_radical); radicalClassical.setText(String.valueOf(mJapaneseCharacter.getRadicalClassic())); } else { view.findViewById(R.id.kanjidict_radical_container).setVisibility(View.GONE); } if (mJapaneseCharacter.getGrade() != 0) { Log.i(LOG_TAG, "Setting grade: " + mJapaneseCharacter.getGrade()); TextView grade = (TextView) view.findViewById(R.id.kanjidict_grade); grade.setText(String.valueOf(mJapaneseCharacter.getGrade())); } else { view.findViewById(R.id.kanjidict_grade_container).setVisibility(View.GONE); } if (mJapaneseCharacter.getStrokeCount() != 0) { Log.i(LOG_TAG, "Setting stroke count: " + mJapaneseCharacter.getStrokeCount()); TextView strokeCount = (TextView) view.findViewById(R.id.kanjidict_stroke_count); strokeCount.setText(String.valueOf(mJapaneseCharacter.getStrokeCount())); } else { view.findViewById(R.id.kanjidict_stroke_count_container).setVisibility(View.GONE); } if (mJapaneseCharacter.getSkip() != null && mJapaneseCharacter.getSkip().length() > 0) { Log.i(LOG_TAG, "Setting skip: " + mJapaneseCharacter.getSkip()); TextView skip = (TextView) view.findViewById(R.id.kanjidict_skip); skip.setText(mJapaneseCharacter.getSkip()); } else { view.findViewById(R.id.kanjidict_skip_container).setVisibility(View.GONE); } if (mJapaneseCharacter.getRmGroupJaKun() != null && mJapaneseCharacter.getRmGroupJaKun().size() > 0) { Log.i(LOG_TAG, "Setting kunyomi: " + mJapaneseCharacter.getRmGroupJaKun()); TextView kunyomi = (TextView) view.findViewById(R.id.kanjidict_kunyomi); kunyomi.setText(MiscellaneousUtil.processKunyomi(getActivity(), mJapaneseCharacter.getRmGroupJaKun())); } else { view.findViewById(R.id.kanjidict_kunyomi_container).setVisibility(View.GONE); } if (mJapaneseCharacter.getRmGroupJaOn() != null && mJapaneseCharacter.getRmGroupJaOn().size() > 0) { Log.i(LOG_TAG, "Setting onnyomi: " + mJapaneseCharacter.getRmGroupJaOn()); int count = mJapaneseCharacter.getRmGroupJaOn().size(); int i = 1; StringBuilder strBuilder = new StringBuilder(); for (String onyomi : mJapaneseCharacter.getRmGroupJaOn()) { strBuilder.append(onyomi); if (i < count) { strBuilder.append(", "); } i++; } TextView onyomi = (TextView) view.findViewById(R.id.kanjidict_onyomi); onyomi.setText(strBuilder); } else { view.findViewById(R.id.kanjidict_onyomi_container).setVisibility(View.GONE); } if (mJapaneseCharacter.getNanori() != null && mJapaneseCharacter.getNanori().size() > 0) { Log.i(LOG_TAG, "Setting nanori: " + mJapaneseCharacter.getNanori()); int count = mJapaneseCharacter.getNanori().size(); int i = 1; StringBuilder strBuilder = new StringBuilder(); for (String nanori : mJapaneseCharacter.getNanori()) { strBuilder.append(nanori); if (i < count) { strBuilder.append(", "); } i++; } TextView nanori = (TextView) view.findViewById(R.id.kanjidict_nanori); nanori.setText(strBuilder); } else { view.findViewById(R.id.kanjidict_nanori_container).setVisibility(View.GONE); } boolean hasMeaning = false; LinearLayout container = (LinearLayout) view.findViewById(R.id.kanjidict_meanings_lines_container); container.removeAllViews(); if ((mEnglish || (!mDutch && !mFrench && !mGerman && !mRussian)) && mJapaneseCharacter.getMeaningEnglish() != null && mJapaneseCharacter.getMeaningEnglish().size() > 0) { Log.i(LOG_TAG, "Setting english meaning"); hasMeaning = true; View languageView = mInflater.inflate(R.layout.kanji_meaning, container, false); TextView language = (TextView) languageView.findViewById(R.id.kanjidict_language); if (!mFrench && !mDutch && !mGerman && !mRussian) { language.setVisibility(View.GONE); } language.setText(R.string.language_english); int i = 1; int count = mJapaneseCharacter.getMeaningEnglish().size(); StringBuilder strBuilder = new StringBuilder(); for (String meaning : mJapaneseCharacter.getMeaningEnglish()) { strBuilder.append(meaning); if (i < count) { strBuilder.append(", "); } i++; } TextView meaningTextView = (TextView) languageView.findViewById(R.id.kanjidict_translation); meaningTextView.setText(strBuilder); Log.i(LOG_TAG, "Setting english meaning: " + strBuilder); container.addView(languageView); } if (mFrench && mJapaneseCharacter.getMeaningFrench() != null && mJapaneseCharacter.getMeaningFrench().size() > 0) { Log.i(LOG_TAG, "Setting french meaning"); hasMeaning = true; View languageView = mInflater.inflate(R.layout.kanji_meaning, container, false); TextView language = (TextView) languageView.findViewById(R.id.kanjidict_language); if (!mEnglish && !mDutch && !mGerman && !mRussian) { language.setVisibility(View.GONE); } language.setText(R.string.language_french); int i = 1; int count = mJapaneseCharacter.getMeaningFrench().size(); StringBuilder strBuilder = new StringBuilder(); for (String meaning : mJapaneseCharacter.getMeaningFrench()) { strBuilder.append(meaning); if (i < count) { strBuilder.append(", "); } i++; } TextView meaningTextView = (TextView) languageView.findViewById(R.id.kanjidict_translation); meaningTextView.setText(strBuilder); container.addView(languageView); } if (mDutch && mJapaneseCharacter.getMeaningDutch() != null && mJapaneseCharacter.getMeaningDutch().size() > 0) { Log.i("DisplayCharacter", "Setting dutch meaning"); hasMeaning = true; View languageView = mInflater.inflate(R.layout.kanji_meaning, container, false); TextView language = (TextView) languageView.findViewById(R.id.kanjidict_language); if (!mFrench && !mEnglish && !mGerman && !mRussian) { language.setVisibility(View.GONE); } language.setText(R.string.language_dutch); int i = 1; int count = mJapaneseCharacter.getMeaningDutch().size(); StringBuilder strBuilder = new StringBuilder(); for (String meaning : mJapaneseCharacter.getMeaningDutch()) { strBuilder.append(meaning); if (i < count) { strBuilder.append(", "); } i++; } TextView meaningTextView = (TextView) languageView.findViewById(R.id.kanjidict_translation); meaningTextView.setText(strBuilder); container.addView(languageView); } if (mGerman && mJapaneseCharacter.getMeaningGerman() != null && mJapaneseCharacter.getMeaningGerman().size() > 0) { Log.i(LOG_TAG, "Setting german meaning"); hasMeaning = true; View languageView = mInflater.inflate(R.layout.kanji_meaning, container, false); TextView language = (TextView) languageView.findViewById(R.id.kanjidict_language); if (!mFrench && !mDutch && !mEnglish && !mRussian) { language.setVisibility(View.GONE); } language.setText(R.string.language_german); int i = 1; int count = mJapaneseCharacter.getMeaningGerman().size(); StringBuilder strBuilder = new StringBuilder(); for (String meaning : mJapaneseCharacter.getMeaningGerman()) { strBuilder.append(meaning); if (i < count) { strBuilder.append(", "); } i++; } TextView meaningTextView = (TextView) languageView.findViewById(R.id.kanjidict_translation); meaningTextView.setText(strBuilder); container.addView(languageView); } if (mRussian && mJapaneseCharacter.getMeaningRussian() != null && mJapaneseCharacter.getMeaningRussian().size() > 0) { Log.i(LOG_TAG, "Setting russian meaning"); hasMeaning = true; View languageView = mInflater.inflate(R.layout.kanji_meaning, container, false); TextView language = (TextView) languageView.findViewById(R.id.kanjidict_language); if (!mFrench && !mDutch && !mEnglish && !mGerman) { language.setVisibility(View.GONE); } language.setText(R.string.language_russian); int i = 1; int count = mJapaneseCharacter.getMeaningRussian().size(); StringBuilder strBuilder = new StringBuilder(); for (String meaning : mJapaneseCharacter.getMeaningRussian()) { strBuilder.append(meaning); if (i < count) { strBuilder.append(", "); } i++; } TextView meaningTextView = (TextView) languageView.findViewById(R.id.kanjidict_translation); meaningTextView.setText(strBuilder); container.addView(languageView); } if (!hasMeaning) { Log.i(LOG_TAG, "Doesn't have meanings"); view.findViewById(R.id.kanjidict_meanings_container).setVisibility(View.GONE); } if (mJapaneseCharacter.getDicRef() != null && mJapaneseCharacter.getDicRef().size() > 0) { Log.i(LOG_TAG, "Setting dictionary references"); Map<String, String> dictionaries = getDictionaryCodes(); LinearLayout dictionariesContainer = (LinearLayout) view .findViewById(R.id.kanjidict_dictionaries_records); dictionariesContainer.removeAllViews(); for (String key : mJapaneseCharacter.getDicRef().keySet()) { View dictionaryLine = mInflater.inflate(R.layout.dictionary_line, dictionariesContainer, false); String dictName = dictionaries.get(key); if (dictName != null && dictName.length() > 0) { TextView dictNameView = (TextView) dictionaryLine.findViewById(R.id.kanjidict_dictionary_dict); dictNameView.setText(dictName); TextView dictNumber = (TextView) dictionaryLine.findViewById(R.id.kanjidict_dictionary_number); dictNumber.setText(mJapaneseCharacter.getDicRef().get(key)); dictionariesContainer.addView(dictionaryLine); } } } else { view.findViewById(R.id.kanjidict_dictionaries_container).setVisibility(View.GONE); } }
From source file:com.ninetwozero.battlelog.fragments.ProfileOverviewFragment.java
public final void showProfile(ProfileInformation data) { // Do we have valid data? if (data == null) { return;//from ww w.jav a 2 s .co m } // Get activity Activity activity = getActivity(); if (activity == null) { return; } // Let's start drawing the... layout ((TextView) activity.findViewById(R.id.text_username)).setText(data.getUsername()); // When did was the users last login? if (data.isPlaying() && data.isOnline()) { ((TextView) activity.findViewById(R.id.text_online)).setText( getString(R.string.info_profile_playing).replace( "{server name}", data.getCurrentServer() ) ); } else if (data.isOnline()) { ((TextView) activity.findViewById(R.id.text_online)).setText(R.string.info_profile_online); } else { ((TextView) activity.findViewById(R.id.text_online)).setText(data.getLastLogin(context)); } // Is the status ""? if (!data.getStatusMessage().equals("")) { // Set the status ((TextView) activity.findViewById(R.id.text_status)).setText(data.getStatusMessage()); ((TextView) activity.findViewById(R.id.text_status_date)).setText( PublicUtils.getRelativeDate(context, data.getStatusMessageChanged(), R.string.info_lastupdate)); } else { // Hide the view ((RelativeLayout) activity.findViewById(R.id.wrap_status)).setVisibility(View.GONE); } // Do we have a presentation? if (data.getPresentation() != null && !data.getPresentation().equals("")) { ((TextView) activity.findViewById(R.id.text_presentation)).setText(data.getPresentation()); } else { ((TextView) activity.findViewById(R.id.text_presentation)).setText(R.string.info_profile_empty_pres); } // Any platoons? if (data.getNumPlatoons() > 0) { // Init View convertView; LinearLayout platoonWrapper = (LinearLayout) activity.findViewById(R.id.list_platoons); // Clear the platoonWrapper ((TextView) activity.findViewById(R.id.text_platoon)).setVisibility(View.GONE); platoonWrapper.removeAllViews(); // Iterate over the platoons for (PlatoonData currentPlatoon : data.getPlatoons()) { // Does it already exist? if (platoonWrapper.findViewWithTag(currentPlatoon) != null) { continue; } // Recycle convertView = layoutInflater.inflate(R.layout.list_item_platoon, platoonWrapper, false); // Set the TextViews ((TextView) convertView.findViewById(R.id.text_name)).setText(currentPlatoon.getName()); ((TextView) convertView.findViewById(R.id.text_tag)).setText("[" + currentPlatoon.getTag() + "]"); ((TextView) convertView.findViewById(R.id.text_members)) .setText(currentPlatoon.getCountMembers() + ""); ((TextView) convertView.findViewById(R.id.text_fans)).setText(currentPlatoon.getCountFans() + ""); // Almost forgot - we got a Bitmap too! ((ImageView) convertView.findViewById(R.id.image_badge)).setImageBitmap( BitmapFactory.decodeFile(PublicUtils.getCachePath(context) + currentPlatoon.getImage()) ); // Store it in the tag convertView.setTag(currentPlatoon); convertView.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // On-click startActivity( new Intent(context, PlatoonActivity.class).putExtra( "platoon", (PlatoonData) v.getTag() ) ); } } ); // Add it! platoonWrapper.addView(convertView); } } else { ((LinearLayout) activity.findViewById(R.id.list_platoons)).removeAllViews(); ((TextView) activity.findViewById(R.id.text_platoon)).setVisibility(View.VISIBLE); } // Set the username ((TextView) activity.findViewById(R.id.text_username)).setText(data.getUsername()); }
From source file:org.namelessrom.devicecontrol.appmanager.AppDetailsActivity.java
private void setupPermissionsView() { final LinearLayout permissionsView = (LinearLayout) findViewById(R.id.permissions_section); final boolean unsupported = Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN; if (unsupported) { permissionsView.setVisibility(View.GONE); return;//from w w w .j ava 2 s .com } AppSecurityPermissions asp = new AppSecurityPermissions(this, mAppItem.getPackageName()); // Make the security sections header visible LinearLayout securityList = (LinearLayout) findViewById(R.id.security_settings_list); securityList.removeAllViews(); securityList.addView(asp.getPermissionsView()); // If this app is running under a shared user ID with other apps, // update the description to explain this. String[] packages = mPm.getPackagesForUid(mAppItem.getApplicationInfo().uid); if (packages != null && packages.length > 1) { final ArrayList<CharSequence> pnames = new ArrayList<>(); for (final String pkg : packages) { if (mAppItem.getPackageName().equals(pkg)) { continue; } try { ApplicationInfo ainfo = mPm.getApplicationInfo(pkg, 0); pnames.add(ainfo.loadLabel(mPm)); } catch (PackageManager.NameNotFoundException ignored) { } } final int N = pnames.size(); if (N > 0) { final Resources res = getResources(); String appListStr; if (N == 1) { appListStr = pnames.get(0).toString(); } else if (N == 2) { appListStr = res.getString(R.string.join_two_items, pnames.get(0), pnames.get(1)); } else { appListStr = pnames.get(N - 2).toString(); for (int i = N - 3; i >= 0; i--) { appListStr = res.getString( i == 0 ? R.string.join_many_items_first : R.string.join_many_items_middle, pnames.get(i), appListStr); } appListStr = res.getString(R.string.join_many_items_last, appListStr, pnames.get(N - 1)); } final TextView descr = (TextView) findViewById(R.id.security_settings_desc); descr.setText(res.getString(R.string.security_settings_desc_multi, mAppItem.getApplicationInfo().loadLabel(mPm), appListStr)); } } }
From source file:com.mycelium.wallet.activity.modern.RecordsFragment.java
private void update() { if (!isAdded()) { return;//from w w w . j a v a 2 s.co m } LinearLayout llRecords = (LinearLayout) getView().findViewById(R.id.llRecords); llRecords.removeAllViews(); if (!_mbwManager.getExpertMode()) { // Hide all the key management functionality from non-experts getView().findViewById(R.id.svRecords).setVisibility(View.GONE); getView().findViewById(R.id.tvExpertModeNeeded).setVisibility(View.VISIBLE); getView().findViewById(R.id.llLocked).setVisibility(View.GONE); } else if (_mbwManager.isKeyManagementLocked()) { // Key management is locked getView().findViewById(R.id.svRecords).setVisibility(View.GONE); getView().findViewById(R.id.tvExpertModeNeeded).setVisibility(View.GONE); getView().findViewById(R.id.llLocked).setVisibility(View.VISIBLE); } else { // Make all the key management functionality available to experts getView().findViewById(R.id.svRecords).setVisibility(View.VISIBLE); getView().findViewById(R.id.tvExpertModeNeeded).setVisibility(View.GONE); getView().findViewById(R.id.llLocked).setVisibility(View.GONE); List<Record> activeRecords = _recordManager.getRecords(Tag.ACTIVE); List<Record> archivedRecords = _recordManager.getRecords(Tag.ARCHIVE); Record selectedRecord = _recordManager.getSelectedRecord(); LinearLayout active = createRecordViewList( activeRecords.isEmpty() ? R.string.active_name_empty : R.string.active_name, activeRecords, selectedRecord, true); llRecords.addView(active); llRecords.addView(createRecordViewList( archivedRecords.isEmpty() ? R.string.archive_name_empty : R.string.archive_name, archivedRecords, selectedRecord, false)); } }
From source file:org.otempo.view.StationActivity.java
/** * Actualiza la parte del layout que visualiza predicciones *///ww w . j ava 2 s.com private void updateLayout() { final LinearLayout scrolled = findViewById(R.id.scrolled); scrolled.removeAllViews(); final LinearLayout predictedGroup = findViewById(R.id.predictedGroup); if (predictedGroup != null) { // en landscape no hay predictedGroup.setVisibility(LinearLayout.INVISIBLE); } final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutUtils.dips(75, this), LinearLayout.LayoutParams.WRAP_CONTENT); Station currentStation = _stationManager.getStation(); if (currentStation == null) { // Si no hay estacin elegida, nada ms que hacer... return; } final int currentStationId = currentStation.getId(); if (currentStation.getPredictions().size() > 0) { removeDialog(DIALOG_LOADING_ID); if (predictedGroup != null) { // en landscape no hay final TextView predictionTime = findViewById(R.id.predictionTime); predictionTime.setText(getPredictionTimeString(currentStation.getLastCreationDate())); predictedGroup.setVisibility(LinearLayout.VISIBLE); } currentStation.acceptPredictionVisitor(new StationPredictionVisitor() { @Override public void apply(@NonNull StationShortTermPrediction shortPred, final int index) { Calendar predictionDate = shortPred.getDate(); if (predictionDate == null || !DateUtils.isFromToday(predictionDate)) { return; } LinearLayout day = new LinearLayout(StationActivity.this); day.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { showDialog(DIALOG_DAY_COMMENT_MASK + index + currentStationId * MAX_PREDICTED_DAYS); } }); day.setOrientation(LinearLayout.VERTICAL); TextView dayName = getDayName(shortPred.getDate()); day.addView(dayName); ImageView morningIcon = new ImageView(StationActivity.this); morningIcon.setImageResource(ResourceUtils.getResource(shortPred.getSkyStateMorning(), true)); day.addView(morningIcon); ImageView afternoonIcon = new ImageView(StationActivity.this); afternoonIcon .setImageResource(ResourceUtils.getResource(shortPred.getSkyStateAfternoon(), true)); day.addView(afternoonIcon); ImageView nightIcon = new ImageView(StationActivity.this); nightIcon.setImageResource(ResourceUtils.getResource(shortPred.getSkyStateNight(), false)); day.addView(nightIcon); TextView temps = new TextView(StationActivity.this); temps.setText(shortPred.getMinTemp() + " - " + shortPred.getMaxTemp() + " C"); temps.setGravity(Gravity.CENTER_HORIZONTAL); day.addView(temps); if (DateUtils.isToday(predictionDate)) { day.setBackgroundResource(R.drawable.today_bg); temps.setTypeface(Typeface.DEFAULT, Typeface.BOLD); dayName.setTypeface(Typeface.DEFAULT, Typeface.BOLD); } scrolled.addView(day, params); } @Override public void apply(@NonNull StationMediumTermPrediction medPred, final int index) { Calendar predictionDate = medPred.getDate(); if (predictionDate == null || !DateUtils.isFromToday(predictionDate)) { return; } LinearLayout day = new LinearLayout(StationActivity.this); day.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { showDialog(DIALOG_DAY_COMMENT_MASK + index + currentStationId * MAX_PREDICTED_DAYS); } }); day.setOrientation(LinearLayout.VERTICAL); TextView dayName = getDayName(medPred.getDate()); day.addView(dayName); ImageView morningIcon = new ImageView(StationActivity.this); morningIcon.setImageResource(ResourceUtils.getResource(medPred.getSkyState(), true)); day.addView(morningIcon); TextView temps = new TextView(StationActivity.this); temps.setText(medPred.getMinTemp() + " - " + medPred.getMaxTemp() + " C"); temps.setGravity(Gravity.CENTER_HORIZONTAL); temps.setTextColor(Color.WHITE); day.addView(temps); scrolled.addView(day, params); } }); } else { // Ahora mostramos el dilogo si hace falta, y sino borramos la marca de skip if (_skipDialog) { _skipDialog = false; } else { if (!this.isFinishing()) { showDialog(DIALOG_LOADING_ID); fetchThenShow(currentStation, false); } } } }
From source file:anastasoft.rallyvision.activity.MenuPrincipal.java
public void makeConnectBOrange() { LinearLayout mConnectLayout = (LinearLayout) findViewById(R.id.ConnecLayout); mConnectLayout.removeAllViews(); // Create new LayoutInflater - this has to be done this way, as you can't directly inflate an XML without creating an inflater object first LayoutInflater inflater = getLayoutInflater(); mConnectLayout.addView(inflater.inflate(R.layout.connect_button_orange, null)); }