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();
}
}
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");
}
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();
}
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);
}
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;
}
Aggregations