@Override
    public View getView(int position, View convertView, ViewGroup parent) {
      LayoutInflater inflater =
          (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      View rowView = inflater.inflate(R.layout.list_item_icon, parent, false);
      TextView textView = (TextView) rowView.findViewById(R.id.label);

      ImageView imageView = (ImageView) rowView.findViewById(R.id.icon);
      textView.setText(mValues[position]);

      // Set icons
      String s = mValues[position];
      if (s.equals("CPU")) {
        imageView.setImageResource(R.drawable.ic_drawer_cpu);
      } else if (s.equals("System")) {
        imageView.setImageResource(R.drawable.ic_drawer_system);
      } else if (s.equals("Disks")) {
        imageView.setImageResource(R.drawable.ic_drawer_disks);
      } else if (s.equals("Processes")) {
        imageView.setImageResource(R.drawable.ic_drawer_processes);
      } else if (s.equals("GPU")) {
        imageView.setImageResource(R.drawable.ic_drawer_gpu);
      } else if (s.equals("Overview")) {
        imageView.setImageResource(R.drawable.ic_drawer_overview);
      } else if (s.equals("History")) {
        imageView.setImageResource(R.drawable.ic_drawer_history);
      } else if (s.equals("Notifications")) {
        imageView.setImageResource(R.drawable.ic_drawer_notifications);
      }
      imageView.setContentDescription(s + " icon");

      return rowView;
    }
Example #2
0
  private boolean checkDisabledAndClickAction(final IndexItem item) {
    RightButtonAction clickAction = getClickAction(item);
    boolean disabled = clickAction != RightButtonAction.DOWNLOAD;
    OnClickListener action = getRightButtonAction(item, clickAction);
    if (clickAction != RightButtonAction.DOWNLOAD) {
      rightButton.setText(R.string.get_plugin);
      rightButton.setVisibility(View.VISIBLE);
      rightImageButton.setVisibility(View.GONE);
      rightButton.setOnClickListener(action);
    } else {
      rightButton.setVisibility(View.GONE);
      rightImageButton.setVisibility(View.VISIBLE);
      final boolean isDownloading = context.getDownloadThread().isDownloading(item);
      if (isDownloading) {
        rightImageButton.setImageDrawable(
            getContentIcon(context, R.drawable.ic_action_remove_dark));
        rightImageButton.setContentDescription(context.getString(R.string.shared_string_cancel));
      } else if (item.isDownloaded() && !item.isOutdated()) {
        rightImageButton.setImageDrawable(
            getContentIcon(context, R.drawable.ic_overflow_menu_white));
        rightImageButton.setContentDescription(context.getString(R.string.shared_string_more));
      } else {
        rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_import));
        rightImageButton.setContentDescription(context.getString(R.string.shared_string_download));
      }
      rightImageButton.setOnClickListener(action);
    }

    return disabled;
  }
 /** Sets the content description for the star icon based on whether it's currently starred. */
 private void setStarContentDescription(boolean isFavorite) {
   if (isFavorite) {
     mFavoriteIcon.setContentDescription(
         mContext.getResources().getString(R.string.remove_star_action));
   } else {
     mFavoriteIcon.setContentDescription(
         mContext.getResources().getString(R.string.set_star_action));
   }
 }
Example #4
0
    @Override
    public void bindView(View view, Context context, Cursor cursor) {
      Filter filter = new Filter();
      filter.createFromDb(cursor);
      String filterDesc = filter.getRepresentation(context);

      TextView tv = (TextView) view.findViewById(R.id.line1);
      ImageView icon = (ImageView) view.findViewById(R.id.action_icon);

      tv.setText(filterDesc);
      icon.setContentDescription(filterDesc);
      switch (filter.action) {
        case Filter.ACTION_CAN_CALL:
          icon.setImageResource(R.drawable.ic_menu_goto);
          break;
        case Filter.ACTION_CANT_CALL:
          icon.setImageResource(R.drawable.ic_menu_blocked_user);
          break;
        case Filter.ACTION_REPLACE:
          icon.setImageResource(android.R.drawable.ic_menu_edit);
          break;
        case Filter.ACTION_DIRECTLY_CALL:
          icon.setImageResource(R.drawable.ic_menu_answer_call);
          break;
        case Filter.ACTION_AUTO_ANSWER:
          icon.setImageResource(R.drawable.ic_menu_auto_answer);
          break;
        default:
          break;
      }
    }
  public void onReceive(Context context, Intent intent) {
    final String action = intent.getAction();
    if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
      final int level = intent.getIntExtra(BatteryManager.EXTRA_DOCK_LEVEL, 0);
      mDockStatus =
          intent.getIntExtra(
              BatteryManager.EXTRA_DOCK_STATUS, BatteryManager.DOCK_BATTERY_STATUS_UNKNOWN);
      mDockPresent = intent.getBooleanExtra(BatteryManager.EXTRA_DOCK_PRESENT, false);

      int N = mIconViews.size();
      for (int i = 0; i < N; i++) {
        ImageView v = mIconViews.get(i);
        v.setImageLevel(level);
        v.setContentDescription(mContext.getString(R.string.accessibility_battery_level, level));
      }

      N = mLabelViews.size();
      for (int i = 0; i < N; i++) {
        TextView v = mLabelViews.get(i);
        v.setText(mContext.getString(BATTERY_TEXT_STYLE_MIN, level));
      }

      updateBattery();
    }
  }
  @Override
  public View getView(
      Context context,
      View recycled,
      int thumbWidth,
      int thumbHeight,
      int placeholderResourcedId,
      LocalDataAdapter adapter,
      boolean isInProgress) {
    final ImageView imageView;
    if (recycled != null) {
      imageView = (ImageView) recycled;
    } else {
      imageView = new ImageView(context);
      imageView.setTag(R.id.mediadata_tag_viewtype, getItemViewType().ordinal());
    }

    byte[] jpegData = Storage.getJpegForSession(mUri);
    int currentVersion = Storage.getJpegVersionForSession(mUri);
    Glide.with(context)
        .loadFromImage(jpegData, mUri.toString() + currentVersion)
        .skipDiskCache(true)
        .fitCenter()
        .into(imageView);

    imageView.setContentDescription(
        context.getResources().getString(R.string.media_processing_content_description));
    return imageView;
  }
