If you think the Android project sms-smap-gateway listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.android.smap.utils;
//www.java2s.comimport android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.UnderlineSpan;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;
import com.android.smap.R;
publicclass MWUiUtils {
/**
* Hide keyboard
*
* @param Activity
*/publicstaticvoid hideKeyboard(Activity activity) {
InputMethodManager imm = (InputMethodManager) activity
.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null && activity != null) {
View currentFocus = activity.getCurrentFocus();
if (currentFocus != null) {
imm.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0);
}
}
}
/**
* Turns a textview into a clickable hyperlink with the provided text and attaches an
* OnClickListener.
*
* @param text
* @param view
* @param lis
*/publicstaticvoid makeHyperlink(String text, TextView view, OnClickListener lis) {
SpannableString ss = new SpannableString(text);
ss.setSpan(new UnderlineSpan(), 0, ss.length(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
view.setText(ss);
view.setMovementMethod(LinkMovementMethod
.getInstance());
view.setOnClickListener(lis);
}
/**
* Show simple error popup messages
*
* @param messageResource
*/publicstaticvoid showMessagePopup(Context context, String message) {
showMessagePopup(context, message,
new DialogInterface.OnClickListener() {
publicvoid onClick(DialogInterface dialog,
int which) {
dialog.dismiss();
}
});
}
/**
* Used to show error popup messages.
*
* @param messageResource
*/privatestaticvoid showMessagePopup(Context context,
String message,
DialogInterface.OnClickListener listener) {
new AlertDialog.Builder(context)
.setMessage(message)
.setCancelable(false)
.setNegativeButton(R.string.ok, listener)
.show();
}
}