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:fr.cph.chicago.core.activity.BusMapActivity.java

public void drawBuses(@NonNull final List<Bus> buses) {
    mapFragment.getMapAsync(googleMap -> {
        Stream.of(busMarkers).forEach(Marker::remove);
        busMarkers.clear();/*from  w ww  .  j ava 2s.  c om*/
        final BitmapDescriptor bitmapDescr = busListener.getCurrentBitmapDescriptor();
        Stream.of(buses).forEach(bus -> {
            final LatLng point = new LatLng(bus.getPosition().getLatitude(), bus.getPosition().getLongitude());
            final Marker marker = googleMap.addMarker(new MarkerOptions().position(point)
                    .title("To " + bus.getDestination()).snippet(bus.getId() + "").icon(bitmapDescr)
                    .anchor(0.5f, 0.5f).rotation(bus.getHeading()).flat(true));
            busMarkers.add(marker);

            final LayoutInflater layoutInflater = (LayoutInflater) BusMapActivity.this.getBaseContext()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            final View view = layoutInflater.inflate(R.layout.marker_train, viewGroup, false);
            final TextView title = (TextView) view.findViewById(R.id.title);
            title.setText(marker.getTitle());

            views.put(marker, view);
        });

        busListener.setBusMarkers(busMarkers);
        googleMap.setOnCameraChangeListener(busListener);
    });
}

From source file:fr.univsavoie.ltp.client.map.Popup.java

public final void popupGetStatus(JSONArray pStatusesArray) {
    DisplayMetrics dm = new DisplayMetrics();
    this.activity.getWindowManager().getDefaultDisplay().getMetrics(dm);

    //final int height = dm.heightPixels;
    final int width = dm.widthPixels;
    final int height = dm.heightPixels;

    int popupWidth = (int) (width * 0.75);
    int popupHeight = height;

    // Inflate the popup_layout.xml
    ScrollView viewGroup = (ScrollView) this.activity.findViewById(R.id.popupGetStatus);
    LayoutInflater layoutInflater = (LayoutInflater) this.activity
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    final View layout = layoutInflater.inflate(R.layout.popup_get_status, viewGroup);
    layout.setBackgroundResource(R.drawable.popup_gradient);

    // Crer le PopupWindow
    final PopupWindow popupPublishStatus = new PopupWindow(layout, popupWidth, LayoutParams.WRAP_CONTENT, true);
    popupPublishStatus.setBackgroundDrawable(new BitmapDrawable());
    popupPublishStatus.setOutsideTouchable(true);

    // Some offset to align the popup a bit to the right, and a bit down, relative to button's position.
    final int OFFSET_X = 0;
    final int OFFSET_Y = 0;

    // Displaying the popup at the specified location, + offsets.
    this.activity.findViewById(R.id.layoutMain).post(new Runnable() {
        public void run() {
            popupPublishStatus.showAtLocation(layout, Gravity.CENTER, OFFSET_X, OFFSET_Y);
        }/*from   w  w w . java  2 s.c o  m*/
    });

    /*
     * Evenements composants du PopupWindow
     */

    // Find the ListView resource. 
    ListView mainListView = (ListView) layout.findViewById(R.id.listViewStatus);

    ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

    SimpleAdapter adapter = new SimpleAdapter(this.activity, list, R.layout.custom_row_view,
            new String[] { "content", "lat", "lon" }, new int[] { R.id.text1, R.id.text2, R.id.text3 });

    try {
        // Appel REST pour recuperer les status de l'utilisateur connect
        //Session session = new Session(this.activity);
        //session.parseJSONUrl("https://jibiki.univ-savoie.fr/ltpdev/rest.php/api/1/statuses", "STATUSES", "GET");

        // Parser la liste des amis dans le OverlayItem ArrayList
        HashMap<String, String> temp;
        for (int i = 0; (i < 6); i++) {
            // Obtenir le status
            JSONObject status = pStatusesArray.getJSONObject(i);

            temp = new HashMap<String, String>();
            temp.put("content", status.getString("content"));
            temp.put("lat", String.valueOf(status.getDouble("lat")));
            temp.put("lon", String.valueOf(status.getDouble("lon")));
            list.add(temp);
        }
    } catch (JSONException jex) {
        Log.e("Catch", "popupGetStatus / JSONException : " + jex.getStackTrace());
    } catch (Exception ex) {
        Log.e("Catch", "popupGetStatus / Exception : " + ex.getLocalizedMessage());
    }

    mainListView.setAdapter(adapter);
}

