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

The following examples show how to use de.keyboardsurfer.android.widget.crouton.Crouton. 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 check out the related API usage on the sidebar.
Example #1
Source File: LoadableDecorator.java    From android-oauth-client with 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 #2
Source File: SimpleOAuth2ExplicitActivity.java    From android-oauth-client with Apache License 2.0 6 votes vote down vote up
@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 #3
Source File: SimpleOAuth2ImplicitActivity.java    From android-oauth-client with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: CroutonSampleActivity.java    From android-opensource-library-56 with Apache License 2.0 6 votes vote down vote up
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 #5
Source File: StravaActivity.java    From android-oauth-client with 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 #6
Source File: SimpleOAuth2ExplicitActivity.java    From android-oauth-client with Apache License 2.0 6 votes vote down vote up
@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 #7
Source File: SimpleOAuth10aActivity.java    From android-oauth-client with Apache License 2.0 6 votes vote down vote up
@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
Source File: CustomizedProgressActivity.java    From android-oauth-client with Apache License 2.0 6 votes vote down vote up
@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 File: QuickReturnBaseActivity.java    From QuickReturn with 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 #10
Source File: QuickReturnBaseActivity.java    From QuickReturn with 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 #11
Source File: AbstractBarterLiFragment.java    From barterli_android with 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 #12
Source File: ArtistActivity.java    From Cheerleader with 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 File: HomeActivity.java    From line-sdk-starter-android with 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 File: AmuleRemoteApplication.java    From aMuleRemote with GNU General Public License v3.0 5 votes vote down vote up
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 #15
Source File: CroutonSampleActivity.java    From android-opensource-library-56 with Apache License 2.0 5 votes vote down vote up
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 #16
Source File: ConfigurationActivity.java    From Noyze with 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 #17
Source File: ConfigurationActivity.java    From Noyze with 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 #18
Source File: AbstractBarterLiActivity.java    From barterli_android with 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 #19
Source File: AbstractBarterLiActivity.java    From barterli_android with 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 #20
Source File: UsageTips.java    From glimmr with 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 #21
Source File: BaseActivity.java    From glimmr with 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 #22
Source File: ConfigurationActivity.java    From Noyze with 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 #23
Source File: ConfigurationActivity.java    From Noyze with 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 #24
Source File: ConfigurationActivity.java    From Noyze with 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 #25
Source File: ConfigurationActivity.java    From Noyze with 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 #26
Source File: ConfigurationActivity.java    From Noyze with 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 #27
Source File: ConfigurationActivity.java    From Noyze with 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 #28
Source File: QuickReturnBaseActivity.java    From QuickReturn with Apache License 2.0 5 votes vote down vote up
@Override
protected void onDestroy() {
    super.onDestroy();

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

    Crouton.cancelAllCroutons();
}
 
Example #29
Source File: PlurkActivity.java    From android-oauth-client with Apache License 2.0 4 votes vote down vote up
@Override
protected void onDestroy() {
    Crouton.cancelAllCroutons();
    super.onDestroy();
}
 
Example #30
Source File: CustomizedProgressActivity.java    From android-oauth-client with Apache License 2.0 4 votes vote down vote up
@Override
protected void onDestroy() {
    Crouton.cancelAllCroutons();
    super.onDestroy();
}