### Apply Various Page Transition Animations in XPage Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Illustrates different `CoreAnim` options for page transition animations. Examples include no animation, present (bottom-to-top), slide (left-to-right), fade (cross-fade), and zoom (scale). ```Java switch(position) { case 0: openPage(TestFragment.PAGE_NAME, null, CoreAnim.none);//没有动画 break; case 1: openPage(TestFragment.PAGE_NAME, null, CoreAnim.present);//由下到上动画 break; case 2: openPage(TestFragment.PAGE_NAME, null, CoreAnim.slide);//从左到右动画 break; case 3: openPage(TestFragment.PAGE_NAME, null, CoreAnim.fade);//渐变 break; case 4: openPage(TestFragment.PAGE_NAME, null, CoreAnim.zoom);//放大 break; default: break; } ``` -------------------------------- ### Configure Automatic Page Registration with XPage Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Demonstrates how to initialize XPage for automatic page registration using `PageConfig.getInstance()`. This method is recommended for projects utilizing `@Page` annotations, enabling debug logging and setting a default container Activity. ```Java PageConfig.getInstance() // //页面注册,默认不设置的话使用的就是自动注册 // .setPageConfiguration(new AutoPageConfiguration()) .debug("PageLog") //开启调试 .setContainActivityClazz(XPageActivity.class) //设置默认的容器Activity .init(this); //初始化页面配置 ``` -------------------------------- ### Static Fragment Page Registration via corepage.json Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Demonstrates how to statically register Fragment pages and their associated parameters by creating a `corepage.json` file in the `assets` folder. This allows for declarative page configuration. ```JSON [ { "name": "测试页面1", "classPath": "com.xuexiang.xpagedemo.fragment.TestFragment1", "params": "" }, { "name": "测试页面2", "classPath": "com.xuexiang.xpagedemo.fragment.TestFragment2", "params": { "key1":"这是参数1的值", "key2":"这是参数2的值" } } ] ``` -------------------------------- ### Navigate Pages with PageOption in XPage Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Shows how to use `PageOption.to()` to construct page navigation options. This includes setting animations, request codes for results, controlling back stack behavior, opening in a new activity, and passing parameters. ```Java PageOption.to(TestFragment.class) //跳转的fragment .setAnim(CoreAnim.zoom) //页面跳转动画 .setRequestCode(100) //请求码,用于返回结果 .setAddToBackStack(true) //是否加入堆栈 .setNewActivity(true, ContainActivity.class) //是否使用新的Activity打开 .putBoolean(DateReceiveFragment.KEY_IS_NEED_BACK, true) //传递的参数 .open(this); //打开页面进行跳转 ``` -------------------------------- ### Configure Maven Jitpack Repository in Gradle Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Adds the Jitpack Maven repository to the project's root `build.gradle` file, enabling the resolution of dependencies hosted on Jitpack, such as the XPage library. ```Gradle allprojects { repositories { ... maven { url "https://jitpack.io" } } } ``` -------------------------------- ### Pass Data and Handle Results During XPage Navigation Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Demonstrates how to pass data using a `Bundle` to a target fragment and how to open a page for a result using `openPageForResult`. This allows for dynamic data transfer and result handling between pages. ```Java Bundle params = new Bundle(); switch(position) { case 0: params.putBoolean(DateReceiveFragment.KEY_IS_NEED_BACK, false); int id = (int) (Math.random() * 100); params.putString(DateReceiveFragment.KEY_EVENT_NAME, "事件" + id); params.putString(DateReceiveFragment.KEY_EVENT_DATA, "事件" + id + "携带的数据"); openPage(DateReceiveFragment.class, params); break; case 1: params.putBoolean(DateReceiveFragment.KEY_IS_NEED_BACK, true); openPageForResult(DateReceiveFragment.class, params, 100); break; default: break; } ``` -------------------------------- ### Perform Manual Dynamic Page Registration in XPage Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Illustrates how to manually register pages by implementing `PageConfiguration` and adding `PageInfo` objects. This provides fine-grained control over page registration, allowing specific fragments to be added. ```Java PageConfig.getInstance() .setPageConfiguration(new PageConfiguration() { //页面注册 @Override public List registerPages(Context context) { List pageInfos = new ArrayList<>(); addPageInfoAndSubPages(pageInfos, MainFragment.class); pageInfos.add(PageConfig.getPageInfo(DateReceiveFragment.class)); return pageInfos; //手动注册页面 } }) .debug("PageLog") //开启调试 .init(this); //初始化页面配置 ``` -------------------------------- ### Add XPage Library Dependencies for Kotlin Projects Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Configures XPage dependencies for Kotlin projects, utilizing the `kotlin-kapt` plugin for annotation processing instead of `annotationProcessor`, in the app's `build.gradle`. ```Gradle apply plugin: 'kotlin-kapt' dependencies { ... //XPage implementation 'com.github.xuexiangjys.XPage:xpage-lib:3.4.0' kapt 'com.github.xuexiangjys.XPage:xpage-compiler:3.4.0' } ``` -------------------------------- ### Add XPage Library Dependencies for Android Support Library Projects Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Includes the XPage core library, its annotation processor, and ButterKnife dependencies for projects using the Android Support Library (version 2.3.0 and below) in the app's `build.gradle`. ```Gradle dependencies { ... // XPage implementation 'com.github.xuexiangjys.XPage:xpage-lib:2.3.0' annotationProcessor 'com.github.xuexiangjys.XPage:xpage-compiler:2.3.0' // ButterKnife的sdk implementation 'com.jakewharton:butterknife:8.4.0' annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0' } ``` -------------------------------- ### Add XPage Library Dependencies for AndroidX Projects Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Includes the XPage core library and its annotation processor for AndroidX-compatible projects (version 3.0.0 and above) in the app's `build.gradle` dependencies. This configuration is suitable for modern Android development. ```Gradle dependencies { ... // XPage implementation 'com.github.xuexiangjys.XPage:xpage-lib:3.4.0' annotationProcessor 'com.github.xuexiangjys.XPage:xpage-compiler:3.4.0' } ``` -------------------------------- ### Register Module Name for XPage Annotation Processor Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Registers the current module's name with the XPage annotation processor within the `defaultConfig` block of the module's `build.gradle`. This is crucial for proper page registration, especially in multi-module projects. ```Gradle defaultConfig { ... javaCompileOptions { annotationProcessorOptions { arguments = [ moduleName : project.getName() ] } } } ``` -------------------------------- ### Upgrade XPage Fragment View Inflation Method Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Illustrates the required method signature change for Fragment view inflation when upgrading XPage from versions below 3.3.0 to 3.4.0 or higher. The deprecated `inflateView` method is replaced by `onCreateContentView`. ```Java @Deprecated protected abstract View inflateView(LayoutInflater inflater, ViewGroup container); ------> 替换为 protected abstract View onCreateContentView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot); ``` -------------------------------- ### Open New Activity to Prevent Tab Container State Interference Source: https://github.com/xuexiangjys/xpage/blob/master/README.md To ensure that opening a new page does not affect the state of the current tab container, set `setNewActivity(true)` when navigating with `PageOption.to()`. This creates a new container for the opened page. ```Java PageOption.to(TestFragment.class) //新建一个容器,以不影响当前容器 .setNewActivity(true) .open(this); ``` -------------------------------- ### Customize XPage TitleBar Appearance using Themes Source: https://github.com/xuexiangjys/xpage/blob/master/README.md Shows how to define and apply custom styles for the XPage TitleBar within an Android application theme. This includes setting background, colors, immersive mode, navigation icon, height, and various text sizes for title, subtitle, and action elements. ```XML ``` -------------------------------- ### Override initTitleBar for Fragments in Tabbed Layouts Source: https://github.com/xuexiangjys/xpage/blob/master/README.md When using ViewPager to load Fragments in a tabbed layout, the `initTitleBar` method of the Fragment needs to be overridden to return `null` if it's not annotated with `@Page`. This prevents unwanted title bar behavior. ```Java @Override protected TitleBar initTitleBar() { //不使用@Page标注的一定要注意覆盖这个方法 return null; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.