List of usage examples for android.widget LinearLayout removeAllViews
public void removeAllViews()
From source file:com.houseofslack.pullscoring.Scoring.java
private void redrawOneSetOfScores(LinearLayout layout, List<Integer> scores, int scoreLayoutId, int scrollLayoutId, String teamName, int teamAndScoreId) { LayoutInflater inflater = getLayoutInflater(); layout.removeAllViews(); int totalScore = 0; for (int score : scores) { totalScore += score;//from w ww.ja va 2s. co m TextView textView = (TextView) inflater.inflate(scoreLayoutId, null); textView.setText(String.valueOf(score)); layout.addView(textView); } TextView textView = (TextView) findViewById(teamAndScoreId); textView.setText(getString(R.string.total_score, teamName, totalScore)); // set the scroll view to the bottom of the display final ScrollView scrollView = (ScrollView) findViewById(scrollLayoutId); scrollView.post(new Runnable() { @Override public void run() { scrollView.fullScroll(ScrollView.FOCUS_DOWN); } }); }
From source file:com.sft.blackcatapp.SearchCoachActivity.java
private void showOpenCityPopupWindow(View parent) { if (openCityPopupWindow == null) { LinearLayout popWindowLayout = (LinearLayout) View.inflate(mContext, R.layout.pop_window, null); popWindowLayout.removeAllViews(); // LinearLayout popWindowLayout = new LinearLayout(mContext); popWindowLayout.setOrientation(LinearLayout.VERTICAL); ListView OpenCityListView = new ListView(mContext); OpenCityListView.setDividerHeight(0); OpenCityListView.setCacheColorHint(android.R.color.transparent); OpenCityListView.setOnItemClickListener(new OnItemClickListener() { @Override/*from www . j a v a 2s.c o m*/ public void onItemClick(AdapterView<?> parent, View view, int position, long id) { OpenCityVO selectCity = openCityList.get(position); System.out.println(selectCity.getName()); cityname = selectCity.getName().replace("", ""); licensetype = ""; coachname = ""; ordertype = "0"; index = 1; obtainCaoch(); openCityPopupWindow.dismiss(); openCityPopupWindow = null; } }); LinearLayout.LayoutParams param = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); popWindowLayout.addView(OpenCityListView, param); OpenCityAdapter openCityAdapter = new OpenCityAdapter(mContext, openCityList); OpenCityListView.setAdapter(openCityAdapter); openCityPopupWindow = new PopupWindow(popWindowLayout, 130, LayoutParams.WRAP_CONTENT); } openCityPopupWindow.setFocusable(true); openCityPopupWindow.setOutsideTouchable(true); // Back??? openCityPopupWindow.setBackgroundDrawable(new BitmapDrawable()); openCityPopupWindow.showAsDropDown(parent); }
From source file:com.csipsimple.service.SipNotifications.java
@SuppressWarnings("deprecation") private void searchNotificationPrimaryText(Context aContext) { try {// w w w.j a v a 2 s . com Notification ntf = new Notification(); ntf.setLatestEventInfo(aContext, TO_SEARCH, "", null); LinearLayout group = new LinearLayout(aContext); ViewGroup event = (ViewGroup) ntf.contentView.apply(aContext, group); recurseSearchNotificationPrimaryText(event); group.removeAllViews(); } catch (Exception e) { Log.e(THIS_FILE, "Can't retrieve the color", e); } }
From source file:org.deviceconnect.android.manager.setting.DevicePluginInfoFragment.java
/** * ?.//from w w w . j a v a 2 s. c o m * @param plugin ? */ public void updateInfo(final DevicePlugin plugin) { View view = getView(); if (view == null) { return; } mPluginInfo = plugin.getInfo(); boolean isEnabled = plugin.isEnabled(); String packageName = mPluginInfo.getPackageName(); Integer iconId = mPluginInfo.getPluginIconId(); String name = mPluginInfo.getDeviceName(); Drawable icon = DConnectUtil.loadPluginIcon(getActivity(), packageName, iconId); String versionName = mPluginInfo.getVersionName(); String managerPackageName = getActivity().getPackageName(); TextView nameView = view.findViewById(R.id.plugin_package_name); nameView.setText(name); if (icon != null) { ImageView iconView = view.findViewById(R.id.plugin_icon); iconView.setImageDrawable(icon); } TextView versionView = view.findViewById(R.id.plugin_version); versionView.setText(getString(R.string.activity_deviceplugin_info_version, versionName)); Button settingBtn = view.findViewById(R.id.plugin_settings_btn); settingBtn.setEnabled(isEnabled); settingBtn.setOnClickListener((v) -> { openSettings(); }); Button deleteBtn = view.findViewById(R.id.plugin_delete_btn); deleteBtn.setOnClickListener((v) -> { openUninstall(); }); deleteBtn.setEnabled(!packageName.equals(managerPackageName)); Button restartBtn = view.findViewById(R.id.plugin_restart_btn); restartBtn.setEnabled(isEnabled); restartBtn.setOnClickListener((v) -> { restartDevicePlugin(); }); TextView connectionTypeView = view.findViewById(R.id.plugin_connection_type); int resId; switch (mPluginInfo.getConnectionType()) { case BINDER: resId = R.string.activity_deviceplugin_info_connection_type_binder; break; case BROADCAST: resId = R.string.activity_deviceplugin_info_connection_type_broadcast; break; case INTERNAL: resId = R.string.activity_deviceplugin_info_connection_type_included_with_manager; break; default: resId = R.string.activity_deviceplugin_info_connection_type_unknown; break; } connectionTypeView.setText(getString(resId)); LinearLayout mainLayout = view.findViewById(R.id.plugin_support_profiles); Map<String, DevicePluginXmlProfile> profiles = mPluginInfo.getSupportedProfiles(); if (profiles != null) { String locale = Locale.getDefault().getLanguage(); for (String key : profiles.keySet()) { String profileName = key; DevicePluginXmlProfile p = profiles.get(key); if (p != null) { Map<String, DevicePluginXmlProfileLocale> locales = p.getXmlProfileLocales(); if (locales != null) { DevicePluginXmlProfileLocale xmlLocale = locales.get(locale); if (xmlLocale != null) { profileName = xmlLocale.getName(); } } } TextView tv = new TextView(getActivity()); tv.setText(getString(R.string.activity_deviceplugin_info_profile_name, profileName)); mainLayout.addView(tv); } } mErrorView = view.findViewById(R.id.plugin_connection_error_view); mErrorView.showErrorMessage(plugin); if (BuildConfig.DEBUG) { CommunicationHistory history = plugin.getHistory(); View baud = view.findViewById(R.id.activity_deviceplugin_info_baud_rate); baud.setVisibility(View.VISIBLE); TextView average = baud.findViewById(R.id.activity_deviceplugin_info_average_baud_rate); average.setText( getString(R.string.activity_deviceplugin_info_baud_rate_unit, history.getAverageBaudRate())); TextView request = baud.findViewById(R.id.activity_deviceplugin_info_worst_request); request.setText(history.getWorstBaudRateRequest()); TextView worst = baud.findViewById(R.id.activity_deviceplugin_info_worst_baud_rate); worst.setText( getString(R.string.activity_deviceplugin_info_baud_rate_unit, history.getWorstBaudRate())); LayoutInflater inflater = getLayoutInflater(); LinearLayout baudRateListLayout = baud.findViewById(R.id.activity_deviceplugin_info_baud_rate_list); baudRateListLayout.removeAllViews(); List<CommunicationHistory.Info> baudRateList = history.getRespondedCommunications(); for (int i = baudRateList.size() - 1; i >= 0; i--) { CommunicationHistory.Info b = baudRateList.get(i); View v = inflater.inflate(R.layout.item_baud_rate_list, null); TextView br = v.findViewById(R.id.activity_deviceplugin_info_request); br.setText(b.getRequestPath()); TextView bb = v.findViewById(R.id.activity_deviceplugin_info_baud_rate); bb.setText(getString(R.string.activity_deviceplugin_info_baud_rate_unit, b.getRoundTripTime())); TextView d = v.findViewById(R.id.activity_deviceplugin_info_date); d.setText(b.getDateString()); baudRateListLayout.addView(v); } LinearLayout timeoutListLayout = baud.findViewById(R.id.activity_deviceplugin_info_timeout_list); timeoutListLayout.removeAllViews(); List<CommunicationHistory.Info> timeoutList = history.getNotRespondedCommunications(); for (int i = timeoutList.size() - 1; i >= 0; i--) { CommunicationHistory.Info t = timeoutList.get(i); View v = inflater.inflate(R.layout.item_timeout_list, null); TextView br = v.findViewById(R.id.activity_deviceplugin_info_request); br.setText(t.getRequestPath()); TextView d = v.findViewById(R.id.activity_deviceplugin_info_date); d.setText(t.getDateString()); timeoutListLayout.addView(v); } } }
From source file:com.gh4a.IssueLabelListActivity.java
private void fillData() { final Typeface condensed = getApplicationContext().condensed; LinearLayout ll = (LinearLayout) findViewById(R.id.main_content); ll.removeAllViews(); mAllLabelLayout = new ArrayList<Map<String, Object>>(); for (final Label label : mLabels) { Map<String, Object> selectedLabelItems = new HashMap<String, Object>(); selectedLabelItems.put("label", label); final View rowView = getLayoutInflater().inflate(R.layout.row_issue_label, null); final View viewColor = (View) rowView.findViewById(R.id.view_color); final LinearLayout llEdit = (LinearLayout) rowView.findViewById(R.id.ll_edit); selectedLabelItems.put("llEdit", llEdit); final EditText etLabel = (EditText) rowView.findViewById(R.id.et_label); selectedLabelItems.put("etLabel", etLabel); final TextView tvLabel = (TextView) rowView.findViewById(R.id.tv_title); selectedLabelItems.put("tvLabel", tvLabel); tvLabel.setTypeface(condensed);/*from w w w . j a v a2 s . c o m*/ tvLabel.setText(label.getName()); viewColor.setBackgroundColor(Color.parseColor("#" + label.getColor())); selectedLabelItems.put("viewColor", viewColor); mAllLabelLayout.add(selectedLabelItems); viewColor.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (llEdit.getVisibility() == View.VISIBLE) { llEdit.setVisibility(View.GONE); unselectLabel(tvLabel, viewColor, label.getColor()); } else { llEdit.setVisibility(View.VISIBLE); selectLabel(tvLabel, viewColor, label.getColor(), true, etLabel); etLabel.setText(label.getName()); mActionMode = startActionMode(new EditActionMode(label.getName(), etLabel)); } } }); tvLabel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { LinearLayout llEdit = (LinearLayout) rowView.findViewById(R.id.ll_edit); if (llEdit.getVisibility() == View.VISIBLE) { llEdit.setVisibility(View.GONE); unselectLabel(tvLabel, viewColor, label.getColor()); } else { llEdit.setVisibility(View.VISIBLE); selectLabel(tvLabel, viewColor, label.getColor(), true, etLabel); etLabel.setText(label.getName()); mActionMode = startActionMode(new EditActionMode(label.getName(), etLabel)); } } }); if (!StringUtils.isBlank(mSelectedLabel) && mSelectedLabel.equals(label.getName())) { selectLabel(tvLabel, viewColor, label.getColor(), false, etLabel); llEdit.setVisibility(View.VISIBLE); etLabel.setText(label.getName()); } final View color1 = (View) rowView.findViewById(R.id.color_444444); color1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { selectLabel(tvLabel, viewColor, (String) color1.getTag(), false, etLabel); } }); final View color2 = (View) rowView.findViewById(R.id.color_02d7e1); color2.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { selectLabel(tvLabel, viewColor, (String) color2.getTag(), false, etLabel); } }); final View color3 = (View) rowView.findViewById(R.id.color_02e10c); color3.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { selectLabel(tvLabel, viewColor, (String) color3.getTag(), false, etLabel); } }); final View color4 = (View) rowView.findViewById(R.id.color_0b02e1); color4.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { selectLabel(tvLabel, viewColor, (String) color4.getTag(), false, etLabel); } }); final View color5 = (View) rowView.findViewById(R.id.color_d7e102); color5.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { selectLabel(tvLabel, viewColor, (String) color5.getTag(), false, etLabel); } }); final View color6 = (View) rowView.findViewById(R.id.color_DDDDDD); color6.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { selectLabel(tvLabel, viewColor, (String) color6.getTag(), false, etLabel); } }); final View color7 = (View) rowView.findViewById(R.id.color_e102d8); color7.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { selectLabel(tvLabel, viewColor, (String) color7.getTag(), false, etLabel); } }); final View color8 = (View) rowView.findViewById(R.id.color_e10c02); color8.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { selectLabel(tvLabel, viewColor, (String) color8.getTag(), false, etLabel); } }); ll.addView(rowView); } }
From source file:com.i2max.i2smartwork.common.work.WorkDetailViewFragment.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.size() <= 0) { targetLayout.setVisibility(View.GONE); } else {//from w w w . jav a 2 s . c om 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) { 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); } }); targetLayout.addView(fileView); } } }
From source file:com.farmerbb.taskbar.service.DashboardService.java
private void removeWidget(int cellId, boolean tempRemove) { widgets.remove(cellId);// www. j ava 2s. co m DashboardCell cellLayout = cells.get(cellId); Bundle bundle = (Bundle) cellLayout.getTag(); mAppWidgetHost.deleteAppWidgetId(bundle.getInt("appWidgetId")); bundle.remove("appWidgetId"); LinearLayout linearLayout = (LinearLayout) cellLayout.findViewById(R.id.dashboard); linearLayout.removeAllViews(); cellLayout.setTag(bundle); cellLayout.setOnClickListener(cellOcl); cellLayout.setOnHoverListener(cellOhl); cellLayout.setOnLongClickListener(null); cellLayout.setOnGenericMotionListener(null); cellLayout.setOnInterceptedLongPressListener(null); SharedPreferences pref = U.getSharedPreferences(this); SharedPreferences.Editor editor = pref.edit(); editor.remove("dashboard_widget_" + Integer.toString(cellId)); if (tempRemove) { editor.putBoolean("dashboard_widget_" + Integer.toString(cellId) + "_placeholder", true); addPlaceholder(cellId); } else editor.remove("dashboard_widget_" + Integer.toString(cellId) + "_provider"); editor.apply(); }
From source file:ca.mudar.parkcatcher.ui.fragments.DetailsFragment.java
private void initDetails(Cursor data) { mIsStarred = (data.getInt(PostDetailsQuery.IS_STARRED) == 1); mGeoLat = data.getDouble(PostDetailsQuery.LAT); mGeoLng = data.getDouble(PostDetailsQuery.LNG); // Start the reverse geocode address search if (ConnectionHelper.hasConnection(getActivity())) { mView.findViewById(R.id.details_progress_address).setVisibility(View.VISIBLE); final Thread thread = new Thread(this); thread.start();/*from w w w . ja v a2 s . com*/ } else { mView.findViewById(R.id.details_progress_address).setVisibility(View.GONE); } final boolean isForbidden = (data.getInt(PostDetailsQuery.IS_FORBIDDEN) == 1); final LinearLayout panelsWrapper = (LinearLayout) mView.findViewById(R.id.details_panels_wrapper); panelsWrapper.removeAllViews(); // Panels LayoutParams and Color final LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); final float SCALE = getActivity().getResources().getDisplayMetrics().density; // Convert dips to pixels float valueDips = 16.0f; int valuePixels = (int) (valueDips * SCALE); params.setMargins(0, 0, 0, valuePixels); final int textColor = getResources().getColor(R.color.details_panel_text); do { final String desc = data.getString(PostDetailsQuery.DESCRIPTION); mShareDesc += Const.LINE_SEPARATOR + desc; panelsWrapper.addView(getPanel(desc, params, textColor)); } while (data.moveToNext()); final TextView titleUi = (TextView) mView.findViewById(R.id.details_title); if (isForbidden) { titleUi.setText(R.string.details_title_forbidden); } else { titleUi.setText(R.string.details_title_allowed); } getSherlockActivity().invalidateOptionsMenu(); }
From source file:com.nadmm.airports.wx.TafFragment.java
protected void showTaf(Intent intent) { if (getActivity() == null) { return;/*from w w w .j a v a2 s . c o m*/ } Taf taf = (Taf) intent.getSerializableExtra(NoaaService.RESULT); if (taf == null) { return; } View detail = findViewById(R.id.wx_detail_layout); LinearLayout layout = (LinearLayout) findViewById(R.id.wx_status_layout); TextView tv = (TextView) findViewById(R.id.status_msg); layout.removeAllViews(); if (!taf.isValid) { tv.setVisibility(View.VISIBLE); layout.setVisibility(View.VISIBLE); tv.setText("Unable to get TAF 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 TAF for this station"); addBulletedRow(layout, "Station is currently out of service"); addBulletedRow(layout, "Station has not updated the TAF for more than 12 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_age); tv.setText(TimeUtils.formatElapsedTime(taf.issueTime)); // Raw Text tv = (TextView) findViewById(R.id.wx_raw_taf); tv.setText(taf.rawText.replaceAll("(FM|BECMG|TEMPO)", "\n $1")); layout = (LinearLayout) findViewById(R.id.taf_summary_layout); layout.removeAllViews(); String fcstType; if (taf.rawText.startsWith("TAF AMD ")) { fcstType = "Amendment"; } else if (taf.rawText.startsWith("TAF COR ")) { fcstType = "Correction"; } else { fcstType = "Normal"; } addRow(layout, "Forecast type", fcstType); addRow(layout, "Issued at", TimeUtils.formatDateTime(getActivity(), taf.issueTime)); addRow(layout, "Valid from", TimeUtils.formatDateTime(getActivity(), taf.validTimeFrom)); addRow(layout, "Valid to", TimeUtils.formatDateTime(getActivity(), taf.validTimeTo)); if (taf.remarks != null && taf.remarks.length() > 0 && !taf.remarks.equals("AMD")) { addRow(layout, "\u2022 " + taf.remarks); } LinearLayout topLayout = (LinearLayout) findViewById(R.id.taf_forecasts_layout); topLayout.removeAllViews(); StringBuilder sb = new StringBuilder(); for (Forecast forecast : taf.forecasts) { RelativeLayout grp_layout = (RelativeLayout) inflate(R.layout.grouped_detail_item); // Keep track of forecast conditions across all change groups if (mLastForecast == null || forecast.changeIndicator == null || forecast.changeIndicator.equals("FM")) { mLastForecast = forecast; } else { if (forecast.visibilitySM < Float.MAX_VALUE) { mLastForecast.visibilitySM = forecast.visibilitySM; } if (forecast.skyConditions.size() > 0) { mLastForecast.skyConditions = forecast.skyConditions; } } sb.setLength(0); if (forecast.changeIndicator != null) { sb.append(forecast.changeIndicator); sb.append(" "); } sb.append(TimeUtils.formatDateRange(getActivity(), forecast.timeFrom, forecast.timeTo)); tv = (TextView) grp_layout.findViewById(R.id.group_extra); tv.setVisibility(View.GONE); tv = (TextView) grp_layout.findViewById(R.id.group_name); tv.setText(sb.toString()); String flightCategory = WxUtils.computeFlightCategory(mLastForecast.skyConditions, mLastForecast.visibilitySM); WxUtils.setFlightCategoryDrawable(tv, flightCategory); LinearLayout fcst_layout = (LinearLayout) grp_layout.findViewById(R.id.group_details); if (forecast.probability < Integer.MAX_VALUE) { addRow(fcst_layout, "Probability", String.format("%d%%", forecast.probability)); } if (forecast.changeIndicator != null && forecast.changeIndicator.equals("BECMG")) { addRow(fcst_layout, "Becoming at", TimeUtils.formatDateTime(getActivity(), forecast.timeBecoming)); } if (forecast.windSpeedKnots < Integer.MAX_VALUE) { String wind; if (forecast.windDirDegrees == 0 && forecast.windSpeedKnots == 0) { wind = "Calm"; } else if (forecast.windDirDegrees == 0) { wind = String.format(Locale.US, "Variable at %d knots", forecast.windSpeedKnots); } else { wind = String.format(Locale.US, "%s (%s true) at %d knots", GeoUtils.getCardinalDirection(forecast.windDirDegrees), FormatUtils.formatDegrees(forecast.windDirDegrees), forecast.windSpeedKnots); } String gust = ""; if (forecast.windGustKnots < Integer.MAX_VALUE) { gust = String.format(Locale.US, "Gusting to %d knots", forecast.windGustKnots); } addRow(fcst_layout, "Winds", wind, gust); } if (forecast.visibilitySM < Float.MAX_VALUE) { String value = forecast.visibilitySM > 6 ? "6+ SM" : FormatUtils.formatStatuteMiles(forecast.visibilitySM); addRow(fcst_layout, "Visibility", value); } if (forecast.vertVisibilityFeet < Integer.MAX_VALUE) { addRow(fcst_layout, "Visibility", FormatUtils.formatFeetAgl(forecast.vertVisibilityFeet)); } for (WxSymbol wx : forecast.wxList) { addRow(fcst_layout, "Weather", wx.toString()); } for (SkyCondition sky : forecast.skyConditions) { addRow(fcst_layout, "Clouds", sky.toString()); } if (forecast.windShearSpeedKnots < Integer.MAX_VALUE) { String shear = String.format(Locale.US, "%s (%s true) at %d knots", GeoUtils.getCardinalDirection(forecast.windShearDirDegrees), FormatUtils.formatDegrees(forecast.windShearDirDegrees), forecast.windShearSpeedKnots); String height = FormatUtils.formatFeetAgl(forecast.windShearHeightFeetAGL); addRow(fcst_layout, "Wind shear", shear, height); } if (forecast.altimeterHg < Float.MAX_VALUE) { addRow(fcst_layout, "Altimeter", FormatUtils.formatAltimeter(forecast.altimeterHg)); } for (TurbulenceCondition turbulence : forecast.turbulenceConditions) { String value = WxUtils.decodeTurbulenceIntensity(turbulence.intensity); String height = FormatUtils.formatFeetRangeAgl(turbulence.minAltitudeFeetAGL, turbulence.maxAltitudeFeetAGL); addRow(fcst_layout, "Turbulence", value, height); } for (IcingCondition icing : forecast.icingConditions) { String value = WxUtils.decodeIcingIntensity(icing.intensity); String height = FormatUtils.formatFeetRangeAgl(icing.minAltitudeFeetAGL, icing.maxAltitudeFeetAGL); addRow(fcst_layout, "Icing", value, height); } topLayout.addView(grp_layout, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); } tv = (TextView) findViewById(R.id.wx_fetch_time); tv.setText("Fetched on " + TimeUtils.formatDateTime(getActivity(), taf.fetchTime)); tv.setVisibility(View.VISIBLE); stopRefreshAnimation(); setFragmentContentShown(true); }
From source file:org.namelessrom.devicecontrol.modules.appmanager.AppDetailsActivity.java
private void setupPermissionsView() { final LinearLayout permissionsView = (LinearLayout) findViewById(R.id.permissions_section); final boolean supported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1; if (!supported) { permissionsView.setVisibility(View.GONE); return;/*from ww w . j a v a 2 s. c om*/ } 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)); } } }