Example usage for android.widget FrameLayout FrameLayout

List of usage examples for android.widget FrameLayout FrameLayout

Introduction

In this page you can find the example usage for android.widget FrameLayout FrameLayout.

Prototype

public FrameLayout(@NonNull Context context) 

Source Link

Usage

From source file:com.example.kent_zheng.sdk_adaptertransition.AdapterTransitionFragment.java

/**
 * Copy all the visible views in the mAbsListView into a new FrameLayout and return it.
 *
 * @return a FrameLayout with all the visible views inside.
 *//*from   w  w  w. j  av  a  2s.  c o  m*/
private FrameLayout copyVisibleViews() {
    // This is the FrameLayout we return afterwards.
    FrameLayout layout = new FrameLayout(getActivity());
    // The transition framework requires to set ID for all views to be animated.
    layout.setId(ROOT_ID);
    // We only copy visible views.
    int first = mAbsListView.getFirstVisiblePosition();
    int index = 0;
    while (true) {
        // This is one of the views that we copy. Note that the argument for getChildAt is a
        // zero-oriented index, and it doesn't usually match with its position in the list.
        View source = mAbsListView.getChildAt(index);

        if (null == source) { //
            break;
        }

        // This is the copy of the original view.
        View destination = mAdapter.getView(first + index, null, layout);
        assert destination != null;
        destination.setId(ROOT_ID + first + index);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(source.getWidth(), source.getHeight());
        params.leftMargin = (int) source.getX();
        params.topMargin = (int) source.getY();
        layout.addView(destination, params);
        ++index;
    }
    return layout;
}

From source file:org.getlantern.firetweet.fragment.support.BaseSupportListFragment.java

/**
 * Provide default implementation to return a simple list view. Subclasses
 * can override to replace with their own layout. If doing so, the returned
 * view hierarchy <em>must</em> have a ListView whose id is
 * {@link android.R.id#list android.R.id.list} and can optionally have a
 * sibling view id {@link android.R.id#empty android.R.id.empty} that is to
 * be shown when the list is empty.//from w w  w  .  j a v a  2  s. c  om
 * <p/>
 * <p/>
 * If you are overriding this method with your own custom content, consider
 * including the standard layout {@link android.R.layout#list_content} in
 * your layout file, so that you continue to retain all of the standard
 * behavior of ListFragment. In particular, this is currently the only way
 * to have the built-in indeterminant progress state be shown.
 */
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    final Context context = getActivity();

    final FrameLayout root = new FrameLayout(context);

    // ------------------------------------------------------------------

    final LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    final ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(progress, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(pframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    final ExtendedFrameLayout lframe = new ExtendedFrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    lframe.setTouchInterceptor(mInternalOnTouchListener);

    final TextView tv = new TextView(getActivity());
    tv.setTextAppearance(context, ThemeUtils.getTextAppearanceLarge(context));
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lv.setOnScrollListener(this);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    root.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    // ------------------------------------------------------------------

    root.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    return root;
}

From source file:android.support.design.widget.TextInputLayout.java

public TextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    // Can't call through to super(Context, AttributeSet, int) since it doesn't exist on API 10
    super(context, attrs);

    ThemeUtils.checkAppCompatTheme(context);

    setOrientation(VERTICAL);//from ww  w. j a va2s . c  om
    setWillNotDraw(false);
    setAddStatesFromChildren(true);

    mInputFrame = new FrameLayout(context);
    mInputFrame.setAddStatesFromChildren(true);
    addView(mInputFrame);

    mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
    mCollapsingTextHelper.setPositionInterpolator(new AccelerateInterpolator());
    mCollapsingTextHelper.setCollapsedTextGravity(Gravity.TOP | GravityCompat.START);

    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.TextInputLayout,
            defStyleAttr, R.style.Widget_Design_TextInputLayout);
    mHintEnabled = a.getBoolean(R.styleable.TextInputLayout_hintEnabled, true);
    setHint(a.getText(R.styleable.TextInputLayout_android_hint));
    mHintAnimationEnabled = a.getBoolean(R.styleable.TextInputLayout_hintAnimationEnabled, true);

    if (a.hasValue(R.styleable.TextInputLayout_android_textColorHint)) {
        mDefaultTextColor = mFocusedTextColor = a
                .getColorStateList(R.styleable.TextInputLayout_android_textColorHint);
    }

    final int hintAppearance = a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, -1);
    if (hintAppearance != -1) {
        setHintTextAppearance(a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, 0));
    }

    mErrorTextAppearance = a.getResourceId(R.styleable.TextInputLayout_errorTextAppearance, 0);
    final boolean errorEnabled = a.getBoolean(R.styleable.TextInputLayout_errorEnabled, false);

    final boolean counterEnabled = a.getBoolean(R.styleable.TextInputLayout_counterEnabled, false);
    setCounterMaxLength(a.getInt(R.styleable.TextInputLayout_counterMaxLength, INVALID_MAX_LENGTH));
    mCounterTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterTextAppearance, 0);
    mCounterOverflowTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterOverflowTextAppearance,
            0);

    mPasswordToggleEnabled = a.getBoolean(R.styleable.TextInputLayout_passwordToggleEnabled, false);
    mPasswordToggleDrawable = a.getDrawable(R.styleable.TextInputLayout_passwordToggleDrawable);
    mPasswordToggleContentDesc = a.getText(R.styleable.TextInputLayout_passwordToggleContentDescription);
    if (a.hasValue(R.styleable.TextInputLayout_passwordToggleTint)) {
        mHasPasswordToggleTintList = true;
        mPasswordToggleTintList = a.getColorStateList(R.styleable.TextInputLayout_passwordToggleTint);
    }
    if (a.hasValue(R.styleable.TextInputLayout_passwordToggleTintMode)) {
        mHasPasswordToggleTintMode = true;
        mPasswordToggleTintMode = ViewUtils
                .parseTintMode(a.getInt(R.styleable.TextInputLayout_passwordToggleTintMode, -1), null);
    }

    a.recycle();

    setErrorEnabled(errorEnabled);
    setCounterEnabled(counterEnabled);
    applyPasswordToggleTint();

    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        // Make sure we're important for accessibility if we haven't been explicitly not
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    ViewCompat.setAccessibilityDelegate(this, new TextInputAccessibilityDelegate());
}

