List of usage examples for android.widget ImageView setImageResource
@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync") public void setImageResource(@DrawableRes int resId)
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; /*//from ww w. j a v a 2 s .c om 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); }
From source file:com.bookkos.bircle.CaptureActivity.java
private void customToast(String toast_text, int icon, boolean bool) { getLayoutInflater();//www . j av a 2s .co m LayoutInflater inflater = getLayoutInflater(); int resource = 0; if (bool == true) { resource = R.layout.success_toast; } else { resource = R.layout.failure_toast; } View layout = inflater.inflate(resource, null); ImageView image = (ImageView) layout.findViewById(R.id.image); image.setImageResource(icon); TextView text = (TextView) layout.findViewById(R.id.text); text.setText(Html.fromHtml(toast_text)); final Toast toast = new Toast(this); layout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { toast.cancel(); } }); toast.setView(layout); toast.setGravity(Gravity.CENTER, 0, 0); if (modeFlag == true) { toast.setDuration(Toast.LENGTH_SHORT); } else { toast.setDuration(Toast.LENGTH_LONG); } toast.show(); // Toast.makeText(context, toast_text, Toast.LENGTH_SHORT).show(); }
From source file:com.bofsoft.laio.laiovehiclegps.Fragment.BaiduMapFragment.java
/** * ///*from ww w . j a v a 2 s . c o m*/ */ private void showLocation(final GPSInfoData gpsInfoData) { int i = 0; if (gpsInfoData == null) { return; } //maker? if (mList != null) { for (i = 0; i < mList.size(); i++) { Marker marker = mList.get(i); if (marker.getExtraInfo().getString("License").equalsIgnoreCase(gpsInfoData.License)) { marker.setToTop(); break; } } } // // InfoWindowview // if (marker == null) { // return; // } // for (i = 0; i < mList.size(); i++) { // if (marker == mList.get(i)) { // currentMarkerNum = i; // break; // } // } // latitude = carListData.InfoList.get(currentMarkerNum).Latitude; // longitude = carListData.InfoList.get(currentMarkerNum).Longitude; // // GPSGPS?????? LatLng tmpLL = new LatLng(gpsInfoData.getLatitude(), gpsInfoData.getLongitude()); // GPSGPS?????? CoordinateConverter converter = new CoordinateConverter(); converter.from(CoordinateConverter.CoordType.GPS); converter.coord(tmpLL); final LatLng pt = converter.convert(); View view = LayoutInflater.from(getActivity()).inflate(R.layout.map_popwindow, null); // ImageView iv_close = (ImageView) view.findViewById(R.id.iv_close); TextView tv_CarLicense = (TextView) view.findViewById(R.id.tv_CarLicense); LinearLayout ll_Navigation = (LinearLayout) view.findViewById(R.id.ll_Navigation); LinearLayout ll_Track = (LinearLayout) view.findViewById(R.id.ll_Track); final ImageView iv_Track = (ImageView) view.findViewById(R.id.iv_Track); final TextView tv_Track = (TextView) view.findViewById(R.id.tv_Track); TextView tv_equipmentTime = (TextView) view.findViewById(R.id.tv_equipmentTime); TextView tv_status = (TextView) view.findViewById(R.id.tv_status); TextView tv_speed = (TextView) view.findViewById(R.id.tv_speed); TextView tv_latlong = (TextView) view.findViewById(R.id.tv_latlong); TextView tv_address = (TextView) view.findViewById(R.id.tv_address); iv_close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mBaiduMap.hideInfoWindow();//?? isPopWindowShow = false; iv_normal.setVisibility(View.VISIBLE); iv_satellite.setVisibility(View.VISIBLE); iv_traffic.setVisibility(View.VISIBLE); } }); tv_CarLicense.setText(carListData.InfoList.get(currentMarkerNum).License); ll_Navigation.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // isTrack = false; iv_Track.setImageResource(R.mipmap.popwindow_track_on); tv_Track.setText(""); GPS_Monitor(false); ll_distance.setVisibility(View.GONE); mMarkerTemp = null; routeplanToNavi(BNRoutePlanNode.CoordinateType.BD09LL); } }); if (mMarkerTemp != null && mMarkerTemp.getLicense().equalsIgnoreCase(gpsInfoData.getLicense())) { if (ll_distance.getVisibility() == View.VISIBLE) { isTrack = true; iv_Track.setImageResource(R.mipmap.popwindow_track_off); tv_Track.setText(""); } } else { if (ll_distance.getVisibility() == View.VISIBLE) { GPS_Monitor(false); ll_distance.setVisibility(View.GONE); mMarkerTemp = null; } } ll_Track.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // if (isTrack) { isTrack = false; iv_Track.setImageResource(R.mipmap.popwindow_track_on); tv_Track.setText(""); GPS_Monitor(false); ll_distance.setVisibility(View.GONE); mMarkerTemp = null; } else { isTrack = true; iv_Track.setImageResource(R.mipmap.popwindow_track_off); tv_Track.setText(""); GPS_Monitor(true); ll_distance.setVisibility(View.VISIBLE); tv_distance.setText(getDistance(curLocation, pt)); mMarkerTemp = gpsInfoData; } showLocation(gpsInfoData); } }); tv_equipmentTime.setText(carListData.InfoList.get(currentMarkerNum).Datetime); if (carListData.InfoList.get(currentMarkerNum).Status == 0) { tv_status.setText(""); } else { tv_status.setText(carListData.InfoList.get(currentMarkerNum).StatusContent); } tv_speed.setText(carListData.InfoList.get(currentMarkerNum).Speed + "km/h"); tv_latlong.setText(gpsInfoData.getLongitude() + "," + gpsInfoData.getLatitude() + " ?:" + carListData.InfoList.get(currentMarkerNum).getDirectionStr()); hasPopAddress = true; // mSearch.reverseGeoCode(new ReverseGeoCodeOption().location(pt)); if (gpsInfoData.getAddress() == null || gpsInfoData.getAddress().length() == 0) { HomeFragment.LoadAddHelper loadAddHelper = new HomeFragment.LoadAddHelper(gpsInfoData); loadAddHelper.loadReverseGeoCode(); } tv_address.setText( "? " + (carListData.InfoList.get(currentMarkerNum).getAddress() == null ? "" : carListData.InfoList.get(currentMarkerNum).getAddress())); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(pt);//.zoom(18) mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); // InfoWindow mInfoWindow = new InfoWindow(view, pt, -30); iv_normal.setVisibility(View.GONE); iv_satellite.setVisibility(View.GONE); iv_traffic.setVisibility(View.GONE); mBaiduMap.showInfoWindow(mInfoWindow); // isPopWindowShow = true; mShowMarker = gpsInfoData; }
From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java
public void setonehourglass(final ImageView iv) { int resourceint = R.drawable.hourglassicon; Bitmap resourcebm = BitmapFactory.decodeResource(getResources(), resourceint); iv.setImageResource(resourceint); iv.setClickable(false);/* www .j a v a 2s . co m*/ iv.addOnLayoutChangeListener(hourglasslistener); }
From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java
private void setupGroupIndicator(View view, boolean expanded, Transfer item) { ImageView groupIndicator = findView(view, R.id.view_transfer_list_item_group_indicator); if (groupIndicator != null) { if (item.getItems().size() <= 1) { //show the file type for the only file there is String extension = null; String path = null;//w w w . j a v a2 s .c om if (item instanceof BittorrentDownload) { BittorrentDownload bItem = (BittorrentDownload) item; if (bItem.getItems().size() > 0) { TransferItem transferItem = bItem.getItems().get(0); path = transferItem.getFile().getAbsolutePath(); extension = FilenameUtils.getExtension(path); } } else if (item instanceof DownloadTransfer) { DownloadTransfer transferItem = (DownloadTransfer) item; if (transferItem.getSavePath() != null) { path = transferItem.getSavePath().getAbsolutePath(); extension = FilenameUtils.getExtension(path); } } else if (item instanceof PeerHttpUpload) { PeerHttpUpload transferItem = (PeerHttpUpload) item; path = transferItem.getFD().filePath; extension = FilenameUtils.getExtension(path); } if (extension != null && extension.equals("apk")) { try { //Apk apk = new Apk(context,path); //TODO: Get the APK Icon so we can show the APK icon on the transfer manager once //it's finished downloading, or as it's uploading to another peer. //apk.getDrawable(id); //in the meantime, just hardcode it groupIndicator.setImageResource(R.drawable.browse_peer_application_icon_selector_menu); } catch (Throwable e) { groupIndicator.setImageResource(R.drawable.browse_peer_application_icon_selector_menu); } } else { groupIndicator.setImageResource(getFileTypeIconId(extension)); } } else { groupIndicator.setImageResource( expanded ? R.drawable.transfer_menuitem_minus : R.drawable.transfer_menuitem_plus); } } }
From source file:com.lifehackinnovations.siteaudit.FloorPlanActivity.java
public void getscaledialog() { ImageView googlemaps = new ImageView(this); googlemaps.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); googlemaps.setPadding(25, 25, 25, 25); googlemaps.setImageResource(R.drawable.google_maps256x256); googlemaps.setOnClickListener(new ImageView.OnClickListener() { public void onClick(View v) { startActivity(u.intent("Getscalefromgooglemaps")); getscaledialog.cancel();/*from w w w . jav a2 s. co m*/ } }); ImageView twopoints = new ImageView(this); twopoints.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); twopoints.setPadding(25, 25, 25, 25); twopoints.setImageResource(R.drawable.pointsonmapicon); twopoints.setOnClickListener(new ImageView.OnClickListener() { public void onClick(View v) { ACTION = ACTION_GETSCALEFROMPOINTS; toptoolbar.setVisibility(View.INVISIBLE); righttoolbar.setVisibility(View.INVISIBLE); floorplantitle.setVisibility(View.VISIBLE); floorplantitle.setText("Please select first point"); GETSCALESTAGE = STAGE_GETFIRSTPOINT; getscaledialog.cancel(); } }); LinearLayout choosepicturelocationlayout; choosepicturelocationlayout = new LinearLayout(this); choosepicturelocationlayout .setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); choosepicturelocationlayout.setOrientation(LinearLayout.HORIZONTAL); choosepicturelocationlayout.addView(googlemaps); choosepicturelocationlayout.addView(twopoints); choosepicturelocationlayout.setGravity(Gravity.CENTER_HORIZONTAL); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Choose Method for Getting Scale") .setMessage("Please choose Google Maps, or Two Points on Map").setView(choosepicturelocationlayout) .setCancelable(false).setIcon(R.drawable.ic_launcher) .setNegativeButton("CANCEL", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).setCancelable(true); getscaledialog = builder.create(); getscaledialog.show(); }
From source file:net.idlesoft.android.apps.github.activities.SingleActivityItem.java
private void loadActivityItemBox() { final TextView date = (TextView) findViewById(R.id.tv_activity_item_date); final ImageView gravatar = (ImageView) findViewById(R.id.iv_activity_item_gravatar); final ImageView icon = (ImageView) findViewById(R.id.iv_activity_item_icon); final TextView title_tv = (TextView) findViewById(R.id.tv_activity_item_title); try {/*from w w w . j a va2 s. co m*/ final JSONObject entry = mJson; final JSONObject payload = entry.getJSONObject("payload"); String end; final SimpleDateFormat dateFormat = new SimpleDateFormat(Hubroid.GITHUB_ISSUES_TIME_FORMAT); final Date item_time = dateFormat.parse(entry.getString("created_at")); final Date current_time = dateFormat.parse(dateFormat.format(new Date())); final long ms = current_time.getTime() - item_time.getTime(); final long sec = ms / 1000; final long min = sec / 60; final long hour = min / 60; final long day = hour / 24; if (day > 0) { if (day == 1) { end = " day ago"; } else { end = " days ago"; } date.setText(day + end); } else if (hour > 0) { if (hour == 1) { end = " hour ago"; } else { end = " hours ago"; } date.setText(hour + end); } else if (min > 0) { if (min == 1) { end = " minute ago"; } else { end = " minutes ago"; } date.setText(min + end); } else { if (sec == 1) { end = " second ago"; } else { end = " seconds ago"; } date.setText(sec + end); } final String actor = entry.getString("actor"); final String eventType = entry.getString("type"); String title = actor + " did something..."; gravatar.setImageBitmap(GravatarCache.getDipGravatar(GravatarCache.getGravatarID(actor), 30.0f, getResources().getDisplayMetrics().density)); if (eventType.contains("PushEvent")) { icon.setImageResource(R.drawable.push); title = actor + " pushed to " + payload.getString("ref").split("/")[2] + " at " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } else if (eventType.contains("WatchEvent")) { final String action = payload.getString("action"); if (action.equalsIgnoreCase("started")) { icon.setImageResource(R.drawable.watch_started); } else { icon.setImageResource(R.drawable.watch_stopped); } title = actor + " " + action + " watching " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } else if (eventType.contains("GistEvent")) { final String action = payload.getString("action"); icon.setImageResource(R.drawable.gist); title = actor + " " + action + "d " + payload.getString("name"); } else if (eventType.contains("ForkEvent")) { icon.setImageResource(R.drawable.fork); title = actor + " forked " + entry.getJSONObject("repository").getString("name") + "/" + entry.getJSONObject("repository").getString("owner"); } else if (eventType.contains("CommitCommentEvent")) { icon.setImageResource(R.drawable.comment); title = actor + " commented on " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } else if (eventType.contains("ForkApplyEvent")) { icon.setImageResource(R.drawable.merge); title = actor + " applied fork commits to " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } else if (eventType.contains("FollowEvent")) { icon.setImageResource(R.drawable.follow); title = actor + " started following " + payload.getJSONObject("target").getString("login"); } else if (eventType.contains("CreateEvent")) { icon.setImageResource(R.drawable.create); if (payload.getString("object").contains("repository")) { title = actor + " created repository " + payload.getString("name"); } else if (payload.getString("object").contains("branch")) { title = actor + " created branch " + payload.getString("object_name") + " at " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } else if (payload.getString("object").contains("tag")) { title = actor + " created tag " + payload.getString("object_name") + " at " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } } else if (eventType.contains("IssuesEvent")) { if (payload.getString("action").equalsIgnoreCase("opened")) { icon.setImageResource(R.drawable.issues_open); } else { icon.setImageResource(R.drawable.issues_closed); } title = actor + " " + payload.getString("action") + " issue " + payload.getInt("number") + " on " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } else if (eventType.contains("DeleteEvent")) { icon.setImageResource(R.drawable.delete); if (payload.getString("object").contains("repository")) { title = actor + " deleted repository " + payload.getString("name"); } else if (payload.getString("object").contains("branch")) { title = actor + " deleted branch " + payload.getString("object_name") + " at " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } else if (payload.getString("object").contains("tag")) { title = actor + " deleted tag " + payload.getString("object_name") + " at " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } } else if (eventType.contains("WikiEvent")) { icon.setImageResource(R.drawable.wiki); title = actor + " " + payload.getString("action") + " a page in the " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name") + " wiki"; } else if (eventType.contains("DownloadEvent")) { icon.setImageResource(R.drawable.download); title = actor + " uploaded a file to " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } else if (eventType.contains("PublicEvent")) { icon.setImageResource(R.drawable.opensource); title = actor + " open sourced " + entry.getJSONObject("repository").getString("name"); } else if (eventType.contains("PullRequestEvent")) { final int number = (payload.get("pull_request") instanceof JSONObject) ? payload.getJSONObject("pull_request").getInt("number") : payload.getInt("number"); if (payload.getString("action").equalsIgnoreCase("opened")) { icon.setImageResource(R.drawable.issues_open); title = actor + " opened pull request " + number + " on " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } else if (payload.getString("action").equalsIgnoreCase("closed")) { icon.setImageResource(R.drawable.issues_closed); title = actor + " closed pull request " + number + " on " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } } else if (eventType.contains("MemberEvent")) { icon.setImageResource(R.drawable.follow); title = actor + " added " + payload.getString("member") + " to " + entry.getJSONObject("repository").getString("owner") + "/" + entry.getJSONObject("repository").getString("name"); } title_tv.setText(title); gravatar.setOnClickListener(new OnClickListener() { public void onClick(final View v) { final Intent i = new Intent(SingleActivityItem.this, Profile.class); i.putExtra("username", actor); startActivity(i); } }); } catch (final JSONException e) { e.printStackTrace(); } catch (final ParseException e) { e.printStackTrace(); } }
From source file:com.google.samples.apps.sergio.ui.BaseActivity.java
/** * Sets up the account box. The account box is the area at the top of the nav drawer that * shows which account the user is logged in as, and lets them switch accounts. It also * shows the user's Google+ cover photo as background. *//*from w w w . ja va 2 s. c om*/ private void setupAccountBox() { mAccountListContainer = (LinearLayout) findViewById(R.id.account_list); if (mAccountListContainer == null) { //This activity does not have an account box return; } final View chosenAccountView = findViewById(R.id.chosen_account_view); Account chosenAccount = AccountUtils.getActiveAccount(this); if (chosenAccount == null) { // No account logged in; hide account box chosenAccountView.setVisibility(View.GONE); mAccountListContainer.setVisibility(View.GONE); return; } else { chosenAccountView.setVisibility(View.VISIBLE); mAccountListContainer.setVisibility(View.INVISIBLE); } AccountManager am = AccountManager.get(this); Account[] accountArray = am.getAccountsByType(GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE); List<Account> accounts = new ArrayList<Account>(Arrays.asList(accountArray)); accounts.remove(chosenAccount); ImageView coverImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_cover_image); ImageView profileImageView = (ImageView) chosenAccountView.findViewById(R.id.profile_image); TextView nameTextView = (TextView) chosenAccountView.findViewById(R.id.profile_name_text); TextView email = (TextView) chosenAccountView.findViewById(R.id.profile_email_text); mExpandAccountBoxIndicator = (ImageView) findViewById(R.id.expand_account_box_indicator); String name = AccountUtils.getPlusName(this); if (name == null) { nameTextView.setVisibility(View.GONE); } else { nameTextView.setVisibility(View.VISIBLE); nameTextView.setText(name); } String imageUrl = AccountUtils.getPlusImageUrl(this); if (imageUrl != null) { mImageLoader.loadImage(imageUrl, profileImageView); } String coverImageUrl = AccountUtils.getPlusCoverUrl(this); if (coverImageUrl != null) { mImageLoader.loadImage(coverImageUrl, coverImageView); } else { coverImageView.setImageResource(R.drawable.default_cover); } email.setText(chosenAccount.name); if (accounts.isEmpty()) { // There's only one account on the device, so no need for a switcher. mExpandAccountBoxIndicator.setVisibility(View.GONE); mAccountListContainer.setVisibility(View.GONE); chosenAccountView.setEnabled(false); return; } chosenAccountView.setEnabled(true); mExpandAccountBoxIndicator.setVisibility(View.VISIBLE); chosenAccountView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mAccountBoxExpanded = !mAccountBoxExpanded; setupAccountBoxToggle(); } }); setupAccountBoxToggle(); populateAccountList(accounts); }
From source file:com.aware.ui.Plugins_Manager.java
private void drawUI() { //Clear previous states store_grid.removeAllViews();//ww w .j av a 2s . c o m //Build UI Cursor installed_plugins = getContentResolver().query(Aware_Plugins.CONTENT_URI, null, null, null, Aware_Plugins.PLUGIN_NAME + " ASC"); if (installed_plugins != null && installed_plugins.moveToFirst()) { do { final String package_name = installed_plugins .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_PACKAGE_NAME)); final String name = installed_plugins .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_NAME)); final String description = installed_plugins .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_DESCRIPTION)); final String developer = installed_plugins .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_AUTHOR)); final String version = installed_plugins .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_VERSION)); final int status = installed_plugins .getInt(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_STATUS)); final View pkg_view = inflater.inflate(R.layout.plugins_store_pkg_list_item, null, false); pkg_view.setTag(package_name); //each view has the package name as a tag for easier references try { ImageView pkg_icon = (ImageView) pkg_view.findViewById(R.id.pkg_icon); if (status != PLUGIN_NOT_INSTALLED) { ApplicationInfo appInfo = getPackageManager().getApplicationInfo(package_name, PackageManager.GET_META_DATA); pkg_icon.setImageDrawable(appInfo.loadIcon(getPackageManager())); } else { byte[] img = installed_plugins .getBlob(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_ICON)); if (img != null) pkg_icon.setImageBitmap(BitmapFactory.decodeByteArray(img, 0, img.length)); } TextView pkg_title = (TextView) pkg_view.findViewById(R.id.pkg_title); pkg_title.setText(installed_plugins .getString(installed_plugins.getColumnIndex(Aware_Plugins.PLUGIN_NAME))); ImageView pkg_state = (ImageView) pkg_view.findViewById(R.id.pkg_state); switch (status) { case PLUGIN_DISABLED: pkg_state.setVisibility(View.INVISIBLE); pkg_view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = getPluginInfoDialog(name, version, description, developer); if (isClassAvailable(package_name, "Settings")) { builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent open_settings = new Intent(); open_settings.setClassName(package_name, package_name + ".Settings"); startActivity(open_settings); } }); } builder.setPositiveButton("Activate", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Aware.startPlugin(getApplicationContext(), package_name); drawUI(); } }); builder.create().show(); } }); break; case PLUGIN_ACTIVE: pkg_state.setImageResource(R.drawable.ic_pkg_active); pkg_view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = getPluginInfoDialog(name, version, description, developer); if (isClassAvailable(package_name, "Settings")) { builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent open_settings = new Intent(); open_settings.setClassName(package_name, package_name + ".Settings"); startActivity(open_settings); } }); } builder.setPositiveButton("Deactivate", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Aware.stopPlugin(getApplicationContext(), package_name); drawUI(); } }); builder.create().show(); } }); break; case PLUGIN_UPDATED: pkg_state.setImageResource(R.drawable.ic_pkg_updated); pkg_view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = getPluginInfoDialog(name, version, description, developer); if (isClassAvailable(package_name, "Settings")) { builder.setNegativeButton("Settings", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Intent open_settings = new Intent(); open_settings.setClassName(package_name, package_name + ".Settings"); startActivity(open_settings); } }); } builder.setNeutralButton("Deactivate", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Aware.stopPlugin(getApplicationContext(), package_name); drawUI(); } }); builder.setPositiveButton("Update", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Aware.downloadPlugin(getApplicationContext(), package_name, true); } }); builder.create().show(); } }); break; case PLUGIN_NOT_INSTALLED: pkg_state.setImageResource(R.drawable.ic_pkg_download); pkg_view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AlertDialog.Builder builder = getPluginInfoDialog(name, version, description, developer); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setPositiveButton("Install", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Aware.downloadPlugin(getApplicationContext(), package_name, false); } }); builder.create().show(); } }); break; } store_grid.addView(pkg_view); } catch (NameNotFoundException e) { e.printStackTrace(); } } while (installed_plugins.moveToNext()); } if (installed_plugins != null && !installed_plugins.isClosed()) installed_plugins.close(); }
From source file:com.androidquery.AQuery.java
/** * Set the image of an ImageView.// w ww . j av a 2 s .c o m * * @param resid the resource id * @return self * * @see testImage1 */ public AQuery image(int resid) { if (view instanceof ImageView) { ImageView iv = (ImageView) view; iv.setTag(AQuery.TAG_URL, null); if (resid == 0) { iv.setImageBitmap(null); } else { iv.setImageResource(resid); } } return self(); }