Example usage for android.view LayoutInflater from

List of usage examples for android.view LayoutInflater from

Introduction

In this page you can find the example usage for android.view LayoutInflater from.

Prototype

public static LayoutInflater from(Context context) 

Source Link

Document

Obtains the LayoutInflater from the given context.

Usage

From source file:cm.aptoide.pt.MainActivity.java

private void showAddStoreDialog() {
    alertDialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_add_store, null);
    alertDialog = new AlertDialog.Builder(mContext).setView(alertDialogView).create();
    alertDialog.setTitle(getString(R.string.new_store));
    alertDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.new_store), addRepoListener);
    alertDialog.setButton(Dialog.BUTTON_POSITIVE, getString(R.string.search_for_stores), searchStoresListener);
    ((EditText) alertDialogView.findViewById(R.id.edit_uri)).setText(storeUri);
    alertDialog.show();//from   w w w  .ja v  a 2s .c  o m
}

From source file:cm.aptoide.pt.MainActivity.java

private void showAddStoreCredentialsDialog(String string) {
    View credentialsDialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_add_pvt_store, null);
    AlertDialog credentialsDialog = new AlertDialog.Builder(mContext).setView(credentialsDialogView).create();
    credentialsDialog.setTitle(getString(R.string.add_private_store) + " " + RepoUtils.split(string));
    credentialsDialog.setButton(Dialog.BUTTON_NEUTRAL, getString(R.string.new_store),
            new AddStoreCredentialsListener(string, credentialsDialogView));
    credentialsDialog.show();//from ww  w .  ja  va 2 s  .  c  o m
}

From source file:cm.aptoide.pt.MainActivity.java

private void showUpdateStoreCredentialsDialog(String string) {
    View credentialsDialogView = LayoutInflater.from(mContext).inflate(R.layout.dialog_add_pvt_store, null);
    AlertDialog credentialsDialog = new AlertDialog.Builder(mContext).setView(credentialsDialogView).create();
    credentialsDialog.setTitle(getString(R.string.add_private_store) + " " + RepoUtils.split(string));
    credentialsDialog.setButton(Dialog.BUTTON_NEUTRAL, getString(R.string.new_store),
            new UpdateStoreCredentialsListener(string, credentialsDialogView));
    credentialsDialog.show();/*from  w  w w  .j a  v  a 2s.  c  om*/
}

From source file:cm.aptoide.pt.MainActivity.java

private void requestUpdateSelf() {
    View simpleView = LayoutInflater.from(mContext).inflate(R.layout.dialog_simple_layout, null);
    Builder dialogBuilder = new AlertDialog.Builder(mContext).setView(simpleView);
    final AlertDialog updateSelfDialog = dialogBuilder.create();
    updateSelfDialog.setTitle(getText(R.string.update_self_title));
    updateSelfDialog.setIcon(R.drawable.icon_brand_aptoide);
    TextView message = (TextView) simpleView.findViewById(R.id.dialog_message);
    message.setText(getString(R.string.update_self_msg, ApplicationAptoide.MARKETNAME));
    updateSelfDialog.setCancelable(false);
    updateSelfDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes),
            new Dialog.OnClickListener() {
                @Override//from  w w  w.ja v a  2  s.c o m
                public void onClick(DialogInterface arg0, int arg1) {
                    new DownloadSelfUpdate().execute();
                }
            });
    updateSelfDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no),
            new Dialog.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int arg1) {
                    dialog.dismiss();
                }
            });
    updateSelfDialog.show();

}

From source file:com.guardtrax.ui.screens.HomeScreen.java