From source file:com.example.android.adaptertransition.AdapterTransitionFragment.java

/**
 * Copy all the visible views in the mAbsListView into a new FrameLayout and return it.
 *
 * @return a FrameLayout with all the visible views inside.
 *///from  w  w  w  .  j  ava 2 s  .c  om
private FrameLayout copyVisibleViews() {
    // This is the FrameLayout we return afterwards.
    FrameLayout layout = new FrameLayout(getActivity());
    // The transition framework requires to set ID for all views to be animated.
    layout.setId(ROOT_ID);
    // We only copy visible views.
    int first = mAbsListView.getFirstVisiblePosition();
    int index = 0;
    while (true) {
        // This is one of the views that we copy. Note that the argument for getChildAt is a
        // zero-oriented index, and it doesn't usually match with its position in the list.
        View source = mAbsListView.getChildAt(index);
        if (null == source) {
            break;
        }
        // This is the copy of the original view.
        View destination = mAdapter.getView(first + index, null, layout);
        assert destination != null;
        destination.setId(ROOT_ID + first + index);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(source.getWidth(), source.getHeight());
        params.leftMargin = (int) source.getX();
        params.topMargin = (int) source.getY();
        layout.addView(destination, params);
        ++index;
    }
    return layout;
}

From source file:com.kakao.auth.authorization.authcode.KakaoWebViewDialog.java

