Search in sources :

Example 66 with Activity

use of android.app.Activity in project Synthese_2BIN by TheYoungSensei.

the class BusinessDayDetailFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (getArguments().containsKey(ARG_ITEM_ID)) {
        // Load the dummy content specified by the fragment
        // arguments. In a real-world scenario, use a Loader
        // to load content from a content provider.
        mItem = DetailsContent.ITEM_MAP.get(getArguments().getString(ARG_ITEM_ID));
        Activity activity = this.getActivity();
        CollapsingToolbarLayout appBarLayout = (CollapsingToolbarLayout) activity.findViewById(R.id.toolbar_layout);
        if (appBarLayout != null) {
            appBarLayout.setTitle(mItem.content);
        }
    }
    this.model = ((Builder) this.getContext().getApplicationContext()).getModel();
    model.registerCompaniesObserver(this);
    ConnectivityManager connMgr = (ConnectivityManager) this.getContext().getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
    ShowMyCompaniesTask task = new ShowMyCompaniesTask();
    if (networkInfo != null && networkInfo.isConnected()) {
        task.execute();
    }
}
Also used : NetworkInfo(android.net.NetworkInfo) ConnectivityManager(android.net.ConnectivityManager) Activity(android.app.Activity) CollapsingToolbarLayout(android.support.design.widget.CollapsingToolbarLayout)

Example 67 with Activity

use of android.app.Activity in project Weather by Sparker0i.

the class Permissions method showRationale.

private void showRationale() {
    View rootView = ((Activity) mContext).getWindow().getDecorView().findViewById(R.id.fragment);
    Snackbar.make(rootView, "This Permission Is Required to access Weather Data of your location", Snackbar.LENGTH_LONG).show();
    Log.i("Permissions", "showRationale");
}
Also used : WeatherActivity(com.a5corp.weather.activity.WeatherActivity) Activity(android.app.Activity) View(android.view.View)

Example 68 with Activity

use of android.app.Activity in project Presentation by StanKocken.

the class ActivityLifecycleCallbackDelegateTest method testShouldCallListener.

@Test
public void testShouldCallListener() {
    Activity otherActivity = Mockito.mock(Activity.class);
    ActivityLifecycleCallbackDelegate.track(mActivity, mListener);
    ArgumentCaptor<Application.ActivityLifecycleCallbacks> argumentCaptor = ArgumentCaptor.forClass(Application.ActivityLifecycleCallbacks.class);
    verify(mApplication).registerActivityLifecycleCallbacks(argumentCaptor.capture());
    ActivityLifecycleCallbackDelegate activityLifecycleCallbackDelegate = (ActivityLifecycleCallbackDelegate) argumentCaptor.getValue();
    verify(mListener, times(0)).onCreate(null);
    activityLifecycleCallbackDelegate.onActivityCreated(otherActivity, null);
    verify(mListener, times(0)).onCreate(null);
    activityLifecycleCallbackDelegate.onActivityCreated(mActivity, null);
    verify(mListener, times(1)).onCreate(null);
    verify(mListener, times(0)).onStart();
    activityLifecycleCallbackDelegate.onActivityStarted(otherActivity);
    verify(mListener, times(0)).onStart();
    activityLifecycleCallbackDelegate.onActivityStarted(mActivity);
    verify(mListener, times(1)).onStart();
    verify(mListener, times(0)).onResume();
    activityLifecycleCallbackDelegate.onActivityResumed(otherActivity);
    verify(mListener, times(0)).onResume();
    activityLifecycleCallbackDelegate.onActivityResumed(mActivity);
    verify(mListener, times(1)).onResume();
    verify(mListener, times(0)).onPause();
    activityLifecycleCallbackDelegate.onActivityPaused(otherActivity);
    verify(mListener, times(0)).onPause();
    activityLifecycleCallbackDelegate.onActivityPaused(mActivity);
    verify(mListener, times(1)).onPause();
    verify(mListener, times(0)).onStop();
    activityLifecycleCallbackDelegate.onActivityStopped(otherActivity);
    verify(mListener, times(0)).onStop();
    activityLifecycleCallbackDelegate.onActivityStopped(mActivity);
    verify(mListener, times(1)).onStop();
    verify(mListener, times(0)).onSaveInstanceState(null);
    activityLifecycleCallbackDelegate.onActivitySaveInstanceState(otherActivity, null);
    verify(mListener, times(0)).onSaveInstanceState(null);
    activityLifecycleCallbackDelegate.onActivitySaveInstanceState(mActivity, null);
    verify(mListener, times(1)).onSaveInstanceState(null);
    verify(mListener, times(0)).onDestroy();
    activityLifecycleCallbackDelegate.onActivityDestroyed(otherActivity);
    verify(mListener, times(0)).onDestroy();
    activityLifecycleCallbackDelegate.onActivityDestroyed(mActivity);
    verify(mListener, times(1)).onDestroy();
}
Also used : Activity(android.app.Activity) Application(android.app.Application) ActivityLifecycleCallbackDelegate(com.skocken.presentation.util.ActivityLifecycleCallbackDelegate) Test(org.junit.Test)