From source file:com.meetingninja.csse.tasks.TasksFragment.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View rowView = convertView;//  w w  w . jav a2s  . c om
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (rowView == null) {
        rowView = inflater.inflate(R.layout.list_item_task, null);
        viewHolder = new ViewHolder();

        viewHolder.title = (TextView) rowView.findViewById(R.id.list_task_title);
        viewHolder.deadline = (TextView) rowView.findViewById(R.id.list_task_deadline);
        viewHolder.background = rowView.findViewById(R.id.list_task_holder);

        rowView.setTag(viewHolder);
    } else
        viewHolder = (ViewHolder) rowView.getTag();

    // Setup from the meeting_item XML file
    Task task = tasks.get(position);

    viewHolder.title.setText(task.getTitle());
    viewHolder.deadline
            .setText("Deadline:  " + MyDateUtils.JODA_APP_DATE_FORMAT.print(task.getEndTimeInMillis()));

    Calendar cal = Calendar.getInstance();
    cal.setTimeInMillis(task.getEndTimeInMillis());
    cal.add(Calendar.DAY_OF_MONTH, -1);
    if (task.getEndTimeInMillis() == 0L) {

    } else if (task.getIsCompleted()) {
        viewHolder.background.setBackgroundColor(Color.rgb(53, 227, 111));
    } else if (cal.before(Calendar.getInstance())) {
        viewHolder.background.setBackgroundColor(Color.rgb(255, 51, 51));
    } else {
        viewHolder.background.setBackground(null);
    }

    return rowView;
}

From source file:it.angrydroids.epub3reader.TextSelectionSupport.java

private void createSelectionLayer(Context context) {
    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    mSelectionDragLayer = (DragLayer) inflater.inflate(R.layout.selection_drag_layer, null);
    mDragController = new DragController(context);
    mDragController.setDragListener(this);
    mDragController.addDropTarget(mSelectionDragLayer);
    mSelectionDragLayer.setDragController(mDragController);
    mStartSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.startHandle);
    mStartSelectionHandle.setTag(HandleType.START);
    mEndSelectionHandle = (ImageView) mSelectionDragLayer.findViewById(R.id.endHandle);
    mEndSelectionHandle.setTag(HandleType.END);
    final OnTouchListener handleTouchListener = new OnTouchListener() {
        @Override//from w ww  .j a  va2 s.co  m
        public boolean onTouch(View v, MotionEvent event) {
            boolean handledHere = false;
            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                handledHere = startDrag(v);
                mLastTouchedSelectionHandle = (HandleType) v.getTag();
            }
            return handledHere;
        }
    };
    mStartSelectionHandle.setOnTouchListener(handleTouchListener);
    mEndSelectionHandle.setOnTouchListener(handleTouchListener);
}

From source file:com.evvsoft.treeview.SimpleJsonTreeViewAdapter.java

/**
 * Constructor/*from w w w  .  j a  va2s .c  o  m*/
 * 
 * @param context The context where the {@link TreeView} associated
 *            with this SimpleJsonTreeViewAdapter is running
 * @param data The JSON single-level array of JSON objects. Each JSON object
 *            should include ID field, optional reference to the parent ID,
 *            optional isGroup flag and all the entries specified in
 *            "groupFrom" or "childFrom" depending on whether the group item
 * @param keys An array of names of key fields and for internal use.
 *            The first item at index 0 is the name of ID field.
 *            The second item at index 1 is the name of parent ID field.
 *            3-d item is the name of internal flag of group.
 *            4-th item is the name of internal flag of expanded group.
 *            5-th item is the name of internal array of children nodes.
 * @param expandedGroupLayout resource identifier of a view layout that
 *            defines the views for an expanded group. The layout file
 *            should include at least those named views defined in "groupTo"
 * @param collapsedGroupLayout resource identifier of a view layout that
 *            defines the views for a collapsed group. The layout file
 *            should include at least those named views defined in "groupTo"
 * @param groupFrom A list of keys that will be fetched from the JSON object
 *            associated with each group.
 * @param groupTo The group views that should display column in the
 *            "groupFrom" parameter. These should all be TextViews. The
 *            first N views in this list are given the values of the first N
 *            columns in the groupFrom parameter.
 * @param childLayout resource identifier of a view layout that defines the
 *            views for a child (unless it is the last child within a group,
 *            in which case the lastChildLayout is used). The layout file
 *            should include at least those named views defined in "childTo"
 * @param lastChildLayout resource identifier of a view layout that defines
 *            the views for the last child within each group. The layout
 *            file should include at least those named views defined in
 *            "childTo"
 * @param childFrom A list of keys that will be fetched from the JSON object
 *            associated with each child.
 * @param childTo The child views that should display column in the
 *            "childFrom" parameter. These should all be TextViews. The
 *            first N views in this list are given the values of the first N
 *            columns in the childFrom parameter.
 * @throws JSONException
 */
