Skip to content

Instantly share code, notes, and snippets.

View v3n3's full-sized avatar

Julien Veneziano v3n3

View GitHub Profile
public class LinearPattern implements FabulousPattern {
private static final int MAIN_FAB_ANIMATION_DURATION = 200;
@NotNull
@Override
public AnimatorSet getClosingAnimation(@NotNull View element, float destX, float destY) {
AnimatorSet anim = new AnimatorSet();
ObjectAnimator fabX = ObjectAnimator.ofFloat(element, View.X, destX);
fabX.setDuration(MAIN_FAB_ANIMATION_DURATION);
ObjectAnimator fabY = ObjectAnimator.ofFloat(element, View.Y, destY);
@Override
public boolean onOptionsItemSelected(MenuItem item) {
Snackbar.make(binding.getRoot(), item.getTitle(), Snackbar.LENGTH_SHORT).show();
return super.onOptionsItemSelected(item);
}
new Fabulous.Builder(this)
.setFab(binding.exampleOne)
.setFabOverlay(binding.overlay)
.setMenuId(R.menu.menu_sample)
.setMenuPattern(new LinearPattern())
.build();
/**
* Create the routeIntentToScreen method. This method find the Fragment associated with the URL in the intent, extract the variables and set it as {@link com.fueled.flowr.Flowr#currentFragment}
*
* @return The routeIntentToScreen JavaPoet object.
*/
private static MethodSpec routeIntentToScreen() {
return MethodSpec.methodBuilder("routeIntentToScreen")
.addModifiers(Modifier.PUBLIC)
.returns(FlowrDeepLinkInfoClassName)
.addParameter(ClassName.get("android.content", "Intent"), "intent")
private void generateDeepLinkHandler(String handlerPackage, MethodSpec.Builder constructorBuilder) {
TypeSpec classObject = getClassObject()
.addField(linkFragmentMap())
.addMethod(constructorBuilder.build())
.addMethod(bundleUriInfo())
.addMethod(getRegexPattern())
.addMethod(getNamedGroupCandidates())
.addMethod(addFragment())
.addMethod(routeIntentToScreen())
@android.databinding.BindingAdapter("showKeyboard")
public static void showKeyBoard(final EditText editText, final boolean showFlag) {
editText.post(new Runnable() {
@Override
public void run() {
if (showFlag) {
KeyboardUtils.showKeyboard(editText);
} else {
editText.clearFocus();
+ KeyboardUtils.hideKeyboard(editText.getContext(), editText);
/**
* Underline a portion of the text.
*
* @param view The TextView containing the text to underline.
* @param spanSize an array that contain the start index and the end index.
*/
@android.databinding.BindingAdapter("underline")
public static void underlineText(TextView view, @NonNull int[] spanSize) {
if (view != null && spanSize.length == 2) {
SpannableString content = new SpannableString(view.getText());
/**
* Enable a TextView to handle HTML links.
* @param view The TextView where the link will be located.
* @param linkRes The resource id that contains the HTML link.
*/
@SuppressWarnings("deprecation")
@android.databinding.BindingAdapter("link")
public static void addLinkToTextView(TextView view, @StringRes int linkRes) {
if (view != null) {
Resources resources = view.getContext().getResources();
<android.support.design.widget.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionSend"
app:onKeyDone="@{()-> model.doLogin()}"
/>
@BindingAdapter("onKeyDone")
public static void onKeyDone(EditText editText, final OnKeyPressedListener action) {
if (editText != null) {
editText.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
boolean handled = false;
if (keyCode == KeyEvent.KEYCODE_ENTER
&& event.getAction() == KeyEvent.ACTION_DOWN) {
action.onKeyPressed();