Example usage for android.content Context LAYOUT_INFLATER_SERVICE

List of usage examples for android.content Context LAYOUT_INFLATER_SERVICE

Introduction

In this page you can find the example usage for android.content Context LAYOUT_INFLATER_SERVICE.

Prototype

String LAYOUT_INFLATER_SERVICE

To view the source code for android.content Context LAYOUT_INFLATER_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.view.LayoutInflater for inflating layout resources in this context.

Usage

From source file:org.sirimangalo.meditationplus.AdapterMed.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    View rowView;//w  w  w.j  a  va  2  s .  c o  m

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.list_item_med, parent, false);
    } else {
        rowView = convertView;
    }

    JSONObject p = values.get(position);

    TextView walk = (TextView) rowView.findViewById(R.id.one_walking);
    TextView sit = (TextView) rowView.findViewById(R.id.one_sitting);
    ImageView status = (ImageView) rowView.findViewById(R.id.one_status);
    TextView name = (TextView) rowView.findViewById(R.id.one_med);
    ImageView flag = (ImageView) rowView.findViewById(R.id.one_flag);

    View anuView = rowView.findViewById(R.id.anumodana_shell);
    TextView anuText = (TextView) rowView.findViewById(R.id.anumodana);

    try {
        String wo = p.getString("walking");
        String so = p.getString("sitting");
        int wi = Integer.parseInt(wo);
        int si = Integer.parseInt(so);
        int ti = Integer.parseInt(p.getString("start"));
        int ei = Integer.parseInt(p.getString("end"));

        long nowL = System.currentTimeMillis() / 1000;

        int now = (int) nowL;

        boolean finished = false;

        String ws = "0";
        String ss = "0";

        if (ei > now) {

            float secs = now - ti;

            if (secs > wi * 60 || wi == 0) { //walking done
                float ssecs = (int) (secs - (wi * 60));
                if (ssecs < si * 60) // still sitting
                    ss = Integer.toString((int) Math.floor(si - ssecs / 60));
                status.setImageResource(R.drawable.sitting_icon);
            } else { // still walking
                ws = Integer.toString((int) Math.floor(wi - secs / 60));
                ss = so;
                status.setImageResource(R.drawable.walking_icon);
            }

            ws += "/" + wo;
            ss += "/" + so;
        } else {
            ws = wo;
            ss = so;

            double age = 1 - (now - ei) / MAX_AGE;

            String ageColor = Integer.toHexString((int) (255 * age));

            if (ageColor.length() == 1)
                ageColor = "0" + ageColor;

            int alpha = Color.parseColor("#" + ageColor + "000000");

            walk.setTextColor(alpha);
            sit.setTextColor(alpha);
            name.setTextColor(alpha);
            status.setAlpha((float) age);
            flag.setAlpha((float) age);

        }

        walk.setText(ws);
        sit.setText(ss);

        if (p.has("country")) {
            int id = context.getResources().getIdentifier("flag_" + p.getString("country").toLowerCase(),
                    "drawable", context.getPackageName());
            flag.setImageResource(id);
            flag.setVisibility(View.VISIBLE);
        }

        final String username = p.getString("username");
        final String edit = p.getString("can_edit");
        name.setText(username);

        name.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                context.showProfile(username);
            }
        });

        String type = p.getString("type");
        if ("love".equals(type))
            status.setImageResource(R.drawable.love_icon);

        String anu = p.getString("anumodana");
        if (!anu.equals("0"))
            anuText.setText(anu);

        if (p.getString("anu_me").equals("1")) {
            anuText.setTextColor(0xFF00BB00);
            anuText.setTypeface(null, Typeface.BOLD);
        }

        final String sid = p.getString("sid");

        anuView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.d(TAG, "anu clicked");
                SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
                String loggedUsername = prefs.getString("username", "");
                String loginToken = prefs.getString("login_token", "");
                ArrayList<NameValuePair> nvp = new ArrayList<NameValuePair>();
                nvp.add(new BasicNameValuePair("form_id", "anumed_" + sid));
                nvp.add(new BasicNameValuePair("login_token", loginToken));
                nvp.add(new BasicNameValuePair("submit", "Refresh"));
                nvp.add(new BasicNameValuePair("username", loggedUsername));
                nvp.add(new BasicNameValuePair("source", "android"));
                PostTaskRunner postTask = new PostTaskRunner(postHandler, context);
                postTask.doPostTask(nvp);

            }
        });

    } catch (Exception e) {
        e.printStackTrace();
    }
    return rowView;
}