private void displaytourInfo() {
    String message = "";
    int i = 0;/*from   w  ww  .j a  va  2s  .  c o m*/
    int tagCount = 0;
    boolean singleDisplay = false; //indicates that only 1 item is to be displayed in the tour list
    List<Boolean> tourtagsIncluded = new ArrayList<Boolean>();
    List<Boolean> tourtagsScanned = new ArrayList<Boolean>();
    List<Integer> tourOrder = new ArrayList<Integer>();
    List<String> messageList = new ArrayList<String>();

    //check if this is a single display (second last character of tour name is a space)
    singleDisplay = isSingleRandomTour();
    tourDB.open();

    Cursor c = tourDB.getRecordByTour(GTConstants.tourName);

    if (c != null && c.moveToFirst()) {
        tourtagsScanned = refreshtourtagList(c.getCount(), false, true, false, false);
        tourtagsIncluded = refreshtourtagList(c.getCount(), false, false, true, false);
        tourOrder = gettourOrder(c.getCount());

        //initialize the message array which wil be used to display the messages in the random order
        while (messageList.size() < c.getCount())
            messageList.add("");

        for (i = 0; i < c.getCount(); i++) {
            if (tourtagsScanned.get(i) && tourtagsIncluded.get(i) && !singleDisplay)
                messageList.add(tourOrder.get(i),
                        "<br><font color='#00FF00'>" + c.getString(2) + "</font><br/>");
            else if (!tourtagsScanned.get(i) && !Utility.istourOntime(tourEnd)
                    && Utility.getcurrentState().equals(GTConstants.onShift) && tourtagsIncluded.get(i)
                    && !singleDisplay)
                messageList.add(tourOrder.get(i),
                        "<br><font color='#FF0000'>" + c.getString(2) + "</font><br/>");
            else if (!tourtagsScanned.get(i) && tourtagsIncluded.get(i) && !singleDisplay)
                messageList.add(tourOrder.get(i),
                        "<br><font color='#FFFFFF'>" + c.getString(2) + "</font><br/>");
            else if (singleDisplay && i == touritemNumber)
                messageList.add(tourOrder.get(i),
                        "<br><font color='#FFFFFF'>" + c.getString(2) + "</font><br/>");

            //get the number of tags included
            if (tourtagsIncluded.get(i))
                tagCount++;
            c.moveToNext();
        }
    }

    tourDB.close();

    //create the message string
    for (i = 0; i < messageList.size(); i++)
        if (messageList.get(i).length() > 1)
            message = message + messageList.get(i);

    LayoutInflater inflater = LayoutInflater.from(HomeScreen.this);
    View view = inflater.inflate(R.layout.scroll_dialog, null);

    TextView textview = (TextView) view.findViewById(R.id.dialogtext);
    textview.setText(Html.fromHtml(message));
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(HomeScreen.this);

    //create custom title
    TextView title = new TextView(HomeScreen.this);

    //if this is a single display tour then do not indicate how many tags are in the tour
    if (isSingleRandomTour()) //this is a single display tour
        title.setText(GTConstants.tourName + CRLF + tourTime + CRLF);
    else
        title.setText(GTConstants.tourName + CRLF + tourTime + CRLF + String.valueOf(tagCount) + " Tags");
    title.setPadding(10, 10, 10, 10);
    title.setGravity(Gravity.CENTER);
    title.setTextColor(Color.parseColor("#79ABFF"));
    title.setTextSize(20);
    alertDialog.setCustomTitle(title);

    //alertDialog.setTitle(tourName + CRLF + String.valueOf(i-1) + " Tags"); 
    alertDialog.setView(view);
    alertDialog.setPositiveButton("OK", null);
    AlertDialog alert = alertDialog.create();
    alert.show();
}

From source file:cm.aptoide.pt.MainActivity.java

public void showFollow() {
    View socialNetworksView = LayoutInflater.from(this).inflate(R.layout.dialog_social_networks, null);
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this).setView(socialNetworksView);
    final AlertDialog socialDialog = dialogBuilder.create();
    socialDialog.setIcon(android.R.drawable.ic_menu_share);
    socialDialog.setTitle(getString(R.string.social_networks));
    socialDialog.setCancelable(true);//  w w w.j  a va2  s . c om

    Button facebookButton = (Button) socialNetworksView.findViewById(R.id.find_facebook);
    facebookButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isAppInstalled("com.facebook.katana")) {
                Intent sharingIntent;
                try {
                    getPackageManager().getPackageInfo("com.facebook.katana", 0);
                    sharingIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("fb://profile/225295240870860"));
                    startActivity(sharingIntent);
                } catch (NameNotFoundException e) {
                    e.printStackTrace();
                }
            } else {
                Intent intent = new Intent(mContext, WebViewFacebook.class);
                startActivity(intent);
            }

        }
    });

    Button twitterButton = (Button) socialNetworksView.findViewById(R.id.follow_twitter);
    twitterButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isAppInstalled("com.twitter.android")) {
                String url = "http://www.twitter.com/aptoide";
                Intent twitterIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                startActivity(twitterIntent);
            } else {
                Intent intent = new Intent(mContext, WebViewTwitter.class);
                startActivity(intent);
            }
        }
    });
    socialDialog.show();
}

