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:com.github.shareme.blackandroids.greenandroid.viewdecorator.ViewDecoratorInstaller.java

@UiThread
public boolean install(@NonNull Activity activity) {
    LayoutInflater layoutInflater = activity.getLayoutInflater();

    if (layoutInflater.getFactory() == null) {
        LayoutInflaterFactory layoutInflaterFactory = new DecoratingLayoutInflaterFactory(
                getPlatformViewFactory(layoutInflater), viewDecorator);
        LayoutInflaterCompat.setFactory(layoutInflater, layoutInflaterFactory);
        return true;
    }//from  ww w  .ja  v a  2 s  .c om

    return false;
}

From source file:com.forrestguice.suntimeswidget.AboutDialog.java

@NonNull
@Override//ww w .j av  a 2 s . c  o m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Activity myParent = getActivity();
    LayoutInflater inflater = myParent.getLayoutInflater();
    @SuppressLint("InflateParams")
    View dialogContent = inflater.inflate(R.layout.layout_dialog_about, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(myParent);
    builder.setView(dialogContent);
    AlertDialog dialog = builder.create();

    initViews(getActivity(), dialogContent);
    return dialog;
}

From source file:pl.wasat.smarthma.adapter.NewsArticleListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    Activity activity = (Activity) getContext();
    LayoutInflater inflater = activity.getLayoutInflater();

    convertView = inflater.inflate(R.layout.view_cell_article, null);

    SwipeDetector swipeDetector = new SwipeDetector(convertView, position);
    swipeDetector.setOnClickListener(listener);
    convertView.setOnTouchListener(swipeDetector);

    NewsArticle article = getItem(position);

    TextView textView = (TextView) convertView.findViewById(R.id.article_title_text);
    textView.setText(article.getTitle());

    TextView dateView = (TextView) convertView.findViewById(R.id.article_listing_smallprint);
    String pubDate = article.getPubDate();
    dateView.setText(pubDate);//from   ww  w.  j a v a2s . com

    if (article.isRead()) {
        LinearLayout row = (LinearLayout) convertView.findViewById(R.id.view_cell_article_row_background);
        row.setBackgroundColor(ContextCompat.getColor(activity, R.color.row_selected));
    }
    return convertView;
}

From source file:com.forrestguice.suntimeswidget.EquinoxDialog.java

@NonNull
@Override/*from   ww  w  .j  a v  a 2  s  .  c o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Activity myParent = getActivity();
    LayoutInflater inflater = myParent.getLayoutInflater();

    View dialogContent = inflater.inflate(R.layout.layout_dialog_equinox, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(myParent);
    builder.setView(dialogContent);
    AlertDialog dialog = builder.create();

    initViews(dialogContent);
    if (savedInstanceState != null) {
        Log.d("DEBUG", "EquinoxDialog onCreate (restoreState)");
        equinoxView.loadState(savedInstanceState);
    }

    dialog.setOnShowListener(onShowListener);
    return dialog;
}

From source file:com.forrestguice.suntimeswidget.HelpDialog.java

/**
 * @param savedInstanceState a previously saved state (or null)
 * @return a Dialog object ready to be displayed
 *//*from  w  w  w .j av  a 2  s  . c om*/
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Activity myParent = getActivity();
    LayoutInflater inflater = myParent.getLayoutInflater();
    @SuppressLint("InflateParams")
    View dialogContent = inflater.inflate(R.layout.layout_dialog_help, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(myParent);
    builder.setView(dialogContent);
    AlertDialog dialog = builder.create();

    initViews(dialogContent);
    if (savedInstanceState != null) {
        //Log.d("DEBUG", "HelpDialog onCreate (restoreState)");
        rawContent = savedInstanceState.getString(KEY_HELPTEXT);
    }
    setContent(rawContent);
    return dialog;
}

From source file:com.forrestguice.suntimeswidget.LightMapDialog.java