Example #7
0
  @SuppressLint("InflateParams")
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    if (convertView == null) {
      LayoutInflater mInflater =
          (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
      convertView = mInflater.inflate(R.layout.list_item_review, null);
    }
    ReviewListItem reviewItem = reviewItems.get(position);

    ImageView iv = (ImageView) convertView.findViewById(R.id.imageView_review_thumb);
    ImageLoader il = new ImageLoader(iv);
    il.execute(reviewItem.getUrl());
    iv.setContentDescription(reviewItem.getDescription());

    TextView tv;
    tv = (TextView) convertView.findViewById(R.id.textView_date);
    tv.setText(reviewItem.getDate());

    tv = (TextView) convertView.findViewById(R.id.textView_rating);
    tv.setText(reviewItem.getRating());

    tv = (TextView) convertView.findViewById(R.id.textView_comment);
    tv.setText(reviewItem.getComment());

    return convertView;
  }
  private void addIconTabBĂ„deTekstOgBillede(
      final int position, int resId, Bitmap res, String title) {
    FrameLayout tabfl = new FrameLayout(getContext());
    if (Build.VERSION.SDK_INT > 11) tabfl.setLayoutTransition(new LayoutTransition());
    ImageView tabi = new ImageView(getContext());
    tabi.setContentDescription(title);
    if (res != null) {
      tabi.setImageBitmap(res);
      tabi.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
      tabi.setAdjustViewBounds(true);
    } else {
      tabi.setImageResource(resId);
    }
    tabi.setVisibility(View.GONE);
    TextView tabt = new TextView(getContext());
    tabt.setText(title);
    tabt.setTypeface(App.skrift_gibson);
    tabt.setGravity(Gravity.CENTER);
    tabt.setSingleLine();

    tabfl.addView(tabi);
    tabfl.addView(tabt);

    LayoutParams lp = (LayoutParams) tabi.getLayoutParams();
    lp.gravity = Gravity.CENTER;
    lp = (LayoutParams) tabt.getLayoutParams();
    lp.width = lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
    lp.gravity = Gravity.CENTER;

    addTab(position, tabfl);
  }
 private View createInputMethodItem(final InputMethodInfo imi, final InputMethodSubtype subtype) {
   final CharSequence subtypeName;
   if (subtype == null || subtype.overridesImplicitlyEnabledSubtype()) {
     subtypeName = null;
   } else {
     subtypeName = getSubtypeName(imi, subtype);
   }
   final CharSequence imiName = getIMIName(imi);
   final Drawable icon = getSubtypeIcon(imi, subtype);
   final View view = View.inflate(mContext, R.layout.system_bar_input_methods_item, null);
   final ImageView subtypeIcon = (ImageView) view.findViewById(R.id.item_icon);
   final TextView itemTitle = (TextView) view.findViewById(R.id.item_title);
   final TextView itemSubtitle = (TextView) view.findViewById(R.id.item_subtitle);
   final ImageView settingsIcon = (ImageView) view.findViewById(R.id.item_settings_icon);
   final View subtypeView = view.findViewById(R.id.item_subtype);
   if (subtypeName == null) {
     itemTitle.setText(imiName);
     itemSubtitle.setVisibility(View.GONE);
   } else {
     itemTitle.setText(subtypeName);
     itemSubtitle.setVisibility(View.VISIBLE);
     itemSubtitle.setText(imiName);
   }
   subtypeIcon.setImageDrawable(icon);
   subtypeIcon.setContentDescription(itemTitle.getText());
   final String settingsActivity = imi.getSettingsActivity();
   if (!TextUtils.isEmpty(settingsActivity)) {
     settingsIcon.setOnClickListener(
         new View.OnClickListener() {
           @Override
           public void onClick(View arg0) {
             Intent intent = new Intent(Intent.ACTION_MAIN);
             intent.setClassName(imi.getPackageName(), settingsActivity);
             intent.setFlags(
                 Intent.FLAG_ACTIVITY_NEW_TASK
                     | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
                     | Intent.FLAG_ACTIVITY_CLEAR_TOP);
             startActivity(intent);
             closePanel(true);
           }
         });
   } else {
     // Do not show the settings icon if the IME does not have a settings preference
     view.findViewById(R.id.item_vertical_separator).setVisibility(View.GONE);
     settingsIcon.setVisibility(View.GONE);
   }
   mRadioViewAndImiMap.put(
       subtypeView, new Pair<InputMethodInfo, InputMethodSubtype>(imi, subtype));
   subtypeView.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           Pair<InputMethodInfo, InputMethodSubtype> imiAndSubtype = updateRadioButtonsByView(v);
           closePanel(false);
           setInputMethodAndSubtype(imiAndSubtype.first, imiAndSubtype.second);
         }
       });
   return view;
 }
