Example usage for android.app Activity getLayoutInflater

List of usage examples for android.app Activity getLayoutInflater

Introduction

In this page you can find the example usage for android.app Activity getLayoutInflater.

Prototype

@NonNull
public LayoutInflater getLayoutInflater() 

Source Link

Document

Convenience for calling android.view.Window#getLayoutInflater .

Usage

From source file:de.hska.iam.presentationapp.fragments.dialogs.DisplayTimeDialog.java

@NonNull
@Override//from w w w  .j a v  a  2  s.  c om
public Dialog onCreateDialog(final Bundle savedInstanceState) {
    Activity activity = getActivity();
    preferences = new DisplayTimeDialogPreferences(activity);
    LayoutInflater inflater = activity.getLayoutInflater();
    View dialogView = inflater.inflate(R.layout.time_picker_dialog, null);
    secondsPicker = (NumberPicker) dialogView.findViewById(R.id.secondsTimePicker);
    minutesPicker = (NumberPicker) dialogView.findViewById(R.id.minutesTimePicker);
    setupSecondsPicker();
    setupMinutesPicker();
    return createAlertDialog(dialogView);
}

From source file:dynamite.zafroshops.app.fragment.ZopServicesFragment.java

@NonNull
@Override/*from www  .jav a 2  s. c o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    data = (ArrayList<ZopServiceType>) getArguments().get(NEW_ZOP_SERVICES);
    tempData = new ArrayList<>();

    for (int i = 0; i < data.size(); i++) {
        tempData.add(data.get(i));
    }

    Activity activity = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    final LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.services_dialog, null);

    builder.setView(view).setTitle(R.string.services_editing)
            .setPositiveButton(R.string.button_submit, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    data.clear();
                    for (int i = 0; i < tempData.size(); i++) {
                        data.add(tempData.get(i));
                    }

                    Intent intent = new Intent();
                    intent.putExtra(NEW_ZOP_SERVICES_COUNT_KEY, data.size());
                    getTargetFragment().onActivityResult(getTargetRequestCode(), NEW_ZOP_SERVICES_RESULT_CODE,
                            intent);
                }
            }).setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            });

    ListView listView = (ListView) view.findViewById(R.id.servicesContainer);

    zopServiceAdapter = new ZopServiceAdapter(activity, R.id.serviceItem, tempData);
    listView.setAdapter(zopServiceAdapter);

    return builder.create();
}

From source file:com.esri.squadleader.view.AddLayerFromWebDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (null != listener) {
        final Activity activity = getActivity();
        LayoutInflater inflater = activity.getLayoutInflater();
        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
        final View inflatedView = inflater.inflate(R.layout.add_layer_from_web, null);
        builder.setView(inflatedView);//from  w  w  w .  j a v  a 2s. c o  m
        builder.setTitle(getString(R.string.add_layer_from_web));
        builder.setNegativeButton(R.string.cancel, null);
        builder.setPositiveButton(R.string.add_layer, new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                final boolean useAsBasemap;
                boolean _useAsBasemap = false;
                View checkboxView = inflatedView.findViewById(R.id.checkBox_basemap);
                if (null != checkboxView && checkboxView instanceof CheckBox) {
                    _useAsBasemap = ((CheckBox) checkboxView).isChecked();
                }
                useAsBasemap = _useAsBasemap;
                View serviceUrlView = inflatedView.findViewById(R.id.editText_serviceUrl);
                if (null != serviceUrlView && serviceUrlView instanceof EditText) {
                    final String urlString = ((EditText) serviceUrlView).getText().toString();
                    addLayer(useAsBasemap, urlString);
                }
            }
        });
        return builder.create();
    } else {
        return null;
    }
}

From source file:im.vector.util.BugReporter.java

/**
 * Send a bug report either with email or with Vector.
 *///ww  w .  java2s.c om