@SuppressLint("SetJavaScriptEnabled")
private void setUpWebView(int margin) {
    // TODO xml   ??
    FrameLayout webViewContainer = new FrameLayout(getContext());
    webView = new WebView(getContext());
    webView.setVerticalScrollBarEnabled(false);
    webView.setHorizontalScrollBarEnabled(false);
    webView.setWebViewClient(new DialogWebViewClient());
    webView.setWebChromeClient(new KakaoWebChromeClient());
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(url, headers);/* w w  w. j  a  v a  2  s  .c  o m*/
    webView.canGoBack();
    webView.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    webView.setVisibility(View.INVISIBLE);
    webView.getSettings().setSaveFormData(KakaoSDK.getAdapter().getSessionConfig().isSaveFormData());
    webView.getSettings().setSavePassword(false);
    webViewContainer.setPadding(margin, margin, margin, margin);
    webViewContainer.addView(webView);
    contentFrameLayout.addView(webViewContainer);
}

From source file:com.commonsware.cwac.crossport.design.widget.TextInputLayout.java

public TextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    // Can't call through to super(Context, AttributeSet, int) since it doesn't exist on API 10
    super(context, attrs);

    // ThemeUtils.checkAppCompatTheme(context);

    setOrientation(VERTICAL);/* ww  w .j a  va2 s  . c  o m*/
    setWillNotDraw(false);
    setAddStatesFromChildren(true);

    mInputFrame = new FrameLayout(context);
    mInputFrame.setAddStatesFromChildren(true);
    addView(mInputFrame);

    mCollapsingTextHelper.setTextSizeInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
    mCollapsingTextHelper.setPositionInterpolator(new AccelerateInterpolator());
    mCollapsingTextHelper.setCollapsedTextGravity(Gravity.TOP | GravityCompat.START);

    mHintExpanded = mCollapsingTextHelper.getExpansionFraction() == 1f;

    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TextInputLayout, defStyleAttr,
            R.style.Widget_Design_TextInputLayout);
    mHintEnabled = a.getBoolean(R.styleable.TextInputLayout_hintEnabled, true);
    setHint(a.getText(R.styleable.TextInputLayout_android_hint));
    mHintAnimationEnabled = a.getBoolean(R.styleable.TextInputLayout_hintAnimationEnabled, true);

    if (a.hasValue(R.styleable.TextInputLayout_android_textColorHint)) {
        mDefaultTextColor = mFocusedTextColor = a
                .getColorStateList(R.styleable.TextInputLayout_android_textColorHint);
    }

    final int hintAppearance = a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, -1);
    if (hintAppearance != -1) {
        setHintTextAppearance(a.getResourceId(R.styleable.TextInputLayout_hintTextAppearance, 0));
    }

    mErrorTextAppearance = a.getResourceId(R.styleable.TextInputLayout_errorTextAppearance, 0);
    final boolean errorEnabled = a.getBoolean(R.styleable.TextInputLayout_errorEnabled, false);

    final boolean counterEnabled = a.getBoolean(R.styleable.TextInputLayout_counterEnabled, false);
    setCounterMaxLength(a.getInt(R.styleable.TextInputLayout_counterMaxLength, INVALID_MAX_LENGTH));
    mCounterTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterTextAppearance, 0);
    mCounterOverflowTextAppearance = a.getResourceId(R.styleable.TextInputLayout_counterOverflowTextAppearance,
            0);

    mPasswordToggleEnabled = a.getBoolean(R.styleable.TextInputLayout_passwordToggleEnabled, false);
    mPasswordToggleDrawable = a.getDrawable(R.styleable.TextInputLayout_passwordToggleDrawable);
    mPasswordToggleContentDesc = a.getText(R.styleable.TextInputLayout_passwordToggleContentDescription);
    if (a.hasValue(R.styleable.TextInputLayout_passwordToggleTint)) {
        mHasPasswordToggleTintList = true;
        mPasswordToggleTintList = a.getColorStateList(R.styleable.TextInputLayout_passwordToggleTint);
    }
    if (a.hasValue(R.styleable.TextInputLayout_passwordToggleTintMode)) {
        mHasPasswordToggleTintMode = true;
        mPasswordToggleTintMode = ViewUtils
                .parseTintMode(a.getInt(R.styleable.TextInputLayout_passwordToggleTintMode, -1), null);
    }

    a.recycle();

    setErrorEnabled(errorEnabled);
    setCounterEnabled(counterEnabled);
    applyPasswordToggleTint();

    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        // Make sure we're important for accessibility if we haven't been explicitly not
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }

    ViewCompat.setAccessibilityDelegate(this, new TextInputAccessibilityDelegate());
}

