Java Code Examples for de.keyboardsurfer.android.widget.crouton.Crouton

The following examples show how to use de.keyboardsurfer.android.widget.crouton.Crouton. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: QuickReturn   Source File: QuickReturnBaseActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void showCrouton(int colorRes, int messageRes) {
        Style croutonStyle = new Style.Builder()
                .setHeight(QuickReturnUtils.dp2px(this, 50))
//                                .setTextColor(getResources().getColor(R.color.white))
                .setGravity(Gravity.CENTER)
                .setBackgroundColor(colorRes)
                .build();

        Crouton.makeText(this, messageRes, croutonStyle)
                .setConfiguration(new Configuration.Builder()
                        .setDuration(Configuration.DURATION_SHORT)
                        .setInAnimation(R.anim.crouton_in_delayed)
                        .setOutAnimation(R.anim.crouton_out)
                        .build())
                .show();
    }
 
Example 2
Source Project: QuickReturn   Source File: QuickReturnBaseActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void showCrouton(int colorRes, String message) {
        Style croutonStyle = new Style.Builder()
                .setHeight(QuickReturnUtils.dp2px(this, 50))
//                                .setTextColor(getResources().getColor(R.color.white))
                .setGravity(Gravity.CENTER)
                .setBackgroundColor(colorRes)
                .build();

        Crouton.makeText(this, message, croutonStyle)
                .setConfiguration(new Configuration.Builder()
                        .setDuration(Configuration.DURATION_SHORT)
                        .setInAnimation(R.anim.crouton_in_delayed)
                        .setOutAnimation(R.anim.crouton_out)
                        .build())
                .show();
    }
 
Example 3
private void customView() {
    View view = getLayoutInflater().inflate(R.layout.notice_crouton, null);
    ((TextView) view.findViewById(R.id.message))
            .setText("Hello Crouton!! Let's enjoy!!");

    Configuration config = new Configuration.Builder().setDuration(
            Configuration.DURATION_INFINITE).build();

    final Crouton crouton = Crouton.make(this, view);
    crouton.setConfiguration(config);

    view.findViewById(R.id.ok_button).setOnClickListener(
            new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Crouton.hide(crouton);
                }
            });
    crouton.show();
}
 
Example 4
@Override
public void onLoadFinished(Loader<Result<Credential>> loader,
        Result<Credential> result) {
    if (loader.getId() == LOADER_GET_TOKEN) {
        message.setText(result.success ? result.data.getAccessToken() : "");
    } else {
        message.setText("");
    }
    if (result.success) {
        if (loader.getId() == LOADER_GET_TOKEN) {
            setButtonText(R.string.delete_token);
        } else {
            setButtonText(R.string.get_token);
        }
    } else {
        setButtonText(R.string.get_token);
        Crouton.makeText(getActivity(), result.errorMessage, Style.ALERT).show();
    }
    getActivity().setProgressBarIndeterminateVisibility(false);
    button.setEnabled(true);
}
 
Example 5
@Override
public void onLoadFinished(Loader<Result<Credential>> loader,
        Result<Credential> result) {
    if (loader.getId() == LOADER_GET_TOKEN) {
        message.setText(result.success ? result.data.getAccessToken() : "");
    } else {
        message.setText("");
    }
    if (result.success) {
        if (loader.getId() == LOADER_GET_TOKEN) {
            setButtonText(R.string.delete_token);
        } else {
            setButtonText(R.string.get_token);
        }
    } else {
        setButtonText(R.string.get_token);
        Crouton.makeText(getActivity(), result.errorMessage, Style.ALERT).show();
    }
    getActivity().setProgressBarIndeterminateVisibility(false);
    button.setEnabled(true);
}
 
