Example #1
1
 public int getIdFromName(String instanceName) {
   String res = mActivity.getPackageName() + ":id/" + instanceName;
   int id = mActivity.getResources().getIdentifier(res, "id", mActivity.getPackageName());
   if (id == 0) {
     for (ViewGroup viewgrp : mViewGroup) {
       id = viewgrp.getResources().getIdentifier(res, "id", mActivity.getPackageName());
       if (id != 0) break;
     }
   }
   return id;
 }
Example #2
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // Get the data item for this position
    File file = getItem(position);
    // Check if an existing view is being reused, otherwise inflate the view
    ViewHolder viewHolder; // view lookup cache stored in tag
    if (convertView == null) {
      viewHolder = new ViewHolder();
      LayoutInflater inflater = LayoutInflater.from(getContext());
      convertView = inflater.inflate(R.layout.contact_item, parent, false);
      viewHolder.name = (TextView) convertView.findViewById(R.id.name);
      viewHolder.createdAt = (TextView) convertView.findViewById(R.id.occupation);
      viewHolder.image = (ImageView) convertView.findViewById(R.id.image);
      convertView.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }
    // Populate the data into the template view using the data object
    viewHolder.name.setText(file.getFileName());
    SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
    try {
      Date date = isoFormat.parse(file.getCreatedAt());
      SimpleDateFormat outputDateFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.US);
      viewHolder.createdAt.setText(outputDateFormat.format(date));
    } catch (ParseException e) {
      viewHolder.createdAt.setText(file.getCreatedAt());
    }

    int[] images = {R.drawable.file_icon, R.drawable.image_icon};
    int selected = images[file.getFileName().charAt(0) % 2];

    viewHolder.image.setImageBitmap(BitmapFactory.decodeResource(parent.getResources(), selected));
    // Return the completed view to render on screen
    return convertView;
  }
  @Override
  public View getView(int pos, View convertView, ViewGroup parent) {
    LinearLayout alertView = null;
    Floor flo = getItem(pos);
    // Now inflate the view
    if (convertView == null) {
      alertView = new LinearLayout(getContext());
      String inflater = Context.LAYOUT_INFLATER_SERVICE;
      LayoutInflater layInflate;
      layInflate = (LayoutInflater) getContext().getSystemService(inflater);
      layInflate.inflate(resource, alertView, true);
    } else {
      alertView = (LinearLayout) convertView;
    }

    // Get text boxes
    ImageView artIcon = (ImageView) alertView.findViewById(R.id.buildingIcon);
    TextView nameText = (TextView) alertView.findViewById(R.id.buildingName);

    // Assign correct data from the alert object
    nameText.setText(flo.floorName);
    // Assign default image
    Bitmap b = BitmapFactory.decodeResource(parent.getResources(), R.drawable.building_default);

    if (flo.floorName == "Loading...") {
      b = null;
    }

    artIcon.setImageBitmap(b);

    return alertView;
  }
