Search in sources :

Example 46 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project MaterialLibrary by DeveloperPaul123.

the class BaseRecyclerFabActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
    coordinatorLayout = new CoordinatorLayout(this);
    coordinatorLayout.setLayoutParams(params);
    CoordinatorLayout.LayoutParams coorLayoutParams = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    coorLayoutParams.setBehavior(new MaterialFabDefaultBehavior());
    coorLayoutParams.gravity = Gravity.BOTTOM | Gravity.RIGHT;
    materialFloatingActionButton = new MaterialFloatingActionButton(this);
    materialFloatingActionButton.setLayoutParams(coorLayoutParams);
    coordinatorLayout.addView(materialFloatingActionButton);
    getHomeLayout().addView(coordinatorLayout);
    ScrollListener scrollListener = new ScrollListener();
    scrollListener.setRecyclerView(getRecyclerView());
    scrollListener.setScrollThreshold(getResources().getDimensionPixelOffset(R.dimen.material_library_scroll_threshold));
    getRecyclerView().addOnScrollListener(scrollListener);
    materialFloatingActionButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onActionButtonClicked();
        }
    });
    isShowing = true;
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) MaterialFabDefaultBehavior(com.devpaul.materiallibrary.behaviors.MaterialFabDefaultBehavior) FrameLayout(android.widget.FrameLayout) MaterialFloatingActionButton(com.devpaul.materiallibrary.views.MaterialFloatingActionButton) AbstractRecyclerScrollListener(com.devpaul.materiallibrary.abstracts.AbstractRecyclerScrollListener) View(android.view.View)

Example 47 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project smooth-app-bar-layout by henrytao-me.

the class BaseBehavior method getSupportedScrollTarget.

private View getSupportedScrollTarget(View target) {
    if (target instanceof SwipeRefreshLayout && ((SwipeRefreshLayout) target).getChildCount() > 0) {
        SwipeRefreshLayout parent = (SwipeRefreshLayout) target;
        View child;
        int n = parent.getChildCount();
        for (int i = 0; i < n; i++) {
            child = parent.getChildAt(i);
            if (child instanceof NestedScrollView || child instanceof RecyclerView) {
                return child;
            }
        }
        return ((SwipeRefreshLayout) target).getChildAt(0);
    } else if (target instanceof CoordinatorLayout) {
        Stack<View> stack = new Stack<>();
        stack.add(target);
        while (stack.size() > 0) {
            View view = stack.pop();
            if (view instanceof NestedScrollView || view instanceof RecyclerView) {
                return view;
            }
            if (view instanceof ViewGroup) {
                int n = ((ViewGroup) view).getChildCount();
                for (int i = 0; i < n; i++) {
                    stack.add(((ViewGroup) view).getChildAt(i));
                }
            }
        }
    }
    return target;
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ViewGroup(android.view.ViewGroup) ObservableRecyclerView(me.henrytao.smoothappbarlayout.base.ObservableRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) ObservableNestedScrollView(me.henrytao.smoothappbarlayout.base.ObservableNestedScrollView) NestedScrollView(android.support.v4.widget.NestedScrollView) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ObservableRecyclerView(me.henrytao.smoothappbarlayout.base.ObservableRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) ObservableNestedScrollView(me.henrytao.smoothappbarlayout.base.ObservableNestedScrollView) View(android.view.View) NestedScrollView(android.support.v4.widget.NestedScrollView) Stack(java.util.Stack)

Example 48 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project AgileDev by LZ9.

the class StatusBarUtil method setColorForSwipeBack.

/**
 * 为滑动返回界面设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForSwipeBack(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
        View rootView = contentView.getChildAt(0);
        int statusBarHeight = getStatusBarHeight(activity);
        if (rootView != null && rootView instanceof CoordinatorLayout) {
            final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                coordinatorLayout.setFitsSystemWindows(false);
                contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
                boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
                if (isNeedRequestLayout) {
                    contentView.setPadding(0, statusBarHeight, 0, 0);
                    coordinatorLayout.post(new Runnable() {

                        @Override
                        public void run() {
                            coordinatorLayout.requestLayout();
                        }
                    });
                }
            } else {
                coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
            }
        } else {
            contentView.setPadding(0, statusBarHeight, 0, 0);
            contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        }
        setTransparentForWindow(activity);
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ViewGroup(android.view.ViewGroup) View(android.view.View)

Example 49 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project TicktockMusic by Lauzy.

the class StatusBarUtil method setColorForSwipeBack.

/**
 * 为滑动返回界面设置状态栏颜色
 *
 * @param activity       需要设置的activity
 * @param color          状态栏颜色值
 * @param statusBarAlpha 状态栏透明度
 */
public static void setColorForSwipeBack(Activity activity, @ColorInt int color, @IntRange(from = 0, to = 255) int statusBarAlpha) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        ViewGroup contentView = ((ViewGroup) activity.findViewById(android.R.id.content));
        View rootView = contentView.getChildAt(0);
        int statusBarHeight = getStatusBarHeight(activity);
        if (rootView != null && rootView instanceof CoordinatorLayout) {
            final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) rootView;
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                coordinatorLayout.setFitsSystemWindows(false);
                contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
                boolean isNeedRequestLayout = contentView.getPaddingTop() < statusBarHeight;
                if (isNeedRequestLayout) {
                    contentView.setPadding(0, statusBarHeight, 0, 0);
                    coordinatorLayout.post(new Runnable() {

                        @Override
                        public void run() {
                            coordinatorLayout.requestLayout();
                        }
                    });
                }
            } else {
                coordinatorLayout.setStatusBarBackgroundColor(calculateStatusColor(color, statusBarAlpha));
            }
        } else {
            contentView.setPadding(0, statusBarHeight, 0, 0);
            contentView.setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
        }
        setTransparentForWindow(activity);
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ViewGroup(android.view.ViewGroup) View(android.view.View)

