use of android.view.ViewStub in project android_frameworks_base by crdroidandroid.
the class DecorView method createStandaloneActionMode.
private ActionMode createStandaloneActionMode(ActionMode.Callback callback) {
endOnGoingFadeAnimation();
cleanupPrimaryActionMode();
// cleanupPrimaryActionMode() invocation above.
if (mPrimaryActionModeView == null || !mPrimaryActionModeView.isAttachedToWindow()) {
if (mWindow.isFloating()) {
// Use the action bar theme.
final TypedValue outValue = new TypedValue();
final Resources.Theme baseTheme = mContext.getTheme();
baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
final Context actionBarContext;
if (outValue.resourceId != 0) {
final Resources.Theme actionBarTheme = mContext.getResources().newTheme();
actionBarTheme.setTo(baseTheme);
actionBarTheme.applyStyle(outValue.resourceId, true);
actionBarContext = new ContextThemeWrapper(mContext, 0);
actionBarContext.getTheme().setTo(actionBarTheme);
} else {
actionBarContext = mContext;
}
mPrimaryActionModeView = new ActionBarContextView(actionBarContext);
mPrimaryActionModePopup = new PopupWindow(actionBarContext, null, R.attr.actionModePopupWindowStyle);
mPrimaryActionModePopup.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION);
mPrimaryActionModePopup.setContentView(mPrimaryActionModeView);
mPrimaryActionModePopup.setWidth(MATCH_PARENT);
actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize, outValue, true);
final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics());
mPrimaryActionModeView.setContentHeight(height);
mPrimaryActionModePopup.setHeight(WRAP_CONTENT);
mShowPrimaryActionModePopup = new Runnable() {
public void run() {
mPrimaryActionModePopup.showAtLocation(mPrimaryActionModeView.getApplicationWindowToken(), Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
endOnGoingFadeAnimation();
if (shouldAnimatePrimaryActionModeView()) {
mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA, 0f, 1f);
mFadeAnim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
mPrimaryActionModeView.setVisibility(VISIBLE);
}
@Override
public void onAnimationEnd(Animator animation) {
mPrimaryActionModeView.setAlpha(1f);
mFadeAnim = null;
}
});
mFadeAnim.start();
} else {
mPrimaryActionModeView.setAlpha(1f);
mPrimaryActionModeView.setVisibility(VISIBLE);
}
}
};
} else {
ViewStub stub = (ViewStub) findViewById(R.id.action_mode_bar_stub);
if (stub != null) {
mPrimaryActionModeView = (ActionBarContextView) stub.inflate();
mPrimaryActionModePopup = null;
}
}
}
if (mPrimaryActionModeView != null) {
mPrimaryActionModeView.killMode();
ActionMode mode = new StandaloneActionMode(mPrimaryActionModeView.getContext(), mPrimaryActionModeView, callback, mPrimaryActionModePopup == null);
return mode;
}
return null;
}
use of android.view.ViewStub in project httpclient by pixmob.
the class ActionBarSherlockCompat method startActionMode.
@Override
public ActionMode startActionMode(ActionMode.Callback callback) {
if (DEBUG)
Log.d(TAG, "[startActionMode] callback: " + callback);
if (mActionMode != null) {
mActionMode.finish();
}
final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback);
ActionMode mode = null;
// Emulate Activity's onWindowStartingActionMode:
initActionBar();
if (aActionBar != null) {
mode = aActionBar.startActionMode(wrappedCallback);
}
if (mode != null) {
mActionMode = mode;
} else {
if (mActionModeView == null) {
ViewStub stub = (ViewStub) mDecor.findViewById(R.id.abs__action_mode_bar_stub);
if (stub != null) {
mActionModeView = (ActionBarContextView) stub.inflate();
}
}
if (mActionModeView != null) {
mActionModeView.killMode();
mode = new StandaloneActionMode(mActivity, mActionModeView, wrappedCallback, true);
if (callback.onCreateActionMode(mode, mode.getMenu())) {
mode.invalidate();
mActionModeView.initForMode(mode);
mActionModeView.setVisibility(View.VISIBLE);
mActionMode = mode;
mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
} else {
mActionMode = null;
}
}
}
if (mActionMode != null && mActivity instanceof OnActionModeStartedListener) {
((OnActionModeStartedListener) mActivity).onActionModeStarted(mActionMode);
}
return mActionMode;
}
use of android.view.ViewStub in project SmartAndroidSource by jaychou2012.
the class ActionBarSherlockCompat method startActionMode.
@Override
public ActionMode startActionMode(ActionMode.Callback callback) {
if (ActionBarSherlock.DEBUG)
Log.d(TAG, "[startActionMode] callback: " + callback);
if (mActionMode != null) {
mActionMode.finish();
}
final ActionMode.Callback wrappedCallback = new ActionModeCallbackWrapper(callback);
ActionMode mode = null;
// Emulate Activity's onWindowStartingActionMode:
initActionBar();
if (aActionBar != null) {
mode = aActionBar.startActionMode(wrappedCallback);
}
if (mode != null) {
mActionMode = mode;
} else {
if (mActionModeView == null) {
ViewStub stub = (ViewStub) mDecor.findViewById(getThemedContext().getResources().getIdentifier("abs__action_mode_bar_stub", "id", getThemedContext().getPackageName()));
// .findViewById(R.id.abs__action_mode_bar_stub);
if (stub != null) {
mActionModeView = (ActionBarContextView) stub.inflate();
}
}
if (mActionModeView != null) {
mActionModeView.killMode();
mode = new StandaloneActionMode(mActivity, mActionModeView, wrappedCallback, true);
if (callback.onCreateActionMode(mode, mode.getMenu())) {
mode.invalidate();
mActionModeView.initForMode(mode);
mActionModeView.setVisibility(View.VISIBLE);
mActionMode = mode;
mActionModeView.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
} else {
mActionMode = null;
}
}
}
if (mActionMode != null && mActivity instanceof OnActionModeStartedListener) {
((OnActionModeStartedListener) mActivity).onActionModeStarted(mActionMode);
}
return mActionMode;
}
use of android.view.ViewStub in project Klyph by jonathangerbaud.
the class PickerFragment method inflateTitleBar.
private void inflateTitleBar(ViewGroup view) {
ViewStub stub = (ViewStub) view.findViewById(R.id.com_facebook_picker_title_bar_stub);
if (stub != null) {
View titleBar = stub.inflate();
final RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
layoutParams.addRule(RelativeLayout.BELOW, R.id.com_facebook_picker_title_bar);
listView.setLayoutParams(layoutParams);
if (titleBarBackground != null) {
titleBar.setBackgroundDrawable(titleBarBackground);
}
doneButton = (Button) view.findViewById(R.id.com_facebook_picker_done_button);
if (doneButton != null) {
doneButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
logAppEvents(true);
appEventsLogged = true;
if (onDoneButtonClickedListener != null) {
onDoneButtonClickedListener.onDoneButtonClicked(PickerFragment.this);
}
}
});
if (getDoneButtonText() != null) {
doneButton.setText(getDoneButtonText());
}
if (doneButtonBackground != null) {
doneButton.setBackgroundDrawable(doneButtonBackground);
}
}
titleTextView = (TextView) view.findViewById(R.id.com_facebook_picker_title);
if (titleTextView != null) {
if (getTitleText() != null) {
titleTextView.setText(getTitleText());
}
}
}
}
use of android.view.ViewStub in project Klyph by jonathangerbaud.
the class DonationsFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
/* Flattr */
if (mFlattrEnabled) {
// inflate flattr view into stub
ViewStub flattrViewStub = (ViewStub) getActivity().findViewById(R.id.donations__flattr_stub);
flattrViewStub.inflate();
buildFlattrView();
}
/* Google */
if (mGoogleEnabled) {
// inflate google view into stub
ViewStub googleViewStub = (ViewStub) getActivity().findViewById(R.id.donations__google_stub);
googleViewStub.inflate();
// choose donation amount
mGoogleSpinner = (Spinner) getActivity().findViewById(R.id.donations__google_android_market_spinner);
ArrayAdapter<CharSequence> adapter;
if (mDebug) {
adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item, CATALOG_DEBUG);
} else {
adapter = new ArrayAdapter<CharSequence>(getActivity(), android.R.layout.simple_spinner_item, mGoogleCatalogValues);
}
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mGoogleSpinner.setAdapter(adapter);
Button btGoogle = (Button) getActivity().findViewById(R.id.donations__google_android_market_donate_button);
btGoogle.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
donateGoogleOnClick(v);
}
});
// Create the helper, passing it our context and the public key to verify signatures with
if (mDebug)
Log.d(TAG, "Creating IAB helper.");
mHelper = new IabHelper(getActivity(), mGooglePubkey);
// enable debug logging (for a production application, you should set this to false).
mHelper.enableDebugLogging(mDebug);
// will be called once setup completes.
if (mDebug)
Log.d(TAG, "Starting setup.");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
if (mDebug)
Log.d(TAG, "Setup finished.");
if (!result.isSuccess()) {
// Oh noes, there was a problem.
openDialog(android.R.drawable.ic_dialog_alert, R.string.donations__google_android_market_not_supported_title, getString(R.string.donations__google_android_market_not_supported));
return;
}
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null)
return;
}
});
}
/* PayPal */
if (mPaypalEnabled) {
// inflate paypal view into stub
ViewStub paypalViewStub = (ViewStub) getActivity().findViewById(R.id.donations__paypal_stub);
paypalViewStub.inflate();
Button btPayPal = (Button) getActivity().findViewById(R.id.donations__paypal_donate_button);
btPayPal.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
donatePayPalOnClick(v);
}
});
}
}
Aggregations