Example #4
0
  public View getView(int position, View convertView, ViewGroup parent) {

    // Declare Variables
    ImageView imgImg;
    TextView txtTitle;
    TextView txtContenido;
    TextView txtdate;
    // http://developer.android.com/intl/es/reference/android/view/LayoutInflater.html
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View itemView = inflater.inflate(R.layout.list_row, parent, false);

    // Locate the TextViews in listview_item.xml
    imgImg = (ImageView) itemView.findViewById(R.id.imagen_single_post_circuito);
    txtTitle = (TextView) itemView.findViewById(R.id.tv_titulo_single_post_circuito);
    txtContenido = (TextView) itemView.findViewById(R.id.tv_contenido_single_post_circuito);
    txtdate = (TextView) itemView.findViewById(R.id.txtdate);
    // Capture position and set to the TextViews
    imgImg.setImageDrawable(parent.getResources().getDrawable(R.drawable.ic_launcher));
    txtTitle.setText(titulos[position]);
    txtdate.setText(date);
    txtContenido.setText(contenido[position]);

    return itemView;
  }
 private static TextView createField(
     @NonNull LayoutInflater inflater,
     @NonNull ViewGroup parent,
     @NonNull final FormField field,
     @NonNull final String value,
     boolean readOnly,
     @NonNull View.OnClickListener onClickListener) {
   final TextView textView =
       (TextView) inflater.inflate(R.layout.edit_user_profile_field, parent, false);
   final SpannableString formattedValue = new SpannableString(value);
   formattedValue.setSpan(
       new ForegroundColorSpan(parent.getResources().getColor(R.color.edx_grayscale_neutral_dark)),
       0,
       formattedValue.length(),
       Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
   textView.setText(
       ResourceUtil.getFormattedString(
           parent.getResources(),
           R.string.edit_user_profile_field,
           new HashMap<String, CharSequence>() {
             {
               put("label", field.getLabel());
               put("value", formattedValue);
             }
           }));
   Context context = parent.getContext();
   TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
       textView,
       null,
       null,
       new IconDrawable(context, FontAwesomeIcons.fa_angle_right)
           .colorRes(context, R.color.edx_grayscale_neutral_light)
           .sizeDp(context, 24),
       null);
   if (readOnly) {
     textView.setEnabled(false);
     textView.setBackgroundColor(
         textView.getResources().getColor(R.color.edx_grayscale_neutral_x_light));
   } else {
     textView.setOnClickListener(onClickListener);
   }
   parent.addView(textView);
   return textView;
 }
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup parent) {
    Log.d(TAG, "onCreateViewHolder");

    sDefaultBackgroundColor = parent.getResources().getColor(R.color.default_background);
    sSelectedBackgroundColor = parent.getResources().getColor(R.color.selected_background);
    mDefaultCardImage = parent.getResources().getDrawable(R.drawable.movie);

    ImageCardView cardView =
        new ImageCardView(parent.getContext()) {
          @Override
          public void setSelected(boolean selected) {
            updateCardBackgroundColor(this, selected);
            super.setSelected(selected);
          }
        };

    cardView.setFocusable(true);
    cardView.setFocusableInTouchMode(true);
    updateCardBackgroundColor(cardView, false);
    return new ViewHolder(cardView);
  }