From source file:com.nttec.everychan.http.recaptcha.Recaptcha2fallback.java

@Override
public void handle(final Activity activity, final CancellableTask task, final Callback callback) {
    try {/*from   w ww . ja v a2 s .  co m*/
        final HttpClient httpClient = ((HttpChanModule) MainApplication.getInstance().getChanModule(chanName))
                .getHttpClient();
        final String usingURL = scheme + RECAPTCHA_FALLBACK_URL + publicKey
                + (sToken != null && sToken.length() > 0 ? ("&stoken=" + sToken) : "");
        String refererURL = baseUrl != null && baseUrl.length() > 0 ? baseUrl : usingURL;
        Header[] customHeaders = new Header[] { new BasicHeader(HttpHeaders.REFERER, refererURL) };
        String htmlChallenge;
        if (lastChallenge != null && lastChallenge.getLeft().equals(usingURL)) {
            htmlChallenge = lastChallenge.getRight();
        } else {
            htmlChallenge = HttpStreamer.getInstance().getStringFromUrl(usingURL,
                    HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient,
                    null, task, false);
        }
        lastChallenge = null;

        Matcher challengeMatcher = Pattern.compile("name=\"c\" value=\"([\\w-]+)").matcher(htmlChallenge);
        if (challengeMatcher.find()) {
            final String challenge = challengeMatcher.group(1);
            HttpResponseModel responseModel = HttpStreamer.getInstance().getFromUrl(
                    scheme + RECAPTCHA_IMAGE_URL + challenge + "&k=" + publicKey,
                    HttpRequestModel.builder().setGET().setCustomHeaders(customHeaders).build(), httpClient,
                    null, task);
            try {
                InputStream imageStream = responseModel.stream;
                final Bitmap challengeBitmap = BitmapFactory.decodeStream(imageStream);

                final String message;
                Matcher messageMatcher = Pattern.compile("imageselect-message(?:.*?)>(.*?)</div>")
                        .matcher(htmlChallenge);
                if (messageMatcher.find())
                    message = RegexUtils.removeHtmlTags(messageMatcher.group(1));
                else
                    message = null;

                final Bitmap candidateBitmap;
                Matcher candidateMatcher = Pattern
                        .compile("fbc-imageselect-candidates(?:.*?)src=\"data:image/(?:.*?);base64,([^\"]*)\"")
                        .matcher(htmlChallenge);
                if (candidateMatcher.find()) {
                    Bitmap bmp = null;
                    try {
                        byte[] imgData = Base64.decode(candidateMatcher.group(1), Base64.DEFAULT);
                        bmp = BitmapFactory.decodeByteArray(imgData, 0, imgData.length);
                    } catch (Exception e) {
                    }
                    candidateBitmap = bmp;
                } else
                    candidateBitmap = null;

                activity.runOnUiThread(new Runnable() {
                    final int maxX = 3;
                    final int maxY = 3;
                    final boolean[] isSelected = new boolean[maxX * maxY];

                    @SuppressLint("InlinedApi")
                    @Override
                    public void run() {
                        LinearLayout rootLayout = new LinearLayout(activity);
                        rootLayout.setOrientation(LinearLayout.VERTICAL);

                        if (candidateBitmap != null) {
                            ImageView candidateView = new ImageView(activity);
                            candidateView.setImageBitmap(candidateBitmap);
                            int picSize = (int) (activity.getResources().getDisplayMetrics().density * 50
                                    + 0.5f);
                            candidateView.setLayoutParams(new LinearLayout.LayoutParams(picSize, picSize));
                            candidateView.setScaleType(ImageView.ScaleType.FIT_XY);
                            rootLayout.addView(candidateView);
                        }

                        if (message != null) {
                            TextView textView = new TextView(activity);
                            textView.setText(message);
                            CompatibilityUtils.setTextAppearance(textView, android.R.style.TextAppearance);
                            textView.setLayoutParams(
                                    new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                            LinearLayout.LayoutParams.WRAP_CONTENT));
                            rootLayout.addView(textView);
                        }

                        FrameLayout frame = new FrameLayout(activity);
                        frame.setLayoutParams(
                                new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT));

                        final ImageView imageView = new ImageView(activity);
                        imageView.setLayoutParams(new FrameLayout.LayoutParams(
                                FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
                        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                        imageView.setImageBitmap(challengeBitmap);
                        frame.addView(imageView);

                        final LinearLayout selector = new LinearLayout(activity);
                        selector.setLayoutParams(new FrameLayout.LayoutParams(
                                FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
                        AppearanceUtils.callWhenLoaded(imageView, new Runnable() {
                            @Override
                            public void run() {
                                selector.setLayoutParams(new FrameLayout.LayoutParams(imageView.getWidth(),
                                        imageView.getHeight()));
                            }
                        });
                        selector.setOrientation(LinearLayout.VERTICAL);
                        selector.setWeightSum(maxY);
                        for (int y = 0; y < maxY; ++y) {
                            LinearLayout subSelector = new LinearLayout(activity);
                            subSelector.setLayoutParams(new LinearLayout.LayoutParams(
                                    LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));
                            subSelector.setOrientation(LinearLayout.HORIZONTAL);
                            subSelector.setWeightSum(maxX);
                            for (int x = 0; x < maxX; ++x) {
                                FrameLayout switcher = new FrameLayout(activity);
                                switcher.setLayoutParams(new LinearLayout.LayoutParams(0,
                                        LinearLayout.LayoutParams.MATCH_PARENT, 1f));
                                switcher.setTag(new int[] { x, y });
                                switcher.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        int[] coord = (int[]) v.getTag();
                                        int index = coord[1] * maxX + coord[0];
                                        isSelected[index] = !isSelected[index];
                                        v.setBackgroundColor(isSelected[index] ? Color.argb(128, 0, 255, 0)
                                                : Color.TRANSPARENT);
                                    }
                                });
                                subSelector.addView(switcher);
                            }
                            selector.addView(subSelector);
                        }

                        frame.addView(selector);
                        rootLayout.addView(frame);

                        Button checkButton = new Button(activity);
                        checkButton.setLayoutParams(
                                new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
                                        LinearLayout.LayoutParams.WRAP_CONTENT));
                        checkButton.setText(android.R.string.ok);
                        rootLayout.addView(checkButton);

                        ScrollView dlgView = new ScrollView(activity);
                        dlgView.addView(rootLayout);

                        final Dialog dialog = new Dialog(activity);
                        dialog.setTitle("Recaptcha");
                        dialog.setContentView(dlgView);
                        dialog.setCanceledOnTouchOutside(false);
                        dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                            @Override
                            public void onCancel(DialogInterface dialog) {
                                if (!task.isCancelled()) {
                                    callback.onError("Cancelled");
                                }
                            }
                        });
                        dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
                                ViewGroup.LayoutParams.WRAP_CONTENT);
                        dialog.show();

                        checkButton.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                if (task.isCancelled())
                                    return;
                                Async.runAsync(new Runnable() {
                                    @Override
                                    public void run() {
                                        try {
                                            List<NameValuePair> pairs = new ArrayList<NameValuePair>();
                                            pairs.add(new BasicNameValuePair("c", challenge));
                                            for (int i = 0; i < isSelected.length; ++i)
                                                if (isSelected[i])
                                                    pairs.add(new BasicNameValuePair("response",
                                                            Integer.toString(i)));

                                            HttpRequestModel request = HttpRequestModel.builder()
                                                    .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8"))
                                                    .setCustomHeaders(new Header[] {
                                                            new BasicHeader(HttpHeaders.REFERER, usingURL) })
                                                    .build();
                                            String response = HttpStreamer.getInstance().getStringFromUrl(
                                                    usingURL, request, httpClient, null, task, false);
                                            String hash = "";
                                            Matcher matcher = Pattern.compile(
                                                    "fbc-verification-token(?:.*?)<textarea[^>]*>([^<]*)<",
                                                    Pattern.DOTALL).matcher(response);
                                            if (matcher.find())
                                                hash = matcher.group(1);

                                            if (hash.length() > 0) {
                                                Recaptcha2solved.push(publicKey, hash);
                                                activity.runOnUiThread(new Runnable() {
                                                    @Override
                                                    public void run() {
                                                        callback.onSuccess();
                                                    }
                                                });
                                            } else {
                                                lastChallenge = Pair.of(usingURL, response);
                                                throw new RecaptchaException(
                                                        "incorrect answer (hash is empty)");
                                            }
                                        } catch (final Exception e) {
                                            Logger.e(TAG, e);
                                            if (task.isCancelled())
                                                return;
                                            handle(activity, task, callback);
                                        }
                                    }
                                });
                            }
                        });
                    }
                });
            } finally {
                responseModel.release();
            }
        } else
            throw new Exception("can't parse recaptcha challenge answer");
    } catch (final Exception e) {
        Logger.e(TAG, e);
        if (!task.isCancelled()) {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    callback.onError(e.getMessage() != null ? e.getMessage() : e.toString());
                }
            });
        }
    }
}

