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;
}
}
}
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();
}
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();*/
}
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();
}
}
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();
}
}
Aggregations