Example #7
0
 /** adds a circular drop shadow to the avatar's parent view (Lollipop+ only) */
 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
 private void addDropShadowToAvatar() {
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
     mAvatarFrame.setOutlineProvider(
         new ViewOutlineProvider() {
           @Override
           public void getOutline(View view, Outline outline) {
             outline.setOval(0, 0, view.getWidth(), view.getHeight());
           }
         });
     mAvatarFrame.setElevation(
         mAvatarFrame.getResources().getDimensionPixelSize(R.dimen.card_elevation));
   }
 }
  private boolean setFieldsBySection(ViewGroup viewG, int fldSect, int index) {

    if (weatherControl == null || weatherControl.get(index) == null) {
      return false;
    }

    int dayOfWeek =
        getResources()
            .getIdentifier("dayOfWeek" + fldSect, "id", viewG.getContext().getPackageName());
    int tempNum =
        getResources()
            .getIdentifier("temp_num" + fldSect, "id", viewG.getContext().getPackageName());
    int windImg =
        getResources()
            .getIdentifier("wind_image" + fldSect, "id", viewG.getContext().getPackageName());
    int predominant =
        getResources()
            .getIdentifier(
                "weather_predominant" + fldSect, "id", viewG.getContext().getPackageName());

    // Temperature
    ((TextView) viewG.findViewById(dayOfWeek))
        .setText(this.weatherControl.get(index).getDayOfWeekAmPm());

    ((TextView) viewG.findViewById(tempNum)).setText(weatherControl.get(index).getTemperature());

    // Wind
    int windId =
        viewG
            .getResources()
            .getIdentifier(
                "sailing_wind" + weatherControl.get(index).getWindIconLevel().toLowerCase(),
                "drawable",
                "com.yanas.mobileapp.weathercast");

    if (windId != 0) {
      ((ImageView) viewG.findViewById(windImg)).setImageResource(windId);
    }

    LayerDrawable layerDr =
        new LayerDrawable(
            DisplayWeatherInfoAccessPageFragment.getGraphicWeather(
                viewG, weatherControl.get(index), predominant));
    ((ImageView) viewG.findViewById(predominant)).setImageDrawable(layerDr);

    return true;
  }
 @Override
 public View getGroupView(
     int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
   PrefixVideoGroup data = dataSource.get(groupPosition);
   PrefixGroupItem item = null;
   if (convertView == null) {
     int height = (int) (80 * parent.getResources().getDisplayMetrics().density);
     item = new PrefixGroupItem(parent.getContext());
     item.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, height));
     item.setOnClickListener(this);
   } else {
     item = (PrefixGroupItem) convertView;
   }
   item.setTag(groupPosition);
   item.update(data.type, data.title);
   return item;
 }
  /**
   * Call this method when asynchronous refresh has completed to reset the state of the Pull to
   * Refresh view
   */
  public void onRefreshCompleted() {
    pullToRefreshState = PullToRefreshState.NONE;
    this.refreshable = true;
    disableLoadingView();

    if (refreshViewParent != null) {
      refreshViewParent.getLayoutParams().height =
          (int) refreshViewParent.getResources().getDimension(R.dimen.cu__ptr_loading_image_height);
      refreshViewParent.setLayoutParams(refreshViewParent.getLayoutParams());
      refreshViewParent.postInvalidate();

      if (layoutEventListener != null)
        layoutEventListener.onOpenedDistanceChanged(refreshViewParent.getLayoutParams().height);

      onReleasedPullToRefreshViewBeforeThreshold();
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    container.setLayoutDirection(container.getResources().getConfiguration().getLayoutDirection());
    // initialize the inflater
    mInflater = inflater;

    View rootView = mInflater.inflate(R.layout.manage_applications_content, container, false);
    mContentContainer = container;
    mRootView = rootView;

    mViewPager = (ViewPager) rootView.findViewById(R.id.pager);
    MyPagerAdapter adapter = new MyPagerAdapter();
    mViewPager.setAdapter(adapter);
    mViewPager.setOnPageChangeListener(adapter);
    PagerTabStrip tabs = (PagerTabStrip) rootView.findViewById(R.id.tabs);
    tabs.setTabIndicatorColorResource(android.R.color.holo_blue_light);

    // We have to do this now because PreferenceFrameLayout looks at it
    // only when the view is added.
    if (container instanceof PreferenceFrameLayout) {
      ((PreferenceFrameLayout.LayoutParams) rootView.getLayoutParams()).removeBorders = true;
    }

    if (savedInstanceState != null && savedInstanceState.getBoolean(EXTRA_RESET_DIALOG)) {
      buildResetDialog();
    }

    if (savedInstanceState == null) {
      // Reverse the tab list once if the language is RTL.
      if (container.isLayoutRtl()) {
        Collections.reverse(mTabs);
      }
      // First time init: make sure view pager is showing the correct tab.
      for (int i = 0; i < mTabs.size(); i++) {
        TabInfo tab = mTabs.get(i);
        if (tab.mListType == mDefaultListType) {
          mViewPager.setCurrentItem(i);
          break;
        }
      }
    }

    return rootView;
  }
 @Override
 public View getChildView(
     int groupPosition,
     int childPosition,
     boolean isLastChild,
     View convertView,
     ViewGroup parent) {
   PrefixVideoChildItem item = null;
   if (convertView == null) {
     int height = (int) (100 * parent.getResources().getDisplayMetrics().density);
     item = new PrefixVideoChildItem(parent.getContext());
     item.setOnClickListener(clickListener);
     item.viewActionContainer.setOnClickListener(clickListener);
     item.pgs.setOnClickListener(clickListener);
     item.setLayoutParams(new AbsListView.LayoutParams(LayoutParams.MATCH_PARENT, height));
   } else {
     item = (PrefixVideoChildItem) convertView;
   }
   item.update(dataSource.get(groupPosition).items.get(childPosition));
   return item;
 }
  @Override
  public View getView(int position, View convertView, final ViewGroup parent) {
    final Library library = this.getItem(position);
    final ViewHolder holder;

    if (convertView == null) {
      convertView = inflater.inflate(R.layout.listitem_opensource, null);

      holder = new ViewHolder();
      holder.libraryName = (TextView) convertView.findViewById(R.id.libraryName);
      holder.libraryCreator = (TextView) convertView.findViewById(R.id.libraryCreator);
      holder.libraryDescription = (TextView) convertView.findViewById(R.id.libraryDescription);

      holder.libraryBottomDivider = convertView.findViewById(R.id.libraryBottomDivider);
      holder.libraryBottomContainer = convertView.findViewById(R.id.libraryBottomContainer);

      holder.libraryVersion = (TextView) convertView.findViewById(R.id.libraryVersion);
      holder.libraryLicense = (TextView) convertView.findViewById(R.id.libraryLicense);

      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    // Set texts
    holder.libraryName.setText(library.getLibraryName());
    holder.libraryCreator.setText(library.getAuthor());
    if (TextUtils.isEmpty(library.getLibraryDescription())) {
      holder.libraryDescription.setText(library.getLibraryDescription());
    } else {
      holder.libraryDescription.setText(Html.fromHtml(library.getLibraryDescription()));
    }

    // Set License or Version Text
    if (TextUtils.isEmpty(library.getLibraryVersion())
            && library.getLicense() != null
            && TextUtils.isEmpty(library.getLicense().getLicenseName())
        || (!showVersion && !showLicense)) {
      holder.libraryBottomDivider.setVisibility(View.GONE);
      holder.libraryBottomContainer.setVisibility(View.GONE);
    } else {
      holder.libraryBottomDivider.setVisibility(View.VISIBLE);
      holder.libraryBottomContainer.setVisibility(View.VISIBLE);

      if (!TextUtils.isEmpty(library.getLibraryVersion()) && showVersion) {
        holder.libraryVersion.setText(library.getLibraryVersion());
      }
      if (library.getLicense() != null
          && !TextUtils.isEmpty(library.getLicense().getLicenseName())
          && showLicense) {
        holder.libraryLicense.setText(library.getLicense().getLicenseName());
      }
    }

    // Define onClickListener
    if (!TextUtils.isEmpty(library.getAuthorWebsite())) {
      holder.libraryCreator.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View view) {
              try {
                Intent browserIntent =
                    new Intent(Intent.ACTION_VIEW, Uri.parse(library.getAuthorWebsite()));
                parent.getContext().startActivity(browserIntent);
              } catch (Exception ex) {
              }
            }
          });
    }

    if (!TextUtils.isEmpty(library.getLibraryWebsite())) {
      holder.libraryDescription.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              try {
                Intent browserIntent =
                    new Intent(Intent.ACTION_VIEW, Uri.parse(library.getLibraryWebsite()));
                parent.getContext().startActivity(browserIntent);
              } catch (Exception ex) {
              }
            }
          });
    }

    if (library.getLicense() != null
        && !TextUtils.isEmpty((library.getLicense().getLicenseWebsite()))) {
      holder.libraryBottomContainer.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View view) {
              try {
                if (showLicenseDialog
                    && !TextUtils.isEmpty(library.getLicense().getLicenseDescription())) {
                  AlertDialog.Builder builder = new AlertDialog.Builder(parent.getContext());
                  builder.setMessage(Html.fromHtml(library.getLicense().getLicenseDescription()));
                  builder.create().show();
                } else {
                  Intent browserIntent =
                      new Intent(
                          Intent.ACTION_VIEW, Uri.parse(library.getLicense().getLicenseWebsite()));
                  parent.getContext().startActivity(browserIntent);
                }
              } catch (Exception ex) {
              }
            }
          });
    }

    int padding = parent.getResources().getDimensionPixelSize(R.dimen.card_padding_openSource);
    if (position + 1 == getCount()) {
      convertView.setPadding(padding, padding, padding, padding);
    } else {
      convertView.setPadding(padding, padding, padding, 0);
    }

    return convertView;
  }