@NonNull
@Override/*from ww  w.  ja v  a2 s. c om*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Activity myParent = getActivity();
    LayoutInflater inflater = myParent.getLayoutInflater();

    View dialogContent = inflater.inflate(R.layout.layout_dialog_lightmap, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(myParent);
    builder.setView(dialogContent);
    AlertDialog dialog = builder.create();

    initViews(dialogContent);
    if (savedInstanceState != null) {
        Log.d("DEBUG", "LightMapDialog onCreate (restoreState)");
    }

    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(DialogInterface dialogInterface) {
            lightmap.updateViews(data);
        }
    });

    themeViews(dialog.getContext());
    return dialog;
}

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

@NonNull
@Override//from   w w w  .ja  v a 2s . c om
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    final LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.privacy_dialog, null);
    SharedPreferences preferences = activity.getPreferences(0);
    final SharedPreferences.Editor editor = preferences.edit();

    builder.setView(view).setTitle(R.string.privacy_title).setPositiveButton(R.string.help_ok,
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            });

    return builder.create();
}

From source file:com.dnielfe.manager.dialogs.DirectoryInfoDialog.java

public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Activity activity = this.getActivity();
    mView = activity.getLayoutInflater().inflate(R.layout.dialog_directory_info, null);
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(R.string.dir_info);
    builder.setView(mView);/* w  ww. j  av a  2  s .  c  o m*/
    builder.setNeutralButton(R.string.ok, null);
    return builder.create();
}

From source file:pl.wasat.smarthma.adapter.SearchListAdapter.java

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Activity activity = (Activity) getContext();
    LayoutInflater inflater = activity.getLayoutInflater();

    View rowView = inflater.inflate(R.layout.view_cell_collection_search, parent, false);
    final EntryISO searchItem = getItem(position);

    TextView textView = (TextView) rowView.findViewById(R.id.search_list_name);
    textView.setText(searchItem.getTitle());

    TextView dateView = (TextView) rowView.findViewById(R.id.search_listing_smallprint);

    /*        final String pubDate = "These data were published: %1$s  and updated: %1$s"
        + DateUtils.getISOPubDate(searchItem) + " and updated: "
        + searchItem.getUpdated();*/
    final String pubDate = String.format(activity.getString(R.string.these_data_are_published_and_updated),
            DateUtils.getISOPubDate(searchItem), searchItem.getUpdated());
    dateView.setText(pubDate);//from www.ja  v  a2  s . c  om

    if (!searchItem.isNotRead()) {
        View row = rowView.findViewById(R.id.view_cell_collection_search_row_background);
        row.setBackgroundColor(ContextCompat.getColor(activity, R.color.row_selected));
    }

    final ImageView button = (ImageView) rowView.findViewById(R.id.star_button);
    updateFavourite(searchItem.isFavourite(), button, activity);

    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            setFavourite(!searchItem.isFavourite(), button, activity, searchItem);
            FavouritesDbAdapter dba = new FavouritesDbAdapter(activity);
            if (searchItem.isFavourite()) {
                dba.openToWrite();
                dba.insertEntry(searchItem);
                dba.close();
                Toast.makeText(activity, activity.getString(R.string.collection_added_to_favourites),
                        Toast.LENGTH_LONG).show();
            } else {
                dba.openToWrite();
                dba.removeEntry(searchItem);
                dba.close();
            }
            dba.openToRead();
            dba.close();
        }
    });
    SwipeDetector swipeDetector = new SwipeDetector(rowView, position);
    swipeDetector.setOnClickListener(listener);
    rowView.setOnTouchListener(swipeDetector);
    return rowView;
}

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

@NonNull
@Override/*from   w  w w .j  a  va 2  s  .  c  o m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Activity activity = getActivity();
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    final LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.help_dialog, null);
    SharedPreferences preferences = activity.getPreferences(0);
    final SharedPreferences.Editor editor = preferences.edit();

    builder.setView(view).setTitle(R.string.help_title).setPositiveButton(R.string.help_ok,
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {

                }
            });

    Switch locationToggle = (Switch) view.findViewById(R.id.help_toggle);
    locationToggle.setChecked(preferences.getBoolean(StorageKeys.HELP_TOGGLE_KEY, false));
    locationToggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            editor.putBoolean(StorageKeys.HELP_TOGGLE_KEY, b);
            editor.commit();
        }
    });

    return builder.create();
}