jetpack

AndroidX下使用Activity和Fragment的变化

∥☆過路亽.° 提交于 2020-04-13 11:42:10
【今日推荐】:为什么一到面试就懵逼!>>> 过去的一段时间,AndroidX 软件包下的 Activity/Fragmet 的 API 发生了很多变化。让我们看看它们是如何提升Android 的开发效率以及如何适应当下流行的编程规则和模式。 本文中描述的所有功能现在都可以在稳定的 AndroidX 软件包中使用,它们在去年均已发布或移至稳定版本。 在构造器中传入布局 ID 从 AndroidX AppCompat 1.1.0 和 Fragment 1.1.0 ( 译者注:AppCompat 包含 Fragment,且 Fragment 包含 Activity,详情见【整理】Jetpack 主要组件的依赖及传递关系 )开始,您可以使用将 layoutId 作为参数的构造函数: class MyActivity : AppCompatActivity(R.layout.my_activity) class MyFragmentActivity: FragmentActivity(R.layout.my_fragment_activity) class MyFragment : Fragment(R.layout.my_fragment) 这种方法可以减少 Activity/Fragment 中方法重写的数量,并使类更具可读性。无需在Activity 中重写 onCreate()

在PreferenceActivity中使用什么代替“ addPreferencesFromResource”?

最后都变了- 提交于 2020-02-26 05:17:53
我刚刚注意到一个事实,即方法 addPreferencesFromResource(int preferencesResId) 在Android的文档中( Reference Entry ) 已 被标记为 已弃用 。 不幸的是,该方法的说明中没有提供替代方法。 为了将preferenceScreen.xml连接到匹配的PreferenceActivity,应该使用哪种方法呢? #1楼 要向上述正确答案添加更多信息,请阅读 Android-er 的 示例, 我发现您可以轻松地将您的偏好活动转换为偏好片段。 如果您有以下活动: public class MyPreferenceActivity extends PreferenceActivity { @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.my_preference_screen); } } 您要做的唯一更改是创建一个内部片段类,将 addPreferencesFromResources() 移入片段,然后从活动中调用该片段,如下所示: public class MyPreferenceActivity

Wordpress - The Jetpack server could not communicate with your site’s XML-RPC URL

↘锁芯ラ 提交于 2020-01-15 12:24:07
问题 When I try to install Jetpack on my Wordpress website I get the following error: Error Details: The Jetpack server could not communicate with your site’s XML-RPC URL. Please check to make sure example.com/xmlrpc.php is working properly. It should show ‘XML‑RPC server accepts POST requests only.’ on a line by itself when viewed in a browser and should not have any blank lines or extra output anywhere. When I goto the URL I see this: XML‑RPC server accepts POST requests only. Which is expected.

Wordpress - The Jetpack server could not communicate with your site’s XML-RPC URL

时光怂恿深爱的人放手 提交于 2020-01-15 12:23:57
问题 When I try to install Jetpack on my Wordpress website I get the following error: Error Details: The Jetpack server could not communicate with your site’s XML-RPC URL. Please check to make sure example.com/xmlrpc.php is working properly. It should show ‘XML‑RPC server accepts POST requests only.’ on a line by itself when viewed in a browser and should not have any blank lines or extra output anywhere. When I goto the URL I see this: XML‑RPC server accepts POST requests only. Which is expected.

Jetpack Publicize: Sharing only on Twitter for a category

こ雲淡風輕ζ 提交于 2019-12-23 03:01:51
问题 On my current project I have three post categories (Column, Pickup and News) and use Jetpack Publicize to share any new post on both Facebook and Twitter. For the "News" category, I'd like to only publicize on Twitter (so somehow deactivating Facebook sharing for this category exclusively). I have been looking at the Jetpack documentation and adjusted their recommended code: add_filter( 'wpas_submit_post?', 'news_twitter_submit_post', 10, 4 ); function news_twitter_submit_post( $ret, $post_id

AAC架构学习(初识)

