package net.softglobe.tutorials;

import android.graphics.Color;
import android.support.constraint.ConstraintLayout;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import static android.support.design.widget.Snackbar.LENGTH_LONG;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void show(View v){
        final ConstraintLayout constraintLayout = findViewById(R.id.con);
        Snackbar snackbar = Snackbar.make(constraintLayout,"This is default Snackbar",LENGTH_LONG);
        snackbar.show();
    }

    public void callback(View v){
        final ConstraintLayout constraintLayout = findViewById(R.id.con);
            Snackbar snackbar = Snackbar
                .make(constraintLayout, "One new message", LENGTH_LONG)
                .setAction("Show", new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Snackbar snackbar1 = Snackbar.make(constraintLayout, "Hi, This is Technopoints", LENGTH_LONG);
                        snackbar1.show();
                    }
                });
        snackbar.show();
        snackbar.setActionTextColor(Color.WHITE);
        // Changing action button text color
        View sbView = snackbar.getView();
        TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
        textView.setTextColor(Color.YELLOW);

    }
}
