List of usage examples for android.widget ImageView setVisibility
@RemotableViewMethod @Override public void setVisibility(int visibility)
From source file:android.support.v7.preference.Preference.java
/** * Binds the created View to the data for this Preference. * <p>/*from w w w . jav a 2 s .c om*/ * This is a good place to grab references to custom Views in the layout and * set properties on them. * <p> * Make sure to call through to the superclass's implementation. * * @param holder The ViewHolder that provides references to the views to fill in. These views * will be recycled, so you should not hold a reference to them after this method * returns. */ public void onBindViewHolder(PreferenceViewHolder holder) { holder.itemView.setOnClickListener(mClickListener); holder.itemView.setId(mViewId); final TextView titleView = (TextView) holder.findViewById(android.R.id.title); if (titleView != null) { final CharSequence title = getTitle(); if (!TextUtils.isEmpty(title)) { titleView.setText(title); titleView.setVisibility(View.VISIBLE); } else { titleView.setVisibility(View.GONE); } } final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary); if (summaryView != null) { final CharSequence summary = getSummary(); if (!TextUtils.isEmpty(summary)) { summaryView.setText(summary); summaryView.setVisibility(View.VISIBLE); } else { summaryView.setVisibility(View.GONE); } } final ImageView imageView = (ImageView) holder.findViewById(android.R.id.icon); if (imageView != null) { if (mIconResId != 0 || mIcon != null) { if (mIcon == null) { mIcon = ContextCompat.getDrawable(getContext(), mIconResId); } if (mIcon != null) { imageView.setImageDrawable(mIcon); } } imageView.setVisibility(mIcon != null ? View.VISIBLE : View.GONE); } View imageFrame = holder.findViewById(R.id.icon_frame); if (imageFrame == null) { imageFrame = holder.findViewById(AndroidResources.ANDROID_R_ICON_FRAME); } if (imageFrame != null) { imageFrame.setVisibility(mIcon != null ? View.VISIBLE : View.GONE); } if (mShouldDisableView) { setEnabledStateOnViews(holder.itemView, isEnabled()); } else { setEnabledStateOnViews(holder.itemView, true); } final boolean selectable = isSelectable(); holder.itemView.setFocusable(selectable); holder.itemView.setClickable(selectable); holder.setDividerAllowedAbove(selectable); holder.setDividerAllowedBelow(selectable); }
From source file:com.android.contacts.list.ContactListItemView.java
private void addStarImageHeader() { mHeaderView = new ImageView(getContext()); final ImageView headerImageView = (ImageView) mHeaderView; headerImageView.setImageDrawable(// w w w .j a v a 2 s.c om getResources().getDrawable(R.drawable.quantum_ic_star_vd_theme_24, getContext().getTheme())); headerImageView .setImageTintList(ColorStateList.valueOf(getResources().getColor(R.color.material_star_pink))); headerImageView.setContentDescription(getContext().getString(R.string.contactsFavoritesLabel)); headerImageView.setVisibility(View.VISIBLE); addView(headerImageView); }
From source file:org.akvo.caddisfly.sensor.colorimetry.strip.instructions.InstructionActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_instruction); final PageIndicatorView pageIndicatorView = (PageIndicatorView) findViewById(R.id.pager_indicator); final ImageView imagePageLeft = (ImageView) findViewById(R.id.image_pageLeft); final ImageView imagePageRight = (ImageView) findViewById(R.id.image_pageRight); StripTest.Brand brand = (new StripTest()).getBrand(getIntent().getStringExtra(Constant.UUID)); setTitle(brand.getName());//from w ww . j av a 2 s. c o m JSONArray instructions = brand.getInstructions(); if (instructions != null) { for (int i = 0; i < instructions.length(); i++) { try { Object item = instructions.getJSONObject(i).get("text"); JSONArray jsonArray; if (item instanceof JSONArray) { jsonArray = (JSONArray) item; } else { String text = (String) item; jsonArray = new JSONArray(); jsonArray.put(text); } fragments.add(InstructionDetailFragment.newInstance(jsonArray, instructions.getJSONObject(i).has("png") ? instructions.getJSONObject(i).getString("png") : "")); } catch (JSONException e) { Timber.e(e); } } pageIndicatorView.setPageCount(instructions.length()); } mViewPager = (ViewPager) findViewById(R.id.pager); final PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(pagerAdapter); mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { pageIndicatorView.setActiveIndex(position); if (position < 1) { imagePageLeft.setVisibility(View.INVISIBLE); } else { imagePageLeft.setVisibility(View.VISIBLE); } if (position > pagerAdapter.getCount() - 2) { imagePageRight.setVisibility(View.INVISIBLE); } else { imagePageRight.setVisibility(View.VISIBLE); } } @Override public void onPageScrollStateChanged(int state) { } }); imagePageLeft.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mViewPager.setCurrentItem(Math.max(0, mViewPager.getCurrentItem() - 1)); } }); imagePageRight.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mViewPager.setCurrentItem(Math.min(fragments.size() - 1, mViewPager.getCurrentItem() + 1)); } }); if (pagerAdapter.getCount() < 2) { imagePageLeft.setVisibility(View.GONE); imagePageRight.setVisibility(View.GONE); } }
From source file:nu.yona.timepicker.time.TimePickerDialog.java
private void updateTab(String tabId) { if (tabId.equals(getString(R.string.from))) { if (tabHost.getTabWidget().getChildCount() > 1) { ImageView iv = (ImageView) tabHost.getTabWidget().getChildAt(0).findViewById(R.id.tabIndicator); iv.setVisibility(View.VISIBLE); ImageView iv1 = (ImageView) tabHost.getTabWidget().getChildAt(1).findViewById(R.id.tabIndicatorEnd); iv1.setVisibility(View.GONE); } else {/*from ww w .j a va 2 s .c om*/ ImageView iv = (ImageView) tabHost.getTabWidget().getChildAt(0).findViewById(R.id.tabIndicator); iv.setVisibility(View.VISIBLE); } } else if (tabId.equals(getString(R.string.to))) { ImageView iv = (ImageView) tabHost.getTabWidget().getChildAt(0).findViewById(R.id.tabIndicator); iv.setVisibility(View.GONE); ImageView iv1 = (ImageView) tabHost.getTabWidget().getChildAt(1).findViewById(R.id.tabIndicatorEnd); iv1.setVisibility(View.VISIBLE); } }
From source file:de.dfki.iui.opentok.cordova.plugin.OpenTokPlugin.java
private void doUpdateViewIconStatus(final ImageView icon, final int ressourceId, final int visibility) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override/*from ww w .j av a2 s. co m*/ public void run() { icon.setImageResource(ressourceId); icon.setVisibility(visibility); } }); }
From source file:com.android.tv.settings.dialog.DialogFragment.java
private void setContentView(View content) { TextView titleView = (TextView) content.findViewById(R.id.title); TextView breadcrumbView = (TextView) content.findViewById(R.id.breadcrumb); TextView descriptionView = (TextView) content.findViewById(R.id.description); titleView.setText(mTitle);/* w ww . j a va 2 s .co m*/ breadcrumbView.setText(mBreadcrumb); descriptionView.setText(mDescription); final ImageView iconImageView = (ImageView) content.findViewById(R.id.icon); if (mIconBackgroundColor != Color.TRANSPARENT) { iconImageView.setBackgroundColor(mIconBackgroundColor); } if (AccessibilityHelper.forceFocusableViews(getActivity())) { titleView.setFocusable(true); titleView.setFocusableInTouchMode(true); descriptionView.setFocusable(true); descriptionView.setFocusableInTouchMode(true); breadcrumbView.setFocusable(true); breadcrumbView.setFocusableInTouchMode(true); } if (mIconResourceId != 0) { iconImageView.setImageResource(mIconResourceId); updateViewSize(iconImageView); } else { if (mIconBitmap != null) { iconImageView.setImageBitmap(mIconBitmap); updateViewSize(iconImageView); } else { if (mIconUri != null) { iconImageView.setVisibility(View.INVISIBLE); DrawableDownloader bitmapDownloader = DrawableDownloader.getInstance(content.getContext()); mBitmapCallBack = new BitmapCallback() { @Override public void onBitmapRetrieved(Drawable bitmap) { if (bitmap != null) { mIconBitmap = (bitmap instanceof BitmapDrawable) ? ((BitmapDrawable) bitmap).getBitmap() : null; iconImageView.setVisibility(View.VISIBLE); iconImageView.setImageDrawable(bitmap); updateViewSize(iconImageView); } } }; bitmapDownloader.getBitmap(new BitmapWorkerOptions.Builder(content.getContext()) .resource(mIconUri).width(iconImageView.getLayoutParams().width).build(), mBitmapCallBack); } else { iconImageView.setVisibility(View.GONE); } } } content.setTag(R.id.title, titleView); content.setTag(R.id.breadcrumb, breadcrumbView); content.setTag(R.id.description, descriptionView); content.setTag(R.id.icon, iconImageView); }
From source file:fiskinfoo.no.sintef.fiskinfoo.Implementation.UtilityOnClickListeners.java
public OnClickListener getToolEntryEditDialogOnClickListener(final Activity activity, final FragmentManager fragmentManager, final GpsLocationTracker locationTracker, final ToolEntry toolEntry, final User user) { return new OnClickListener() { @Override/*from www. j a v a 2 s . c o m*/ public void onClick(final View editButton) { final DialogInterface dialogInterface = new UtilityDialogs(); final Dialog dialog = dialogInterface.getDialog(editButton.getContext(), R.layout.dialog_register_new_tool, R.string.edit_tool); ((Button) dialog.findViewById(R.id.dialog_register_tool_create_tool_button)) .setText(editButton.getContext().getString(R.string.save)); final Button updateButton = (Button) dialog .findViewById(R.id.dialog_register_tool_create_tool_button); final Button cancelButton = (Button) dialog.findViewById(R.id.dialog_register_tool_cancel_button); final LinearLayout fieldContainer = (LinearLayout) dialog .findViewById(R.id.dialog_register_tool_main_container); final DatePickerRow setupDateRow = new DatePickerRow(editButton.getContext(), editButton.getContext().getString(R.string.tool_set_date_colon), fragmentManager); final TimePickerRow setupTimeRow = new TimePickerRow(editButton.getContext(), editButton.getContext().getString(R.string.tool_set_time_colon), fragmentManager, false); final CoordinatesRow coordinatesRow = new CoordinatesRow(activity, locationTracker); final SpinnerRow toolRow = new SpinnerRow(editButton.getContext(), editButton.getContext().getString(R.string.tool_type), ToolType.getValues()); final CheckBoxRow toolRemovedRow = new CheckBoxRow(editButton.getContext(), editButton.getContext().getString(R.string.tool_removed_row_text), true); final EditTextRow commentRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.comment_field_header), editButton.getContext().getString(R.string.comment_field_hint)); final EditTextRow contactPersonNameRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.contact_person_name), editButton.getContext().getString(R.string.contact_person_name)); final EditTextRow contactPersonPhoneRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.contact_person_phone), editButton.getContext().getString(R.string.contact_person_phone)); final EditTextRow contactPersonEmailRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.contact_person_email), editButton.getContext().getString(R.string.contact_person_email)); final EditTextRow vesselNameRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.vessel_name), editButton.getContext().getString(R.string.vessel_name)); final EditTextRow vesselPhoneNumberRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.vessel_phone_number), editButton.getContext().getString(R.string.vessel_phone_number)); final EditTextRow vesselIrcsNumberRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.ircs_number), editButton.getContext().getString(R.string.ircs_number)); final EditTextRow vesselMmsiNumberRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.mmsi_number), editButton.getContext().getString(R.string.mmsi_number)); final EditTextRow vesselImoNumberRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.imo_number), editButton.getContext().getString(R.string.imo_number)); final EditTextRow vesselRegistrationNumberRow = new EditTextRow(editButton.getContext(), editButton.getContext().getString(R.string.registration_number), editButton.getContext().getString(R.string.registration_number)); final ErrorRow errorRow = new ErrorRow(editButton.getContext(), editButton.getContext().getString(R.string.error_minimum_identification_factors_not_met), false); final SimpleDateFormat sdfMilliSeconds = new SimpleDateFormat( editButton.getContext().getString(R.string.datetime_format_yyyy_mm_dd_t_hh_mm_ss_sss), Locale.getDefault()); final SimpleDateFormat sdf = new SimpleDateFormat( editButton.getContext().getString(R.string.datetime_format_yyyy_mm_dd_t_hh_mm_ss), Locale.getDefault()); View.OnClickListener deleteButtonRowOnClickListener = new OnClickListener() { @Override public void onClick(View v) { String confirmationText; switch (toolEntry.getToolStatus()) { case STATUS_RECEIVED: case STATUS_SENT_UNCONFIRMED: confirmationText = v.getContext() .getString(R.string.confirm_registered_tool_deletion_text); break; case STATUS_UNSENT: case STATUS_UNREPORTED: confirmationText = v.getContext().getString(R.string.confirm_tool_deletion_text); break; case STATUS_REMOVED_UNCONFIRMED: confirmationText = v.getContext() .getString(R.string.confirm_registered_tool_with_local_changes_deletion_text); break; default: confirmationText = v.getContext() .getString(R.string.confirm_tool_deletion_text_general); break; } final Dialog deleteToolDialog = dialogInterface.getConfirmationDialog(v.getContext(), v.getContext().getString(R.string.delete_tool), confirmationText, v.getContext().getString(R.string.delete)); Button confirmToolDeletionButton = (Button) deleteToolDialog .findViewById(R.id.dialog_bottom_confirm_bottom); confirmToolDeletionButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { View parentView = (View) ((editButton.getParent()).getParent()); ((LinearLayout) parentView).removeView(((View) (editButton.getParent()))); Toast.makeText(v.getContext(), v.getContext().getString(R.string.tool_deleted), Toast.LENGTH_LONG).show(); user.getToolLog().removeTool(toolEntry.getSetupDate(), toolEntry.getToolLogId()); user.writeToSharedPref(v.getContext()); deleteToolDialog.dismiss(); dialog.dismiss(); } }); deleteToolDialog.show(); } }; View.OnClickListener archiveToolOnClickListener = new OnClickListener() { @Override public void onClick(View v) { String confirmationText; switch (toolEntry.getToolStatus()) { case STATUS_RECEIVED: confirmationText = v.getContext().getString(R.string.confirm_registered_tool_archiving); break; case STATUS_UNSENT: if (!toolEntry.getId().isEmpty()) { confirmationText = v.getContext().getString(R.string.confirm_tool_archiving_text); } else { confirmationText = v.getContext().getString( R.string.confirm_registered_tool_with_local_changes_archiving_text); } break; default: confirmationText = v.getContext() .getString(R.string.confirm_tool_archiving_text_general); break; } final Dialog archiveDialog = dialogInterface.getConfirmationDialog(v.getContext(), v.getContext().getString(R.string.archive_tool), confirmationText, v.getContext().getString(R.string.archive)); Button confirmToolArchiveButton = (Button) archiveDialog .findViewById(R.id.dialog_bottom_confirm_bottom); confirmToolArchiveButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { View parentView = (View) ((editButton.getParent()).getParent()).getParent(); ((LinearLayout) parentView) .removeView(((View) (editButton.getParent()).getParent())); Toast.makeText(v.getContext(), v.getContext().getString(R.string.tool_archived), Toast.LENGTH_LONG).show(); toolEntry.setToolStatus(ToolEntryStatus.STATUS_REMOVED); user.writeToSharedPref(v.getContext()); archiveDialog.dismiss(); dialog.dismiss(); } }); archiveDialog.show(); } }; ActionRow archiveRow = new ActionRow(editButton.getContext(), editButton.getContext().getString(R.string.archive_tool), R.drawable.ic_archive_black_24dp, archiveToolOnClickListener); ActionRow deleteRow = new ActionRow(editButton.getContext(), editButton.getContext().getString(R.string.delete_tool), R.drawable.ic_delete_black_24dp, deleteButtonRowOnClickListener); commentRow.setInputType(InputType.TYPE_CLASS_TEXT); commentRow.setHelpText(editButton.getContext().getString(R.string.comment_help_description)); vesselNameRow.setInputType(InputType.TYPE_CLASS_TEXT); contactPersonPhoneRow .setHelpText(editButton.getContext().getString(R.string.vessel_name_help_description)); vesselPhoneNumberRow.setInputType(InputType.TYPE_CLASS_PHONE); vesselIrcsNumberRow.setInputType(InputType.TYPE_CLASS_TEXT); vesselIrcsNumberRow.setInputFilters(new InputFilter[] { new InputFilter.LengthFilter( editButton.getContext().getResources().getInteger(R.integer.input_length_ircs)), new InputFilter.AllCaps() }); vesselIrcsNumberRow.setHelpText(editButton.getContext().getString(R.string.ircs_help_description)); vesselMmsiNumberRow.setInputType(InputType.TYPE_CLASS_NUMBER); vesselMmsiNumberRow.setInputFilters(new InputFilter[] { new InputFilter.LengthFilter( editButton.getContext().getResources().getInteger(R.integer.input_length_mmsi)) }); vesselMmsiNumberRow.setHelpText(editButton.getContext().getString(R.string.mmsi_help_description)); vesselImoNumberRow.setInputType(InputType.TYPE_CLASS_NUMBER); vesselImoNumberRow.setInputFilters(new InputFilter[] { new InputFilter.LengthFilter( editButton.getContext().getResources().getInteger(R.integer.input_length_imo)) }); vesselImoNumberRow.setHelpText(editButton.getContext().getString(R.string.imo_help_description)); vesselRegistrationNumberRow.setInputType(InputType.TYPE_CLASS_TEXT); vesselRegistrationNumberRow.setInputFilters(new InputFilter[] { new InputFilter.LengthFilter(editButton.getContext().getResources() .getInteger(R.integer.input_length_registration_number)), new InputFilter.AllCaps() }); vesselRegistrationNumberRow.setHelpText( editButton.getContext().getString(R.string.registration_number_help_description)); contactPersonNameRow.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME); contactPersonPhoneRow.setInputType(InputType.TYPE_CLASS_PHONE); contactPersonEmailRow.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); contactPersonNameRow.setHelpText( editButton.getContext().getString(R.string.contact_person_name_help_description)); contactPersonPhoneRow.setHelpText( editButton.getContext().getString(R.string.contact_person_phone_help_description)); contactPersonEmailRow.setHelpText( editButton.getContext().getString(R.string.contact_person_email_help_description)); coordinatesRow.setCoordinates(activity, toolEntry.getCoordinates()); setupDateRow.setEnabled(false); /* Should these fields be editable after tools are reported? */ // vesselRegistrationNumberRow.setEnabled(toolEntry.getToolStatus() == ToolEntryStatus.STATUS_UNREPORTED); // vesselImoNumberRow.setEnabled(toolEntry.getToolStatus() == ToolEntryStatus.STATUS_UNREPORTED); // vesselMmsiNumberRow.setEnabled(toolEntry.getToolStatus() == ToolEntryStatus.STATUS_UNREPORTED); // vesselNameRow.setEnabled(toolEntry.getToolStatus() == ToolEntryStatus.STATUS_UNREPORTED); // vesselIrcsNumberRow.setEnabled(toolEntry.getToolStatus() == ToolEntryStatus.STATUS_UNREPORTED); ArrayAdapter<String> currentAdapter = toolRow.getAdapter(); toolRow.setSelectedSpinnerItem(currentAdapter.getPosition(toolEntry.getToolType().toString())); toolRemovedRow.setChecked(!toolEntry.getRemovedTime().isEmpty()); commentRow.setText(toolEntry.getComment()); contactPersonNameRow.setText(toolEntry.getContactPersonName()); contactPersonPhoneRow .setText(!toolEntry.getContactPersonPhone().equals("") ? toolEntry.getContactPersonPhone() : toolEntry.getVesselPhone()); contactPersonEmailRow .setText(!toolEntry.getContactPersonEmail().equals("") ? toolEntry.getContactPersonEmail() : toolEntry.getVesselEmail()); vesselNameRow.setText(toolEntry.getVesselName()); vesselPhoneNumberRow.setText(toolEntry.getVesselPhone()); vesselIrcsNumberRow.setText(toolEntry.getIRCS()); vesselMmsiNumberRow.setText(toolEntry.getMMSI()); vesselImoNumberRow.setText(toolEntry.getIMO()); vesselRegistrationNumberRow.setText(toolEntry.getRegNum()); sdf.setTimeZone(TimeZone.getTimeZone("UTC")); Date setupDate = null; String toolSetupDateTime; try { setupDate = sdf.parse(toolEntry.getSetupDateTime()); } catch (ParseException e) { e.printStackTrace(); } sdfMilliSeconds.setTimeZone(TimeZone.getDefault()); toolSetupDateTime = sdfMilliSeconds.format(setupDate); setupDateRow.setDate(toolSetupDateTime.substring(0, 10)); setupTimeRow.setTime(toolSetupDateTime.substring(toolEntry.getSetupDateTime().indexOf('T') + 1, toolEntry.getSetupDateTime().indexOf('T') + 6)); fieldContainer.addView(coordinatesRow.getView()); fieldContainer.addView(setupDateRow.getView()); fieldContainer.addView(setupTimeRow.getView()); fieldContainer.addView(toolRow.getView()); fieldContainer.addView(toolRemovedRow.getView()); fieldContainer.addView(commentRow.getView()); fieldContainer.addView(contactPersonNameRow.getView()); fieldContainer.addView(contactPersonPhoneRow.getView()); fieldContainer.addView(contactPersonEmailRow.getView()); fieldContainer.addView(vesselNameRow.getView()); fieldContainer.addView(vesselPhoneNumberRow.getView()); fieldContainer.addView(vesselIrcsNumberRow.getView()); fieldContainer.addView(vesselMmsiNumberRow.getView()); fieldContainer.addView(vesselImoNumberRow.getView()); fieldContainer.addView(vesselRegistrationNumberRow.getView()); fieldContainer.addView(errorRow.getView()); if (toolEntry.getToolStatus() != ToolEntryStatus.STATUS_UNREPORTED) { fieldContainer.addView(archiveRow.getView()); } fieldContainer.addView(deleteRow.getView()); updateButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View updateButton) { List<Point> coordinates = coordinatesRow.getCoordinates(); ToolType toolType = ToolType.createFromValue(toolRow.getCurrentSpinnerItem()); boolean toolRemoved = toolRemovedRow.isChecked(); String vesselName = vesselNameRow.getFieldText(); String vesselPhoneNumber = vesselPhoneNumberRow.getFieldText(); String toolSetupDate = setupDateRow.getDate(); String toolSetupTime = setupTimeRow.getTime(); String toolSetupDateTime; String commentString = commentRow.getFieldText(); String vesselIrcsNumber = vesselIrcsNumberRow.getFieldText(); String vesselMmsiNumber = vesselMmsiNumberRow.getFieldText(); String vesselImoNumber = vesselImoNumberRow.getFieldText(); String registrationNumber = vesselRegistrationNumberRow.getFieldText(); String contactPersonName = contactPersonNameRow.getFieldText(); String contactPersonPhone = contactPersonPhoneRow.getFieldText(); String contactPersonEmail = contactPersonEmailRow.getFieldText(); FiskInfoUtility utility = new FiskInfoUtility(); boolean validated; boolean edited = false; boolean ircsValidated; boolean mmsiValidated; boolean imoValidated; boolean regNumValidated; boolean minimumIdentificationFactorsMet; validated = coordinates != null; if (!validated) { return; } validated = utility.validateName(contactPersonNameRow.getFieldText().trim()); contactPersonNameRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_name)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, contactPersonNameRow.getView().getBottom()); contactPersonNameRow.requestFocus(); } }); return; } validated = utility.validatePhoneNumber(contactPersonPhoneRow.getFieldText().trim()); contactPersonPhoneRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_phone_number)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, contactPersonPhoneRow.getView().getBottom()); contactPersonPhoneRow.requestFocus(); } }); return; } validated = utility.isEmailValid(contactPersonEmailRow.getFieldText().trim()); contactPersonEmailRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_email)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, contactPersonEmailRow.getView().getBottom()); contactPersonEmailRow.requestFocus(); } }); return; } validated = vesselNameRow.getFieldText().trim() != null && !vesselNameRow.getFieldText().isEmpty(); vesselNameRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_vessel_name)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, vesselNameRow.getView().getBottom()); vesselNameRow.requestFocus(); } }); return; } validated = vesselPhoneNumberRow.getFieldText().trim() != null && !vesselPhoneNumberRow.getFieldText().isEmpty(); vesselPhoneNumberRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_phone_number)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, vesselPhoneNumberRow.getView().getBottom()); vesselPhoneNumberRow.requestFocus(); } }); return; } validated = (ircsValidated = utility.validateIRCS(vesselIrcsNumber)) || vesselIrcsNumber.isEmpty(); vesselIrcsNumberRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_ircs)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, vesselIrcsNumberRow.getView().getBottom()); vesselIrcsNumberRow.requestFocus(); } }); return; } validated = (mmsiValidated = utility.validateMMSI(vesselMmsiNumber)) || vesselMmsiNumber.isEmpty(); vesselMmsiNumberRow.setError(validated ? null : updateButton.getContext().getString(R.string.error_invalid_mmsi)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, vesselMmsiNumberRow.getView().getBottom()); vesselMmsiNumberRow.requestFocus(); } }); return; } validated = (imoValidated = utility.validateIMO(vesselImoNumber)) || vesselImoNumber.isEmpty(); vesselImoNumberRow.setError( validated ? null : updateButton.getContext().getString(R.string.error_invalid_imo)); if (!validated) { ((ScrollView) fieldContainer.getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent()).scrollTo(0, vesselImoNumberRow.getView().getBottom()); vesselImoNumberRow.requestFocus(); } }); return; } validated = (regNumValidated = utility.validateRegistrationNumber(registrationNumber)) || registrationNumber.isEmpty(); vesselRegistrationNumberRow.setError(validated ? null : editButton.getContext().getString(R.string.error_invalid_registration_number)); if (!validated) { ((ScrollView) fieldContainer.getParent().getParent()).post(new Runnable() { @Override public void run() { ((ScrollView) fieldContainer.getParent().getParent()).scrollTo(0, vesselRegistrationNumberRow.getView().getBottom()); vesselRegistrationNumberRow.requestFocus(); } }); return; } sdf.setTimeZone(TimeZone.getDefault()); Date setupDate = null; String setupDateString = toolSetupDate + "T" + toolSetupTime + ":00Z"; try { setupDate = sdf.parse(setupDateString); } catch (ParseException e) { e.printStackTrace(); } sdfMilliSeconds.setTimeZone(TimeZone.getTimeZone("UTC")); setupDateString = sdfMilliSeconds.format(setupDate); toolSetupDateTime = setupDateString.substring(0, setupDateString.indexOf('.')).concat("Z"); minimumIdentificationFactorsMet = !vesselName.isEmpty() && (ircsValidated || mmsiValidated || imoValidated || regNumValidated); if ((coordinates != null && coordinates.size() != toolEntry.getCoordinates().size()) || toolType != toolEntry.getToolType() || (toolRemoved) == (toolEntry.getRemovedTime().isEmpty()) || (vesselName != null && !vesselName.equals(toolEntry.getVesselName())) || (vesselPhoneNumber != null && !vesselPhoneNumber.equals(toolEntry.getVesselPhone())) || (toolSetupDateTime != null && !toolSetupDateTime.equals(toolEntry.getSetupDateTime())) || (vesselIrcsNumber != null && !vesselIrcsNumber.equals(toolEntry.getIRCS())) || (vesselMmsiNumber != null && !vesselMmsiNumber.equals(toolEntry.getMMSI())) || (vesselImoNumber != null && !vesselImoNumber.equals(toolEntry.getIMO())) || (registrationNumber != null && !registrationNumber.equals(toolEntry.getRegNum())) || (contactPersonName != null && !contactPersonName.equals(toolEntry.getContactPersonName())) || (contactPersonPhone != null && !contactPersonPhone.equals(toolEntry.getContactPersonPhone())) || (contactPersonEmail != null && !contactPersonEmail.equals(toolEntry.getContactPersonEmail())) || (commentString != null && !commentString.equals(toolEntry.getComment()))) { edited = true; } else { List<Point> points = toolEntry.getCoordinates(); for (int i = 0; i < coordinates.size(); i++) { if (coordinates.get(i).getLatitude() != points.get(i).getLatitude() || coordinates.get(i).getLongitude() != points.get(i).getLongitude()) { edited = true; break; } } } if (edited) { if (!minimumIdentificationFactorsMet) { errorRow.setVisibility(!minimumIdentificationFactorsMet); return; } Date lastChangedDate = new Date(); Date previousSetupDate = null; SimpleDateFormat sdfSetupCompare = new SimpleDateFormat("yyyyMMdd", Locale.getDefault()); String lastChangedDateString = sdfMilliSeconds.format(lastChangedDate).concat("Z"); sdfSetupCompare.setTimeZone(TimeZone.getTimeZone("UTC")); try { previousSetupDate = sdf.parse(toolEntry.getSetupDateTime() .substring(0, toolEntry.getSetupDateTime().length() - 1).concat(".000")); } catch (ParseException e) { e.printStackTrace(); } if (!sdfSetupCompare.format(previousSetupDate) .equals(sdfSetupCompare.format(setupDate))) { // TODO: setup date is changed, tool needs to be moved in log so the app does not crash when trying to delete tool. // user.getToolLog().removeTool(toolEntry.getSetupDate(), toolEntry.getToolLogId()); // user.getToolLog().addTool(toolEntry, toolEntry.getSetupDateTime().substring(0, 10)); // user.writeToSharedPref(editButton.getContext()); } ToolEntryStatus toolStatus = (toolRemoved ? ToolEntryStatus.STATUS_REMOVED_UNCONFIRMED : (toolEntry.getToolStatus() == ToolEntryStatus.STATUS_UNREPORTED ? ToolEntryStatus.STATUS_UNREPORTED : ToolEntryStatus.STATUS_UNSENT)); toolEntry.setToolStatus(toolStatus); toolEntry.setCoordinates(coordinates); toolEntry.setToolType(toolType); toolEntry.setVesselName(vesselName); toolEntry.setVesselPhone(vesselPhoneNumber); toolEntry.setSetupDateTime(toolSetupDateTime); toolEntry.setRemovedTime(toolRemoved ? lastChangedDateString : null); toolEntry.setComment(commentString); toolEntry.setIRCS(vesselIrcsNumber); toolEntry.setMMSI(vesselMmsiNumber); toolEntry.setIMO(vesselImoNumber); toolEntry.setRegNum(registrationNumber); toolEntry.setLastChangedDateTime(lastChangedDateString); toolEntry.setLastChangedBySource(lastChangedDateString); toolEntry.setContactPersonName(contactPersonName); toolEntry.setContactPersonPhone(contactPersonPhone); toolEntry.setContactPersonEmail(contactPersonEmail); try { ImageView notificationView = (ImageView) ((View) editButton.getParent()) .findViewById(R.id.tool_log_row_reported_image_view); if (notificationView != null) { notificationView.setVisibility(View.VISIBLE); notificationView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Toast.makeText(v.getContext(), R.string.notification_tool_unreported_changes, Toast.LENGTH_LONG).show(); } }); } TextView dateTimeTextView = (TextView) ((View) editButton.getParent()) .findViewById(R.id.tool_log_row_latest_date_text_view); TextView toolTypeTextView = (TextView) ((View) editButton.getParent()) .findViewById(R.id.tool_log_row_tool_type_text_view); TextView positionTextView = (TextView) ((View) editButton.getParent()) .findViewById(R.id.tool_log_row_tool_position_text_view); StringBuilder sb = new StringBuilder(); sb.append(FiskInfoUtility .decimalToDMS((toolEntry.getCoordinates().get(0).getLatitude()))); sb.append(", "); sb.append(FiskInfoUtility .decimalToDMS((toolEntry.getCoordinates().get(0).getLongitude()))); String coordinateString = sb.toString(); coordinateString = toolEntry.getCoordinates().size() < 2 ? coordinateString : coordinateString + "\n.."; sdfMilliSeconds.setTimeZone(TimeZone.getTimeZone("GMT+1")); setupDateString = sdfMilliSeconds.format(setupDate); dateTimeTextView.setText(setupDateString.substring(0, 16).replace("T", " ")); toolTypeTextView.setText(toolEntry.getToolType().toString()); positionTextView.setText(coordinateString); Date toolDate; Date currentDate = new Date(); try { toolDate = sdf.parse(toolEntry.getSetupDateTime() .substring(0, toolEntry.getSetupDateTime().length() - 1) .concat(".000")); long diff = currentDate.getTime() - toolDate.getTime(); double days = diff / updateButton.getContext().getResources() .getInteger(R.integer.milliseconds_in_a_day); if (days > 14) { dateTimeTextView.setTextColor(ContextCompat .getColor(updateButton.getContext(), (R.color.error_red))); } else { dateTimeTextView.setTextColor(toolTypeTextView.getCurrentTextColor()); } } catch (ParseException e) { e.printStackTrace(); return; } } catch (ClassCastException e) { e.printStackTrace(); } user.writeToSharedPref(updateButton.getContext()); } else { Toast.makeText(editButton.getContext(), R.string.no_changes_made, Toast.LENGTH_LONG) .show(); } dialog.dismiss(); } }); cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); } }; }
From source file:com.android.contacts.list.MultiSelectContactsListFragment.java
/** * Show account icon, count of contacts and account name in the header of the list. */// w ww . j a v a2s . c o m protected void bindListHeader(Context context, View listView, View accountFilterContainer, AccountWithDataSet accountWithDataSet, int memberCount) { if (memberCount < 0) { hideHeaderAndAddPadding(context, listView, accountFilterContainer); return; } bindListHeaderCommon(listView, accountFilterContainer); final AccountTypeManager accountTypeManager = AccountTypeManager.getInstance(context); final AccountType accountType = accountTypeManager.getAccountType(accountWithDataSet.type, accountWithDataSet.dataSet); // Set text of count of contacts and account name final TextView accountFilterHeader = (TextView) accountFilterContainer .findViewById(R.id.account_filter_header); final String headerText = shouldShowAccountName(accountType) ? String.format(context.getResources().getQuantityString(R.plurals.contacts_count_with_account, memberCount), memberCount, accountWithDataSet.name) : context.getResources().getQuantityString(R.plurals.contacts_count, memberCount, memberCount); accountFilterHeader.setText(headerText); accountFilterHeader.setAllCaps(false); // Set icon of the account final Drawable icon = accountType != null ? accountType.getDisplayIcon(context) : null; final ImageView accountFilterHeaderIcon = (ImageView) accountFilterContainer .findViewById(R.id.account_filter_icon); // If it's a writable Google account, we set icon size as 24dp; otherwise, we set it as // 20dp. And we need to change margin accordingly. This is because the Google icon looks // smaller when the icons are of the same size. if (accountType instanceof GoogleAccountType) { accountFilterHeaderIcon.getLayoutParams().height = getResources() .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_size); accountFilterHeaderIcon.getLayoutParams().width = getResources() .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_size); setMargins(accountFilterHeaderIcon, getResources().getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_left_margin), getResources().getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_right_margin)); } else { accountFilterHeaderIcon.getLayoutParams().height = getResources() .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_size_alt); accountFilterHeaderIcon.getLayoutParams().width = getResources() .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_size_alt); setMargins(accountFilterHeaderIcon, getResources() .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_left_margin_alt), getResources() .getDimensionPixelOffset(R.dimen.contact_browser_list_header_icon_right_margin_alt)); } accountFilterHeaderIcon.requestLayout(); accountFilterHeaderIcon.setVisibility(View.VISIBLE); accountFilterHeaderIcon.setImageDrawable(icon); }
From source file:co.taqat.call.LinphoneActivity.java
private void displayMainAccount() { defaultAccount.setVisibility(View.VISIBLE); ImageView status = (ImageView) defaultAccount.findViewById(R.id.main_account_status); TextView address = (TextView) defaultAccount.findViewById(R.id.main_account_address); TextView displayName = (TextView) defaultAccount.findViewById(R.id.main_account_display_name); LinphoneProxyConfig proxy = LinphoneManager.getLc().getDefaultProxyConfig(); if (proxy == null) { displayName.setText(getString(R.string.no_account)); status.setVisibility(View.GONE); address.setText(""); statusFragment.resetAccountStatus(); LinphoneManager.getInstance().subscribeFriendList(false); defaultAccount.setOnClickListener(new OnClickListener() { @Override/*from w ww .j a v a2 s . co m*/ public void onClick(View view) { LinphoneActivity.instance().displayAccountSettings(0); openOrCloseSideMenu(false); } }); } else { //address.setText(proxy.getAddress().asStringUriOnly()); displayName.setText(LinphoneUtils.getAddressDisplayName(proxy.getAddress())); status.setImageResource(getStatusIconResource(proxy.getState())); status.setVisibility(View.VISIBLE); defaultAccount.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { LinphoneActivity.instance() .displayAccountSettings(LinphonePreferences.instance().getDefaultAccountIndex()); openOrCloseSideMenu(false); } }); } }
From source file:com.liberorignanese.android.stepindicatorview.Step.java
public void setUpView(View stepView, Step previous, Step next, int orientation, boolean useSecondaryStepColor) { ImageView iconView = (ImageView) stepView.findViewById(R.id.icon_step_layout); ImageView lineStartView = (ImageView) stepView.findViewById(R.id.linestart_step_layout); ImageView lineEndView = (ImageView) stepView.findViewById(R.id.lineend_step_layout); TextView textView = (TextView) stepView.findViewById(R.id.text_step_layout); int line_completed = orientation == LinearLayout.HORIZONTAL ? (useSecondaryStepColor ? R.drawable.line_completed_horizontal_secondary : R.drawable.line_completed_horizontal) : (useSecondaryStepColor ? R.drawable.line_completed_vertical_secondary : R.drawable.line_completed_vertical); int line_uncompleted = orientation == LinearLayout.HORIZONTAL ? (useSecondaryStepColor ? R.drawable.line_uncompleted_horizontal_secondary : R.drawable.line_uncompleted_horizontal) : (useSecondaryStepColor ? R.drawable.line_uncompleted_vertical_secondary : R.drawable.line_uncompleted_vertical); int icon_completed = useSecondaryStepColor ? R.drawable.icon_check_secondary : R.drawable.icon_check; int icon_uncompleted = useSecondaryStepColor ? R.drawable.icon_circle_secondary : R.drawable.icon_circle; int icon_completed_current = useSecondaryStepColor ? R.drawable.icon_check_secondary_current : R.drawable.icon_check_current; int step_backgroundcolor = Color.TRANSPARENT; int step_textcolor = useSecondaryStepColor ? R.color.stepviewindicator_maincolor_secondary : R.color.stepviewindicator_maincolor; int step_iscurrent_backgroundcolor = useSecondaryStepColor ? R.color.stepviewindicator_maincolor_secondary : R.color.stepviewindicator_maincolor; int step_iscurrent_textcolor = useSecondaryStepColor ? R.color.stepviewindicator_checkcolor_secondary : R.color.stepviewindicator_checkcolor; /*// w w w . j a v a 2 s .c o m if(useSecondaryStepColor){ } */ if (previous == null) { lineStartView.setVisibility(View.INVISIBLE); } else { lineStartView.setVisibility(View.VISIBLE); if (previous.isCompleted()) { lineStartView.setImageResource(line_completed); lineStartView.setImageAlpha(255); } else { lineStartView.setImageResource(line_uncompleted); lineStartView.setImageAlpha(alpha); } } if (next == null) { lineEndView.setVisibility(View.INVISIBLE); } else { lineEndView.setVisibility(View.VISIBLE); if (isCompleted()) { lineEndView.setImageResource(line_completed); lineEndView.setImageAlpha(255); } else { lineEndView.setImageResource(line_uncompleted); lineEndView.setImageAlpha(alpha); } } textView.setText(getText()); if (isCompleted()) { iconView.setImageResource(current ? icon_completed_current : icon_completed); iconView.setImageAlpha(255); } else { iconView.setImageResource(icon_uncompleted); if (isCurrent()) { iconView.setImageAlpha(255); } else { iconView.setImageAlpha(alpha); } } if (isCurrent()) { textView.setTypeface(null, Typeface.BOLD); textView.setTextColor(ContextCompat.getColor(stepView.getContext(), step_iscurrent_textcolor)); textView.setBackgroundColor( ContextCompat.getColor(stepView.getContext(), step_iscurrent_backgroundcolor)); } else { textView.setTypeface(null, Typeface.NORMAL); textView.setTextColor(ContextCompat.getColor(stepView.getContext(), step_textcolor)); textView.setBackgroundColor(step_backgroundcolor); } /* if(useSecondaryStepColor){ textView.setTextColor(ContextCompat.getColor(stepView.getContext(), R.color.stepviewindicator_maincolor_secondary)); }else{ textView.setTextColor(ContextCompat.getColor(stepView.getContext(), R.color.stepviewindicator_maincolor)); } */ stepView.setOnClickListener(onClickListener); }