Example #10
0
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
      // Read weather condition ID from cursor
      int weatherId = data.getInt(data.getColumnIndex(WeatherEntry.COLUMN_WEATHER_ID));
      // Use placeholder Image
      mIconView.setImageResource(Utility.getArtResourceForWeatherCondition(weatherId));

      // Read date from cursor and update views for day of week and date
      String date = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_DATETEXT));
      String friendlyDateText = Utility.getDayName(getActivity(), date);
      String dateText = Utility.getFormattedMonthDay(getActivity(), date);
      mFriendlyDateView.setText(friendlyDateText);
      mDateView.setText(dateText);

      // Read description from cursor and update view
      String description = data.getString(data.getColumnIndex(WeatherEntry.COLUMN_SHORT_DESC));
      mDescriptionView.setText(description);

      // For accessibility, add a content description to the icon field.
      mIconView.setContentDescription(description);

      // Read high temperature from cursor and update view
      boolean isMetric = Utility.isMetric(getActivity());

      double high = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MAX_TEMP));
      String highString = Utility.formatTemperature(getActivity(), high, isMetric);
      mHighTempView.setText(highString);

      // Read low temperature from cursor and update view
      double low = data.getDouble(data.getColumnIndex(WeatherEntry.COLUMN_MIN_TEMP));
      String lowString = Utility.formatTemperature(getActivity(), low, isMetric);
      mLowTempView.setText(lowString);

      // Read humidity from cursor and update view
      float humidity = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_HUMIDITY));
      mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));

      // Read wind speed and direction from cursor and update view
      float windSpeedStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_WIND_SPEED));
      float windDirStr = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_DEGREES));
      mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));

      // Read pressure from cursor and update view
      float pressure = data.getFloat(data.getColumnIndex(WeatherEntry.COLUMN_PRESSURE));
      mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure));

      // We still need this for the share intent
      mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low);

      // If onCreateOptionsMenu has already happened, we need to update the share intent now.
      if (mShareActionProvider != null) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
      }
    }
  }
Example #11
0
 protected void populateView(View tabView, TextView textView, int position) {
   ImageView imageView = (ImageView) tabView;
   imageView.setImageDrawable(
       ContextCompat.getDrawable(getContext(), mAdapter.getPageIcon(position)));
   if (position != this.mViewPager.getCurrentItem()) {
     imageView.setAlpha(TAB_DIM_ALPHA);
   }
   imageView.setContentDescription(this.mAdapter.getPageTitle(position));
   this.mTabLookup[position] = tabView;
 }
 public void applyFromResolveInfo(PackageManager pm, ResolveInfo info) {
   mIsAppWidget = false;
   CharSequence label = info.loadLabel(pm);
   final ImageView image = (ImageView) findViewById(R.id.widget_preview);
   image.setContentDescription(label);
   final TextView name = (TextView) findViewById(R.id.widget_name);
   name.setText(label);
   final TextView dims = (TextView) findViewById(R.id.widget_dims);
   if (dims != null) {
     dims.setText(String.format(mDimensionsFormatString, 1, 1));
   }
 }
