Java Code Examples for android.app.Activity#equals()

The following examples show how to use android.app.Activity#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivityUtils.java    From AndroidRipper with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Removes a given activity from the activity stack
 * 
 * @param activity the activity to remove
 */

private void removeActivityFromStack(Activity activity){

	Iterator<WeakReference<Activity>> activityStackIterator = activityStack.iterator();
	while(activityStackIterator.hasNext()){
		Activity activityFromWeakReference = activityStackIterator.next().get();

		if(activityFromWeakReference == null){
			activityStackIterator.remove();
		}

		if(activity != null && activityFromWeakReference != null && activityFromWeakReference.equals(activity)){
			activityStackIterator.remove();
		}
	}
}
 
Example 2
Source File: ActivityUtils.java    From AndroidUtilCode with Apache License 2.0 6 votes vote down vote up
/**
 * Finish to the activity.
 *
 * @param activity      The activity.
 * @param isIncludeSelf True to include the activity, false otherwise.
 * @param isLoadAnim    True to use animation for the outgoing activity, false otherwise.
 */
public static boolean finishToActivity(@NonNull final Activity activity,
                                       final boolean isIncludeSelf,
                                       final boolean isLoadAnim) {
    List<Activity> activities = UtilsBridge.getActivityList();
    for (Activity act : activities) {
        if (act.equals(activity)) {
            if (isIncludeSelf) {
                finishActivity(act, isLoadAnim);
            }
            return true;
        }
        finishActivity(act, isLoadAnim);
    }
    return false;
}
 
Example 3
Source File: ActivityUtils.java    From AndroidUtilCode with Apache License 2.0 6 votes vote down vote up
/**
 * Finish to the activity.
 *
 * @param activity      The activity.
 * @param isIncludeSelf True to include the activity, false otherwise.
 * @param enterAnim     A resource ID of the animation resource to use for the
 *                      incoming activity.
 * @param exitAnim      A resource ID of the animation resource to use for the
 *                      outgoing activity.
 */
public static boolean finishToActivity(@NonNull final Activity activity,
                                       final boolean isIncludeSelf,
                                       @AnimRes final int enterAnim,
                                       @AnimRes final int exitAnim) {
    List<Activity> activities = UtilsBridge.getActivityList();
    for (Activity act : activities) {
        if (act.equals(activity)) {
            if (isIncludeSelf) {
                finishActivity(act, enterAnim, exitAnim);
            }
            return true;
        }
        finishActivity(act, enterAnim, exitAnim);
    }
    return false;
}
 
Example 4
Source File: ActivityManager.java    From Android_framework with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * 删除栈上该activity之上的所有activity
 */
public void finishAfterActivity(Activity activity){
    if (activity!=null && mStack.search(activity) == -1){
        L.e("在栈中找不到该activity", ActivityManager.class);
        return;
    }
    while (mStack.peek() != null){
        Activity temp = mStack.pop();
        if (temp!=null && temp.equals(activity)){
            mStack.push(temp);
            break;
        }
        if (temp!=null)
            temp.finish();
    }
}
 
Example 5
Source File: GoogleFlipGameApplication.java    From tilt-game-android with MIT License 6 votes vote down vote up
@Override
public void onActivityDestroyed(Activity activity) {
    if (sCurrentActivity == null || activity.equals(sCurrentActivity)) {
        if (sBluetoothServerService != null) {
            sBluetoothServerService.stop();
        }
        if (sBluetoothClientService != null) {
            sBluetoothClientService.stop();
        }
        if (sOrientationProvider != null) {
            sOrientationProvider.stop();
        }

        restoreBluetoothDeviceName();
    }
}
 
Example 6
Source File: _SocialSdk.java    From SocialSdkLibrary with Apache License 2.0 5 votes vote down vote up
WeakReference<Activity> find(Activity activity) {
    Activity weakAct;
    for (WeakReference<Activity> activityWeakReference : mActivityList) {
        weakAct = activityWeakReference.get();
        if (weakAct != null && weakAct.equals(activity)) {
            return activityWeakReference;
        }
    }
    return null;
}
 
Example 7
Source File: App.java    From Simpler with Apache License 2.0 5 votes vote down vote up
private Activity findActivity(Activity activity) {
    if (null == activity || null == mActivityList) {
        return null;
    }
    for (Activity aty : mActivityList) {
        if (null == aty) {
            continue;
        }
        if (activity.equals(aty)) {
            return aty;
        }
    }
    return null;
}
 
Example 8
Source File: ActivityUtils.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
/**
 * Return whether the activity exists in activity's stack.
 *
 * @param activity The activity.
 * @return {@code true}: yes<br>{@code false}: no
 */
public static boolean isActivityExistsInStack(@NonNull final Activity activity) {
    List<Activity> activities = UtilsBridge.getActivityList();
    for (Activity aActivity : activities) {
        if (aActivity.equals(activity)) {
            return true;
        }
    }
    return false;
}
 
Example 9
Source File: ActivityStackManager.java    From DialogUtil with Apache License 2.0 5 votes vote down vote up
/**
 * 在基类activity 的 onDetachToWindow时调用
 * @param activity
 */
public void removeTopAttached(Activity activity){
    if(activity ==null){
        return;
    }
    if(topAttachedActivityWeakRef!=null){
        Activity activity1 =  topAttachedActivityWeakRef.get();
        if(activity.equals(activity1)){
            topAttachedActivityWeakRef = null;
        }

    }
}
 
Example 10
Source File: CoreApplication.java    From Cangol-appcore with Apache License 2.0 5 votes vote down vote up
/**
 * 添加一个activity到管理列表里
 *
 * @param activity
 */
public final  void addActivityToManager(Activity activity) {
    boolean contain=false;
    for (final SoftReference<Activity> activityReference : getActivityManager()) {
        if (activityReference != null && activity.equals(activityReference.get())) {
            contain=true;
        }
    }
    if(!contain)
        getActivityManager().add(new SoftReference<Activity>(activity));
}
 
Example 11
Source File: AppSingleton.java    From science-journal with Apache License 2.0 4 votes vote down vote up
public void setNoLongerResumedActivity(Activity activity) {
  if (activity.equals(resumedActivity.getValue().orNull())) {
    resumedActivity.onNext(Optional.absent());
  }
}
 
Example 12
Source File: Intent.java    From unity-ads-android with Apache License 2.0 4 votes vote down vote up
public static void removeActiveActivity (Activity activity) {
	if (_activeActivity != null && _activeActivity.get() != null && activity != null && activity.equals(_activeActivity.get())) {
		_activeActivity = null;
	}
}
 
Example 13
Source File: GoogleFlipGameApplication.java    From tilt-game-android with MIT License 4 votes vote down vote up
public static void clearActivity(Activity activity) {
    if (activity.equals(sCurrentActivity)) {
        sCurrentActivity = null;
    }
}
 
Example 14
Source File: AbstractFragmentActivity.java    From gsn with GNU General Public License v3.0 4 votes vote down vote up
private void clearReferences(){
	Activity currActivity = TinyGSN.getCurrentActivity();
	if (currActivity != null && currActivity.equals(this))
		TinyGSN.setCurrentActivity(null);
}
 
Example 15
Source File: AbstractActivity.java    From gsn with GNU General Public License v3.0 4 votes vote down vote up
private void clearReferences(){
	Activity currActivity = TinyGSN.getCurrentActivity();
	if (currActivity != null && currActivity.equals(this))
		TinyGSN.setCurrentActivity(null);
}