Java Code Examples for android.view.LayoutInflater.cloneInContext()

The following are Jave code examples for showing how to use cloneInContext() of the android.view.LayoutInflater class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: mvvm-template   File: BaseBottomSheetDialog.java   View Source Code Vote up 6 votes
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final Context contextThemeWrapper = new ContextThemeWrapper(getContext(), getContext().getTheme());
    LayoutInflater themeAwareInflater = inflater.cloneInContext(contextThemeWrapper);
    View view = themeAwareInflater.inflate(layoutRes(), container, false);
    unbinder = ButterKnife.bind(this, view);
    view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override public void onGlobalLayout() {
            view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            View parent = getDialog().findViewById(R.id.design_bottom_sheet);
            if (parent != null) {
                bottomSheetBehavior = BottomSheetBehavior.from(parent);
                if (bottomSheetBehavior != null) {
                    bottomSheetBehavior.setBottomSheetCallback(bottomSheetCallback);
                    bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
                }
            }
        }
    });
    return view;
}
 
Example 2
Project: adyen-android   File: IssuerSelectionFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView()");
    final View fragmentView;
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), theme);
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
    fragmentView = localInflater.inflate(R.layout.issuer_selection_fragment, container, false);

    for (InputDetail inputDetail : paymentMethod.getInputDetails()) {
        if (inputDetail.getKey().equals("idealIssuer") || inputDetail.getKey().equals("issuer")) {
            issuers = inputDetail.getItems();
            break;
        }
    }

    final IssuerListAdapter issuerListAdapter = new IssuerListAdapter(getActivity(), issuers);
    final ListView listView = (ListView) fragmentView.findViewById(R.id.issuer_methods_list);
    listView.setAdapter(issuerListAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(final AdapterView<?> adapterView, final View view, final int i, final long l) {
            String selectedIssuer = issuers.get(i).getId();
            issuerSelectionListener.onIssuerSelected(selectedIssuer);
        }
    });

    if (getActivity() instanceof CheckoutActivity) {
        ((CheckoutActivity) getActivity()).setActionBarTitle(paymentMethod.getName());
    }
    return fragmentView;
}
 
Example 3
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 4
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 5
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 6
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 7
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 8
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 9
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 10
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 11
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 12
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 13
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 14
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 15
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 16
Project: ProgressManager   File: a.java   View Source Code Vote up 5 votes
@Override
public LayoutInflater onGetLayoutInflater() {
    final LayoutInflater result = Activity.this.getLayoutInflater();
    if (onUseFragmentManagerInflaterFactory()) {
        return result.cloneInContext(Activity.this);
    }
    return result;
}
 
Example 17
Project: SOS-The-Healthcare-Companion   File: LoginFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.DarkTheme);
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
    View view = localInflater.inflate(R.layout.fragment_login, container, false);
    ButterKnife.bind(this, view);

    sharedPreferences = getActivity().getSharedPreferences("Profile", MODE_PRIVATE);
    return view;
}
 
Example 18
Project: springreplugin   File: PluginContext.java   View Source Code Vote up 5 votes
@Override
public Object getSystemService(String name) {
    if (LAYOUT_INFLATER_SERVICE.equals(name)) {
        if (mInflater == null) {
            LayoutInflater inflater = (LayoutInflater) super.getSystemService(name);
            // 新建一个,设置其工厂
            mInflater = inflater.cloneInContext(this);
            mInflater.setFactory(mFactory);
            // 再新建一个,后续可再次设置工厂
            mInflater = mInflater.cloneInContext(this);
        }
        return mInflater;
    }
    return super.getSystemService(name);
}
 