public static void sendBugReport() {
    final Activity currentActivity = VectorApp.getCurrentActivity();

    // no current activity so cannot display an alert
    if (null == currentActivity) {
        sendBugReport(VectorApp.getInstance().getApplicationContext(), true, true, "", null);
        return;
    }

    final Context appContext = currentActivity.getApplicationContext();
    LayoutInflater inflater = currentActivity.getLayoutInflater();
    View dialogLayout = inflater.inflate(R.layout.dialog_bug_report, null);

    final AlertDialog.Builder dialog = new AlertDialog.Builder(currentActivity);
    dialog.setTitle(R.string.send_bug_report);
    dialog.setView(dialogLayout);

    final EditText bugReportText = (EditText) dialogLayout.findViewById(R.id.bug_report_edit_text);
    final CheckBox includeLogsButton = (CheckBox) dialogLayout
            .findViewById(R.id.bug_report_button_include_logs);
    final CheckBox includeCrashLogsButton = (CheckBox) dialogLayout
            .findViewById(R.id.bug_report_button_include_crash_logs);

    final ProgressBar progressBar = (ProgressBar) dialogLayout.findViewById(R.id.bug_report_progress_view);
    final TextView progressTextView = (TextView) dialogLayout.findViewById(R.id.bug_report_progress_text_view);

    dialog.setPositiveButton(R.string.send, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // will be overridden to avoid dismissing the dialog while displaying the progress
        }
    });

    dialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // will be overridden to avoid dismissing the dialog while displaying the progress
        }
    });

    //
    final AlertDialog bugReportDialog = dialog.show();
    final Button cancelButton = bugReportDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
    final Button sendButton = bugReportDialog.getButton(AlertDialog.BUTTON_POSITIVE);

    if (null != cancelButton) {
        cancelButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // check if there is no upload in progress
                if (includeLogsButton.isEnabled()) {
                    bugReportDialog.dismiss();
                } else {
                    mIsCancelled = true;
                    cancelButton.setEnabled(false);
                }
            }
        });
    }

    if (null != sendButton) {
        sendButton.setEnabled(false);

        sendButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // disable the active area while uploading the bug report
                bugReportText.setEnabled(false);
                sendButton.setEnabled(false);
                includeLogsButton.setEnabled(false);
                includeCrashLogsButton.setEnabled(false);

                progressTextView.setVisibility(View.VISIBLE);
                progressTextView.setText(appContext.getString(R.string.send_bug_report_progress, 0 + ""));

                progressBar.setVisibility(View.VISIBLE);
                progressBar.setProgress(0);

                sendBugReport(VectorApp.getInstance(), includeLogsButton.isChecked(),
                        includeCrashLogsButton.isChecked(), bugReportText.getText().toString(),
                        new IMXBugReportListener() {
                            @Override
                            public void onUploadFailed(String reason) {
                                try {
                                    if (null != VectorApp.getInstance() && !TextUtils.isEmpty(reason)) {
                                        Toast.makeText(VectorApp.getInstance(),
                                                VectorApp.getInstance()
                                                        .getString(R.string.send_bug_report_failed, reason),
                                                Toast.LENGTH_LONG).show();
                                    }
                                } catch (Exception e) {
                                    Log.e(LOG_TAG, "## onUploadFailed() : failed to display the toast "
                                            + e.getMessage());
                                }

                                try {
                                    // restore the dialog if the upload failed
                                    bugReportText.setEnabled(true);
                                    sendButton.setEnabled(true);
                                    includeLogsButton.setEnabled(true);
                                    includeCrashLogsButton.setEnabled(true);
                                    cancelButton.setEnabled(true);

                                    progressTextView.setVisibility(View.GONE);
                                    progressBar.setVisibility(View.GONE);
                                } catch (Exception e) {
                                    Log.e(LOG_TAG, "## onUploadFailed() : failed to restore the dialog button "
                                            + e.getMessage());

                                    try {
                                        bugReportDialog.dismiss();
                                    } catch (Exception e2) {
                                        Log.e(LOG_TAG, "## onUploadFailed() : failed to dismiss the dialog "
                                                + e2.getMessage());
                                    }
                                }

                                mIsCancelled = false;
                            }

                            @Override
                            public void onUploadCancelled() {
                                onUploadFailed(null);
                            }

                            @Override
                            public void onProgress(int progress) {
                                if (progress > 100) {
                                    Log.e(LOG_TAG, "## onProgress() : progress > 100");
                                    progress = 100;
                                } else if (progress < 0) {
                                    Log.e(LOG_TAG, "## onProgress() : progress < 0");
                                    progress = 0;
                                }

                                progressBar.setProgress(progress);
                                progressTextView.setText(
                                        appContext.getString(R.string.send_bug_report_progress, progress + ""));
                            }

                            @Override
                            public void onUploadSucceed() {
                                try {
                                    if (null != VectorApp.getInstance()) {
                                        Toast.makeText(VectorApp.getInstance(),
                                                VectorApp.getInstance().getString(
                                                        R.string.send_bug_report_sent),
                                                Toast.LENGTH_LONG).show();
                                    }
                                } catch (Exception e) {
                                    Log.e(LOG_TAG, "## onUploadSucceed() : failed to dismiss the toast "
                                            + e.getMessage());
                                }

                                try {
                                    bugReportDialog.dismiss();
                                } catch (Exception e) {
                                    Log.e(LOG_TAG, "## onUploadSucceed() : failed to dismiss the dialog "
                                            + e.getMessage());
                                }
                            }
                        });
            }
        });
    }

    bugReportText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (null != sendButton) {
                sendButton.setEnabled(bugReportText.getText().toString().length() > 10);
            }
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
}

From source file:com.iwedia.adapters.ListViewTimeAdapter.java

