Search in sources :

Example 51 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project BottomBar by roughike.

the class BottomBar method initializeShyBehavior.

private void initializeShyBehavior() {
    ViewParent parent = getParent();
    boolean hasAbusiveParent = parent != null && parent instanceof CoordinatorLayout;
    if (!hasAbusiveParent) {
        throw new RuntimeException("In order to have shy behavior, the " + "BottomBar must be a direct child of a CoordinatorLayout.");
    }
    if (!shyHeightAlreadyCalculated) {
        int height = getHeight();
        if (height != 0) {
            updateShyHeight(height);
            getShySettings().shyHeightCalculated();
            shyHeightAlreadyCalculated = true;
        }
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ViewParent(android.view.ViewParent)

Example 52 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project PermissionsSample by CesarValiente.

the class BaseActivity method showSnackBarPermissionMessage.

protected void showSnackBarPermissionMessage(int message) {
    final CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_coordinator_layout);
    Snackbar snackbar = Snackbar.make(coordinatorLayout, getString(message), Snackbar.LENGTH_LONG).setAction(getString(R.string.snackbar_settings), new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            intent.setData(Uri.parse("package:" + BuildConfig.APPLICATION_ID));
            startActivity(intent);
        }
    });
    snackbar.show();
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) Snackbar(android.support.design.widget.Snackbar)

Example 53 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project GogoNew by kuldeep725.

the class MapsActivity method onBackPressed.

@Override
public void onBackPressed() {
    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (drawer.isDrawerOpen(GravityCompat.START)) {
        drawer.closeDrawer(GravityCompat.START);
    } else {
        if (doubleBackToExitPressedOnce) {
            super.onBackPressed();
            return;
        }
        this.doubleBackToExitPressedOnce = true;
        // Toast.makeText(this, "Please click BACK again to exit", Toast.LENGTH_SHORT).show();
        CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout);
        Snackbar.make(coordinatorLayout, "Click again to exit", Snackbar.LENGTH_SHORT).show();
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                doubleBackToExitPressedOnce = false;
            }
        }, 2000);
    }
/*new AlertDialog.Builder(this)
                                .setIcon(android.R.drawable.ic_dialog_alert)
                                .setTitle("Closing Activity")
                                .setMessage("Are you sure you want to close this activity?")
                                .setPositiveButton("Exit", new DialogInterface.OnClickListener()
                                {
                                        @Override
                                        public void onClick(DialogInterface dialog, int which) {
                                                finish();
                                        }

                                })
                                .setNegativeButton("No", null)
                                .show();*/
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) Handler(android.os.Handler) DrawerLayout(android.support.v4.widget.DrawerLayout)

Example 54 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project GogoNew by kuldeep725.

the class MapsActivity method showInternetStatus.

public void showInternetStatus() {
    // Log.e(TAG, "showInternetStatus fired");
    ConnectivityManager connec = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
    // Check for network connections
    if (connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED || connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTING || connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTING || connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED) {
        // Log.e(TAG, "HERE I COME (flagInternet) = "+flagInternet);
        if (!flagInternet)
            return;
        flagInternet = false;
        CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout);
        Snackbar snackbar = Snackbar.make(coordinatorLayout, "Connected", Snackbar.LENGTH_SHORT);
        View sbView = snackbar.getView();
        sbView.setBackgroundColor(Color.parseColor(primeColorString));
        final float scale = getResources().getDisplayMetrics().density;
        final float dps = 40;
        // converting 40 dp into pixels
        int pixels = (int) (dps * scale + 0.5f);
        TextView tview = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
        tview.setTextColor(ColorStateList.valueOf(Color.parseColor("#FFFFFF")));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            tview.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
        }
        snackbar.show();
    } else if (connec.getNetworkInfo(0).getState() == NetworkInfo.State.DISCONNECTED || connec.getNetworkInfo(1).getState() == NetworkInfo.State.DISCONNECTED) {
        if (flagInternet)
            return;
        // Log.e(TAG, "NOW I GO (flagInternet) = "+ flagInternet);
        flagInternet = true;
        CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout);
        Snackbar snackbar = Snackbar.make(coordinatorLayout, "No Internet Connection", Snackbar.LENGTH_INDEFINITE);
        View sbView = snackbar.getView();
        sbView.setBackgroundColor(Color.parseColor("#cc0000"));
        final float scale = getResources().getDisplayMetrics().density;
        final float dps = 40;
        // converting 40 dp into pixels
        int pixels = (int) (dps * scale + 0.5f);
        TextView tview = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
        tview.setTextColor(ColorStateList.valueOf(Color.parseColor("#ffffff")));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            tview.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
        }
        snackbar.show();
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) ConnectivityManager(android.net.ConnectivityManager) TextView(android.widget.TextView) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) TextView(android.widget.TextView) Paint(android.graphics.Paint) Snackbar(android.support.design.widget.Snackbar)

Example 55 with CoordinatorLayout

use of android.support.design.widget.CoordinatorLayout in project GogoNew by kuldeep725.

the class MapsActivity method showNetworkState.

public void showNetworkState(int a) {
    Log.e(TAG, "showNetworkState fired");
    Log.e(TAG, "a=" + a);
    // Log.e(TAG, "NETWORKINFO.isConnected()" + networkInfo.isConnected());
    if (a == 1) {
        // if connected with internet
        Log.e(TAG, "YES");
        Toast.makeText(this, " Connected ", Toast.LENGTH_LONG).show();
        CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout);
        Log.e(TAG, "COORDINATORLAYOUT");
        Snackbar snackbar = Snackbar.make(coordinatorLayout, "Connected", Snackbar.LENGTH_LONG);
        Log.e(TAG, "snackbar = " + snackbar.toString());
        View sbView = snackbar.getView();
        Log.e(TAG, "sbview=" + sbView.toString());
        sbView.setBackgroundColor(Color.parseColor(primeColorString));
        TextView tview = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
        Log.e(TAG, "TVIEW=" + tview.toString());
        tview.setTextColor(ColorStateList.valueOf(Color.parseColor("#FFFFFF")));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            tview.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
        }
        // snackbar.setActionTextColor(ColorStateList.valueOf(Color.parseColor(primeColorString)));
        snackbar.show();
    } else {
        Log.e(TAG, "NO");
        Toast.makeText(this, " Not Connected ", Toast.LENGTH_LONG).show();
        CoordinatorLayout coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout);
        Snackbar snackbar = Snackbar.make(coordinatorLayout, "No Internet Connection", Snackbar.LENGTH_LONG);
        View sbView = snackbar.getView();
        sbView.setBackgroundColor(Color.parseColor("#cc0000"));
        TextView tview = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
        tview.setTextColor(ColorStateList.valueOf(Color.parseColor("#ffffff")));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            tview.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
        }
        // snackbar.setActionTextColor(ColorStateList.valueOf(Color.parseColor(primeColorString)));
        snackbar.show();
    }
}
Also used : CoordinatorLayout(android.support.design.widget.CoordinatorLayout) TextView(android.widget.TextView) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) TextView(android.widget.TextView) 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