public SimpleJsonTreeViewAdapter(Context context, JSONArray data, String[] keys, int expandedGroupLayout,
        int collapsedGroupLayout, String[] groupFrom, int[] groupTo, int childLayout, int lastChildLayout,
        String[] childFrom, int[] childTo) throws JSONException {
    this.mKeys = keys;
    if (keys.length >= 1)
        this.mIdField = keys[0];
    if (keys.length >= 2)
        this.mIdParentField = keys[1];
    this.mExpandedGroupLayout = expandedGroupLayout;
    this.mCollapsedGroupLayout = collapsedGroupLayout;
    this.mGroupFrom = groupFrom;
    this.mGroupTo = groupTo;
    this.mChildLayout = childLayout;
    this.mLastChildLayout = lastChildLayout;
    this.mChildFrom = childFrom;
    this.mChildTo = childTo;
    this.mNodes = convertToTreeJSONArray(data);
    this.mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

From source file:com.zia.freshdocs.widget.adapter.CMISAdapter.java

/**
 * Display file information//from w  ww .  j  a v a  2s  .  c  o  m
 * 
 * @param context
 */

public void showFileInfo(Context context, int position, boolean isFile) {

    final NodeRef ref = getItem(position);
    try {
        //We need to get the instance of the LayoutInflater, use the context of this activity
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        //Inflate the view from a predefined XML layout
        View layout = inflater.inflate(R.layout.file_info_dialog, null, false);
        // create a WRAP_CONTENT PopupWindow
        PopupWindow mPopUp = new PopupWindow(layout, WindowManager.LayoutParams.FILL_PARENT,
                WindowManager.LayoutParams.WRAP_CONTENT, true);
        mPopUp.setBackgroundDrawable(new BitmapDrawable());
        mPopUp.setOutsideTouchable(true);
        // display the popup in the center
        mPopUp.showAtLocation(layout, Gravity.CENTER, 0, 0);

        TextView title = (TextView) layout.findViewById(R.id.dialog_title);
        if (isFile)
            title.setText(context.getString(R.string.str_file_information));
        else
            title.setText(context.getString(R.string.str_folder_information));

        UITableView tableView = (UITableView) layout.findViewById(R.id.tableView);

        ViewItem viewItem;

        if (ref.getName() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_name), ref.getName());
            tableView.addViewItem(viewItem);
        }
        if (ref.getCreateBy() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_created_by),
                    ref.getCreateBy());
            tableView.addViewItem(viewItem);
        }

        if (ref.getLastModificationDate() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_last_modification_date),
                    ref.getLastModificationDate());
            tableView.addViewItem(viewItem);
        }

        if (ref.getLastModifiedBy() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_last_modified_by),
                    ref.getLastModifiedBy());
            tableView.addViewItem(viewItem);
        }

        if (ref.getContent() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_content),
                    ref.getContent());
            tableView.addViewItem(viewItem);
        }

        if (ref.getContentType() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_content_type),
                    ref.getContentType());
            tableView.addViewItem(viewItem);
        }

        if (ref.getObjectId() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_object_id),
                    ref.getObjectId());
            tableView.addViewItem(viewItem);
        }

        if (ref.getParentId() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_parent_id),
                    ref.getParentId());
            tableView.addViewItem(viewItem);
        }

        if (ref.getVersion() != null) {
            viewItem = Utils.createCustomView(context, context.getString(R.string.str_version),
                    ref.getVersion());
            tableView.addViewItem(viewItem);
        }

        tableView.commit();

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

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

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

    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.dialog_edit_connection, null);
    init(v);

    if (savedInstanceState != null && savedInstanceState.containsKey("cid"))
        server = ServersDataSource.getInstance().getServer(savedInstanceState.getInt("cid"));

    final AlertDialog d = new AlertDialog.Builder(ctx)
            .setInverseBackgroundForced(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB)
            .setTitle((server == null) ? "Add A Network" : "Edit Connection").setView(v)
            .setPositiveButton((server == null) ? "Add" : "Save", null)
            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    NetworkConnection.getInstance().removeHandler(EditConnectionFragment.this);
                }
            }).create();
    d.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            Button b = d.getButton(AlertDialog.BUTTON_POSITIVE);
            b.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    NetworkConnection.getInstance().removeHandler(EditConnectionFragment.this);
                    NetworkConnection.getInstance().addHandler(EditConnectionFragment.this);
                    reqid = save();
                }
            });
        }
    });
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    return d;
}