Example 19
Project: adyen-android   File: QiwiWalletFragment.java   View Source Code Vote up 4 votes
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    final View fragmentView;
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), theme);
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
    fragmentView = localInflater.inflate(R.layout.qiwi_wallet_fragment, container, false);


    final EditText telephoneNumber = (EditText) fragmentView.findViewById(R.id.telephone_number_edit_text);

    final Spinner countryCode = (Spinner) fragmentView.findViewById(R.id.country_code_spinner);

    Collection<InputDetail> inputDetails = paymentMethod.getInputDetails();
    for (InputDetail inputDetail : inputDetails) {
        if ("qiwiwallet.telephoneNumberPrefix".equals(inputDetail.getKey())) {
            java.util.ArrayList<String> countryCodes = new java.util.ArrayList<>();
            for (InputDetail.Item country : inputDetail.getItems()) {
                countryCodes.add(country.getName() + " (" + country.getId() + ")");
            }
            ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.select_dialog_item, countryCodes);
            countryCode.setAdapter(adapter);

            // TODO: Use a proper list adapter here to get rid of string magic below.
        }
    }

    final Button confirmButton = (Button) fragmentView.findViewById(R.id.collect_direct_debit_data);
    confirmButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String countryCodeString = countryCode.getSelectedItem().toString();
            String strippedCountryCode = countryCodeString.substring(countryCodeString.indexOf("+"), countryCodeString.indexOf(")"));
            qiwiWalletPaymentDetailsListener.onPaymentDetails(strippedCountryCode, telephoneNumber.getText().toString());
        }
    });
    confirmButton.setEnabled(true);

    final TextView amountTextview = (TextView) fragmentView.findViewById(R.id.amount_text_view);
    final String valueString = AmountUtil.format(amount, true, StringUtils.getLocale(getActivity()));
    final String amountString = getString(R.string.payButton_formatted, valueString);
    amountTextview.setText(amountString);

    if (getActivity() instanceof CheckoutActivity) {
        ((CheckoutActivity) getActivity()).setActionBarTitle(paymentMethod.getName());
    }

    return fragmentView;
}
 
Example 20
Project: adyen-android   File: PaymentMethodSelectionFragment.java   View Source Code Vote up 4 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    Log.d(TAG, "onCreateView()");
    final View fragmentView;

    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), theme);
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
    fragmentView = localInflater.inflate(R.layout.payment_method_selection_fragment, container, false);

    final PaymentListAdapter paymentListAdapter = new PaymentListAdapter(
            getActivity(), paymentMethods);
    final ListView listView = (ListView) fragmentView.findViewById(android.R.id.list);
    listView.setAdapter(paymentListAdapter);

    final PaymentListAdapter adyenUIPreferredPaymentListAdapter = new PaymentListAdapter(
            getActivity(), preferredPaymentMethods);
    final ListView preferredListView = (ListView) fragmentView.findViewById(R.id.preferred_payment_methods_list);
    preferredListView.setAdapter(adyenUIPreferredPaymentListAdapter);

    listView.setOnItemClickListener(new OnPaymentMethodClick());
    preferredListView.setOnItemClickListener(new OnPreferredPaymentMethodClick());

    ViewTreeObserver listVTO = listView.getViewTreeObserver();
    listVTO.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            listView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            resizeListView(listView, true);
        }
    });

    ViewTreeObserver preferredListVTO = preferredListView.getViewTreeObserver();
    preferredListVTO.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            preferredListView.getViewTreeObserver().removeGlobalOnLayoutListener(this);
            resizeListView(preferredListView, false);
        }
    });

    preferredPaymentMethodsLayout = fragmentView.findViewById(R.id.preferred_payment_methods_layout);

    /*
    paymentMethods.clear();
    preferredPaymentMethods.clear();
    preferredPaymentMethods.addAll(((CheckoutActivity) getActivity()).getPreferredPaymentMethods());
    paymentMethods.addAll(((CheckoutActivity) getActivity()).getAvailablePaymentMethods());
    adyenUIPreferredPaymentListAdapter.notifyDataSetChanged();
    paymentListAdapter.notifyDataSetChanged();
    */

    if (preferredPaymentMethods.isEmpty()) {
        preferredPaymentMethodsLayout.setVisibility(View.GONE);
    } else {
        preferredPaymentMethodsLayout.setVisibility(View.VISIBLE);
    }

    if (getActivity() instanceof CheckoutActivity) {
        ((CheckoutActivity) getActivity()).setActionBarTitle(R.string.paymentMethods_title);
    }

    return fragmentView;
}