List of usage examples for android.widget ImageView setImageResource
@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync") public void setImageResource(@DrawableRes int resId)
From source file:eu.operando.proxy.wifi.AccessPointsDetail.java
public void setView(@NonNull Resources resources, @NonNull View view, @NonNull final WiFiDetail wiFiDetail) { TextView ssidLabel = (TextView) view.findViewById(R.id.ssid); ssidLabel.setText(wiFiDetail.getTitle()); TextView textLinkSpeed = (TextView) view.findViewById(R.id.linkSpeed); String ipAddress = wiFiDetail.getWiFiAdditional().getIPAddress(); boolean isConnected = StringUtils.isNotBlank(ipAddress); if (!isConnected) { textLinkSpeed.setVisibility(View.GONE); ssidLabel.setTextColor(resources.getColor(android.R.color.white)); } else {//from www . j a v a 2 s .c o m ssidLabel.setTextColor(resources.getColor(R.color.connected)); int linkSpeed = wiFiDetail.getWiFiAdditional().getLinkSpeed(); if (linkSpeed == WiFiConnection.LINK_SPEED_INVALID) { textLinkSpeed.setVisibility(View.GONE); } else { textLinkSpeed.setVisibility(View.VISIBLE); textLinkSpeed.setText(String.format("%d%s", linkSpeed, WifiInfo.LINK_SPEED_UNITS)); } } WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); Strength strength = wiFiSignal.getStrength(); ImageView imageView = (ImageView) view.findViewById(R.id.levelImage); imageView.setImageResource(strength.imageResource()); imageView.setColorFilter(resources.getColor(strength.colorResource())); Security security = wiFiDetail.getSecurity(); ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage); securityImage.setImageResource(security.imageResource()); securityImage.setColorFilter(resources.getColor(R.color.icons_color)); TextView textLevel = (TextView) view.findViewById(R.id.level); textLevel.setText(String.format("%ddBm", wiFiSignal.getLevel())); textLevel.setTextColor(resources.getColor(strength.colorResource())); ((TextView) view.findViewById(R.id.channel)) .setText(String.format("%d", wiFiSignal.getWiFiChannel().getChannel())); ((TextView) view.findViewById(R.id.frequency)) .setText(String.format("%d%s", wiFiSignal.getFrequency(), WifiInfo.FREQUENCY_UNITS)); ((TextView) view.findViewById(R.id.distance)).setText(String.format("%.1fm", wiFiSignal.getDistance())); ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities()); LayoutInflater layoutInflater = mainContext.getLayoutInflater(); final WiFiApConfig wiFiApConfig = wiFiDetail.getWiFiAdditional().getWiFiApConfig(); ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage); if (wiFiApConfig != null) { configuredImage.setVisibility(View.VISIBLE); if (isOperandoCompatible(wiFiApConfig)) { configuredImage.setColorFilter(resources.getColor(android.R.color.holo_green_light)); view.setOnClickListener( new ConfiguredClickListener(context, wiFiDetail, wiFiApConfig, isConnected)); } else { configuredImage.setColorFilter(resources.getColor(android.R.color.holo_red_light)); view.setOnClickListener(new ForgetClickListener(context, wiFiDetail)); } } else { configuredImage.setVisibility(View.GONE); view.setOnClickListener(new ConnectClickListener(context, wiFiDetail, layoutInflater)); } }
From source file:eu.operando.operandoapp.wifi.AccessPointsDetail.java
public void setView(@NonNull Resources resources, @NonNull View view, @NonNull final WiFiDetail wiFiDetail) { TextView ssidLabel = (TextView) view.findViewById(R.id.ssid); ssidLabel.setText(wiFiDetail.getTitle()); TextView textLinkSpeed = (TextView) view.findViewById(R.id.linkSpeed); textLinkSpeed.setTextColor(Color.BLACK); String ipAddress = wiFiDetail.getWiFiAdditional().getIPAddress(); boolean isConnected = StringUtils.isNotBlank(ipAddress); if (!isConnected) { textLinkSpeed.setVisibility(View.GONE); ssidLabel.setTextColor(resources.getColor(android.R.color.black)); } else {//from w w w .j ava 2 s .c o m ssidLabel.setTextColor(resources.getColor(R.color.connected)); int linkSpeed = wiFiDetail.getWiFiAdditional().getLinkSpeed(); if (linkSpeed == WiFiConnection.LINK_SPEED_INVALID) { textLinkSpeed.setVisibility(View.GONE); } else { textLinkSpeed.setVisibility(View.VISIBLE); textLinkSpeed.setText(String.format("%d%s", linkSpeed, WifiInfo.LINK_SPEED_UNITS)); } } WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); Strength strength = wiFiSignal.getStrength(); ImageView imageView = (ImageView) view.findViewById(R.id.levelImage); imageView.setImageResource(strength.imageResource()); imageView.setColorFilter(resources.getColor(strength.colorResource())); Security security = wiFiDetail.getSecurity(); ImageView securityImage = (ImageView) view.findViewById(R.id.securityImage); securityImage.setImageResource(security.imageResource()); securityImage.setColorFilter(resources.getColor(R.color.icons_color)); TextView textLevel = (TextView) view.findViewById(R.id.level); textLevel.setText(String.format("%ddBm", wiFiSignal.getLevel())); textLevel.setTextColor(Color.BLACK); //textLevel.setTextColor(resources.getColor(strength.colorResource())); ((TextView) view.findViewById(R.id.channel)) .setText(String.format("%d", wiFiSignal.getWiFiChannel().getChannel())); ((TextView) view.findViewById(R.id.frequency)) .setText(String.format("%d%s", wiFiSignal.getFrequency(), WifiInfo.FREQUENCY_UNITS)); ((TextView) view.findViewById(R.id.distance)).setText(String.format("%.1fm", wiFiSignal.getDistance())); ((TextView) view.findViewById(R.id.capabilities)).setText(wiFiDetail.getCapabilities()); LayoutInflater layoutInflater = mainContext.getLayoutInflater(); final WiFiApConfig wiFiApConfig = wiFiDetail.getWiFiAdditional().getWiFiApConfig(); ImageView configuredImage = (ImageView) view.findViewById(R.id.configuredImage); if (wiFiApConfig != null) { configuredImage.setVisibility(View.VISIBLE); if (isOperandoCompatible(wiFiApConfig)) { configuredImage.setColorFilter(resources.getColor(android.R.color.holo_green_light)); view.setOnClickListener( new ConfiguredClickListener(context, wiFiDetail, wiFiApConfig, isConnected)); } else { configuredImage.setColorFilter(resources.getColor(android.R.color.holo_red_light)); view.setOnClickListener(new ForgetClickListener(context, wiFiDetail)); } } else { configuredImage.setVisibility(View.GONE); view.setOnClickListener(new ConnectClickListener(context, wiFiDetail, layoutInflater)); } }
From source file:com.blackmoon.english.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initRecyclerView();/* ww w .ja v a 2 s . co m*/ initToolbar(); setupDrawerLayout(); content = findViewById(R.id.content); final ImageView avatar = (ImageView) findViewById(R.id.avatar); avatar.setScaleType(ImageView.ScaleType.CENTER_CROP); avatar.setImageResource(R.drawable.listening_english); }
From source file:kr.co.generic.wifianalyzer.wifi.AccessPointDetail.java
private void setViewExtra(@NonNull Context context, @NonNull View view, @NonNull WiFiDetail wiFiDetail) { ImageView configuredImage = (ImageView) view.findViewById(kr.co.generic.wifianalyzer.R.id.configuredImage); WiFiAdditional wiFiAdditional = wiFiDetail.getWiFiAdditional(); if (wiFiAdditional.isConfiguredNetwork()) { configuredImage.setVisibility(View.VISIBLE); configuredImage//w w w . j a v a2 s . c o m .setColorFilter(ContextCompat.getColor(context, kr.co.generic.wifianalyzer.R.color.connected)); } else { configuredImage.setVisibility(View.GONE); } WiFiSignal wiFiSignal = wiFiDetail.getWiFiSignal(); Strength strength = wiFiSignal.getStrength(); ImageView imageView = (ImageView) view.findViewById(kr.co.generic.wifianalyzer.R.id.levelImage); imageView.setImageResource(strength.imageResource()); imageView.setColorFilter(ContextCompat.getColor(context, strength.colorResource())); ((TextView) view.findViewById(kr.co.generic.wifianalyzer.R.id.channel_frequency_range)) .setText(wiFiSignal.getFrequencyStart() + " - " + wiFiSignal.getFrequencyEnd()); ((TextView) view.findViewById(kr.co.generic.wifianalyzer.R.id.width)) .setText("(" + wiFiSignal.getWiFiWidth().getFrequencyWidth() + WiFiSignal.FREQUENCY_UNITS + ")"); ((TextView) view.findViewById(kr.co.generic.wifianalyzer.R.id.capabilities)) .setText(wiFiDetail.getCapabilities()); }
From source file:android.hqs.view.pager.indicator.IconPageIndicator.java
public void notifyDataSetChanged() { mIconsLayout.removeAllViews();/*from www. j a v a 2s .c o m*/ IconPagerAdapter iconAdapter = (IconPagerAdapter) mViewPager.getAdapter(); int count = iconAdapter.getCount(); for (int i = 0; i < count; i++) { ImageView view = new ImageView(getContext(), null, R.attr.vpiIconPageIndicatorStyle); view.setImageResource(iconAdapter.getIconResId(i)); mIconsLayout.addView(view); } if (mSelectedIndex > count) { mSelectedIndex = count - 1; } setCurrentItem(mSelectedIndex); requestLayout(); }
From source file:com.maedi.user.godok.v1.viewpagerindicator.IconPageIndicator.java
public void notifyDataSetChanged() { mIconsLayout.removeAllViews();//from w ww .jav a 2s .c o m com.viewpagerindicator.IconPagerAdapter iconAdapter = (IconPagerAdapter) mViewPager.getAdapter(); int count = iconAdapter.getCount(); for (int i = 0; i < count; i++) { ImageView view = new ImageView(getContext(), null, R.attr.vpiIconPageIndicatorStyle); view.setImageResource(iconAdapter.getIconResId(i)); mIconsLayout.addView(view); } if (mSelectedIndex > count) { mSelectedIndex = count - 1; } setCurrentItem(mSelectedIndex); requestLayout(); }
From source file:com.app.laundry.tabs.lib.IconPageIndicator2.java
public void notifyDataSetChanged() { mIconsLayout.removeAllViews();/* w ww .j a v a 2 s .c o m*/ IconPagerAdapter2 iconAdapter = (IconPagerAdapter2) mViewPager.getAdapter(); int count = iconAdapter.getCount(); for (int i = 0; i < count; i++) { ImageView view = new ImageView(getContext(), null, R.attr.vpiIconPageIndicatorStyle); view.setImageResource(iconAdapter.getIconResId(i)); mIconsLayout.addView(view); } if (mSelectedIndex > count) { mSelectedIndex = count - 1; } setCurrentItem(mSelectedIndex); requestLayout(); }
From source file:com.android.browser.GearsPermissionsDialog.java
public void setupDialog(TextView message, ImageView icon) { if (mDialogType.equalsIgnoreCase(LOCAL_DATA_STRING)) { message.setText(R.string.query_data_prompt); icon.setImageResource(android.R.drawable.ic_popup_disk_full); } else if (mDialogType.equalsIgnoreCase(LOCATION_DATA_STRING)) { message.setText(R.string.location_prompt); icon.setImageResource(R.drawable.ic_dialog_menu_generic); }/*from w w w . jav a 2 s.c o m*/ }
From source file:com.example.face.IconPageIndicator.java
public void notifyDataSetChanged() { mIconsLayout.removeAllViews();// ww w. j a va 2 s . co m IconPagerAdapter iconAdapter = (IconPagerAdapter) mViewPager.getAdapter(); int count = iconAdapter.getCount(); for (int i = 0; i < count; i++) { ImageView view = new ImageView(getContext(), null, R.attr.vpiIconPageIndicatorStyle); view.setImageResource(iconAdapter.getIconResId(i)); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); layoutParams.setMargins(10, 0, 10, 0); mIconsLayout.addView(view, layoutParams); } if (mSelectedIndex > count) { mSelectedIndex = count - 1; } setCurrentItem(mSelectedIndex); requestLayout(); }
From source file:com.lovejoy777sarootool.rootool.preview.IconPreview.java
private static void loadFromRes(final File file, final ImageView icon) { Drawable mimeIcon = null;/*from w ww . j av a 2s .c o m*/ if (file != null && file.isDirectory()) { String[] files = file.list(); if (file.canRead() && files != null && files.length > 0) mimeIcon = mResources.getDrawable(R.drawable.type_folder); else mimeIcon = mResources.getDrawable(R.drawable.type_folder_empty); } else if (file != null && file.isFile()) { final String fileExt = FilenameUtils.getExtension(file.getName()); mimeIcon = mMimeTypeIconCache.get(fileExt); if (mimeIcon == null) { final int mimeIconId = MimeTypes.getIconForExt(fileExt); if (mimeIconId != 0) { mimeIcon = mResources.getDrawable(mimeIconId); mMimeTypeIconCache.put(fileExt, mimeIcon); } } } if (mimeIcon != null) { icon.setImageDrawable(mimeIcon); } else { // default icon icon.setImageResource(R.drawable.type_unknown); } }