繁体   English   中英

回收查看项目单击所花费的时间太长,无法调出该活动

[英]Recycle View item click takes too long to bring up the activity

我是android Recycle视图的新手,我在下面的代码中工作得很好,但是唯一的问题是我第一次在我的活动加载时加载速度非常慢,而在第一次休息后,所有相同的活动加载速度都更快刻不容缓。

 holder.mImgView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //String animal = mDataSet.get(position);
            final Course course1 = mDataSet.getItem(position);
            String animal = course1.getTitle();
            Toast.makeText(mContext, animal, Toast.LENGTH_SHORT).show();

            Intent intent = new Intent(mContext, DetailActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setType("text/plain");
            intent.putExtra(COURSE_TITLE, course.getTitle());
            intent.putExtra(COURSE_DESC, course.getDescription());
            intent.putExtra(COURSE_NO, course.getCourseNumber());

            mContext.startActivities(new Intent[]{intent});

我注意到,在新活动开始之前(活动类之外),它会在日志中执行太多操作,这可能会给您一些提示。 日志可以在这里看到:

01-12 22:30:48.500 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 11.654ms   
01-12 22:31:06.870 27490-27490  com.example.android.recycle D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN  
01-12 22:31:07.550 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 351.452ms  
01-12 22:31:08.830 27490-27490  com.example.android.recycle D/SRIB_DCS: log_dcs ThreadedRenderer::initialize entered!  
01-12 22:31:09.230 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 28.800ms   
01-12 22:31:09.440 27490-27490  com.example.android.recycle D/PhoneWindow: *FMB* installDecor mIsFloating : false  
01-12 22:31:09.440 27490-27490  com.example.android.recycle D/PhoneWindow: *FMB* installDecor flags : -2139029248  
01-12 22:31:10.270 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 71.765ms   
01-12 22:31:10.690 27490-27505  com.example.android.recycle W/art: Suspending all threads took: 119.470ms  
01-12 22:31:10.710 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 14.256ms   
01-12 22:31:10.710 27490-27505  com.example.android.recycle I/art: Background sticky concurrent mark sweep GC freed 1727(277KB) AllocSpace objects, 3(113KB) LOS objects, 0%    free, 49MB/49MB, paused 124.064ms total 318.834ms
01-12 22:31:10.910 27490-27505  com.example.android.recycle I/art: Background partial concurrent mark sweep GC freed 587(51KB) AllocSpace objects, 1(10MB) LOS objects, 29% free, 38MB/54MB, paused 6.012ms total 188.648ms
01-12 22:31:12.560 27490-27490  com.example.android.recycle W/ResourcesManager: Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contain    s no resources.
01-12 22:31:12.560 27490-27490  com.example.android.recycle W/ResourcesManager: Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.
01-12 22:31:12.860 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 159.304ms  
01-12 22:31:13.270 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 59.209ms   
01-12 22:31:13.720 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 18.736ms   
01-12 22:31:13.750 27490-27490  com.example.android.recycle W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc 
01-12 22:31:13.760 27490-27490  com.example.android.recycle W/AudioCapabilities: Unsupported mime audio/evrc   
01-12 22:31:13.780 27490-27490  com.example.android.recycle W/AudioCapabilities: Unsupported mime audio/qcelp  
01-12 22:31:13.790 27490-27490  com.example.android.recycle W/AudioCapabilities: Unsupported mime audio/mpeg-L1
01-12 22:31:13.800 27490-27490  com.example.android.recycle W/AudioCapabilities: Unsupported mime audio/mpeg-L2
01-12 22:31:13.830 27490-27490  com.example.android.recycle W/AudioCapabilities: Unsupported mime audio/x-ms-wma   
01-12 22:31:13.850 27490-27490  com.example.android.recycle W/AudioCapabilities: Unsupported mime audio/x-ima  
01-12 22:31:13.860 27490-27490  com.example.android.recycle W/AudioCapabilities: Unsupported mime audio/qcelp  
01-12 22:31:13.870 27490-27490  com.example.android.recycle W/AudioCapabilities: Unsupported mime audio/evrc   
01-12 22:31:13.900 27490-27490  com.example.android.recycle W/VideoCapabilities: Unsupported mime video/wvc1   
01-12 22:31:13.910 27490-27490  com.example.android.recycle W/VideoCapabilities: Unsupported mime video/x-ms-wmv   
01-12 22:31:13.910 27490-27490  com.example.android.recycle W/Utils: could not parse size range '64x64-1920X1080'  
01-12 22:31:13.940 27490-27490  com.example.android.recycle W/VideoCapabilities: Unrecognized profile/level 32768/2 for video/mp4v-es  
01-12 22:31:13.950 27490-27490  com.example.android.recycle W/VideoCapabilities: Unsupported mime video/wvc1   
01-12 22:31:13.950 27490-27490  com.example.android.recycle W/VideoCapabilities: Unsupported mime video/x-ms-wmv   
01-12 22:31:13.950 27490-27490  com.example.android.recycle W/VideoCapabilities: Unsupported mime video/x-ms-wmv7  
01-12 22:31:13.960 27490-27490  com.example.android.recycle W/VideoCapabilities: Unsupported mime video/x-ms-wmv8  
01-12 22:31:13.960 27490-27490  com.example.android.recycle W/VideoCapabilities: Unsupported mime video/mp43   
01-12 22:31:13.970 27490-27490  com.example.android.recycle W/VideoCapabilities: Unsupported mime video/sorenson   
01-12 22:31:13.980 27490-27490  com.example.android.recycle W/VideoCapabilities: Unsupported mime video/mp4v-esdp  
01-12 22:31:14.010 27490-27490  com.example.android.recycle I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es   
01-12 22:31:14.060 27490-27490  com.example.android.recycle I/ACodec:  [] Now uninitialized
01-12 22:31:14.070 27490-29735  com.example.android.recycle I/OMXClient: Using client-side OMX mux.
01-12 22:31:14.120 27490-29735  com.example.android.recycle I/ACodec: [OMX.qcom.video.decoder.avc] Now Loaded  
01-12 22:31:14.240 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 13.783ms   
01-12 22:31:15.230 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 25.681ms   
01-12 22:31:16.190 27490-27490  com.example.android.recycle I/WebViewFactory: Loading com.google.android.webview version 46.0.2490.76 (code 249007600) 
01-12 22:31:16.420 27490-27490  com.example.android.recycle I/cr.library_loader: Time to load native libraries: 28 ms (timestamps 8250-8278)   
01-12 22:31:16.420 27490-27490  com.example.android.recycle I/cr.library_loader: Expected native library version number "46.0.2490.76", actual native library version number    "46.0.2490.76"
01-12 22:31:16.460 27490-27490  com.example.android.recycle V/WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {60565} 
01-12 22:31:16.460 27490-27490  com.example.android.recycle I/cr.library_loader: Expected native library version number "46.0.2490.76", actual native library version number    "46.0.2490.76"
01-12 22:31:16.530 27490-27490  com.example.android.recycle I/chromium: [INFO:library_loader_hooks.cc(118)] Chromium logging enabled: level = 0, default verbosity = 0 
01-12 22:31:16.600 27490-27490  com.example.android.recycle I/cr.BrowserStartup: Initializing chromium process, singleProcess=true 
01-12 22:31:16.670 27490-27490  com.example.android.recycle E/SysUtils: ApplicationContext is null in ApplicationStatus
01-12 22:31:17.330 27490-27490  com.example.android.recycle E/chromium: [ERROR:browser_gpu_channel_host_factory.cc(258)] Failed to init browser shader disk cache. 
01-12 22:31:17.390 27490-29841  com.example.android.recycle W/cr.media: Requires BLUETOOTH permission  
01-12 22:31:17.570 27490-27490  com.example.android.recycle E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
01-12 22:31:18.250 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 36.905ms   
01-12 22:31:18.580 27490-27490  com.example.android.recycle I/Ads: Starting ad request.
01-12 22:31:18.740 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 19.859ms   
01-12 22:31:18.960 27490-27490  com.example.android.recycle I/Choreographer: Skipped 605 frames!  The application may be doing too much work on its main thread.   
01-12 22:31:19.010 27490-27490  com.example.android.recycle D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null 
01-12 22:31:19.010 27490-27490  com.example.android.recycle D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
01-12 22:31:19.240 27490-27490  com.example.android.recycle D/SRIB_DCS: log_dcs ThreadedRenderer::initialize entered!  
01-12 22:31:19.740 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 20.142ms   
01-12 22:31:19.810 27490-27490  com.example.android.recycle I/Choreographer: Skipped 46 frames!  The application may be doing too much work on its main thread.
01-12 22:31:20.500 27490-27490  com.example.android.recycle V/ActivityThread: updateVisibility : ActivityRecord{3eb83853 token=android.os.BinderProxy@3ce90fd2 {com.example.    android.recycle/com.example.android.prarthana.Main2Activity}} show : false
01-12 22:31:20.770 27490-27490  com.example.android.recycle I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@297d0eeb time:226642629 
01-12 22:31:34.890 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 131.854ms  
01-12 22:31:35.190 27490-27490  com.example.android.recycle I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.WebViewContents    ClientAdapter$WebResourceErrorImpl>
01-12 22:31:35.190 27490-27490  com.example.android.recycle I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.WebViewContents    ClientAdapter$WebResourceErrorImpl>
01-12 22:31:35.260 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 5.297ms
01-12 22:31:35.570 27490-27490  com.example.android.recycle I/art: Rejecting re-init on previously-failed class java.lang.Class<org.chromium.content.browser.FloatingWebActi    onModeCallback>
01-12 22:31:35.570 27490-27490  com.example.android.recycle I/art: Rejecting re-init on previously-failed class java.lang.Class<org.chromium.content.browser.FloatingWebActi    onModeCallback>
01-12 22:31:35.660 27490-27490  com.example.android.recycle W/art: Attempt to remove local handle scope entry from IRT, ignoring   
01-12 22:31:35.760 27490-27490  com.example.android.recycle W/AwContents: onDetachedFromWindow called when already detached. Ignoring  
01-12 22:31:35.810 27490-27490  com.example.android.recycle W/art: Attempt to remove local handle scope entry from IRT, ignoring   
01-12 22:31:35.810 27490-27490  com.example.android.recycle W/art: Attempt to remove local handle scope entry from IRT, ignoring   
01-12 22:31:36.770 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 6.153ms
01-12 22:31:37.050 27490-27490  com.example.android.recycle W/cr.BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 27490
01-12 22:31:39.020 27490-27490  com.example.android.recycle I/Ads: Scheduling ad refresh 60000 milliseconds from now.  
01-12 22:31:39.260 27490-27490  com.example.android.recycle W/art: Attempt to remove local handle scope entry from IRT, ignoring   
01-12 22:31:39.270 27490-27490  com.example.android.recycle W/AwContents: onDetachedFromWindow called when already detached. Ignoring  
01-12 22:31:39.330 27490-27490  com.example.android.recycle W/art: Attempt to remove local handle scope entry from IRT, ignoring   
01-12 22:31:39.330 27490-27490  com.example.android.recycle W/art: Attempt to remove local handle scope entry from IRT, ignoring   
01-12 22:31:39.440 27490-27490  com.example.android.recycle I/Ads: Ad finished loading.
01-12 22:31:39.450 27490-27490  com.example.android.recycle I/Choreographer: Skipped 37 frames!  The application may be doing too much work on its main thread.
01-12 22:31:39.750 27490-27490  com.example.android.recycle W/cr.BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 27490
01-12 22:31:39.850 27490-27490  com.example.android.recycle I/chromium: [INFO:CONSOLE(0)] "Document was loaded from Application Cache with manifest https://googleads.g.doub    leclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.appcache", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
01-12 22:31:39.860 27490-27490  com.example.android.recycle I/chromium: [INFO:CONSOLE(0)] "Application Cache Checking event", source: https://googleads.g.doubleclick.net/ma    ds/static/mad/sdk/native/sdk-core-v40-loader.html (0)
01-12 22:31:40.000 27490-27490  com.example.android.recycle I/chromium: [INFO:CONSOLE(0)] "Application Cache NoUpdate event", source: https://googleads.g.doubleclick.net/ma    ds/static/mad/sdk/native/sdk-core-v40-loader.html (0)
01-12 22:31:49.300 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 7.751ms
01-12 22:31:50.340 27490-27497  com.example.android.recycle W/art: Suspending all threads took: 45.500ms

请给我一些加速的指示。

谢谢。

我认为问题不在回收者视图中,而是在您开始的活动中。 该日志包含有关初始化某些媒体播放或Web视图的很多信息,并且可能会非常昂贵。 如果在主线程中完成此操作,则可能会延迟显示视图,并且看起来单击需要很长时间。

还有一些垃圾收集,总共需要2秒钟。 它看起来可疑,但是您的日志跨度更长,因此可能不是主要问题。

如果我是你我会:

  1. 添加活动生命周期日志记录以准确找出哪个回调存在问题
  2. 使用traceview查找执行时间最长的方法

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM