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:com.aboveware.actionbar.honeycomb.ActionBarHelperHoneycomb.java

@Override
public void setRefreshActionItemState(boolean refreshing) {
    // On Honeycomb, we can set the state of the refresh button by giving it a
    // custom action view.
    if (mOptionsMenu == null) {
        shouldBeRefreshing = refreshing;
        return;//  w w  w  . j a  va2  s .com
    }

    final MenuItem refreshItem = mOptionsMenu.findItem(R.id.menu_refresh);
    if (refreshItem != null) {
        if (refreshing) {
            if (mRefreshIndeterminateProgressView == null) {
                LayoutInflater inflater = (LayoutInflater) getActionBarThemedContext()
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                mRefreshIndeterminateProgressView = inflater.inflate(R.layout.actionbar_indeterminate_progress,
                        null);
            }

            refreshItem.setActionView(mRefreshIndeterminateProgressView);
        } else {
            refreshItem.setActionView(null);
        }
    }
}

From source file:com.android.browser.GearsBaseDialog.java

/**
 * Inflate a given layout in a view (which has to be
 * a ViewGroup, e.g. LinearLayout).//from   w  w w.j a v a2s . c o m
 * This is used to share the basic dialog outline among
 * the different dialog types.
 */
void inflate(int layout, int viewID) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = findViewById(viewID);
    if (view != null) {
        try {
            ViewGroup viewGroup = (ViewGroup) view;
            inflater.inflate(layout, viewGroup);
        } catch (ClassCastException e) {
            String msg = "exception, the view (" + view + ")";
            msg += " is not a ViewGroup";
            Log.e(TAG, msg, e);
        } catch (InflateException e) {
            Log.e(TAG, "exception while inflating the layout", e);
        }
    } else {
        String msg = "problem, trying to inflate a non-existent view";
        msg += " (" + viewID + ")";
        Log.e(TAG, msg);
    }
}

From source file:com.github.omadahealth.circularbarpager.library.CircularBarPager.java

/**
 * Init the view by getting the {@link CircularBar},
 * the {@link android.support.v4.view.ViewPager} and the {@link com.viewpagerindicator.CirclePageIndicator}.
 * Init also some default values as PageTranformer etc...
 *//*from   w  w  w. jav  a  2s .  c o m*/
private void initializeView(AttributeSet attrs, int defStyleAttr) {
    if (attrs != null) {
        final TypedArray attributes = mContext.getTheme().obtainStyledAttributes(attrs,
                R.styleable.CircularViewPager, defStyleAttr, 0);

        boolean enableOnClick = attributes
                .getBoolean(R.styleable.CircularViewPager_progress_pager_on_click_enabled, false);
        isPaddingSet = false;

        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        RelativeLayout view = (RelativeLayout) inflater.inflate(R.layout.circularbar_view_pager, this);

        mCircularBar = (CircularBar) view.findViewById(R.id.circular_bar);
        mViewPager = (ViewPager) view.findViewById(R.id.view_pager);
        mCirclePageIndicator = (CirclePageIndicator) view.findViewById(R.id.circle_page_indicator);

        //Default init
        if (mCircularBar != null) {
            mCircularBar.loadStyledAttributes(attrs, defStyleAttr);
        }
        if (mViewPager != null) {
            mViewPager.setPageTransformer(false, new FadeViewPagerTransformer());
        }

        //If we enable onClick, ie. we can switch between pages with both a swipe and a touch
        //Touch just goes to the next page % number of pages
        if (enableOnClick) {
            final GestureDetectorCompat tapGestureDetector = new GestureDetectorCompat(getContext(),
                    new GestureDetector.SimpleOnGestureListener() {

                        @Override
                        public boolean onSingleTapConfirmed(MotionEvent e) {
                            mViewPager.setCurrentItem(
                                    (mViewPager.getCurrentItem() + 1) % mViewPager.getAdapter().getCount());
                            return super.onSingleTapConfirmed(e);
                        }
                    });
            if (mViewPager != null) {
                mViewPager.setOnTouchListener(new OnTouchListener() {
                    public boolean onTouch(View v, MotionEvent event) {
                        tapGestureDetector.onTouchEvent(event);
                        return false;
                    }
                });
            }

        }
    }
}

From source file:com.irccloud.android.fragment.IgnoreListFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getActivity();/*from w ww  .  ja v  a  2s. co m*/
    if (ctx == null)
        return null;

    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.recyclerview, null);
    recyclerView = v.findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new LinearLayoutManager(v.getContext()));
    empty = v.findViewById(android.R.id.empty);
    empty.setText(
            "You're not ignoring anyone at the moment.\n\nYou can ignore someone by tapping their nickname in the user list, long-pressing a message, or by using /ignore.");
    if (savedInstanceState != null && savedInstanceState.containsKey("cid")) {
        cid = savedInstanceState.getInt("cid");
        ignores = ServersList.getInstance().getServer(cid).raw_ignores;
        adapter = new IgnoresAdapter();
        recyclerView.setAdapter(adapter);
        if (adapter.getItemCount() > 0) {
            empty.setVisibility(View.GONE);
            recyclerView.setVisibility(View.VISIBLE);
        } else {
            empty.setVisibility(View.VISIBLE);
            recyclerView.setVisibility(View.GONE);
        }
    }
    Dialog d = new AlertDialog.Builder(ctx)
            .setTitle("Ignore list for " + ServersList.getInstance().getServer(cid).getName()).setView(v)
            .setPositiveButton("Add Ignore Mask", new AddClickListener())
            .setNegativeButton("Close", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    return d;
}