谁都会走 提交于 2019-12-13 16:51:44
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> Android Jetpack 是google推出的方便开发人员更快速的搭建应用的框架,分为四大块:Architecture、UI、Foundationy 以及 Behavior。 其中的 Architecture组件,则提供了我们相当灵活好用的架构组件。 比较关键的4个模块为: Lifecycle: 能够帮助我们轻松应对Activity/Fragment的生命周期问题,可以更加解耦的方式处理生命周期变化问题,从而轻松避免内存泄漏。 LiveData: 基于观察者模式,并且可以感知生命周期的数据持有类,能够帮助我们更好的解耦数据。 ViewModel: 用来存储和管理 UI 相关的数据,方便数据保存和更新,方便完成数据与UI的绑定(感觉很像MVVM) Room: 提供了数据库持久化功能(感觉类似greendao)。 WorkManager: 非常好用的后台任务模块。 以上则可以构成google官方推荐的android应用新架构 如下图: 从上图可以看出,各个模块相互解耦,互不影响,结构清晰,易于维护。 从此android开发终于有了自己的架构,之前的MVC,MVP,MVVM甚至基于前端的Flux架构,都不是真正意义上为android服务的,这次的AAC架构师google官方为android量身定做

Applying infinite scroll upon wooocmmerece site isn't working as expected

风流意气都作罢 提交于 2019-12-11 17:06:40
问题 I'm trying to implement jetpack's infinite scroll. my website has ?currency_switch=EUR and ?orderby=width-desc these kinds of custom URL parameters, which are successfully implemented without any ajax and for search I am using relevanssi. I am using this code in my functions.php function mytheme_infinite_scroll_init() { add_theme_support( 'infinite-scroll', array( 'container' => 'multiple-products', 'type' => 'scroll', 'posts_per_page' => get_option( 'posts_per_page' ) ) ); } add_action(

postman jetpacks - testing for nested data

百般思念 提交于 2019-12-06 03:33:30
问题 I have a test in postman and the response comes back with 'nested' data. By that I mean we have a 'data' section of the response and a 'messages' section. Inside data there are a ton of other fields and those are the ones I need to be verifying on with Jetpacks. How can I get to these fields? this is what the json response looks like: { "Data": { "QRCode_ID": 168, "Repairer_ID": null, "AssignedToEmployee_ID": null, "TaskName": "003021919913", "DueDate": "2015-07-02T00:12:53.597",

LiveData原理分析

可紊 提交于 2019-12-04 21:35:44
LiveData原理分析 1 LiveData简介 大部分Android应用会从网络或SQLite数据库存取数据,并根据数据更新界面。为了避免ANR,主线程中不能存取数据。而后台线程中无法更新界面。通常的做法是让后台线程将数据通过Handler传递给主线程。但是当界面较为复杂时,使用Handler这种方式变得非常复杂。为了简化界面更新的工作,Google在Jetpack中提供了LiveData组件。LiveData具有保证UI和状态一致、避免内存泄漏、避免手动管理生命周期等优点。 2 LiveData用法 LiveData是一个在线程间传递数据的容器。当后台线程得到数据后,通过postValue()方法投递数据。其他线程通过getValue()得到数据。为了通知其他线程,LiveData采用的观察者模式。通过observe()方法,主线程可以在数据更新后立即得到通知。下面是一个简单的例子: public class BackgroundThread extends Thread { public BackgroundThread(LiveData<Data> aLiveData) { liveData = aLiveData; } @Override public void run() { Data data = readDataFromFile(); liveData

postman jetpacks - testing for nested data

依然范特西╮ 提交于 2019-12-04 08:18:16
I have a test in postman and the response comes back with 'nested' data. By that I mean we have a 'data' section of the response and a 'messages' section. Inside data there are a ton of other fields and those are the ones I need to be verifying on with Jetpacks. How can I get to these fields? this is what the json response looks like: { "Data": { "QRCode_ID": 168, "Repairer_ID": null, "AssignedToEmployee_ID": null, "TaskName": "003021919913", "DueDate": "2015-07-02T00:12:53.597", "DueDateTimeSpan": 1959471956224, "TaskStatus_ID": 1, "Description": "due 6/30, 5:00", "TaskUrgency_ID": null,