From source file:com.hybris.mobile.app.commerce.adapter.StoreListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {

    View rowView;/*w w  w  .  ja va 2  s  .c om*/

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.item_store_locator, parent, false);
        rowView.setTag(new ViewHolder(rowView));
    } else {
        rowView = convertView;
    }

    ViewHolder viewHolder = (ViewHolder) rowView.getTag();

    // Content description
    viewHolder.storePosition.setContentDescription("storePosition_" + position);
    viewHolder.name.setContentDescription("name_" + position);
    viewHolder.description.setContentDescription("description_" + position);
    viewHolder.tel.setContentDescription("tel_" + position);
    viewHolder.directions.setContentDescription("directions_" + position);
    viewHolder.distance.setContentDescription("distance_" + position);

    final PointOfService store = getItem(position);

    // Setting the values
    viewHolder.storePosition.setText(position + 1 + ". ");
    viewHolder.name.setText(store.getName());
    viewHolder.description.setText(store.getAddress().getFormattedAddress());
    viewHolder.tel.setText(store.getAddress().getPhone());
    viewHolder.distance.setText(store.getFormattedDistance());

    // Distance intent
    viewHolder.directions.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mDeviceLocation != null && mDeviceLocation.getDeviceLocation() != null) {
                LocationUtils.sendDirectionsIntent(getContext(),
                        new LatLng(mDeviceLocation.getDeviceLocation().getLatitude(),
                                mDeviceLocation.getDeviceLocation().getLongitude()),
                        new LatLng(store.getGeoPoint().getLatitude(), store.getGeoPoint().getLongitude()));
            } else {
                LocationUtils.sendDirectionsIntent(getContext(), null,
                        new LatLng(store.getGeoPoint().getLatitude(), store.getGeoPoint().getLongitude()));
            }
        }
    });

    // Center map when clicking on the name and description
    viewHolder.name.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            centerMap(store);
        }
    });

    viewHolder.description.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            centerMap(store);
        }
    });

    return rowView;
}

From source file:com.hybris.mobile.app.commerce.adapter.CategoryListPreferenceAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    View rowView;/*  w ww.  j a va  2 s  .  c o  m*/
    CategoryHierarchy category = getItem(position);

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.item_category_offline_pref, parent, false);
        rowView.setTag(new ViewHolder(rowView));
    } else {
        rowView = convertView;
    }

    final ViewHolder viewHolder = (ViewHolder) rowView.getTag();

    viewHolder.categoryName.setText(category.getName());
    viewHolder.category = category;
    viewHolder.position = position;
    viewHolder.checkbox.setChecked(getCheckedStatus(category.getId()));

    // We put a padding for the subcategories
    viewHolder.categoryName.setPadding(getNbParents(category) * 20, 0, 0, 0);

    return rowView;
}

From source file:it.crs4.most.ehrlib.widgets.DvBooleanWidget.java

/**
 * Instantiates a new {@link DvBooleanWidget}
 *
 * @param provider the widget provider/*  w  ww .ja va2s  .com*/
 * @param name the name of this widget
 * @param path the path of the {@link DvBoolean} mapped on this widget
 * @param attributes the attributes of the {@link DvBoolean} mapped on this widget
 * @param parentIndex the parent index
 */
public DvBooleanWidget(WidgetProvider provider, String name, String path, JSONObject attributes,
        int parentIndex) {
    super(provider, name, new DvBoolean(path, attributes), parentIndex);

    LayoutInflater inflater = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.dv_boolean, null);

    _root_view = view;

    _chkBoolean = (CheckBox) _root_view.findViewById(R.id.check_is_selected);

    this.updateLabelsContent();

    _help = (ImageView) _root_view.findViewById(R.id.image_help);

    toolTipRelativeLayout = (ToolTipRelativeLayout) _root_view
            .findViewById(R.id.activity_main_tooltipRelativeLayout);

    _help.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (myToolTipView == null) {
                myToolTipView = toolTipRelativeLayout.showToolTipForView(toolTip, _help);
            } else {
                myToolTipView.remove();
                myToolTipView = null;

            }
        }
    });

}

From source file:com.hybris.mobile.app.commerce.adapter.VariantAdapter.java

/**
 * Create the view for spinner item//from w w  w. j a v  a 2 s.c  om
 *
 * @param position
 * @param convertView
 * @param parent
 * @return
 */
