Search in sources :

Example 16 with Activity

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;
}
Also used : Button(android.widget.Button) Activity(android.app.Activity) View(android.view.View) Fragment(android.support.v4.app.Fragment) DialogFragment(android.support.v4.app.DialogFragment) BigDecimal(java.math.BigDecimal)

Example 17 with Activity

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);
}
Also used : Activity(android.app.Activity)

Example 18 with Activity

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);
}
Also used : FragmentLauncher(com.mapsaurus.paneslayout.FragmentLauncher) Activity(android.app.Activity) Fragment(android.support.v4.app.Fragment)

Example 19 with Activity

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);
}
Also used : WebSettings(android.webkit.WebSettings) FrameLayout(android.widget.FrameLayout) Activity(android.app.Activity) WebViewClient(android.webkit.WebViewClient)

Example 20 with Activity

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();
    }
}
Also used : Bitmap(android.graphics.Bitmap) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Canvas(android.graphics.Canvas) Handler(android.os.Handler) Activity(android.app.Activity) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) View(android.view.View)

Aggregations

Activity (android.app.Activity)1138 View (android.view.View)200 Test (org.junit.Test)166 Intent (android.content.Intent)162 TextView (android.widget.TextView)83 ArrayList (java.util.ArrayList)62 Bundle (android.os.Bundle)53 Context (android.content.Context)51 ViewGroup (android.view.ViewGroup)48 DialogInterface (android.content.DialogInterface)44 AlertDialog (android.app.AlertDialog)41 Robolectric.buildActivity (org.robolectric.Robolectric.buildActivity)40 ImageView (android.widget.ImageView)36 Twitter (twitter4j.Twitter)35 LayoutInflater (android.view.LayoutInflater)34 AppCompatActivity (android.support.v7.app.AppCompatActivity)32 DisplayMetrics (android.util.DisplayMetrics)32 FrameLayout (android.widget.FrameLayout)28 Robolectric.setupActivity (org.robolectric.Robolectric.setupActivity)28 FragmentActivity (android.support.v4.app.FragmentActivity)27