Example 6
Source Project: android-oauth-client   Source File: StravaActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onLoadFinished(Loader<AsyncResourceLoader.Result<Credential>> loader,
                           AsyncResourceLoader.Result<Credential> result) {
    if (loader.getId() == LOADER_GET_TOKEN) {
        message.setText(result.success ? result.data.getAccessToken() : "");
    } else {
        message.setText("");
    }
    if (result.success) {
        if (loader.getId() == LOADER_GET_TOKEN) {
            setButtonText(R.string.delete_token);
        } else {
            setButtonText(R.string.get_token);
        }
    } else {
        setButtonText(R.string.get_token);
        Crouton.makeText(getActivity(), result.errorMessage, Style.ALERT).show();
    }
    getActivity().setProgressBarIndeterminateVisibility(false);
    button.setEnabled(true);
}
 
Example 7
@Override
public void onLoadFinished(Loader<Result<Credential>> loader,
        Result<Credential> result) {
    if (loader.getId() == LOADER_GET_TOKEN) {
        message.setText(result.success ? result.data.getAccessToken() : "");
    } else {
        message.setText("");
    }
    if (result.success) {
        if (loader.getId() == LOADER_GET_TOKEN) {
            setButtonText(R.string.delete_token);
        } else {
            setButtonText(R.string.get_token);
        }
    } else {
        setButtonText(R.string.get_token);
        Crouton.makeText(getActivity(), result.errorMessage, Style.ALERT).show();
    }
    getActivity().setProgressBarIndeterminateVisibility(false);
    button.setEnabled(true);
}
 
Example 8
@Override
public void onLoadFinished(Loader<Result<Credential>> loader,
        Result<Credential> result) {
    if (loader.getId() == LOADER_GET_TOKEN) {
        message.setText(result.success ? result.data.getAccessToken() : "");
    } else {
        message.setText("");
    }
    if (result.success) {
        if (loader.getId() == LOADER_GET_TOKEN) {
            setButtonText(R.string.delete_token);
        } else {
            setButtonText(R.string.get_token);
        }
    } else {
        setButtonText(R.string.get_token);
        Crouton.makeText(getActivity(), result.errorMessage, Style.ALERT).show();
    }
    getActivity().setProgressBarIndeterminateVisibility(false);
    button.setEnabled(true);
}
 
Example 9
Source Project: android-oauth-client   Source File: LoadableDecorator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onLoadFinished(Loader<Result<T>> loader, Result<T> result) {
    mCallbacks.onLoadFinished(loader, result);
    mActive.delete(loader.getId());
    if (mLoaderId == loader.getId()) {
        if (mListFragment.isResumed()) {
            mListFragment.setListShown(true);
        } else {
            mListFragment.setListShownNoAnimation(true);
        }
        if (!result.success) {
            Crouton.makeText(mListFragment.getActivity(),
                    result.errorMessage, Style.ALERT).show();
            LOGGER.log(Level.WARNING, "error: " + result.errorMessage, result.exception);
        }
        mListFragment.setEmptyText(mListFragment.getString(R.string.empty));
    }
    updateWindowIndeterminateProgress();
}
 
Example 10
@Override
public void onLoadFinished(Loader<Result<Credential>> loader,
        Result<Credential> result) {
    if (loader.getId() == LOADER_GET_TOKEN) {
        message.setText(result.success ? result.data.getAccessToken() : "");
    } else {
        message.setText("");
    }
    if (result.success) {
        if (loader.getId() == LOADER_GET_TOKEN) {
            setButtonText(R.string.delete_token);
        } else {
            setButtonText(R.string.get_token);
        }
    } else {
        setButtonText(R.string.get_token);
        Crouton.makeText(getActivity(), result.errorMessage, Style.ALERT).show();
    }
    getActivity().setProgressBarIndeterminateVisibility(false);
    button.setEnabled(true);
}
 
Example 11
public void notifyErrorOnGUI(CharSequence errorText) {
    if (mOnTopActivity != null) {
        Crouton.makeText(mOnTopActivity, errorText, Style.ALERT).show();
    } else {
        Toast.makeText(this, "aMuleRemote: " + errorText, Toast.LENGTH_LONG).show();
    }
}
 