Example #13
0
  /**
   * Sets a list item.
   *
   * @param context the context
   * @param view the list item view
   * @param isRecording true if recording
   * @param isPaused true if paused
   * @param name the name value
   * @param iconId the icon id
   * @param iconContentDescriptionId the icon content description id
   * @param category the category value
   * @param totalTime the total time value
   * @param totalDistance the total distance value
   * @param startTime the start time value
   * @param description the description value
   * @param sharedOwner if shared with me track, the owner, else null
   */
  public static void setListItem(
      Context context,
      View view,
      boolean isRecording,
      boolean isPaused,
      int iconId,
      int iconContentDescriptionId,
      String name,
      String category,
      String totalTime,
      String totalDistance,
      long startTime,
      String description,
      String sharedOwner) {

    if (isRecording) {
      iconId = isPaused ? R.drawable.ic_track_paused : R.drawable.ic_track_recording;
      iconContentDescriptionId =
          isPaused ? R.string.icon_pause_recording : R.string.icon_record_track;
    }

    ImageView iconImageView = (ImageView) view.findViewById(R.id.list_item_icon);
    iconImageView.setImageResource(iconId);
    iconImageView.setContentDescription(context.getString(iconContentDescriptionId));

    TextView nameTextView = (TextView) view.findViewById(R.id.list_item_name);
    nameTextView.setText(name);

    TextView timeDistanceTextView = (TextView) view.findViewById(R.id.list_item_time_distance);
    if (isRecording) {
      timeDistanceTextView.setTextColor(
          context
              .getResources()
              .getColor(isPaused ? android.R.color.white : R.color.recording_text));
    } else {
      // Need to match the style set in list_item.xml
      timeDistanceTextView.setTextAppearance(context, R.style.TextSmall);
    }
    setTextView(
        timeDistanceTextView,
        getTimeDistance(context, isRecording, isPaused, sharedOwner, totalTime, totalDistance));

    String[] startTimeDisplay = getStartTime(isRecording, context, startTime);
    TextView dateTextView = (TextView) view.findViewById(R.id.list_item_date);
    setTextView(dateTextView, startTimeDisplay[0]);

    TextView timeTextView = (TextView) view.findViewById(R.id.list_item_time);
    setTextView(timeTextView, startTimeDisplay[1]);

    TextView descriptionTextView = (TextView) view.findViewById(R.id.list_item_description);
    setTextView(descriptionTextView, getDescription(isRecording, category, description));
  }
 public void refreshViews() {
   int N = mIconViews.size();
   for (int i = 0; i < N; i++) {
     ImageView v = mIconViews.get(i);
     v.setImageResource(mIconId);
     v.setVisibility(mEnabled ? View.VISIBLE : View.GONE);
     v.setContentDescription(
         (mContentDescriptionId == 0) ? null : mContext.getString(mContentDescriptionId));
   }
   for (BluetoothStateChangeCallback cb : mChangeCallbacks) {
     cb.onBluetoothStateChange(mEnabled);
   }
 }
  private void setBatteryIcon(int level, boolean plugged) {
    mLevel = level;
    mPlugged = plugged;
    ContentResolver cr = mContext.getContentResolver();
    mBatteryStyle = Settings.System.getInt(cr, Settings.System.STATUSBAR_BATTERY_ICON, 0);
    int icon;
    if (mBatteryStyle == STYLE_ICON_CIRCLE) {
      icon = plugged ? R.drawable.stat_sys_battery_charge_mod : R.drawable.stat_sys_battery_mod;
    } else {
      icon = plugged ? R.drawable.stat_sys_battery_charge : R.drawable.stat_sys_battery;
    }
    int N = mIconViews.size();
    for (int i = 0; i < N; i++) {
      ImageView v = mIconViews.get(i);
      v.setImageResource(icon);
      v.setImageLevel(level);
      v.setContentDescription(mContext.getString(R.string.accessibility_battery_level, level));
    }
    N = mLabelViews.size();
    for (int i = 0; i < N; i++) {
      TextView v = mLabelViews.get(i);
      v.setText(mContext.getString(R.string.status_bar_settings_battery_meter_format, level));
    }

    // do my stuff here
    if (mBatteryGroup != null) {
      mBatteryText.setText(Integer.toString(level));
      mBatteryCenterText.setText(Integer.toString(level));
      mBatteryTextOnly.setText(Integer.toString(level));
      SpannableStringBuilder formatted = new SpannableStringBuilder(Integer.toString(level) + "%");
      CharacterStyle style = new RelativeSizeSpan(0.7f); // beautiful
      // formatting
      if (level < 10) { // level < 10, 2nd char is %
        formatted.setSpan(style, 1, 2, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
      } else if (level < 100) { // level 10-99, 3rd char is %
        formatted.setSpan(style, 2, 3, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
      } else { // level 100, 4th char is %
        formatted.setSpan(style, 3, 4, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
      }
      mBatteryTextOnly.setText(formatted);
      if (plugged) { // colors hardcoded by now, maybe colorpicker can be
        // added if needed
        mBatteryTextOnly.setTextColor(Color.GREEN);
      } else if (level < 16) {
        mBatteryTextOnly.setTextColor(Color.RED);
      } else {
        mBatteryTextOnly.setTextColor(0xFF33B5E5);
      }
    }
  }
Example #16
0
 public eib(Context context, AttributeSet attributeset) {
   super(context, null);
   if (i == 0) {
     i = getResources().getDimensionPixelSize(g.dX);
   }
   setOrientation(1);
   inflate(context, g.gC, this);
   g = (ImageView) findViewById(h.cG);
   e = (FixedAspectRatioImageView) findViewById(h.cJ);
   h = (ImageView) findViewById(h.cI);
   if (a()) {
     h.setImageResource(com.google.android.apps.hangouts.R.drawable.bu);
     h.setContentDescription(getResources().getString(l.hA));
   }
   setLongClickable(true);
 }
 public void applyFromAppWidgetProviderInfo(
     AppWidgetProviderInfo info, int maxWidth, int[] cellSpan) {
   mIsAppWidget = true;
   final ImageView image = (ImageView) findViewById(R.id.widget_preview);
   if (maxWidth > -1) {
     image.setMaxWidth(maxWidth);
   }
   image.setContentDescription(info.label);
   final TextView name = (TextView) findViewById(R.id.widget_name);
   name.setText(info.label);
   final TextView dims = (TextView) findViewById(R.id.widget_dims);
   if (dims != null) {
     int hSpan = Math.min(cellSpan[0], LauncherModel.getCellCountX());
     int vSpan = Math.min(cellSpan[1], LauncherModel.getCellCountY());
     dims.setText(String.format(mDimensionsFormatString, hSpan, vSpan));
   }
 }
 private void setWatchedToggleState(int unwatchedEpisodes) {
   mWatchedAllEpisodes = unwatchedEpisodes == 0;
   mButtonWatchedAll.setImageResource(
       mWatchedAllEpisodes
           ? Utils.resolveAttributeToResourceId(
               getActivity().getTheme(), R.attr.drawableWatchedAll)
           : Utils.resolveAttributeToResourceId(
               getActivity().getTheme(), R.attr.drawableWatchAll));
   mButtonWatchedAll.setContentDescription(
       getString(mWatchedAllEpisodes ? R.string.unmark_all : R.string.mark_all));
   // set onClick listener not before here to avoid unexpected actions
   mButtonWatchedAll.setOnClickListener(
       new OnClickListener() {
         @Override
         public void onClick(View v) {
           PopupMenu popupMenu = new PopupMenu(v.getContext(), v);
           if (!mWatchedAllEpisodes) {
             popupMenu.getMenu().add(0, CONTEXT_WATCHED_SHOW_ALL_ID, 0, R.string.mark_all);
           }
           popupMenu.getMenu().add(0, CONTEXT_WATCHED_SHOW_NONE_ID, 0, R.string.unmark_all);
           popupMenu.setOnMenuItemClickListener(
               new PopupMenu.OnMenuItemClickListener() {
                 @Override
                 public boolean onMenuItemClick(MenuItem item) {
                   switch (item.getItemId()) {
                     case CONTEXT_WATCHED_SHOW_ALL_ID:
                       {
                         onFlagShowWatched(true);
                         Utils.trackAction(getActivity(), TAG, "Flag all watched (inline)");
                         return true;
                       }
                     case CONTEXT_WATCHED_SHOW_NONE_ID:
                       {
                         onFlagShowWatched(false);
                         Utils.trackAction(getActivity(), TAG, "Flag all unwatched (inline)");
                         return true;
                       }
                   }
                   return false;
                 }
               });
           popupMenu.show();
         }
       });
 }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.activity_drinks);
   // Get the drink from the intent
   int drinkNo;
   drinkNo = (Integer) getIntent().getExtras().get(EXTRA_DRINKNO);
   // Create a cursor
   try {
     SQLiteOpenHelper mcdolandDatabaseHelper = new McDolandDatabaseHelper(this);
     SQLiteDatabase db = mcdolandDatabaseHelper.getReadableDatabase();
     Cursor cursor =
         db.query(
             "DRINK",
             new String[] {"NAME", "DESCRIPTION", "IMAGE_RESOURCE_ID"},
             "_id = ?",
             new String[] {Integer.toString(drinkNo)},
             null,
             null,
             null);
     // Move to the first record in the Cursor
     if (cursor.moveToFirst()) {
       // Get the drink details from the cursor
       String nameText = cursor.getString(0);
       String descriptionText = cursor.getString(1);
       int photoId = cursor.getInt(2);
       // Populate the drink name
       TextView name = (TextView) findViewById(R.id.drinknameTV);
       name.setText(nameText);
       // Populate the drink description
       TextView description = (TextView) findViewById(R.id.drinkdescTV);
       description.setText(descriptionText);
       // Populate the drink image
       ImageView photo = (ImageView) findViewById(R.id.picIV);
       photo.setImageResource(photoId);
       photo.setContentDescription(nameText);
     }
     cursor.close();
     db.close();
   } catch (SQLiteException e) {
     Toast toast = Toast.makeText(this, "Database unavailable", Toast.LENGTH_SHORT);
     toast.show();
   }
 }
 /**
  * Determines visibility of a social icon, sets up a click listener to allow the user to navigate
  * to the social network associated with the icon, and sets up a content description for the icon.
  */
 private void setUpSpeakerSocialIcon(
     final SessionDetailModel.Speaker speaker,
     ImageView socialIcon,
     final String socialUrl,
     String socialNetworkName,
     final String packageName) {
   if (socialUrl == null || socialUrl.isEmpty()) {
     socialIcon.setVisibility(View.GONE);
   } else {
     socialIcon.setContentDescription(
         getString(R.string.speaker_social_page, socialNetworkName, speaker.getName()));
     socialIcon.setOnClickListener(
         new View.OnClickListener() {
           @Override
           public void onClick(View v) {
             UIUtils.fireSocialIntent(getActivity(), Uri.parse(socialUrl), packageName);
           }
         });
   }
 }
Example #21
0
    public void setItem(I item) {
      // Overview (Title/Author, Status/Deadline)
      if (item.getTitle() != null && item.getAuthor() != null) {
        tvTitleAndAuthor.setText(item.getTitle() + ", " + item.getAuthor());
      } else if (item.getTitle() != null) {
        tvTitleAndAuthor.setText(item.getTitle());
      } else {
        setTextOrHide(item.getAuthor(), tvTitleAndAuthor);
      }

      if (coversHidden) {
        ivMediaType.setVisibility(View.GONE);
        ivCover.setVisibility(View.GONE);
      } else {
        if (item.getCover() != null) {
          ivCover.setVisibility(View.VISIBLE);
          ivMediaType.setVisibility(View.GONE);

          Drawable loading =
              VectorDrawableCompat.create(context.getResources(), R.drawable.ic_loading, null);
          Glide.with(context)
              .using(new ISBNToolsUrlLoader(context))
              .load(item.getCover())
              .placeholder(loading)
              .crossFade()
              .into(ivCover);
        } else {
          ivCover.setVisibility(View.GONE);
          Glide.clear(ivCover);
          if (item.getMediaType() != null) {
            ivMediaType.setImageResource(
                ResultsAdapter.getResourceByMediaType(item.getMediaType()));
            ivMediaType.setContentDescription(sp.getMediaTypeName(item.getMediaType()));
            ivMediaType.setVisibility(View.VISIBLE);
          } else {
            ivMediaType.setVisibility(View.INVISIBLE);
          }
        }
      }
    }
Example #22
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_coffee);

    // Get the coffee from the intent
    int drinkNo = (Integer) getIntent().getExtras().get(EXTRA_DRINKNO);
    Drink drink = Drink.drinks[drinkNo];

    // Populate the coffee image
    ImageView photo = (ImageView) findViewById(R.id.photo);
    photo.setImageResource(drink.getImageResourceId());
    photo.setContentDescription(drink.getName());

    // Populate the coffee name
    TextView name = (TextView) findViewById(R.id.name);
    name.setText(drink.getName());

    // Populate the coffee description
    TextView description = (TextView) findViewById(R.id.description);
    description.setText(drink.getDescription());
  }