Example 69 with Activity

use of android.app.Activity in project LshUtils by SenhLinsh.

the class LshFSKeyboardConflictUtil method hidePanelAndKeyboard.

/**
     * 隐藏面板和键盘
     */
public static void hidePanelAndKeyboard(View panelLayout) {
    final Activity activity = (Activity) panelLayout.getContext();
    final View focusView = activity.getCurrentFocus();
    if (focusView != null) {
        LshKeyboardUtils.hideKeyboard(activity.getCurrentFocus());
        focusView.clearFocus();
    }
    panelLayout.setVisibility(View.GONE);
}
Also used : Activity(android.app.Activity) View(android.view.View)

Example 70 with Activity

use of android.app.Activity in project android_frameworks_base by ResurrectionRemix.

the class ActivityInstrumentationTestCase2 method getActivity.

/**
     * Get the Activity under test, starting it if necessary.
     *
     * For each test method invocation, the Activity will not actually be created until the first
     * time this method is called.
     *
     * <p>If you wish to provide custom setup values to your Activity, you may call
     * {@link #setActivityIntent(Intent)} and/or {@link #setActivityInitialTouchMode(boolean)}
     * before your first call to getActivity().  Calling them after your Activity has
     * started will have no effect.
     *
     * <p><b>NOTE:</b> Activities under test may not be started from within the UI thread.
     * If your test method is annotated with {@link android.test.UiThreadTest}, then your Activity
     * will be started automatically just before your test method is run.  You still call this
     * method in order to get the Activity under test.
     *
     * @return the Activity under test
     */
@Override
public T getActivity() {
    Activity a = super.getActivity();
    if (a == null) {
        // set initial touch mode
        getInstrumentation().setInTouchMode(mInitialTouchMode);
        final String targetPackage = getInstrumentation().getTargetContext().getPackageName();
        // inject custom intent, if provided
        if (mActivityIntent == null) {
            a = launchActivity(targetPackage, mActivityClass, null);
        } else {
            a = launchActivityWithIntent(targetPackage, mActivityClass, mActivityIntent);
        }
        setActivity(a);
    }
    return (T) a;
}
Also used : Activity(android.app.Activity)

Aggregations

Activity (android.app.Activity)3220 Intent (android.content.Intent)612 View (android.view.View)535 Test (org.junit.Test)456 TextView (android.widget.TextView)263 Context (android.content.Context)220 ArrayList (java.util.ArrayList)201 Bundle (android.os.Bundle)197 DialogInterface (android.content.DialogInterface)167 SettingsActivity (com.android.settings.SettingsActivity)167 ViewGroup (android.view.ViewGroup)133 ImageView (android.widget.ImageView)116 AlertDialog (android.app.AlertDialog)109 LayoutInflater (android.view.LayoutInflater)109 Preference (android.support.v7.preference.Preference)83 PackageManager (android.content.pm.PackageManager)76 Uri (android.net.Uri)76 EditText (android.widget.EditText)72 ComponentName (android.content.ComponentName)71 Handler (android.os.Handler)71