Example 12
Source Project: Cheerleader   Source File: ArtistActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Used to display crouton toast.
 *
 * @param message text to be displayed.
 */
private void toast(@StringRes int message) {
    if (mCrouton != null) {
        mCrouton.cancel();
        mCrouton = null;
    }
    mCroutonView = new CroutonView(this, getString(message));

    mCrouton = Crouton.make(this, mCroutonView, R.id.activity_artist_main_container);
    mCrouton.show();
}
 
Example 13
Source Project: line-sdk-starter-android   Source File: HomeActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void displayCroutonOnMainThread(final String text, final Style style) {
	final Activity activity = this;
	mainThread.post(new Runnable() {
		@Override
		public void run() {
			Crouton.makeText(activity, text, style).show();
		}
	});
}
 
Example 14
Source Project: Noyze   Source File: ConfigurationActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void launchGooglePlus() {
    Intent google = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.google_plus_url)));
    if (google.resolveActivity(getPackageManager()) != null) {
        startActivity(google);
    } else {
        Crouton.showText(this, R.string.url_error, Style.ALERT);
    }
}
 
Example 15
Source Project: Noyze   Source File: ConfigurationActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroy() {
    LOGI(TAG, "onDestroy()");
    Crouton.cancelAllCroutons();
    try {
        MainThreadBus.get().unregister(this);
    } catch (Throwable t) {
        LOGE(TAG, "Unable to unregister from Otto.", t);
    }
    super.onDestroy();
}
 
Example 16
Source Project: Noyze   Source File: ConfigurationActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void openAccessibility() {
    Intent accessibility = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
    try {
        startActivity(accessibility);
    } catch (ActivityNotFoundException e) {
        LOGE(TAG, "Error opening Accessibility.", e);
        Crouton.showText(getActivity(), R.string.accessibility_error, Style.ALERT);
    }
}
 
Example 17
Source Project: Noyze   Source File: ConfigurationActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void openNotification() {
    Intent notifications = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
    try {
        startActivity(notifications);
    } catch (ActivityNotFoundException e) {
        LOGE(TAG, "Error opening NotificationListener.", e);
        Crouton.showText(getActivity(), R.string.accessibility_error, Style.ALERT);
    }
}
 
Example 18
Source Project: QuickReturn   Source File: QuickReturnBaseActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();

    if (mService != null) {
        unbindService(mServiceConn);
    }

    Crouton.cancelAllCroutons();
}
 
Example 19
Source Project: Noyze   Source File: ConfigurationActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void launchGooglePlus() {
    Intent google = new Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.google_plus_url)));
    if (google.resolveActivity(getPackageManager()) != null) {
        startActivity(google);
    } else {
        Crouton.showText(this, R.string.url_error, Style.ALERT);
    }
}
 
Example 20
Source Project: Noyze   Source File: ConfigurationActivity.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onDestroy() {
    LOGI(TAG, "onDestroy()");
    Crouton.cancelAllCroutons();
    try {
        MainThreadBus.get().unregister(this);
    } catch (Throwable t) {
        LOGE(TAG, "Unable to unregister from Otto.", t);
    }
    super.onDestroy();
}
 
Example 21
Source Project: Noyze   Source File: ConfigurationActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void openAccessibility() {
    Intent accessibility = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
    try {
        startActivity(accessibility);
    } catch (ActivityNotFoundException e) {
        LOGE(TAG, "Error opening Accessibility.", e);
        Crouton.showText(getActivity(), R.string.accessibility_error, Style.ALERT);
    }
}
 
Example 22
Source Project: Noyze   Source File: ConfigurationActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void openNotification() {
    Intent notifications = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
    try {
        startActivity(notifications);
    } catch (ActivityNotFoundException e) {
        LOGE(TAG, "Error opening NotificationListener.", e);
        Crouton.showText(getActivity(), R.string.accessibility_error, Style.ALERT);
    }
}
 