From source file:com.nttec.everychan.ui.presentation.BoardFragment.java

@SuppressLint("InflateParams")
private void saveThisPage() {
    if (!CompatibilityUtils.hasAccessStorage(activity))
        return;// www.  j a v  a 2s  . co m
    DownloadingService.DownloadingQueueItem check = new DownloadingService.DownloadingQueueItem(
            tabModel.pageModel, presentationModel.source.boardModel, DownloadingService.MODE_DOWNLOAD_ALL);
    String itemName = resources.getString(R.string.downloading_thread_format, tabModel.pageModel.boardName,
            tabModel.pageModel.threadNumber);
    if (DownloadingService.isInQueue(check)) {
        Toast.makeText(activity, resources.getString(R.string.notification_download_already_in_queue, itemName),
                Toast.LENGTH_LONG).show();
    } else {
        Context dialogContext = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
                ? new ContextThemeWrapper(activity, R.style.Theme_Neutron)
                : activity;
        View saveThreadDialogView = LayoutInflater.from(dialogContext).inflate(R.layout.dialog_save_thread,
                null);
        final CheckBox saveThumbsChkbox = (CheckBox) saveThreadDialogView
                .findViewById(R.id.dialog_save_thread_thumbs);
        final CheckBox saveAllChkbox = (CheckBox) saveThreadDialogView
                .findViewById(R.id.dialog_save_thread_all);
        switch (settings.getDownloadThreadMode()) {
        case DownloadingService.MODE_DOWNLOAD_ALL:
            saveThumbsChkbox.setChecked(true);
            saveAllChkbox.setChecked(true);
            break;
        case DownloadingService.MODE_DOWNLOAD_THUMBS:
            saveThumbsChkbox.setChecked(true);
            saveAllChkbox.setChecked(false);
            break;
        default:
            saveThumbsChkbox.setChecked(false);
            saveAllChkbox.setChecked(false);
            saveAllChkbox.setEnabled(false);
            break;
        }
        saveThumbsChkbox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (saveThumbsChkbox.isChecked()) {
                    saveAllChkbox.setEnabled(true);
                } else {
                    saveAllChkbox.setEnabled(false);
                    saveAllChkbox.setChecked(false);
                }
            }
        });
        DialogInterface.OnClickListener save = new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                int mode = DownloadingService.MODE_ONLY_CACHE;
                if (saveThumbsChkbox.isChecked()) {
                    mode = DownloadingService.MODE_DOWNLOAD_THUMBS;
                }
                if (saveAllChkbox.isChecked()) {
                    mode = DownloadingService.MODE_DOWNLOAD_ALL;
                }
                settings.saveDownloadThreadMode(mode);
                Intent savePageIntent = new Intent(activity, DownloadingService.class);
                savePageIntent.putExtra(DownloadingService.EXTRA_DOWNLOADING_ITEM,
                        new DownloadingService.DownloadingQueueItem(tabModel.pageModel,
                                presentationModel.source.boardModel, mode));
                activity.startService(savePageIntent);
            }
        };
        AlertDialog saveThreadDialog = new AlertDialog.Builder(dialogContext).setView(saveThreadDialogView)
                .setTitle(R.string.dialog_save_thread_title)
                .setPositiveButton(R.string.dialog_save_thread_save, save)
                .setNegativeButton(android.R.string.cancel, null).create();
        saveThreadDialog.setCanceledOnTouchOutside(false);
        saveThreadDialog.show();
    }
}

