Search in sources :

Example 76 with ViewStub

use of android.view.ViewStub in project android_frameworks_base by crdroidandroid.

the class ViewStubTest method testInflatedId.

@UiThreadTest
@MediumTest
public void testInflatedId() throws Exception {
    final StubbedView activity = getActivity();
    final ViewStub stub = (ViewStub) activity.findViewById(R.id.viewStubWithId);
    final View swapped = stub.inflate();
    assertNotNull("The inflated view is null", swapped);
    assertTrue("The inflated view has no id", swapped.getId() != View.NO_ID);
    assertTrue("The inflated view has the wrong id", swapped.getId() == R.id.stub_inflated);
}
Also used : ViewStub(android.view.ViewStub) StubbedView(android.view.StubbedView) StubbedView(android.view.StubbedView) View(android.view.View) UiThreadTest(android.test.UiThreadTest) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 77 with ViewStub

use of android.view.ViewStub in project android_frameworks_base by crdroidandroid.

the class ViewStubTest method testInflatedLayoutParams.

@UiThreadTest
@MediumTest
public void testInflatedLayoutParams() throws Exception {
    final StubbedView activity = getActivity();
    final ViewStub stub = (ViewStub) activity.findViewById(R.id.viewStubWithId);
    final View swapped = stub.inflate();
    assertNotNull("The inflated view is null", swapped);
    assertEquals("Both stub and inflated should same width", stub.getLayoutParams().width, swapped.getLayoutParams().width);
    assertEquals("Both stub and inflated should same height", stub.getLayoutParams().height, swapped.getLayoutParams().height);
}
Also used : ViewStub(android.view.ViewStub) StubbedView(android.view.StubbedView) StubbedView(android.view.StubbedView) View(android.view.View) UiThreadTest(android.test.UiThreadTest) MediumTest(android.test.suitebuilder.annotation.MediumTest)

Example 78 with ViewStub

use of android.view.ViewStub in project little-bear-dictionary by daimajia.

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;
}
Also used : StandaloneActionMode(com.actionbarsherlock.internal.view.StandaloneActionMode) ViewStub(android.view.ViewStub) StandaloneActionMode(com.actionbarsherlock.internal.view.StandaloneActionMode) ActionMode(com.actionbarsherlock.view.ActionMode)

Example 79 with ViewStub

use of android.view.ViewStub in project Rashr by DsLNeXuS.

the class DonationsFragment method onActivityCreated.

@TargetApi(11)
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    /* 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) {
                try {
                    donateGoogleOnClick(v);
                } catch (ClassNotFoundException ignore) {
                    ignore.printStackTrace();
                }
            }
        });
        // 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);
            }
        });
    }
}
Also used : ViewStub(android.view.ViewStub) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) IabResult(org.sufficientlysecure.donations.google.util.IabResult) View(android.view.View) IabHelper(org.sufficientlysecure.donations.google.util.IabHelper) TargetApi(android.annotation.TargetApi)

Aggregations

ViewStub (android.view.ViewStub)79 View (android.view.View)46 UiThreadTest (android.test.UiThreadTest)18 MediumTest (android.test.suitebuilder.annotation.MediumTest)18 StubbedView (android.view.StubbedView)18 TextView (android.widget.TextView)8 StandaloneActionMode (com.actionbarsherlock.internal.view.StandaloneActionMode)7 ActionMode (com.actionbarsherlock.view.ActionMode)7 Context (android.content.Context)6 Resources (android.content.res.Resources)6 ContextThemeWrapper (android.view.ContextThemeWrapper)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 ObjectAnimator (android.animation.ObjectAnimator)5 Paint (android.graphics.Paint)5 TypedValue (android.util.TypedValue)5 ActionMode (android.view.ActionMode)5 PopupWindow (android.widget.PopupWindow)5 FloatingActionMode (com.android.internal.view.FloatingActionMode)5 StandaloneActionMode (com.android.internal.view.StandaloneActionMode)5