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.acbelter.scheduleview.ScheduleView.java

public ScheduleView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs);
    mClipRect = new Rect();
    mClickedViewBounds = new Rect();
    mSelectedIds = new HashSet<Long>();
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    mTopEdgeEffect = new EdgeEffectCompat(context);
    mBottomEdgeEffect = new EdgeEffectCompat(context);

    mDataSetObserver = new DataSetObserver() {
        @Override/*  w ww  . j av  a  2 s .c  om*/
        public void onChanged() {
            super.onChanged();
            removeAllViewsInLayout();
            requestLayout();
        }

        @Override
        public void onInvalidated() {
            super.onInvalidated();
            removeAllViewsInLayout();
            requestLayout();
        }
    };

    init(context);

    setVerticalScrollBarEnabled(true);
    setHorizontalScrollBarEnabled(false);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScheduleView, defStyle, 0);
    try {
        if (a != null) {
            DisplayMetrics dm = context.getResources().getDisplayMetrics();
            mInternalPaddingTop = (int) a.getDimension(R.styleable.ScheduleView_internalPaddingTop,
                    TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm));
            mInternalPaddingBottom = (int) a.getDimension(R.styleable.ScheduleView_internalPaddingBottom,
                    TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm));
            mTimeMarksDistance = (int) a.getDimension(R.styleable.ScheduleView_timeMarksDistance,
                    TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 40, dm));
            mItemPaddingLeft = (int) a.getDimension(R.styleable.ScheduleView_itemPaddingLeft,
                    TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm));
            mItemPaddingRight = (int) a.getDimension(R.styleable.ScheduleView_itemPaddingRight,
                    TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, dm));
            initializeScrollbars(a);
        }
    } finally {
        if (a != null) {
            a.recycle();
        }
    }

    // Draw the background even if no items to display
    setWillNotDraw(false);

    mActionModeCallback = new ActionMode.Callback() {
        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            mode.getMenuInflater().inflate(R.menu.menu_context, menu);
            mIsActionMode = true;
            return true;
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            if (item.getItemId() == R.id.delete_items) {
                deleteSelectedItems();
            }
            return false;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
            clearSelection();
            mIsActionMode = false;
            mActionMode = null;
            invalidate();
        }
    };
}

From source file:com.quarterfull.newsAndroid.ListView.SubscriptionExpandableListAdapter.java

public SubscriptionExpandableListAdapter(Context mContext, DatabaseConnectionOrm dbConn, ListView listView) {
    favIconHandler = new FavIconHandler(mContext);

    this.inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.mContext = mContext;
    this.dbConn = dbConn;

    mTextColorLightTheme = ContextCompat.getColor(mContext, R.color.slider_listview_text_color_light_theme);

    unreadCountFeeds = new SparseArray<>();
    unreadCountFolders = new SparseArray<>();
    starredCountFeeds = new SparseArray<>();

    mCategoriesArrayList = new ArrayList<>();
    mItemsArrayList = new SparseArray<>();

    this.listView = listView;
}

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

/**
 * Standard constructor.//w ww  .j a va2 s  .  c  om
 *
 * @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.
 * @param c The cursor from which to get the data.
 * @param flags Flags used to determine the behavior of the adapter,
 * as per {@link CursorAdapter#CursorAdapter(Context, Cursor, int)}.
 */
public ResourceDragSortCursorAdapter(Context context, int layout, Cursor c, int flags) {
    super(context, c, flags);
    mLayout = mDropDownLayout = layout;
    mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

From source file:com.birdgang.viewpagerheader.indicator.SpringIndicator.java

private void addTabContainerView() {
    LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    tabContainer = (LinearLayout) inflater.inflate(R.layout.indicator_container, null);
    addView(tabContainer);/* w  ww.  j av a  2  s  .co m*/
}

From source file:fr.cph.chicago.adapter.SearchAdapter.java

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

    LayoutInflater vi = (LayoutInflater) ChicagoTracker.getAppContext()
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    convertView = vi.inflate(R.layout.list_search, null);

    TextView rounteName = (TextView) convertView.findViewById(R.id.station_name);

    if (position < mTrains.size()) {
        final Station station = (Station) getItem(position);
        Set<TrainLine> lines = station.getLines();

        rounteName.setText(station.getName());

        LinearLayout stationColorView = (LinearLayout) convertView.findViewById(R.id.station_color);

        int indice = 0;
        for (TrainLine tl : lines) {
            TextView textView = new TextView(mContext);
            textView.setBackgroundColor(tl.getColor());
            textView.setText(" ");
            textView.setTextSize(mContext.getResources().getDimension(R.dimen.activity_list_station_colors));
            stationColorView.addView(textView);
            if (indice != lines.size()) {
                textView = new TextView(mContext);
                textView.setText("");
                textView.setPadding(0, 0,
                        (int) mContext.getResources().getDimension(R.dimen.activity_list_station_colors_space),
                        0);//ww  w .  j  a  v a2  s .c  om
                textView.setTextSize(
                        mContext.getResources().getDimension(R.dimen.activity_list_station_colors));
                stationColorView.addView(textView);
            }
            indice++;
        }
        convertView.setOnClickListener(
                new FavoritesTrainOnClickListener(mActivity, mContainer, station.getId(), lines));
    } else if (position < mTrains.size() + mBuses.size()) {
        final BusRoute busRoute = (BusRoute) getItem(position);

        TextView type = (TextView) convertView.findViewById(R.id.train_bus_type);
        type.setText("B");

        rounteName.setText(busRoute.getId() + " " + busRoute.getName());

        final TextView loadingTextView = (TextView) convertView.findViewById(R.id.loading_text_view);
        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                loadingTextView.setVisibility(LinearLayout.VISIBLE);
                mActivity.startRefreshAnimation();
                new DirectionAsyncTask().execute(busRoute, loadingTextView);
            }
        });
    } else {
        final BikeStation bikeStation = (BikeStation) getItem(position);

        TextView type = (TextView) convertView.findViewById(R.id.train_bus_type);
        type.setText("D");

        rounteName.setText(bikeStation.getName());

        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ChicagoTracker.getAppContext(), BikeStationActivity.class);
                Bundle extras = new Bundle();
                extras.putParcelable("station", bikeStation);
                intent.putExtras(extras);
                mActivity.startActivity(intent);
                mActivity.overridePendingTransition(R.anim.slide_in, R.anim.slide_out);
            }
        });
    }

    return convertView;
}