Example 50 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project mintube by imshyam.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    mainAct = this;
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    viewStub = (ViewStub) findViewById(R.id.view_stub);
    if (isInternetAvailable(mainAct)) {
        viewStub.setLayoutResource(R.layout.content_main);
        viewStub.inflate();
        exit = false;
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        // Swipe Refresh WebView
        swipeRefreshLayout = (CustomSwipeRefresh) findViewById(R.id.swipe_refresh);
        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

            @Override
            public void onRefresh() {
                swipeRefreshLayout.setRefreshing(true);
                new Handler().post(new Runnable() {

                    @Override
                    public void run() {
                        youtubeView.loadUrl(youtubeView.getUrl());
                    }
                });
            }
        });
        // after initialization
        swipeRefreshLayout.setCanChildScrollUpCallback(new CustomSwipeRefresh.CanChildScrollUpCallback() {

            @Override
            public boolean canSwipeRefreshChildScrollUp() {
                return youtubeView.getScrollY() > 0;
            }
        });
        youtubeView = (WebView) findViewById(R.id.youtube_view);
        youtubeView.getSettings().setJavaScriptEnabled(true);
        youtubeView.setWebViewClient(new WebViewClient() {

            @Override
            public void onPageStarted(WebView view, String str, Bitmap bitmap) {
                super.onPageStarted(view, str, bitmap);
                Log.d("Main Page Loading ", str);
                swipeRefreshLayout.setRefreshing(true);
                currUrl = str;
            }

            @Override
            public void onPageFinished(WebView view, String str) {
                super.onPageFinished(view, str);
                swipeRefreshLayout.setRefreshing(false);
                Log.d("Main Page Finished", str);
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                if (url.contains("?app=desktop") && !url.contains("signin?app=desktop")) {
                    Log.d("Url stopped to load : ", url);
                    CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout);
                    final Snackbar snackbar = Snackbar.make(coordinatorLayout, "Desktop View Unavailable", Snackbar.LENGTH_LONG);
                    // Changing Text Color
                    View snkBar = snackbar.getView();
                    TextView tv = (TextView) snkBar.findViewById(android.support.design.R.id.snackbar_text);
                    tv.setTextColor(Color.parseColor("#e52d27"));
                    snackbar.show();
                    return true;
                }
                return false;
            }

            @Override
            public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    if (String.valueOf(request.getUrl()).contains("http://m.youtube.com/watch?") || String.valueOf(request.getUrl()).contains("https://m.youtube.com/watch?")) {
                        String url = String.valueOf(request.getUrl());
                        Log.d("Yay Catches!!!! ", url);
                        // Video Id
                        VID = url.substring(url.indexOf("&v=") + 3, url.length());
                        Log.d("VID ", VID);
                        // Playlist Id
                        final String listID = url.substring(url.indexOf("&list=") + 6, url.length());
                        Pattern pattern = Pattern.compile("([A-Za-z0-9_-]+)&[\\w]+=.*", Pattern.CASE_INSENSITIVE);
                        Matcher matcher = pattern.matcher(listID.toString());
                        Log.d("ListID", listID);
                        PID = "";
                        if (matcher.matches()) {
                            PID = matcher.group(1);
                        }
                        if (listID.contains("m.youtube.com")) {
                            Log.d("Not a ", "Playlist.");
                            PID = null;
                        } else {
                            Constants.linkType = 1;
                            Log.d("PlaylistID ", PID);
                        }
                        Handler handler = new Handler(getMainLooper());
                        final String finalPID = PID;
                        handler.post(new Runnable() {

                            @Override
                            public void run() {
                                youtubeView.stopLoading();
                                youtubeView.goBack();
                                if (isServiceRunning(PlayerService.class)) {
                                    Log.d("Service : ", "Already Running!");
                                    PlayerService.startVid(VID, finalPID);
                                } else {
                                    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(MainActivity.this)) {
                                        Intent i = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
                                        startActivityForResult(i, OVERLAY_PERMISSION_REQ);
                                    } else {
                                        Intent i = new Intent(MainActivity.this, PlayerService.class);
                                        i.putExtra("VID_ID", VID);
                                        i.putExtra("PLAYLIST_ID", finalPID);
                                        i.setAction(Constants.ACTION.STARTFOREGROUND_WEB_ACTION);
                                        startService(i);
                                    }
                                // Intent i = new Intent(MainActivity.this, PlayerService.class);
                                // i.putExtra("VID_ID", VID);
                                // i.putExtra("PLAYLIST_ID", finalPID);
                                // i.setAction(Constants.ACTION.STARTFOREGROUND_WEB_ACTION);
                                // startService(i);
                                }
                            }
                        });
                    }
                }
                return super.shouldInterceptRequest(view, request);
            }
        });
        youtubeView.canGoBack();
        currUrl = "https://m.youtube.com/";
        youtubeView.loadUrl(currUrl);
    } else {
        viewStub.setLayoutResource(R.layout.content_main_no_internet);
        viewStub.inflate();
        exit = true;
        retry = (Button) findViewById(R.id.retry_internet);
        changeSettings = (Button) findViewById(R.id.change_settings);
        exitApp = (Button) findViewById(R.id.exit_app);
        retry.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mainAct.recreate();
            }
        });
        changeSettings.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(Settings.ACTION_SETTINGS), 0);
            }
        });
        exitApp.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