Example 23
Source Project: glimmr   Source File: BaseActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Clean the file cache when root activity exits.
 */
@Override
protected void onDestroy() {
    super.onDestroy();
    if (BuildConfig.DEBUG) Log.d(getLogTag(), "onDestroy");
    Crouton.cancelAllCroutons();
}
 
Example 24
Source Project: glimmr   Source File: UsageTips.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Show a usage tip via an INFO style crouton.  Tips are shown once per session unless the
 * force param is true.
 * @param activity
 * @param tip
 * @param force
 */
public void show(Activity activity, String tip, boolean force) {
    SharedPreferences defaultSharedPrefs =
            PreferenceManager.getDefaultSharedPreferences(activity);
    boolean enable = defaultSharedPrefs.getBoolean(Constants.KEY_ENABLE_USAGE_TIPS, false);
    if (!enable) {
        if (BuildConfig.DEBUG) Log.d(TAG, "Usage tips disabled in preferences");
        return;
    }
    if (!force && !mShownTips.contains(tip)) {
        Crouton.cancelAllCroutons();
        Crouton.makeText(activity, tip, Style.INFO).show();
        mShownTips.add(tip);
    }
}
 
Example 25
Source Project: barterli_android   Source File: AbstractBarterLiFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onStop() {
    super.onStop();
    Crouton.clearCroutonsForActivity(getActivity());
    mVolleyCallbacks.cancelAll(getTaskTag());
    DBInterface.cancelAll(getTaskTag());
    getActivity().setProgressBarIndeterminateVisibility(false);
}
 
Example 26
Source Project: barterli_android   Source File: AbstractBarterLiActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Display an alert, with a string message
 *
 * @param message The message to display
 * @param style   The {@link AlertStyle} of message to display
 */
public void showCrouton(final String message, final AlertStyle style) {
    //Crouton.make(activity, customView, viewGroupResId, configuration)
    //Crouton.make(this, getCroutonViewForStyle(this, message, style)).show();
    Crouton.make(this, getCroutonViewForStyle(this, message, style))
            .setConfiguration(
                    new de.keyboardsurfer.android.widget.crouton.Configuration.Builder()
                            .setDuration(
                                    de.keyboardsurfer.android.widget.crouton.Configuration
                                            .DURATION_SHORT
                            )
                            .build()
            ).show();
}
 
Example 27
Source Project: barterli_android   Source File: AbstractBarterLiActivity.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Display an alert, with a string message with infinite time
 *
 * @param message The message to display
 * @param style   The {@link AlertStyle} of message to display
 */
public void showInfiniteCrouton(final String message, final AlertStyle style) {
    Crouton.make(this, getCroutonViewForStyle(this, message, style))
            .setConfiguration(
                    new de.keyboardsurfer.android.widget.crouton.Configuration.Builder()
                            .setDuration(
                                    de.keyboardsurfer.android.widget.crouton.Configuration
                                            .DURATION_INFINITE
                            )
                            .build()
            ).show();

}
 
Example 28
private void doesNotDisapear() {
    final Crouton crouton = Crouton.makeText(this,
            "Hello Crouton!!\nClick here!", ENDLESS);

    crouton.setConfiguration(CONFIGURATION_ENDLESS)
            .setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    Crouton.hide(crouton);
                }
            }).show();
}
 
Example 29
Source Project: HeartbeatFixerForGCM   Source File: MainActivity.java    License: Apache License 2.0 4 votes vote down vote up
private void toastHeartbeatFixerState(boolean enabled) {
    final int msgResId = enabled ? R.string.toast_heartbeat_fixer_on : R.string.toast_heartbeat_fixer_off;
    Crouton.makeText(MainActivity.this, msgResId, Style.INFO, R.id.container).show();
}
 
Example 30
Source Project: SmileEssence   Source File: Notificator.java    License: MIT License 4 votes vote down vote up
public static void stopNotification() {
    isRunning = false;
    Crouton.cancelAllCroutons();
}