Example #23
0
  @Override
  public void bind(Element element) {
    image.setImageDrawable(null);
    String imageURL = parseImageURL(element);
    Picasso.with(itemView.getContext())
        .load(imageURL)
        .into(
            image,
            new Callback() {
              @Override
              public void onSuccess() {
                setRatio(image);
              }

              @Override
              public void onError() {
                /*ignored*/
              }
            });

    String title = parseTitle(element);
    primaryText.setText(title);
    image.setContentDescription(title);
    subtext.setText(parseAuthor(element));

    final String articleLink = parseArticleLink(element);
    cardView.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // TODO: 9-7-2015 Check if href is not a re/code web page
            if (articleLink != null) {
              ArticleActivity.openArticle(itemView.getContext(), articleLink);
            }
          }
        });
  }
Example #24
0
 private void home() {
   Button home;
   ImageView image;
   home = (Button) findViewById(R.id.home_btn);
   image = (ImageView) findViewById(R.id.home_btn_img);
   home.setText("Home");
   image.setContentDescription("JMoney");
   home.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View view) {
           Intent i = new Intent(getApplicationContext(), JMoneyActivity.class);
           startActivity(i);
         }
       });
   image.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View view) {
           Intent i = new Intent(getApplicationContext(), JMoneyActivity.class);
           startActivity(i);
         }
       });
 }
 public static void a(ImageView paramImageView, float paramFloat) {
   paramImageView.setImageLevel((int) (10.0F * paramFloat) / 5);
   paramImageView.setContentDescription(a(paramImageView.getContext(), paramFloat));
 }
  public void initViewPager() {

    ImageView imageView, dot;
    // dots = new ImageView[mVpList.size()];
    if (mVpList.size() >= 4) {
      dots = new ImageView[4];
    } else {
      dots = new ImageView[mVpList.size()];
    }

    List<View> imageViews = new ArrayList<View>();
    for (int i = 0; i < dots.length; i++) {
      item = mVpList.get(i);
      String url = Urls.NEWIP + item.getImgUrl();
      final int item_id = item.getVID();
      imageView = new ImageView(mActivity);
      ImageLoader.getInstance().displayImage(url, imageView, options);
      imageView.setLayoutParams(
          new android.view.ViewGroup.LayoutParams(
              android.view.ViewGroup.LayoutParams.MATCH_PARENT,
              android.view.ViewGroup.LayoutParams.MATCH_PARENT));
      imageView.setId(item_id);
      imageView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              Intent intent = new Intent();
              intent.setClass(v.getContext(), VoteInfoActivity.class);
              intent.putExtra("ID", item_id);
              v.getContext().startActivity(intent);
            }
          });
      imageView.setScaleType(ImageView.ScaleType.FIT_XY);
      imageView.setContentDescription(item.getDes());
      imageViews.add(imageView);

      dot = new ImageView(mActivity);
      dot.setLayoutParams(new android.view.ViewGroup.LayoutParams(20, 20));
      dot.setPadding(5, 5, 5, 5);
      dots[i] = dot;
      dots[i].setBackgroundResource(R.drawable.unselectedflag);
      if (i == mVp.getCurrentItem()) {
        dots[i].setBackgroundResource(R.drawable.selectedflag);
        tv_title.setText(item.getDes());
        prePosition = mVp.getCurrentItem();
      }
      ll_dots.addView(dots[i]);
    }
    AdvAdapter advAdapter = new AdvAdapter(imageViews, mActivity);
    mVp.setAdapter(advAdapter);
    mVp.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {

          @Override
          public void onPageSelected(int arg0) {
            ((ImageView) ll_dots.getChildAt(prePosition))
                .setBackgroundResource(R.drawable.unselectedflag);
            ((ImageView) ll_dots.getChildAt(arg0)).setBackgroundResource(R.drawable.selectedflag);
            tv_title.setText(mVpList.get(arg0).getDes());
            what.set(arg0);
            prePosition = arg0;
          }

          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {}

          @Override
          public void onPageScrollStateChanged(int arg0) {}
        });
    mVp.setOnTouchListener(
        new View.OnTouchListener() {

          @SuppressLint("ClickableViewAccessibility")
          @Override
          public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
              case MotionEvent.ACTION_MOVE:
                isContinue = false;
                break;
              case MotionEvent.ACTION_UP:
                isContinue = true;
                break;
              default:
                isContinue = true;
                break;
            }
            return false;
          }
        });
    if (mVpList.size() > 1 && threadNumber < 1) {
      new Thread(
              new Runnable() {

                @Override
                public void run() {
                  while (true) {
                    if (isContinue) {
                      Message message = mHandler.obtainMessage();
                      message.arg1 = what.get();
                      mHandler.sendMessage(message);
                      whatOption();
                    }
                  }
                }
              })
          .start();
      threadNumber++;
    }
  }
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
      // Read weather condition ID from cursor
      int weatherId = data.getInt(COL_WEATHER_CONDITION_ID);

      // Use weather art image
      Glide.with(this)
          .load(Utility.getArtUrlForWeatherCondition(getActivity(), weatherId))
          .error(Utility.getArtResourceForWeatherCondition(weatherId))
          .crossFade()
          .into(mIconView);

      // Read date from cursor and update views for day of week and date
      long date = data.getLong(COL_WEATHER_DATE);
      String friendlyDateText = Utility.getDayName(getActivity(), date);
      String dateText = Utility.getFormattedMonthDay(getActivity(), date);
      mFriendlyDateView.setText(friendlyDateText);
      mDateView.setText(dateText);

      // Read description from cursor and update view
      String description = data.getString(COL_WEATHER_DESC);
      mDescriptionView.setText(description);

      // For accessibility, add a content description to the icon field
      mIconView.setContentDescription(getString(R.string.a11y_forecast_icon, description));

      // Read high temperature from cursor and update view
      boolean isMetric = Utility.isMetric(getActivity());

      double high = data.getDouble(COL_WEATHER_MAX_TEMP);
      String highString = Utility.formatTemperature(getActivity(), high);
      mHighTempView.setText(highString);
      mHighTempView.setContentDescription(getString(R.string.a11y_high_temp, high));

      // Read low temperature from cursor and update view
      double low = data.getDouble(COL_WEATHER_MIN_TEMP);
      String lowString = Utility.formatTemperature(getActivity(), low);
      mLowTempView.setText(lowString);
      mLowTempView.setContentDescription(getString(R.string.a11y_low_temp, low));

      // Read humidity from cursor and update view
      float humidity = data.getFloat(COL_WEATHER_HUMIDITY);
      mHumidityView.setText(getActivity().getString(R.string.format_humidity, humidity));
      mHumidityView.setContentDescription(mHumidityView.getText());

      // Read wind speed and direction from cursor and update view
      float windSpeedStr = data.getFloat(COL_WEATHER_WIND_SPEED);
      float windDirStr = data.getFloat(COL_WEATHER_DEGREES);
      mWindView.setText(Utility.getFormattedWind(getActivity(), windSpeedStr, windDirStr));
      mWindView.setContentDescription(mWindView.getText());

      // Read pressure from cursor and update view
      float pressure = data.getFloat(COL_WEATHER_PRESSURE);
      mPressureView.setText(getActivity().getString(R.string.format_pressure, pressure));
      mPressureView.setContentDescription(mPressureView.getText());

      // We still need this for the share intent
      mForecast = String.format("%s - %s - %s/%s", dateText, description, high, low);

      // If onCreateOptionsMenu has already happened, we need to update the share intent now.
      if (mShareActionProvider != null) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
      }
    }
  }
  private void displaySpeakersData(SessionDetailModel data) {
    final ViewGroup speakersGroup =
        (ViewGroup) getActivity().findViewById(R.id.session_speakers_block);

    // Remove all existing speakers (everything but first child, which is the header)
    for (int i = speakersGroup.getChildCount() - 1; i >= 1; i--) {
      speakersGroup.removeViewAt(i);
    }

    final LayoutInflater inflater = getActivity().getLayoutInflater();

    boolean hasSpeakers = false;

    List<SessionDetailModel.Speaker> speakers = data.getSpeakers();

    for (final SessionDetailModel.Speaker speaker : speakers) {

      String speakerHeader = speaker.getName();
      if (!TextUtils.isEmpty(speaker.getCompany())) {
        speakerHeader += ", " + speaker.getCompany();
      }

      final View speakerView = inflater.inflate(R.layout.speaker_detail, speakersGroup, false);
      final TextView speakerHeaderView = (TextView) speakerView.findViewById(R.id.speaker_header);
      final ImageView speakerImageView = (ImageView) speakerView.findViewById(R.id.speaker_image);
      final TextView speakerAbstractView =
          (TextView) speakerView.findViewById(R.id.speaker_abstract);
      final ImageView plusOneIcon = (ImageView) speakerView.findViewById(R.id.gplus_icon_box);
      final ImageView twitterIcon = (ImageView) speakerView.findViewById(R.id.twitter_icon_box);

      setUpSpeakerSocialIcon(
          speaker,
          twitterIcon,
          speaker.getTwitterUrl(),
          UIUtils.TWITTER_COMMON_NAME,
          UIUtils.TWITTER_PACKAGE_NAME);

      setUpSpeakerSocialIcon(
          speaker,
          plusOneIcon,
          speaker.getPlusoneUrl(),
          UIUtils.GOOGLE_PLUS_COMMON_NAME,
          UIUtils.GOOGLE_PLUS_PACKAGE_NAME);

      // A speaker may have both a Twitter and GPlus page, only a Twitter page or only a
      // GPlus page, or neither. By default, align the Twitter icon to the right and the GPlus
      // icon to its left. If only a single icon is displayed, align it to the right.
      determineSocialIconPlacement(plusOneIcon, twitterIcon);

      if (!TextUtils.isEmpty(speaker.getImageUrl()) && mSpeakersImageLoader != null) {
        mSpeakersImageLoader.loadImage(speaker.getImageUrl(), speakerImageView);
      }

      speakerHeaderView.setText(speakerHeader);
      speakerImageView.setContentDescription(
          getString(R.string.speaker_googleplus_profile, speakerHeader));
      UIUtils.setTextMaybeHtml(speakerAbstractView, speaker.getAbstract());

      if (!TextUtils.isEmpty(speaker.getUrl())) {
        speakerImageView.setEnabled(true);
        speakerImageView.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                Intent speakerProfileIntent =
                    new Intent(Intent.ACTION_VIEW, Uri.parse(speaker.getUrl()));
                speakerProfileIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
                UIUtils.preferPackageForIntent(
                    getActivity(), speakerProfileIntent, UIUtils.GOOGLE_PLUS_PACKAGE_NAME);
                startActivity(speakerProfileIntent);
              }
            });
      } else {
        speakerImageView.setEnabled(false);
        speakerImageView.setOnClickListener(null);
      }

      speakersGroup.addView(speakerView);
      hasSpeakers = true;
    }

    speakersGroup.setVisibility(hasSpeakers ? View.VISIBLE : View.GONE);
    updateEmptyView(data);
  }
  // Run after each indicator change.
  private void apply() {
    if (mWifiGroup == null) return;

    mVpn.setVisibility(mVpnVisible ? View.VISIBLE : View.GONE);
    if (DEBUG) Log.d(TAG, String.format("vpn: %s", mVpnVisible ? "VISIBLE" : "GONE"));

    if (mEthernetVisible) {
      mEthernet.setImageResource(mEthernetIconId);
      mEthernetDark.setImageResource(mEthernetIconId);
      mEthernetGroup.setContentDescription(mEthernetDescription);
      mEthernetGroup.setVisibility(View.VISIBLE);
    } else {
      mEthernetGroup.setVisibility(View.GONE);
    }

    if (DEBUG) Log.d(TAG, String.format("ethernet: %s", (mEthernetVisible ? "VISIBLE" : "GONE")));

    if (mWifiVisible) {
      mWifi.setImageResource(mWifiStrengthId);
      mWifiDark.setImageResource(mWifiStrengthId);
      mWifiGroup.setContentDescription(mWifiDescription);
      mWifiGroup.setVisibility(View.VISIBLE);
    } else {
      mWifiGroup.setVisibility(View.GONE);
    }

    if (DEBUG)
      Log.d(
          TAG,
          String.format("wifi: %s sig=%d", (mWifiVisible ? "VISIBLE" : "GONE"), mWifiStrengthId));

    boolean anyMobileVisible = false;
    int firstMobileTypeId = 0;
    for (PhoneState state : mPhoneStates) {
      if (state.apply(anyMobileVisible)) {
        if (!anyMobileVisible) {
          firstMobileTypeId = state.mMobileTypeId;
          anyMobileVisible = true;
        }
      }
    }

    if (mIsAirplaneMode) {
      mAirplane.setImageResource(mAirplaneIconId);
      mAirplane.setContentDescription(
          mAirplaneContentDescription != 0
              ? mContext.getString(mAirplaneContentDescription)
              : null);
      mAirplane.setVisibility(View.VISIBLE);
    } else {
      mAirplane.setVisibility(View.GONE);
    }

    if (mIsAirplaneMode && mWifiVisible) {
      mWifiAirplaneSpacer.setVisibility(View.VISIBLE);
    } else {
      mWifiAirplaneSpacer.setVisibility(View.GONE);
    }

    if (((anyMobileVisible && firstMobileTypeId != 0) || mNoSimsVisible) && mWifiVisible) {
      mWifiSignalSpacer.setVisibility(View.VISIBLE);
    } else {
      mWifiSignalSpacer.setVisibility(View.GONE);
    }

    mNoSims.setVisibility(mNoSimsVisible ? View.VISIBLE : View.GONE);
    mNoSimsDark.setVisibility(mNoSimsVisible ? View.VISIBLE : View.GONE);

    boolean anythingVisible =
        mNoSimsVisible
            || mWifiVisible
            || mIsAirplaneMode
            || anyMobileVisible
            || mVpnVisible
            || mEthernetVisible;
    setPaddingRelative(0, 0, anythingVisible ? mEndPadding : mEndPaddingNothingVisible, 0);
  }
  @Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    if (data != null && data.moveToFirst()) {
      long movieId = ContentUris.parseId(mUri);
      title = data.getString(COL_MOVIE_TITLE);
      // fetch meta data from async task
      new TmdbApiTask(getActivity(), textView_runtime).execute(String.valueOf(movieId));

      // fetch trailer list
      new TmdbApiTask(
              getActivity(),
              listView_trailers,
              Constants.FETCH_VIDEOS,
              new TmdbApiTask.AsyncResponse() {
                @Override
                public void processFinish(String result) {
                  listView_trailers.setEmptyView(textView_empty_trailer_list);
                  if (mShareActionProvider != null) {
                    Intent shareIntent = createShareVideoIntent(result);
                    mShareActionProvider.setShareIntent(shareIntent);
                  }
                }
              })
          .execute(String.valueOf(movieId));

      // fetch reviews list
      new TmdbApiTask(
              getActivity(),
              linearListView,
              Constants.FETCH_REVIEWS,
              new TmdbApiTask.AsyncResponse() {
                @Override
                public void processFinish(String str) {
                  progressBar.setVisibility(View.GONE);
                  linearListView.setEmptyView(textView_empty_list_item);
                }
              })
          .execute(String.valueOf(movieId));

      if (getActivity().findViewById(R.id.gridView_tiles) == null) {
        // single pane
        getActivity().setTitle(title);
      }

      String year = data.getString(COL_MOVIE_DATE);

      textView_release_year.setText(title + " \n\n" + Utility.getYear(year));

      String overview = data.getString(COL_MOVIE_SYNOPSIS);
      textView_overview.setText(overview);

      String rating = data.getString(COL_MOVIE_RATING);
      textView_vote_average.setText(rating + "/10");

      String poster = data.getString(COL_MOVIE_POSTER);

      imageView_poster_detail.setContentDescription(title);
      Picasso.with(getContext())
          .load(Utility.getPoster_path(Constants.DEFAULT_POSTER_WIDTH, poster))
          .into(imageView_poster_detail);

      Boolean fav = data.getInt(COL_MOVIE_FAV) > 0;
      if (fav) {
        myFab.setSelected(true);
        myFab.setImageResource(R.drawable.ic_favorite_black_24dp);
      } else {
        myFab.setSelected(false);
        myFab.setImageResource(R.drawable.ic_favorite_border_black_24dp);
      }
    }
  }