Also used : Pattern(java.util.regex.Pattern) CustomSwipeRefresh(com.shapps.mintubeapp.CustomViews.CustomSwipeRefresh) WebResourceRequest(android.webkit.WebResourceRequest) Matcher(java.util.regex.Matcher) Handler(android.os.Handler) Intent(android.content.Intent) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) SearchView(android.support.v7.widget.SearchView) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Bitmap(android.graphics.Bitmap) WebResourceResponse(android.webkit.WebResourceResponse) TextView(android.widget.TextView) WebView(android.webkit.WebView) Toolbar(android.support.v7.widget.Toolbar) WebViewClient(android.webkit.WebViewClient) Snackbar(android.support.design.widget.Snackbar)

Aggregations

CoordinatorLayout (android.support.design.widget.CoordinatorLayout)57 View (android.view.View)37 AppBarLayout (android.support.design.widget.AppBarLayout)17 TextView (android.widget.TextView)15 ViewGroup (android.view.ViewGroup)13 RecyclerView (android.support.v7.widget.RecyclerView)12 Intent (android.content.Intent)9 Toolbar (android.support.v7.widget.Toolbar)8 Snackbar (android.support.design.widget.Snackbar)7 ViewParent (android.view.ViewParent)7 ImageView (android.widget.ImageView)7 NavigationView (android.support.design.widget.NavigationView)5 ViewPager (android.support.v4.view.ViewPager)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 SearchView (android.support.v7.widget.SearchView)5 LayoutInflater (android.view.LayoutInflater)5 FrameLayout (android.widget.FrameLayout)5 TabLayout (android.support.design.widget.TabLayout)4 PagerAdapter (android.support.v4.view.PagerAdapter)4 NestedScrollView (android.support.v4.widget.NestedScrollView)4