use of android.app.Activity in project android-betterpickers by code-troopers.
the class NumberPickerDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.number_picker_dialog, container, false);
Button doneButton = (Button) view.findViewById(R.id.done_button);
Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
cancelButton.setTextColor(mTextColor);
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
doneButton.setTextColor(mTextColor);
doneButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
BigDecimal number = mPicker.getEnteredNumber();
if (mMinNumber != null && mMaxNumber != null && (isSmaller(number) || isBigger(number))) {
String errorText = getString(R.string.min_max_error, mMinNumber, mMaxNumber);
mPicker.getErrorView().setText(errorText);
mPicker.getErrorView().show();
return;
} else if (mMinNumber != null && isSmaller(number)) {
String errorText = getString(R.string.min_error, mMinNumber);
mPicker.getErrorView().setText(errorText);
mPicker.getErrorView().show();
return;
} else if (mMaxNumber != null && isBigger(number)) {
String errorText = getString(R.string.max_error, mMaxNumber);
mPicker.getErrorView().setText(errorText);
mPicker.getErrorView().show();
return;
}
for (NumberPickerDialogHandlerV2 handler : mNumberPickerDialogHandlersV2) {
handler.onDialogNumberSet(mReference, mPicker.getNumber(), mPicker.getDecimal(), mPicker.getIsNegative(), number);
}
final Activity activity = getActivity();
final Fragment fragment = getTargetFragment();
if (activity instanceof NumberPickerDialogHandlerV2) {
final NumberPickerDialogHandlerV2 act = (NumberPickerDialogHandlerV2) activity;
act.onDialogNumberSet(mReference, mPicker.getNumber(), mPicker.getDecimal(), mPicker.getIsNegative(), number);
} else if (fragment instanceof NumberPickerDialogHandlerV2) {
final NumberPickerDialogHandlerV2 frag = (NumberPickerDialogHandlerV2) fragment;
frag.onDialogNumberSet(mReference, mPicker.getNumber(), mPicker.getDecimal(), mPicker.getIsNegative(), number);
}
dismiss();
}
});
mPicker = (NumberPicker) view.findViewById(R.id.number_picker);
mPicker.setSetButton(doneButton);
mPicker.setTheme(mTheme);
mPicker.setDecimalVisibility(mDecimalVisibility);
mPicker.setPlusMinusVisibility(mPlusMinusVisibility);
mPicker.setLabelText(mLabelText);
if (mMinNumber != null) {
mPicker.setMin(mMinNumber);
}
if (mMaxNumber != null) {
mPicker.setMax(mMaxNumber);
}
mPicker.setNumber(mCurrentNumber, mCurrentDecimal, mCurrentSign);
getDialog().getWindow().setBackgroundDrawableResource(mDialogBackgroundResId);
return view;
}
use of android.app.Activity in project GeekNews by codeestX.
the class App method exitApp.
public void exitApp() {
if (allActivities != null) {
synchronized (allActivities) {
for (Activity act : allActivities) {
act.finish();
}
}
}
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
}
use of android.app.Activity in project Android-PanesLibrary by cricklet.
the class ExampleFragment method addExampleFragment.
/**
* Create a new ExampleFragment and add it!
*/
private void addExampleFragment() {
// create a new fragment
Fragment f = new ExampleFragment();
//Fragment f = new ExampleListFragment();
// get the activity and add the new fragment after this one!
Activity a = getActivity();
if (a != null && a instanceof FragmentLauncher)
((FragmentLauncher) a).addFragment(ExampleFragment.this, f);
}
use of android.app.Activity in project UltimateAndroid by cymcsg.
the class Html5Webview method init.
private void init(Context context) {
mContext = context;
Activity mActivity = (Activity) mContext;
mLayout = new FrameLayout(context);
mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(mActivity).inflate(R.layout.html5_webview_custom_screen, null);
mContentView = (FrameLayout) mBrowserFrameLayout.findViewById(R.id.html5_webview_main_content);
mCustomViewContainer = (FrameLayout) mBrowserFrameLayout.findViewById(R.id.html5_webview_fullscreen_custom_content);
mLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS);
// Configure the webview
WebSettings s = getSettings();
s.setBuiltInZoomControls(true);
s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
s.setUseWideViewPort(true);
s.setLoadWithOverviewMode(true);
// s.setSavePassword(true);
s.setSaveFormData(true);
s.setJavaScriptEnabled(true);
mWebChromeClient = new MyWebChromeClient();
setWebChromeClient(mWebChromeClient);
setWebViewClient(new WebViewClient());
setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
// enable navigator.geolocation
// s.setGeolocationEnabled(true);
// s.setGeolocationDatabasePath("/data/data/org.itri.html5webview/databases/");
// enable Web Storage: localStorage, sessionStorage
s.setDomStorageEnabled(true);
mContentView.addView(this);
}
use of android.app.Activity in project UltimateAndroid by cymcsg.
the class IntentUtils method startPreviewActivity.
/**
* start screen capture after "delay" milliseconds, so the previous activity's
* state recover to normal state, such as button click, list item click,wait
* them to normal state so we can make a good screen capture
*
* @param context
* @param intent
* @param delay time in milliseconds
*/
public static void startPreviewActivity(final Context context, final Intent intent, long delay) {
final Handler mainThread = new Handler(Looper.getMainLooper());
final Runnable postAction = new Runnable() {
@Override
public void run() {
context.startActivity(intent);
}
};
/** process screen capture on background thread */
Runnable action = new Runnable() {
@Override
public void run() {
/**
* activity's root layout id, you can change the android.R.id.content to your root
* layout id
*/
final View contentView = ((Activity) context).findViewById(android.R.id.content);
ByteArrayOutputStream baos = null;
Bitmap bitmap = null;
try {
bitmap = Bitmap.createBitmap(contentView.getWidth(), contentView.getHeight(), Bitmap.Config.ARGB_8888);
contentView.draw(new Canvas(bitmap));
baos = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, baos);
intent.putExtra(KEY_PREVIEW_IMAGE, baos.toByteArray());
} finally {
try {
/** no need to close, actually do nothing */
if (null != baos)
baos.close();
} catch (IOException e) {
e.printStackTrace();
}
if (null != bitmap && !bitmap.isRecycled()) {
bitmap.recycle();
bitmap = null;
}
}
mainThread.post(postAction);
}
};
if (delay > 0) {
ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
worker.schedule(action, delay, TimeUnit.MILLISECONDS);
} else {
action.run();
}
}
Aggregations