From source file:com.yunluo.android.arcadehub.GameListActivity.java

private void initSliding() {

    slidingDisable();/*w  w w.j a  v  a  2s  .  c  o  m*/

    initLeftView();

    mMainLayout = new RelativeLayout(this);
    mMainLayout.setGravity(Gravity.CENTER_HORIZONTAL);

    mFrameLayout = new FrameLayout(this);

    setContentView(mFrameLayout);

    initRightView();

    mListShowView = mRightView.getListShowView();

    getSlidingMenu().setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);

    if (null != mListShowView) {
        mListShowView.firstRefresh();
    }

}

From source file:ti.modules.titanium.ui.widget.TiUIDrawerLayout.java

private void initLeft() {
    if (leftFrame != null) {
        return;//from  w w w  . j  a  v  a  2  s . co m
    }
    leftFrame = new FrameLayout(proxy.getActivity());

    LayoutParams frameLayout = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    frameLayout.gravity = Gravity.START;
    leftFrame.setLayoutParams(frameLayout);

    layout.addView(leftFrame);

    if (drawerToggle == null) {
        initDrawerToggle();
    }
}

From source file:com.mishiranu.dashchan.ui.navigator.NavigatorActivity.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override//from w w  w.  j  a v  a2 s .c o  m
public void onCreate(Bundle savedInstanceState) {
    currentPreferences = Preferences.getCurrent();
    if (C.API_LOLLIPOP) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        requestWindowFeature(Window.FEATURE_ACTION_MODE_OVERLAY);
    }
    ResourceUtils.applyPreferredTheme(this);
    expandedScreen = new ExpandedScreen(this, Preferences.isExpandedScreen());
    super.onCreate(savedInstanceState);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    float density = ResourceUtils.obtainDensity(this);
    setContentView(R.layout.activity_main);
    ClickableToast.register(clickableToastHolder);
    FavoritesStorage.getInstance().getObservable().register(this);
    watcherServiceClient.bind(this);
    pageManager = new PageManager();
    actionIconSet = new ActionIconSet(this);
    progressView = findViewById(R.id.progress);
    errorView = findViewById(R.id.error);
    errorText = (TextView) findViewById(R.id.error_text);
    listView = (PullableListView) findViewById(android.R.id.list);
    registerForContextMenu(listView);
    drawerCommon = (ViewGroup) findViewById(R.id.drawer_common);
    drawerWide = (ViewGroup) findViewById(R.id.drawer_wide);
    TypedArray typedArray = obtainStyledAttributes(new int[] { R.attr.styleDrawerSpecial });
    int drawerResId = typedArray.getResourceId(0, 0);
    typedArray.recycle();
    ContextThemeWrapper styledContext = drawerResId != 0 ? new ContextThemeWrapper(this, drawerResId) : this;
    int drawerBackground = ResourceUtils.getColor(styledContext, R.attr.backgroundDrawer);
    drawerCommon.setBackgroundColor(drawerBackground);
    drawerWide.setBackgroundColor(drawerBackground);
    drawerListView = new SortableListView(styledContext, this);
    drawerListView.setId(android.R.id.tabcontent);
    drawerListView.setOnSortingStateChangedListener(this);
    drawerForm = new DrawerForm(styledContext, this, this, watcherServiceClient);
    drawerForm.bind(drawerListView);
    drawerParent = new FrameLayout(this);
    drawerParent.addView(drawerListView);
    drawerCommon.addView(drawerParent);
    uiManager = new UiManager(this, this, expandedScreen);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (C.API_LOLLIPOP) {
        FrameLayout foreground = new FrameLayout(this);
        drawerLayout.addView(foreground, drawerLayout.indexOfChild(drawerCommon), new DrawerLayout.LayoutParams(
                DrawerLayout.LayoutParams.MATCH_PARENT, DrawerLayout.LayoutParams.MATCH_PARENT));
        getLayoutInflater().inflate(R.layout.widget_toolbar, foreground);
        Toolbar toolbar = (Toolbar) foreground.findViewById(R.id.toolbar);
        setActionBar(toolbar);
        toolbarView = toolbar;
        expandedScreen.setToolbar(toolbar, foreground);
    } else {
        getActionBar().setIcon(R.drawable.ic_logo); // Show white logo on search
    }
    drawerToggle = new DrawerToggle(this, drawerLayout);
    if (C.API_LOLLIPOP) {
        drawerCommon.setElevation(6f * density);
        drawerWide.setElevation(4f * density);
    } else {
        drawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
    }
    drawerLayout.addDrawerListener(drawerToggle);
    drawerLayout.addDrawerListener(drawerForm);
    if (toolbarView == null) {
        drawerLayout.addDrawerListener(new ExpandedScreenDrawerLocker());
    }
    ViewUtils.applyToolbarStyle(this, toolbarView);
    if (Preferences.isActiveScrollbar()) {
        listView.setFastScrollEnabled(true);
        if (!C.API_LOLLIPOP) {
            ListViewUtils.colorizeListThumb4(listView);
        }
    }
    listView.setOnItemClickListener(this);
    listView.setOnItemLongClickListener(this);
    listView.getWrapper().setOnPullListener(this);
    listView.getWrapper().setPullStateListener(this);
    listView.setClipToPadding(false);
    ScrollListenerComposite scrollListenerComposite = new ScrollListenerComposite();
    listView.setOnScrollListener(scrollListenerComposite);
    scrollListenerComposite.add(new BusyScrollListener(this));
    updateWideConfiguration(true);
    expandedScreen.setDrawerOverToolbarEnabled(!wideMode);
    expandedScreen.setContentListView(listView, scrollListenerComposite);
    expandedScreen.setDrawerListView(drawerParent, drawerListView, drawerForm.getHeaderView());
    expandedScreen.addAdditionalView(progressView, true);
    expandedScreen.addAdditionalView(errorView, true);
    expandedScreen.finishInitialization();
    LocalBroadcastManager.getInstance(this).registerReceiver(newPostReceiver,
            new IntentFilter(C.ACTION_POST_SENT));
    if (savedInstanceState == null) {
        savedInstanceState = pageManager.readFromStorage();
    }
    PageHolder savedCurrentPageHolder = pageManager.restore(savedInstanceState);
    if (savedCurrentPageHolder != null) {
        navigatePageHolder(savedCurrentPageHolder, false);
    } else {
        navigateIntent(getIntent(), false);
    }
    if (savedInstanceState == null) {
        startUpdateTask();
        int drawerInitialPosition = Preferences.getDrawerInitialPosition();
        if (drawerInitialPosition != Preferences.DRAWER_INITIAL_POSITION_CLOSED) {
            if (!wideMode) {
                drawerLayout.post(() -> drawerLayout.openDrawer(Gravity.START));
            }
            if (drawerInitialPosition == Preferences.DRAWER_INITIAL_POSITION_FORUMS) {
                drawerForm.setChanSelectMode(true);
            }
        }
    }
}