From source file:com.nttec.everychan.ui.presentation.BoardFragment.java

@SuppressLint("InflateParams")
private void runDelete(final DeletePostModel deletePostModel, final boolean hasFiles) {
    Context dialogContext = Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB
            ? new ContextThemeWrapper(activity, R.style.Theme_Neutron)
            : activity;/*  w w w. j a  va 2s. co  m*/
    View dlgLayout = LayoutInflater.from(dialogContext).inflate(R.layout.dialog_delete, null);
    final EditText inputField = (EditText) dlgLayout.findViewById(R.id.dialog_delete_password_field);
    final CheckBox onlyFiles = (CheckBox) dlgLayout.findViewById(R.id.dialog_delete_only_files);
    inputField.setText(chan.getDefaultPassword());

    if (!presentationModel.source.boardModel.allowDeletePosts
            && !presentationModel.source.boardModel.allowDeleteFiles) {
        Logger.e(TAG, "board model doesn't support deleting");
        return;
    } else if (!presentationModel.source.boardModel.allowDeletePosts) {
        onlyFiles.setEnabled(false);
        onlyFiles.setChecked(true);
    } else if (presentationModel.source.boardModel.allowDeleteFiles && hasFiles) {
        onlyFiles.setEnabled(true);
    } else {
        onlyFiles.setEnabled(false);
    }

    DialogInterface.OnClickListener dlgOnClick = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            if (currentTask != null)
                currentTask.cancel();
            if (pullableLayout.isRefreshing())
                setPullableNoRefreshing();
            deletePostModel.onlyFiles = onlyFiles.isChecked();
            deletePostModel.password = inputField.getText().toString();
            final ProgressDialog progressDlg = new ProgressDialog(activity);
            final CancellableTask deleteTask = new CancellableTask.BaseCancellableTask();
            progressDlg.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    deleteTask.cancel();
                }
            });
            progressDlg.setCanceledOnTouchOutside(false);
            progressDlg.setMessage(resources.getString(R.string.dialog_delete_progress));
            progressDlg.show();
            Async.runAsync(new Runnable() {
                @Override
                public void run() {
                    String error = null;
                    String targetUrl = null;
                    if (deleteTask.isCancelled())
                        return;
                    try {
                        targetUrl = chan.deletePost(deletePostModel, null, deleteTask);
                    } catch (Exception e) {
                        if (e instanceof InteractiveException) {
                            if (deleteTask.isCancelled())
                                return;
                            ((InteractiveException) e).handle(activity, deleteTask,
                                    new InteractiveException.Callback() {
                                        @Override
                                        public void onSuccess() {
                                            if (!deleteTask.isCancelled()) {
                                                progressDlg.dismiss();
                                                onClick(dialog, which);
                                            }
                                        }

                                        @Override
                                        public void onError(String message) {
                                            if (!deleteTask.isCancelled()) {
                                                progressDlg.dismiss();
                                                Toast.makeText(activity, message, Toast.LENGTH_LONG).show();
                                                runDelete(deletePostModel, hasFiles);
                                            }
                                        }
                                    });
                            return;
                        }

                        Logger.e(TAG, "cannot delete post", e);
                        error = e.getMessage() == null ? "" : e.getMessage();
                    }
                    if (deleteTask.isCancelled())
                        return;
                    final boolean success = error == null;
                    final String result = success ? targetUrl : error;
                    Async.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            if (deleteTask.isCancelled())
                                return;
                            progressDlg.dismiss();
                            if (success) {
                                if (result == null) {
                                    update();
                                } else {
                                    UrlHandler.open(result, activity);
                                }
                            } else {
                                Toast.makeText(activity,
                                        TextUtils.isEmpty(result) ? resources.getString(R.string.error_unknown)
                                                : result,
                                        Toast.LENGTH_LONG).show();
                            }
                        }
                    });
                }
            });
        }
    };
    new AlertDialog.Builder(activity).setTitle(R.string.dialog_delete_password).setView(dlgLayout)
            .setPositiveButton(R.string.dialog_delete_button, dlgOnClick)
            .setNegativeButton(android.R.string.cancel, null).create().show();
}