public ListViewTimeAdapter(Activity activity, ArrayList<String> channelNames, ArrayList<TimeEvent> timeEvents,
        int time) {
    mContext = activity.getApplicationContext();
    mLayoutInflater = activity.getLayoutInflater();
    mChannelNames = channelNames;/*w w w .ja v  a2 s . co  m*/
    initializeEvents(timeEvents, time);
}

From source file:net.d53.syman.mobile.ui.ContentListFragment.java

protected void configureList(Activity activity, ListView listView) {
    super.configureList(activity, listView);

    listView.setFastScrollEnabled(true);
    listView.setDividerHeight(0);/*from  w ww  . j  av  a2s  .  co  m*/

    getListAdapter().addHeader(activity.getLayoutInflater().inflate(layout.content_list_item_labels, null));
}

From source file:net.d53.syman.mobile.ui.ReferrerListFragment.java

@Override
protected void configureList(Activity activity, ListView listView) {
    super.configureList(activity, listView);

    listView.setFastScrollEnabled(true);
    listView.setDividerHeight(0);/*from  ww  w  . j  ava2  s  .  co m*/

    getListAdapter().addHeader(activity.getLayoutInflater().inflate(layout.referrer_list_item_labels, null));
}

From source file:dynamite.zafroshops.app.fragment.ReviewDialogFragment.java

@NonNull
@Override//from www  .j  a v a  2 s  .  com
public Dialog onCreateDialog(Bundle savedInstanceState) {
    rating = 0;
    zopID = getArguments().getString(DIALOG_ZOP_ID);
    location = (Location) getArguments().getSerializable(DIALOG_ZOP_LOCATION);

    Activity activity = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    LayoutInflater inflater = activity.getLayoutInflater();
    final View view = inflater.inflate(R.layout.review_dialog, null);

    builder.setView(view).setTitle(R.string.app_name)
            .setPositiveButton(R.string.dialog_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    MobileConfirmation confirmation = new MobileConfirmation();
                    Boolean confirmed = false;
                    int id = ((RadioGroup) view.findViewById(R.id.review_confirmation_group))
                            .getCheckedRadioButtonId();

                    if (id == view.findViewById(R.id.review_confirmation_know).getId()) {
                        confirmed = true;
                    } else if (id == view.findViewById(R.id.review_confirmation_been).getId()) {
                        confirmed = false;
                    }

                    confirmation.ZopID = Integer.parseInt(zopID);
                    confirmation.Comments = ((EditText) view.findViewById(R.id.review_comments)).getText()
                            .toString();
                    confirmation.Confirmed = confirmed;
                    confirmation.ConfirmedBy = "Android";
                    confirmation.ConfirmedDate = Calendar.getInstance().getTime();
                    confirmation.Rating = rating;

                    // submit
                    ListenableFuture<JsonElement> result = MainActivity.MobileClient
                            .invokeApi("mobileConfirmation", confirmation, JsonElement.class);
                    Futures.addCallback(result, new FutureCallback<JsonElement>() {
                        @Override
                        public void onSuccess(JsonElement result) {
                            ((MenuItem) view.findViewById(R.id.menu_zop_review)).setEnabled(false);
                        }

                        @Override
                        public void onFailure(@NonNull Throwable t) {

                        }
                    });
                }
            }).setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            });

    RadioGroup radioGroup = (RadioGroup) view.findViewById(R.id.review_confirmation_group);

    view.findViewById(R.id.review_rating).setVisibility(View.INVISIBLE);
    radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.review_confirmation_been) {
                view.findViewById(R.id.review_rating).setVisibility(View.VISIBLE);
            } else {
                view.findViewById(R.id.review_rating).setVisibility(View.INVISIBLE);
            }
        }
    });

    return builder.create();
}

From source file:org.wso2.carbon.iot.android.sense.bmonitor.LeDeviceListAdapter.java

public LeDeviceListAdapter(final Activity activity, final EasyObjectCursor<BluetoothLeDevice> cursor) {
    super(activity, R.layout.list_item_device, cursor, new String[0], new int[0], 0);
    mInflator = activity.getLayoutInflater();
    mActivity = activity;/*  w w w  . ja v a  2 s.  c om*/
}

From source file:net.d53.syman.mobile.ui.TrafficListFragment.java

@Override
protected void configureList(Activity activity, ListView listView) {
    super.configureList(activity, listView);

    listView.setFastScrollEnabled(true);
    listView.setDividerHeight(0);/*www  . jav  a  2  s .  c  o  m*/

    View graph = activity.getLayoutInflater().inflate(layout.traffic_graph, null);
    barGraph = (GaugeGraphView) graph.findViewById(id.gauge_graph);
    getListAdapter().addHeader(graph);
    getListAdapter().addHeader(activity.getLayoutInflater().inflate(layout.traffic_list_item_labels, null));
}