From source file:com.parking.swipelistview.sample.adapters.MallAdapter.java

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    final MallItem item = getItem(position);
    ViewHolder holder;//w  w  w .  j a  v  a  2s.com
    if (convertView == null) {
        LayoutInflater li = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = li.inflate(R.layout.mall_row, parent, false);
        holder = new ViewHolder();
        holder.ivImage = (ImageView) convertView.findViewById(R.id.example_row_iv_image);
        holder.tvMallName = (TextView) convertView.findViewById(R.id.example_row_tv_title);
        holder.tvInformation = (TextView) convertView.findViewById(R.id.example_row_tv_description);
        holder.slotAvailable = (TextView) convertView.findViewById(R.id.slot_available);
        holder.bAction1 = (ButtonRectangle) convertView.findViewById(R.id.example_row_b_action_1);
        holder.bAction2 = (ButtonRectangle) convertView.findViewById(R.id.example_row_b_action_2);

        if (login.getGroupUser().equalsIgnoreCase(Constants.USER)) {
            holder.bAction2.setVisibility(View.GONE);
        } else if (login.getGroupUser().equalsIgnoreCase(Constants.STAFF)) {
            holder.bAction2.setVisibility(View.VISIBLE);
            holder.bAction1.setVisibility(View.GONE);
        } else if (login.getGroupUser().equalsIgnoreCase(Constants.ADMIN)) {
            holder.bAction2.setVisibility(View.VISIBLE);
            holder.bAction1.setVisibility(View.VISIBLE);
        }

        //            holder.bAction3 = (ButtonRectangle) convertView.findViewById(R.id.example_row_b_action_3);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    ((SwipeListView) parent).recycle(convertView, position);

    holder.ivImage.setImageDrawable(item.getIcon());
    holder.tvMallName.setText(item.getName());
    holder.tvInformation.setText(item.getInformation());
    holder.slotAvailable.setText(item.getSlotAvailable());

    holder.bAction1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mallName = item.getName();
            MessageUtils messageUtils = new MessageUtils(ctx);
            messageUtils.showDialogConfirmationCallback(
                    ctx.getResources().getString(R.string.confirmation_dialog),
                    ctx.getResources().getString(R.string.message_confirm_booking), buttonCallbackBooking);
        }
    });

    holder.bAction2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mallName = item.getName();
            MessageUtils messageUtils = new MessageUtils(ctx);
            messageUtils.showDialogConfirmationCallback(
                    ctx.getResources().getString(R.string.confirmation_dialog),
                    ctx.getResources().getString(R.string.message_confirm_release), buttonCallbackRelease);
        }
    });

    //        holder.bAction3.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                Uri packageUri = Uri.parse("package:" + item.getPackageName());
    //                Intent uninstallIntent;
    //                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    //                    uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri);
    //                } else {
    //                    uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageUri);
    //                }
    //                context.startActivity(uninstallIntent);
    //            }
    //        });

    return convertView;
}

From source file:com.irccloud.android.fragment.WhoWasFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getActivity();/*from w ww.  j  a  v  a2s  . co m*/
    if (ctx == null)
        return null;

    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.recyclerview, null);
    recyclerView = v.findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new LinearLayoutManager(v.getContext()));
    empty = v.findViewById(android.R.id.empty);
    empty.setText("There was no such nickname");
    if (savedInstanceState != null && savedInstanceState.containsKey("event")) {
        event = new IRCCloudJSONObject(savedInstanceState.getString("event"));
        title = savedInstanceState.getString("title");
        data = event.getJsonNode("lines");
        adapter = new Adapter();
        recyclerView.setAdapter(adapter);
        if (adapter.getItemCount() > 0) {
            empty.setVisibility(View.GONE);
            recyclerView.setVisibility(View.VISIBLE);
        } else {
            empty.setVisibility(View.VISIBLE);
            recyclerView.setVisibility(View.GONE);
        }
    }
    AlertDialog.Builder b = new AlertDialog.Builder(ctx).setTitle(title).setView(v).setNegativeButton("Close",
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });

    AlertDialog d = b.create();
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    return d;
}

From source file:com.collcloud.frame.viewpager.PagerSlidingTabStrip.java