public View getCustomView(int position, View convertView, ViewGroup parent) {

    View rowView;

    if (convertView == null) {
        LayoutInflater inflater = (LayoutInflater) getContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.item_product_variant, parent, false);
    } else {
        rowView = convertView;
    }

    VariantOption productVariant = getItem(position);

    TextView productVariantName = (TextView) rowView.findViewById(R.id.product_variant_name);
    final ImageView productVariantImage = (ImageView) rowView.findViewById(R.id.product_variant_image);
    final ProgressBar productVariantProgressBar = (ProgressBar) rowView
            .findViewById(R.id.product_variant_image_loading);

    productVariantName.setText(
            ((List<VariantOptionQualifier>) productVariant.getVariantOptionQualifiers()).get(0).getValue());

    if (((List<VariantOptionQualifier>) productVariant.getVariantOptionQualifiers()).get(0)
            .getImage() != null) { // Loading the product image
        if (CommerceApplication.isOnline()) {

            if (StringUtils
                    .isNotBlank(((List<VariantOptionQualifier>) productVariant.getVariantOptionQualifiers())
                            .get(0).getImage().getUrl())) {

                CommerceApplication.getContentServiceHelper().loadImage(
                        ((List<VariantOptionQualifier>) productVariant.getVariantOptionQualifiers()).get(0)
                                .getImage().getUrl(),
                        null, productVariantImage, 0, 0, true, new OnRequestListener() {

                            @Override
                            public void beforeRequest() {
                                productVariantImage.setImageResource(android.R.color.transparent);
                                productVariantImage.setVisibility(View.GONE);
                                productVariantProgressBar.setVisibility(View.VISIBLE);
                            }

                            @Override
                            public void afterRequestBeforeResponse() {

                            }

                            @Override
                            public void afterRequest(boolean isDataSynced) {
                                productVariantImage.setVisibility(View.VISIBLE);
                                productVariantProgressBar.setVisibility(View.GONE);
                            }
                        }, true);
            }

        } else {
            Log.i(TAG, "Application offline, displaying no image for variant " + productVariant.getCode());
            productVariantImage
                    .setImageDrawable(getContext().getResources().getDrawable(R.drawable.no_image_product));
            productVariantImage.setVisibility(View.VISIBLE);
        }

    }

    return rowView;
}

From source file:biz.easymenu.easymenung.ItemFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    li = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.setCancelable(false);
    rpc = new Emrpc(getActivity());
    emp = new EmPrefs(getActivity());
    sid = emp.getSid();//w w w .  j a v  a 2s  .  c om
}

From source file:it.crs4.most.ehrlib.widgets.DvTextWidget.java

/**
 * Instantiates a new {@link DvTextWidget}
 *
 * @param provider the widget provider/*w ww  .j  a va 2  s.  com*/
 * @param name the name of this widget
 * @param path the path of the {@link DvText} mapped on this widget
 * @param attributes the attributes of the {@link DvText} mapped on this widget
 * @param parentIndex the parent index
 */
public DvTextWidget(WidgetProvider provider, String name, String path, JSONObject attributes, int parentIndex) {
    super(provider, name, new DvText(path, attributes), parentIndex);

    LayoutInflater inflater = (LayoutInflater) _context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.dv_text, null);

    _root_view = view;

    _title = (TextView) _root_view.findViewById(R.id.txt_title);
    _txtvalidity = (TextView) _root_view.findViewById(R.id.txt_validity);
    _input = (EditText) _root_view.findViewById(R.id.txt_text);

    _input.setMovementMethod(new ScrollingMovementMethod());

    this.updateLabelsContent();

    _help = (ImageView) _root_view.findViewById(R.id.image_help);

    toolTipRelativeLayout = (ToolTipRelativeLayout) _root_view
            .findViewById(R.id.activity_main_tooltipRelativeLayout);

    _help.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (myToolTipView == null) {
                myToolTipView = toolTipRelativeLayout.showToolTipForView(toolTip, _help);
                //myToolTipView.setOnToolTipViewClickedListener(DvTextWidget.this);
            } else {
                myToolTipView.remove();
                myToolTipView = null;

            }
        }
    });

}

From source file:biz.easymenu.easymenung.LoginFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    li = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.setCancelable(false);
    emp = new EmPrefs(getActivity());
    rpc = new Emrpc(getActivity());
}

From source file:com.mobeta.dslv.ResourceDragSortCursorAdapter.java

/**
 * Constructor the enables auto-requery.
 *
 * @deprecated This option is discouraged, as it results in Cursor queries
 * being performed on the application's UI thread and thus can cause poor
 * responsiveness or even Application Not Responding errors.  As an alternative,
 * use {@link android.app.LoaderManager} with a {@link android.content.CursorLoader}.
 *
 * @param context The context where the ListView associated with this adapter is running
 * @param layout resource identifier of a layout file that defines the views
 *            for this list item.  Unless you override them later, this will
 *            define both the item views and the drop down views.
 */// w  w w.  java2s  .c o m
@Deprecated
public ResourceDragSortCursorAdapter(Context context, int layout, Cursor c) {
    super(context, c);
    mLayout = mDropDownLayout = layout;
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}