From source file:com.juick.android.JuickMessagesAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final JuickMessage jmsg = getItem(position);
    final Context context = getContext();
    MessageID mid = jmsg.getMID();/*from   www . jav a 2s. c  om*/
    MicroBlog microBlog = mid != null ? MainActivity.microBlogs.get(mid.getMicroBlogCode()) : null;
    if (microBlog instanceof OwnRenderItems) {
        OwnRenderItems ori = (OwnRenderItems) microBlog;
        return ori.getView(getContext(), jmsg, convertView);
    } else {
        View v1 = convertView;
        if (jmsg.User != null && jmsg.Text != null) {
            MessageViewPreparer messageViewPreparer = new MessageViewPreparer(handler, jmsg, context, v1,
                    getTextSize(context)).invoke();
            v1 = messageViewPreparer.getV1();
            startLoadUserPic(jmsg, messageViewPreparer.getT(), messageViewPreparer.getLrr(),
                    messageViewPreparer.getParsedMessage(), messageViewPreparer.getUserPic());
            if (messageViewPreparer.getParsedPreMessage() != null) {
                startLoadUserPic(jmsg.contextPost, messageViewPreparer.getPret(),
                        messageViewPreparer.getPrelrr(), messageViewPreparer.getParsedPreMessage(),
                        messageViewPreparer.getPreuserPic());
            }
        } else {
            if (v1 == null || !(v1 instanceof TextView)) {
                LayoutInflater vi = (LayoutInflater) getContext()
                        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                v1 = vi.inflate(R.layout.preference_category, null);
            }

            ((TextView) v1).setTextSize(getTextSize(context));

            if (jmsg.Text != null) {
                ((TextView) v1).setText(jmsg.Text);
            } else {
                ((TextView) v1).setText("");
            }
        }
        View v = v1;
        MainActivity.restyleChildrenOrWidget(v, true);
        return v;
    }
}

From source file:com.google.samples.apps.iosched.videolibrary.VideoLibraryFilteredFragment.java

@Override
public View newCollectionItemView(Context context, int groupId, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    return inflater.inflate(R.layout.video_library_item, parent, false);
}

From source file:com.prasanna.android.stacknetwork.utils.MarkdownFormatter.java

private static RelativeLayout getTextViewForCode(final Context context, final String text) {
    final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final RelativeLayout codeLayout = (RelativeLayout) inflater.inflate(R.layout.code, null);
    final WebView webView = (WebView) codeLayout.findViewById(R.id.code);
    loadText(webView, text);//from  w  w w  .j  av a 2 s  .  c  om

    StackXQuickActionMenu quickActionMenu = new StackXQuickActionMenu(context)
            .addEmailQuickActionItem("Code sample from StackX", text).addCopyToClipboardItem(text);
    final QuickActionMenu actionMenu = quickActionMenu.addItem(R.string.fullscreen, new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(context, FullscreenTextActivity.class);
            intent.putExtra(StringConstants.TEXT, text);
            context.startActivity(intent);
        }
    }).build();

    ImageView imageView = (ImageView) codeLayout.findViewById(R.id.codeQuickActionMenu);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            actionMenu.show(v);
        }
    });

    return codeLayout;
}