Package 

Class BaseActivity

  • All Implemented Interfaces:
    android.content.ComponentCallbacks , android.content.ComponentCallbacks2 , android.view.KeyEvent.Callback , android.view.LayoutInflater.Factory , android.view.LayoutInflater.Factory2 , android.view.View.OnCreateContextMenuListener , android.view.Window.Callback , androidx.activity.OnBackPressedDispatcherOwner , androidx.activity.contextaware.ContextAware , androidx.activity.result.ActivityResultCallback , androidx.activity.result.ActivityResultCaller , androidx.activity.result.ActivityResultRegistryOwner , androidx.appcompat.app.ActionBarDrawerToggle.DelegateProvider , androidx.appcompat.app.AppCompatCallback , androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback , androidx.core.app.ActivityCompat.RequestPermissionsRequestCodeValidator , androidx.core.app.OnMultiWindowModeChangedProvider , androidx.core.app.OnNewIntentProvider , androidx.core.app.OnPictureInPictureModeChangedProvider , androidx.core.app.TaskStackBuilder.SupportParentable , androidx.core.content.OnConfigurationChangedProvider , androidx.core.content.OnTrimMemoryProvider , androidx.core.view.KeyEventDispatcher.Component , androidx.core.view.MenuHost , androidx.lifecycle.HasDefaultViewModelProviderFactory , androidx.lifecycle.LifecycleEventObserver , androidx.lifecycle.LifecycleObserver , androidx.lifecycle.LifecycleOwner , androidx.lifecycle.ViewModelStoreOwner , androidx.savedstate.SavedStateRegistryOwner , com.liecoder.framework.base.IBaseService , com.liecoder.framework.base.IPermissionService , com.liecoder.framework.titlebar.ITitleBarClickListener , net.yslibrary.android.keyboardvisibilityevent.KeyboardVisibilityEventListener

    
    public abstract class BaseActivity
    extends BasePermissionActivity implements IBaseService, LifecycleEventObserver, ITitleBarClickListener, KeyboardVisibilityEventListener
                        

    基础活动类,提供通用的活动设置和功能。

    此类继承自 BasePermissionActivity,并实现了多个接口,以提供权限处理、生命周期观察、标题栏点击事件、键盘可见性事件等功能。

    • Constructor Summary

      Constructors 
      Constructor Description
      BaseActivity()
    • Method Summary

      Modifier and Type Method Description
      final Boolean getKeyBoardVisible()
      final Unit setKeyBoardVisible(Boolean keyBoardVisible)
      final SavedStateRegistry getSavedStateRegistry()
      Unit init() 初始化方法。在这个方法中,应执行所有必要的初始化操作,如依赖注入或初始状态设置。
      Unit setupViews() 设置视图的方法。此方法用于配置活动的 UI 组件,例如设置监听器或初始视图状态。
      Unit loadData() 加载数据的方法。在这个方法中,应执行数据加载逻辑,如从网络或本地数据库获取数据。
      Unit setupStatusBar() 设置状态栏的方法。此方法用于配置活动的状态栏,例如状态栏颜色、是否深色内容等。
      Boolean statusBarDarkContent() 判断状态栏内容是否为深色。返回布尔值,指示状态栏的内容颜色是否为深色。
      Integer statusBarColor() 获取状态栏颜色。返回整数值,表示状态栏的颜色。
      Boolean statusBarTranslucent() 判断状态栏是否半透明。返回布尔值,指示状态栏是否设置为半透明。
      Unit onStateChanged(LifecycleOwner source, Lifecycle.Event event)
      Unit onVisibilityChanged(Boolean isOpen)
      Unit onLeftClick(TitleBar titleBar) 处理标题栏左侧点击事件。
      Unit onTitleClick(TitleBar titleBar) 处理标题栏标题的点击事件。
      Unit onRightClick(TitleBar titleBar) 处理标题栏右侧点击事件。
      Unit showLoading(Boolean show, String message) 显示或隐藏Loading框。
      Unit hideLoading() 隐藏Loading框。
      <ERROR CLASS> success(CharSequence message) 显示成功吐司消息。
      <ERROR CLASS> errors(CharSequence message) 显示错误吐司消息。
      <ERROR CLASS> warnings(CharSequence message) 显示警告吐司消息。
      <ERROR CLASS> info(CharSequence message) 显示信息吐司消息。
      Unit custom(CharSequence message, Drawable successIcon, Drawable errorIcon, Drawable warningIcon, Integer gravity, Integer xOffset, Integer yOffset, Integer duration, ToastStyle style) 显示自定义吐司消息。
      • Methods inherited from class androidx.core.app.ComponentActivity

        closeContextMenu, createPendingResult, dismissDialog, dismissKeyboardShortcutsHelper, dispatchGenericMotionEvent, dispatchPopulateAccessibilityEvent, dispatchTouchEvent, dispatchTrackballEvent, enterPictureInPictureMode, enterPictureInPictureMode, finish, finishActivity, finishActivityFromChild, finishAffinity, finishAfterTransition, finishAndRemoveTask, finishFromChild, getActionBar, getApplication, getCallingActivity, getCallingPackage, getChangingConfigurations, getComponentName, getContentScene, getContentTransitionManager, getCurrentFocus, getFragmentManager, getIntent, getLastNonConfigurationInstance, getLayoutInflater, getLoaderManager, getLocalClassName, getMaxNumPictureInPictureActions, getMediaController, getOnBackInvokedDispatcher, getParent, getParentActivityIntent, getPreferences, getReferrer, getRequestedOrientation, getSearchEvent, getSplashScreen, getSystemService, getTaskId, getTitle, getTitleColor, getVoiceInteractor, getVolumeControlStream, getWindow, getWindowManager, hasWindowFocus, isActivityTransitionRunning, isChangingConfigurations, isChild, isDestroyed, isFinishing, isImmersive, isInMultiWindowMode, isInPictureInPictureMode, isLaunchedFromBubble, isLocalVoiceInteractionSupported, isTaskRoot, isVoiceInteraction, isVoiceInteractionRoot, managedQuery, moveTaskToBack, navigateUpTo, navigateUpToFromChild, onActionModeFinished, onActionModeStarted, onActivityReenter, onApplyThemeResource, onAttachFragment, onAttachedToWindow, onChildTitleChanged, onContextItemSelected, onContextMenuClosed, onCreate, onCreateContextMenu, onCreateDescription, onCreateDialog, onCreateDialog, onCreateNavigateUpTaskStack, onCreateOptionsMenu, onCreatePanelView, onCreateThumbnail, onDetachedFromWindow, onEnterAnimationComplete, onGenericMotionEvent, onGetDirectActions, onKeyLongPress, onKeyMultiple, onKeyShortcut, onKeyUp, onLocalVoiceInteractionStarted, onLocalVoiceInteractionStopped, onNavigateUp, onNavigateUpFromChild, onOptionsItemSelected, onOptionsMenuClosed, onPerformDirectAction, onPictureInPictureRequested, onPictureInPictureUiStateChanged, onPostCreate, onPrepareDialog, onPrepareDialog, onPrepareNavigateUpTaskStack, onPrepareOptionsMenu, onProvideAssistContent, onProvideAssistData, onProvideKeyboardShortcuts, onProvideReferrer, onRestart, onRestoreInstanceState, onRestoreInstanceState, onSaveInstanceState, onSearchRequested, onSearchRequested, onTopResumedActivityChanged, onTouchEvent, onTrackballEvent, onUserInteraction, onUserLeaveHint, onVisibleBehindCanceled, onWindowAttributesChanged, onWindowFocusChanged, onWindowStartingActionMode, onWindowStartingActionMode, openContextMenu, overridePendingTransition, overridePendingTransition, postponeEnterTransition, recreate, registerActivityLifecycleCallbacks, registerComponentCallbacks, registerForContextMenu, releaseInstance, removeDialog, requestDragAndDropPermissions, requestPermissions, requestShowKeyboardShortcuts, requestVisibleBehind, requestWindowFeature, requireViewById, runOnUiThread, setActionBar, setContentTransitionManager, setDefaultKeyMode, setEnterSharedElementCallback, setExitSharedElementCallback, setFeatureDrawable, setFeatureDrawableAlpha, setFeatureDrawableResource, setFeatureDrawableUri, setFinishOnTouchOutside, setImmersive, setInheritShowWhenLocked, setIntent, setLocusContext, setMediaController, setPictureInPictureParams, setProgress, setProgressBarIndeterminate, setProgressBarIndeterminateVisibility, setProgressBarVisibility, setRecentsScreenshotEnabled, setRequestedOrientation, setResult, setResult, setSecondaryProgress, setShouldDockBigOverlays, setShowWhenLocked, setTaskDescription, setTitle, setTitle, setTitleColor, setTranslucent, setTurnScreenOn, setVisible, setVolumeControlStream, setVrModeEnabled, shouldDockBigOverlays, shouldShowRequestPermissionRationale, shouldUpRecreateTask, showAssist, showDialog, showDialog, showLockTaskEscapeMessage, startActionMode, startActionMode, startActivities, startActivities, startActivity, startActivity, startActivityFromChild, startActivityFromChild, startActivityFromFragment, startActivityFromFragment, startActivityIfNeeded, startActivityIfNeeded, startIntentSender, startIntentSender, startIntentSenderFromChild, startIntentSenderFromChild, startLocalVoiceInteraction, startLockTask, startManagingCursor, startNextMatchingActivity, startNextMatchingActivity, startPostponedEnterTransition, startSearch, stopLocalVoiceInteraction, stopLockTask, stopManagingCursor, takeKeyEvents, triggerSearch, unregisterActivityLifecycleCallbacks, unregisterComponentCallbacks, unregisterForContextMenu
      • Methods inherited from class com.liecoder.framework.base.BaseActivity

        explainAccessToMoreSensitiveInformation, getExplanationForSensitiveInformation, grantingPermissions, onActivityResult, registerPermissionLauncher, setContentView, showRequestPermissionRationaleDialog, withPermission
      • Methods inherited from class androidx.appcompat.app.AppCompatActivity

        dispatchFragmentsOnCreateView, dump, getSupportFragmentManager, getSupportLoaderManager, markFragmentsCreated, onActivityResult, onAttachFragment, onCreatePanelMenu, onCreateView, onCreateView, onLowMemory, onMultiWindowModeChanged, onNewIntent, onPause, onPictureInPictureModeChanged, onPrepareOptionsPanel, onPreparePanel, onRequestPermissionsResult, onResume, onResumeFragments, onStateNotSaved, setEnterSharedElementCallback, setExitSharedElementCallback, startActivityFromFragment, startActivityFromFragment, startIntentSenderFromFragment, supportFinishAfterTransition, supportPostponeEnterTransition, supportStartPostponedEnterTransition, validateRequestPermissionsRequestCode
      • Methods inherited from class android.app.Activity

        applyOverrideConfiguration, getAssets, getTheme, onPointerCaptureChanged, setTheme
      • Methods inherited from class com.liecoder.framework.base.BasePermissionActivity

        addContentView, attachBaseContext, closeOptionsMenu, dispatchKeyEvent, findViewById, getDelegate, getDrawerToggleDelegate, getMenuInflater, getResources, getSupportActionBar, getSupportParentActivityIntent, invalidateOptionsMenu, onConfigurationChanged, onContentChanged, onCreateSupportNavigateUpTaskStack, onDestroy, onKeyDown, onLocalesChanged, onMenuItemSelected, onMenuOpened, onNightModeChanged, onPanelClosed, onPostCreate, onPostResume, onPrepareSupportNavigateUpTaskStack, onStart, onStop, onSupportActionModeFinished, onSupportActionModeStarted, onSupportContentChanged, onSupportNavigateUp, onTitleChanged, onWindowStartingSupportActionMode, openOptionsMenu, setContentView, setContentView, setContentView, setSupportActionBar, setSupportProgress, setSupportProgressBarIndeterminate, setSupportProgressBarIndeterminateVisibility, setSupportProgressBarVisibility, setTheme, startSupportActionMode, supportInvalidateOptionsMenu, supportNavigateUpTo, supportRequestWindowFeature, supportShouldUpRecreateTask
      • Methods inherited from class android.view.ContextThemeWrapper

        bindIsolatedService, bindService, bindService, bindServiceAsUser, checkCallingOrSelfPermission, checkCallingOrSelfUriPermission, checkCallingOrSelfUriPermissions, checkCallingPermission, checkCallingUriPermission, checkCallingUriPermissions, checkPermission, checkSelfPermission, checkUriPermission, checkUriPermission, checkUriPermissions, clearWallpaper, createAttributionContext, createConfigurationContext, createContext, createContextForSplit, createDeviceProtectedStorageContext, createDisplayContext, createPackageContext, createWindowContext, createWindowContext, databaseList, deleteDatabase, deleteFile, deleteSharedPreferences, enforceCallingOrSelfPermission, enforceCallingOrSelfUriPermission, enforceCallingPermission, enforceCallingUriPermission, enforcePermission, enforceUriPermission, enforceUriPermission, fileList, getApplicationContext, getApplicationInfo, getAttributionSource, getAttributionTag, getBaseContext, getCacheDir, getClassLoader, getCodeCacheDir, getContentResolver, getDataDir, getDatabasePath, getDir, getDisplay, getExternalCacheDir, getExternalCacheDirs, getExternalFilesDir, getExternalFilesDirs, getExternalMediaDirs, getFileStreamPath, getFilesDir, getMainExecutor, getMainLooper, getNoBackupFilesDir, getObbDir, getObbDirs, getOpPackageName, getPackageCodePath, getPackageManager, getPackageName, getPackageResourcePath, getParams, getSharedPreferences, getSystemServiceName, getWallpaper, getWallpaperDesiredMinimumHeight, getWallpaperDesiredMinimumWidth, grantUriPermission, isDeviceProtectedStorage, isRestricted, isUiContext, moveDatabaseFrom, moveSharedPreferencesFrom, openFileInput, openFileOutput, openOrCreateDatabase, openOrCreateDatabase, peekWallpaper, registerReceiver, registerReceiver, registerReceiver, registerReceiver, removeStickyBroadcast, removeStickyBroadcastAsUser, revokeSelfPermissionsOnKill, revokeUriPermission, revokeUriPermission, sendBroadcast, sendBroadcast, sendBroadcastAsUser, sendBroadcastAsUser, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcast, sendOrderedBroadcastAsUser, sendStickyBroadcast, sendStickyBroadcast, sendStickyBroadcastAsUser, sendStickyOrderedBroadcast, sendStickyOrderedBroadcastAsUser, setWallpaper, setWallpaper, startForegroundService, startInstrumentation, startService, stopService, unbindService, unregisterReceiver, updateServiceGroup
      • Methods inherited from class android.content.ContextWrapper

        getColor, getColorStateList, getDrawable, getString, getString, getSystemService, getText, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, obtainStyledAttributes, revokeSelfPermissionOnKill, sendBroadcastWithMultiplePermissions
      • Methods inherited from class androidx.activity.ComponentActivity

        dispatchKeyShortcutEvent, getExtraData, putExtraData, shouldDumpInternalState, superDispatchKeyEvent
      • Methods inherited from class androidx.fragment.app.FragmentActivity

        addMenuProvider, addMenuProvider, addMenuProvider, addOnConfigurationChangedListener, addOnContextAvailableListener, addOnMultiWindowModeChangedListener, addOnNewIntentListener, addOnPictureInPictureModeChangedListener, addOnTrimMemoryListener, ensureViewModelStore, getActivityResultRegistry, getDefaultViewModelCreationExtras, getDefaultViewModelProviderFactory, getLastCustomNonConfigurationInstance, getLifecycle, getOnBackPressedDispatcher, getViewModelStore, invalidateMenu, onBackPressed, onMultiWindowModeChanged, onPictureInPictureModeChanged, onRetainCustomNonConfigurationInstance, onRetainNonConfigurationInstance, onSaveInstanceState, onTrimMemory, peekAvailableContext, registerForActivityResult, registerForActivityResult, removeMenuProvider, removeOnConfigurationChangedListener, removeOnContextAvailableListener, removeOnMultiWindowModeChangedListener, removeOnNewIntentListener, removeOnPictureInPictureModeChangedListener, removeOnTrimMemoryListener, reportFullyDrawn, startActivityForResult, startActivityForResult, startIntentSenderForResult, startIntentSenderForResult
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BaseActivity

        BaseActivity()
    • Method Detail

      • init

         Unit init()

        初始化方法。

        在这个方法中,应执行所有必要的初始化操作,如依赖注入或初始状态设置。

      • setupViews

         Unit setupViews()

        设置视图的方法。

        此方法用于配置活动的 UI 组件,例如设置监听器或初始视图状态。

      • loadData

         Unit loadData()

        加载数据的方法。

        在这个方法中,应执行数据加载逻辑,如从网络或本地数据库获取数据。

      • setupStatusBar

         Unit setupStatusBar()

        设置状态栏的方法。

        此方法用于配置活动的状态栏,例如状态栏颜色、是否深色内容等。

      • statusBarDarkContent

         Boolean statusBarDarkContent()

        判断状态栏内容是否为深色。

        返回布尔值,指示状态栏的内容颜色是否为深色。

      • statusBarColor

         Integer statusBarColor()

        获取状态栏颜色。

        返回整数值,表示状态栏的颜色。

      • statusBarTranslucent

         Boolean statusBarTranslucent()

        判断状态栏是否半透明。

        返回布尔值,指示状态栏是否设置为半透明。

      • onLeftClick

         Unit onLeftClick(TitleBar titleBar)

        处理标题栏左侧点击事件。

        Parameters:
        titleBar - 被点击的标题栏实例。
      • onTitleClick

         Unit onTitleClick(TitleBar titleBar)

        处理标题栏标题的点击事件。

        Parameters:
        titleBar - 被点击的标题栏实例。
      • onRightClick

         Unit onRightClick(TitleBar titleBar)

        处理标题栏右侧点击事件。

        Parameters:
        titleBar - 被点击的标题栏实例。
      • showLoading

         Unit showLoading(Boolean show, String message)

        显示或隐藏Loading框。

        Parameters:
        show - 是否显示加载指示器。
        message - 可选的加载信息提示。
      • success

         <ERROR CLASS> success(CharSequence message)

        显示成功吐司消息。

        Parameters:
        message - 要显示的成功消息。
      • errors

         <ERROR CLASS> errors(CharSequence message)

        显示错误吐司消息。

        Parameters:
        message - 要显示的错误消息。
      • warnings

         <ERROR CLASS> warnings(CharSequence message)

        显示警告吐司消息。

        Parameters:
        message - 要显示的警告消息。
      • info

         <ERROR CLASS> info(CharSequence message)

        显示信息吐司消息。

        Parameters:
        message - 要显示的信息消息。
      • custom

         Unit custom(CharSequence message, Drawable successIcon, Drawable errorIcon, Drawable warningIcon, Integer gravity, Integer xOffset, Integer yOffset, Integer duration, ToastStyle style)

        显示自定义吐司消息。

        Parameters:
        message - 要显示的消息文本。
        successIcon - 成功图标。
        errorIcon - 错误图标。
        warningIcon - 警告图标。
        gravity - 吐司显示位置。
        xOffset - 吐司水平偏移量。
        yOffset - 吐司垂直偏移量。
        duration - 吐司显示时长。
        style - 吐司样式。