public PagerSlidingTabStrip(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    mInflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    setFillViewport(true);/*from   ww  w. jav a 2s  .  c  o m*/
    setWillNotDraw(false);

    tabsContainer = new LinearLayout(context);
    tabsContainer.setOrientation(LinearLayout.HORIZONTAL);
    tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(tabsContainer);

    DisplayMetrics dm = getResources().getDisplayMetrics();

    scrollOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, scrollOffset, dm);
    indicatorHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, indicatorHeight, dm);
    underlineHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, underlineHeight, dm);
    dividerPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerPadding, dm);
    tabPadding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, tabPadding, dm);
    dividerWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dividerWidth, dm);
    tabTextSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, tabTextSize, dm);

    // get system attrs (android:textSize and android:textColor)

    TypedArray a = context.obtainStyledAttributes(attrs, ATTRS);

    tabTextSize = a.getDimensionPixelSize(0, tabTextSize);
    tabTextColor = a.getColor(1, tabTextColor);

    a.recycle();

    // get custom attrs

    a = context.obtainStyledAttributes(attrs, R.styleable.PagerSlidingTabStrip);

    indicatorColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsIndicatorColor, indicatorColor);
    underlineColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsUnderlineColor, underlineColor);
    dividerColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsDividerColor, dividerColor);
    indicatorHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsIndicatorHeight,
            indicatorHeight);
    underlineHeight = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsUnderlineHeight,
            underlineHeight);
    dividerPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsDividerPadding,
            dividerPadding);
    tabPadding = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsTabPaddingLeftRight, tabPadding);
    tabBackgroundResId = a.getResourceId(R.styleable.PagerSlidingTabStrip_pstsTabBackground,
            tabBackgroundResId);
    shouldExpand = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsShouldExpand, shouldExpand);
    scrollOffset = a.getDimensionPixelSize(R.styleable.PagerSlidingTabStrip_pstsScrollOffset, scrollOffset);
    textAllCaps = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTextAllCaps, textAllCaps);

    pstsTextHighLightColor = a.getColor(R.styleable.PagerSlidingTabStrip_pstsTextHighLightColor, dividerColor);

    a.recycle();

    rectPaint = new Paint();
    rectPaint.setAntiAlias(true);
    rectPaint.setStyle(Style.FILL);

    dividerPaint = new Paint();
    dividerPaint.setAntiAlias(true);
    dividerPaint.setStrokeWidth(dividerWidth);

    defaultTabLayoutParams = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.MATCH_PARENT);
    expandedTabLayoutParams = new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1.0f);

    if (locale == null) {
        locale = getResources().getConfiguration().locale;
    }
}

From source file:com.android.calendar.event.CreateEventDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();
    final LayoutInflater layoutInflater = (LayoutInflater) activity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = layoutInflater.inflate(R.layout.create_event_dialog, null);

    mColor = view.findViewById(R.id.color);
    mCalendarName = (TextView) view.findViewById(R.id.calendar_name);
    mAccountName = (TextView) view.findViewById(R.id.account_name);

    mEventTitle = (EditText) view.findViewById(R.id.event_title);
    mEventTitle.addTextChangedListener(this);

    mDate = (TextView) view.findViewById(R.id.event_day);
    if (mDateString != null) {
        mDate.setText(mDateString);/*w w w  .j  ava 2 s  .  com*/
    }

    mAlertDialog = new AlertDialog.Builder(activity).setTitle(R.string.new_event_dialog_label).setView(view)
            .setPositiveButton(R.string.create_event_dialog_save, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    createAllDayEvent();
                    dismiss();
                }
            }).setNeutralButton(R.string.edit_label, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mController.sendEventRelatedEventWithExtraWithTitleWithCalendarId(this,
                            EventType.CREATE_EVENT, -1, mDateInMillis, mDateInMillis + DateUtils.DAY_IN_MILLIS,
                            0, 0, CalendarController.EXTRA_CREATE_ALL_DAY, -1, mEventTitle.getText().toString(),
                            mCalendarId);
                    dismiss();
                }
            }).setNegativeButton(android.R.string.cancel, null).create();

    return mAlertDialog;
}

From source file:com.irccloud.android.fragment.AcceptListFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getActivity();//  ww  w  .j a  v a2s.co  m
    if (ctx == null)
        return null;

    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.recyclerview, null);
    recyclerView = v.findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new LinearLayoutManager(v.getContext()));
    empty = v.findViewById(android.R.id.empty);
    empty.setText(
            "No accepted nicks.\n\nYou can accept someone by tapping their message request or by using /accept.");
    if (savedInstanceState != null && savedInstanceState.containsKey("cid")) {
        cid = savedInstanceState.getInt("cid");
        event = new IRCCloudJSONObject(savedInstanceState.getString("event"));
        acceptList = event.getJsonNode("nicks");
        adapter = new AcceptListAdapter();
        recyclerView.setAdapter(adapter);
        if (adapter.getItemCount() > 0) {
            empty.setVisibility(View.GONE);
            recyclerView.setVisibility(View.VISIBLE);
        } else {
            empty.setVisibility(View.VISIBLE);
            recyclerView.setVisibility(View.GONE);
        }
    }
    Server s = ServersList.getInstance().getServer(cid);
    String network = s.getName();
    if (network == null || network.length() == 0)
        network = s.getHostname();
    AlertDialog d = new AlertDialog.Builder(ctx).setTitle("Accept list for " + network).setView(v)
            .setPositiveButton("Add Nickname", new AddClickListener())
            .setNegativeButton("Close", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();

    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    return d;
}