Search in sources :

Example 1 with NewSecretEvent

use of com.auth0.sharelock.event.NewSecretEvent in project sharelock-android by auth0.

the class SecretInputFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    secretField = (EditText) view.findViewById(R.id.secret_input);
    nextButton = (Button) view.findViewById(R.id.next_button);
    secretField.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            nextButton.setVisibility(s.length() > 0 ? View.VISIBLE : View.INVISIBLE);
            SnackbarManager.dismiss();
        }
    });
    nextButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Secret secret = new Secret(secretField.getText().toString());
            bus.post(new NewSecretEvent(secret));
        }
    });
    ImageView craftedBy = (ImageView) view.findViewById(R.id.crafted_by);
    craftedBy.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(getString(R.string.crafted_by_url)));
            startActivity(intent);
        }
    });
    final Bundle arguments = getArguments();
    if (arguments != null) {
        secretField.setText(arguments.getString(SECRET_INPUT_FRAGMENT_SECRET_ARGUMENT));
    }
}
Also used : Secret(com.auth0.sharelock.Secret) Bundle(android.os.Bundle) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) NewSecretEvent(com.auth0.sharelock.event.NewSecretEvent) Intent(android.content.Intent) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with NewSecretEvent

use of com.auth0.sharelock.event.NewSecretEvent in project sharelock-android by auth0.

the class ComposeActivity method onEvent.

public void onEvent(NewSecretEvent event) {
    secret = event.getSecret();
    final ShareFragment fragment = new ShareFragment();
    getSupportFragmentManager().beginTransaction().setCustomAnimations(android.R.anim.slide_in_left, android.R.anim.slide_out_right, android.R.anim.slide_in_left, android.R.anim.slide_out_right).replace(R.id.sharelock_compose_container, fragment).addToBackStack("Share Step").commit();
}
Also used : ShareFragment(com.auth0.sharelock.fragment.ShareFragment)

Aggregations

Intent (android.content.Intent)1 Bundle (android.os.Bundle)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 Secret (com.auth0.sharelock.Secret)1 NewSecretEvent (com.auth0.sharelock.event.NewSecretEvent)1 ShareFragment (com.auth0.sharelock.fragment.ShareFragment)1