Changed: Rename ActivityUtilsErrno to ActivityErrno

This commit is contained in:
agnostic-apollo
2022-01-06 03:05:05 +05:00
parent 3f84b5345f
commit c1a0d6deff
2 changed files with 7 additions and 9 deletions

View File

@@ -2,9 +2,9 @@ package com.termux.shared.activity;
import com.termux.shared.errors.Errno; import com.termux.shared.errors.Errno;
public class ActivityUtilsErrno extends Errno { public class ActivityErrno extends Errno {
public static final String TYPE = "ActivityUtils Error"; public static final String TYPE = "Activity Error";
/* Errors for starting activities (100-150) */ /* Errors for starting activities (100-150) */
@@ -13,7 +13,7 @@ public class ActivityUtilsErrno extends Errno {
public static final Errno ERRNO_STARTING_ACTIVITY_WITH_NULL_CONTEXT = new Errno(TYPE, 102, "Cannot start \"%1$s\" activity with null Context"); public static final Errno ERRNO_STARTING_ACTIVITY_WITH_NULL_CONTEXT = new Errno(TYPE, 102, "Cannot start \"%1$s\" activity with null Context");
ActivityUtilsErrno(final String type, final int code, final String message) { ActivityErrno(final String type, final int code, final String message) {
super(type, code, message); super(type, code, message);
} }

View File

@@ -34,7 +34,6 @@ public class ActivityUtils {
* in addition to logging a message. The {@code context} must not be * in addition to logging a message. The {@code context} must not be
* {@code null}. * {@code null}.
* @return Returns the {@code error} if starting activity was not successful, otherwise {@code null}. * @return Returns the {@code error} if starting activity was not successful, otherwise {@code null}.
*/ */
public static Error startActivity(Context context, @NonNull Intent intent, public static Error startActivity(Context context, @NonNull Intent intent,
boolean logErrorMessage, boolean showErrorMessage) { boolean logErrorMessage, boolean showErrorMessage) {
@@ -42,7 +41,7 @@ public class ActivityUtils {
String activityName = intent.getComponent() != null ? intent.getComponent().getClassName() : "Unknown"; String activityName = intent.getComponent() != null ? intent.getComponent().getClassName() : "Unknown";
if (context == null) { if (context == null) {
error = ActivityUtilsErrno.ERRNO_STARTING_ACTIVITY_WITH_NULL_CONTEXT.getError(activityName); error = ActivityErrno.ERRNO_STARTING_ACTIVITY_WITH_NULL_CONTEXT.getError(activityName);
if (logErrorMessage) if (logErrorMessage)
error.logErrorAndShowToast(null, LOG_TAG); error.logErrorAndShowToast(null, LOG_TAG);
return error; return error;
@@ -51,7 +50,7 @@ public class ActivityUtils {
try { try {
context.startActivity(intent); context.startActivity(intent);
} catch (Exception e) { } catch (Exception e) {
error = ActivityUtilsErrno.ERRNO_START_ACTIVITY_FAILED_WITH_EXCEPTION.getError(e, activityName, e.getMessage()); error = ActivityErrno.ERRNO_START_ACTIVITY_FAILED_WITH_EXCEPTION.getError(e, activityName, e.getMessage());
if (logErrorMessage) if (logErrorMessage)
error.logErrorAndShowToast(showErrorMessage ? context : null, LOG_TAG); error.logErrorAndShowToast(showErrorMessage ? context : null, LOG_TAG);
return error; return error;
@@ -97,7 +96,6 @@ public class ActivityUtils {
* used instead. * used instead.
* Note that later is deprecated. * Note that later is deprecated.
* @return Returns the {@code error} if starting activity was not successful, otherwise {@code null}. * @return Returns the {@code error} if starting activity was not successful, otherwise {@code null}.
*/ */
public static Error startActivityForResult(Context context, int requestCode, @NonNull Intent intent, public static Error startActivityForResult(Context context, int requestCode, @NonNull Intent intent,
boolean logErrorMessage, boolean showErrorMessage, boolean logErrorMessage, boolean showErrorMessage,
@@ -109,7 +107,7 @@ public class ActivityUtils {
activityResultLauncher.launch(intent); activityResultLauncher.launch(intent);
} else { } else {
if (context == null) { if (context == null) {
error = ActivityUtilsErrno.ERRNO_STARTING_ACTIVITY_WITH_NULL_CONTEXT.getError(activityName); error = ActivityErrno.ERRNO_STARTING_ACTIVITY_WITH_NULL_CONTEXT.getError(activityName);
if (logErrorMessage) if (logErrorMessage)
error.logErrorAndShowToast(null, LOG_TAG); error.logErrorAndShowToast(null, LOG_TAG);
return error; return error;
@@ -127,7 +125,7 @@ public class ActivityUtils {
} }
} }
} catch (Exception e) { } catch (Exception e) {
error = ActivityUtilsErrno.ERRNO_START_ACTIVITY_FOR_RESULT_FAILED_WITH_EXCEPTION.getError(e, activityName, e.getMessage()); error = ActivityErrno.ERRNO_START_ACTIVITY_FOR_RESULT_FAILED_WITH_EXCEPTION.getError(e, activityName, e.getMessage());
if (logErrorMessage) if (logErrorMessage)
error.logErrorAndShowToast(showErrorMessage ? context : null, LOG_TAG); error.logErrorAndShowToast(showErrorMessage ? context : null, LOG_TAG);
return error; return error;