ruboto/ruboto

View on GitHub
assets/app/src/main/resources/ruboto/toast.rb

Summary

Maintainability
A
0 mins
Test Coverage
#######################################################
#
# ruboto/toast.rb
#
# Utility methods for doing a toast.
#
#######################################################

Java::android.content.Context.class_eval do
  def toast(text, duration=Java::android.widget.Toast::LENGTH_SHORT)
    Java::android.widget.Toast.makeText(self, text, duration).show
  end

  def toast_result(result, success, failure, duration=Java::android.widget.Toast::LENGTH_SHORT)
    toast(result ? success : failure, duration)
  end
end