From source file:net.openwatch.acluaz.FormFragmentActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.fragment_tabs_pager);
    // Show the Up button in the action bar.
    this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getDisplayWidth();//from   w  w w .  ja  v a2s.c om
    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);

    inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.personal_tab)).setIndicator(
            inflateCustomTab(getString(R.string.personal_tab))), PersonalFormFragment.class, null);
    mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.incident_tab)).setIndicator(
            inflateCustomTab(getString(R.string.incident_tab))), IncidentFormFragment.class, null);

    /*
    mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.personal_tab)).setIndicator(inflateCustomTab(getString(R.string.personal_tab))),
        PersonalFormFragment.class, null);
            
    mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.event_tab)).setIndicator(inflateCustomTab(getString(R.string.event_tab))),
        RemoteFeedFragmentActivity.RemoteRecordingsListFragment.class, null);
    */
    if (savedInstanceState != null) {
        mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab"));
    }

    DeviceLocation location = new DeviceLocation();
    location.getLocation(getApplicationContext(), new LocationResult() {

        @Override
        public void gotLocation(Location location) {
            if (FormFragmentActivity.this != null
                    && FormFragmentActivity.this.findViewById(R.id.gps_toggle) != null) {
                FormFragmentActivity.this.findViewById(R.id.gps_toggle).setTag(R.id.view_tag, location);
                //Log.i(TAG, "Tagged location_input with : " + FormFragmentActivity.this.findViewById(R.id.gps_toggle).getTag(R.id.view_tag).toString());
            }
        }

    }, true);

    Intent i = getIntent();
    if (!i.hasExtra(Constants.INTERNAL_DB_ID)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(FormFragmentActivity.this);
        builder.setMessage(getString(R.string.pre_form_disclaimer))
                .setPositiveButton(getString(R.string.dialog_ok), new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }

                }).show();
    }
}

From source file:com.morphoss.jumble.frontend.CategoryScreenActivity.java

/**
 * This method creates a popup window when a level is unlocked
 *//*  ww  w.  ja v  a  2 s  . com*/
public void PopupWindowLevel() {

    try {

        LayoutInflater inflater = (LayoutInflater) CategoryScreenActivity.this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.popup_level, (ViewGroup) findViewById(R.id.popup_element));
        DisplayMetrics metrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
        pwindowLevel = new PopupWindow(layout, metrics.widthPixels, metrics.heightPixels, true);
        pwindowLevel.showAtLocation(layout, Gravity.CENTER, 0, 0);
        btnClosePopupLevel = (ImageView) layout.findViewById(R.id.btn_close_popup);
        btnClosePopupLevel.setOnClickListener(cancel_popup_level);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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

@Override
public View onCreateView(LayoutInflater i, ViewGroup container, Bundle savedInstanceState) {
    Context ctx = getActivity();//from  w  w w  .j  av a 2s  .  c  o  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("Loading channel list");
    return v;
}

From source file:asu.edu.msse.gpeddabu.moviedescriptions.MovieListAdapter.java

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
        ViewGroup parent) {//from w w w.  j ava  2s  .  com
    final String childText = (String) getChild(groupPosition, childPosition);
    if (convertView == null) {
        android.util.Log.d(this.getClass().getSimpleName(), "in getChildView null so creating new view");
        LayoutInflater inflater = (LayoutInflater) this.parent
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        convertView = inflater.inflate(R.layout.movie_list, null);
    }
    TextView txtListChild = (TextView) convertView.findViewById(R.id.movieTitle);
    convertView.setOnTouchListener(this);
    convertView.setBackgroundResource(R.color.light_blue);
    txtListChild.setText(childText);
    return convertView;

}

From source file:com.jana.android.ui.fragment.AbstractMapFragment.java

@SuppressWarnings("deprecation")
@Override/*w ww.j  a  va2s .  c om*/
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    Logger.i("AbstractMapFragment.onCreate()");

    Bundle args = getArguments();

    if (args != null && args.size() > 0) {
        mCurrentLocation = args.getParcelable(EXTRA_CURRENT_LOCATION);
    }

    mImageLoader = ImageLoader.getInstance();

    mConfigs = new ImageLoaderConfiguration.Builder(getActivity().getApplicationContext())
            .memoryCacheSize(5 * 1024 * 1024).discCacheSize(10 * 1024 * 1024).build();
    mImageLoader.init(mConfigs);

    mOptions = new DisplayImageOptions.Builder().showImageForEmptyUri(R.mipmap.ic_launcher)
            .showImageOnFail(R.mipmap.ic_launcher).resetViewBeforeLoading(true).cacheOnDisc(true)
            .cacheInMemory(true).imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2)
            .bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true)
            .displayer(new FadeInBitmapDisplayer(300)).build();

    mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}