From e806cac25e3cc4d2447963ffc063766d0edd31a9 Mon Sep 17 00:00:00 2001 From: Radoslaw Gabiga Date: Tue, 20 Dec 2016 09:50:22 +0100 Subject: [PATCH 1/2] Added the ability to toggle between top and bottom --- .../tsnackbar/MainActivity.java | 32 +++++++++++++ app/src/main/res/layout/activity_main.xml | 23 ++++++++++ .../androidadvance/topsnackbar/TSnackbar.java | 46 +++++++++++++++---- topsnackbar/src/main/res/anim/bottom_in.xml | 7 +++ topsnackbar/src/main/res/anim/bottom_out.xml | 7 +++ .../res/layout/tsnackbar_layout_bottom.xml | 22 +++++++++ 6 files changed, 127 insertions(+), 10 deletions(-) create mode 100644 topsnackbar/src/main/res/anim/bottom_in.xml create mode 100644 topsnackbar/src/main/res/anim/bottom_out.xml create mode 100644 topsnackbar/src/main/res/layout/tsnackbar_layout_bottom.xml diff --git a/app/src/main/java/com/androidadvance/tsnackbar/MainActivity.java b/app/src/main/java/com/androidadvance/tsnackbar/MainActivity.java index 9179dc2..876afc9 100644 --- a/app/src/main/java/com/androidadvance/tsnackbar/MainActivity.java +++ b/app/src/main/java/com/androidadvance/tsnackbar/MainActivity.java @@ -27,6 +27,8 @@ protected void onCreate(Bundle savedInstanceState) { Button button_example_4 = (Button) findViewById(R.id.button_example_4); Button button_example_5 = (Button) findViewById(R.id.button_example_5); Button button_example_6 = (Button) findViewById(R.id.button_example_6); + Button button_example_7 = (Button) findViewById(R.id.button_example_7); + Button button_example_8 = (Button) findViewById(R.id.button_example_8); relative_layout_main = (RelativeLayout) findViewById(R.id.relative_layout_main); @@ -143,5 +145,35 @@ public void onClick(View v) { } }); + + button_example_7.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + TSnackbar.make(relative_layout_main, "Hello from VSnackBar 1", TSnackbar.LENGTH_LONG, TSnackbar.POSITION_BOTTOM) + .show(); + } + }); + + button_example_8.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + TSnackbar snackbar = TSnackbar + .make(relative_layout_main, "Had a snack at Snackbar", TSnackbar.LENGTH_LONG, TSnackbar.POSITION_BOTTOM) + .setAction("Undo", new View.OnClickListener() { + @Override + public void onClick(View v) { + Log.d("Action Button", "onClick triggered"); + } + }); + snackbar.setActionTextColor(Color.LTGRAY); + snackbar.addIcon(R.mipmap.ic_core, 200); + View snackbarView = snackbar.getView(); + snackbarView.setBackgroundColor(Color.parseColor("#555555")); + TextView textView = (TextView) snackbarView.findViewById(com.androidadvance.topsnackbar.R.id.snackbar_text); + textView.setTextColor(Color.WHITE); + snackbar.show(); + + } + }); } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 3086ab8..e5951d6 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -99,6 +99,29 @@ android:id="@+id/button_example_6" android:layout_weight="1" /> + + +