Conversation
Summary of ChangesHello @kaaviya98, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces comprehensive logging across several Android fragments responsible for displaying WebView content, particularly for PDF viewing. The added Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds extensive logging for timing and debugging the WebView loading process. While this is very useful for development and performance analysis, this kind of debug code should not be merged into the main branch. It clutters the codebase, adds noise to production logs, and introduces a small performance overhead. I've added comments to remove this logging from all modified files.
| val startTime = System.currentTimeMillis() | ||
| android.util.Log.d("AI_TIMING", "🟦 STEP 8: WebViewFragment.onCreate() STARTED") | ||
|
|
||
| parseArguments() | ||
|
|
||
| android.util.Log.d("AI_TIMING", "✅ STEP 8 DONE: WebViewFragment.onCreate() completed in ${System.currentTimeMillis() - startTime}ms") |
There was a problem hiding this comment.
These timing logs appear to be for debugging purposes. They should be removed from the final code to keep the codebase clean and avoid unnecessary logging in production.
| val startTime = System.currentTimeMillis() | |
| android.util.Log.d("AI_TIMING", "🟦 STEP 8: WebViewFragment.onCreate() STARTED") | |
| parseArguments() | |
| android.util.Log.d("AI_TIMING", "✅ STEP 8 DONE: WebViewFragment.onCreate() completed in ${System.currentTimeMillis() - startTime}ms") | |
| parseArguments() |
| val startTime = System.currentTimeMillis() | ||
| android.util.Log.d("AI_TIMING", "🟦 STEP 9: WebViewFragment.onCreateView() STARTED") | ||
|
|
||
| _layout = WebviewFragmentBinding.inflate(inflater, container, false) | ||
|
|
||
| android.util.Log.d("AI_TIMING", "✅ STEP 9 DONE: WebViewFragment.onCreateView() completed in ${System.currentTimeMillis() - startTime}ms") |
There was a problem hiding this comment.
This debugging code should be removed before merging. It adds noise to the logs and is not necessary for production builds.
| val startTime = System.currentTimeMillis() | |
| android.util.Log.d("AI_TIMING", "🟦 STEP 9: WebViewFragment.onCreateView() STARTED") | |
| _layout = WebviewFragmentBinding.inflate(inflater, container, false) | |
| android.util.Log.d("AI_TIMING", "✅ STEP 9 DONE: WebViewFragment.onCreateView() completed in ${System.currentTimeMillis() - startTime}ms") | |
| _layout = WebviewFragmentBinding.inflate(inflater, container, false) |
| val startTime = System.currentTimeMillis() | ||
| android.util.Log.d("AI_TIMING", "🟦 STEP 10: WebViewFragment.onViewCreated() STARTED") | ||
|
|
||
| showLoading() | ||
| android.util.Log.d("AI_TIMING", " Showing loading spinner... (${System.currentTimeMillis() - startTime}ms)") | ||
|
|
||
| initializedSwipeRefresh() | ||
| android.util.Log.d("AI_TIMING", " Initialized swipe refresh (${System.currentTimeMillis() - startTime}ms)") | ||
|
|
||
| initializeEmptyViewFragment() | ||
| android.util.Log.d("AI_TIMING", " Initialized empty view fragment (${System.currentTimeMillis() - startTime}ms)") | ||
|
|
||
| webView = layout.webView | ||
| listener?.onWebViewInitializationSuccess() | ||
| android.util.Log.d("AI_TIMING", " WebView reference obtained (${System.currentTimeMillis() - startTime}ms)") | ||
|
|
||
| android.util.Log.d("AI_TIMING", "🟦 STEP 11: Calling setupWebView()...") | ||
| val setupStart = System.currentTimeMillis() | ||
| setupWebView() | ||
| android.util.Log.d("AI_TIMING", "✅ STEP 11 DONE: setupWebView() completed in ${System.currentTimeMillis() - setupStart}ms") | ||
|
|
||
| android.util.Log.d("AI_TIMING", "🟦 STEP 12: Calling populateInstituteSettings()...") | ||
| val settingsStart = System.currentTimeMillis() | ||
| populateInstituteSettings() | ||
| android.util.Log.d("AI_TIMING", "✅ STEP 12 DONE: populateInstituteSettings() completed in ${System.currentTimeMillis() - settingsStart}ms") | ||
|
|
||
| android.util.Log.d("AI_TIMING", "🟦 STEP 13: Calling loadContent() - NETWORK REQUEST STARTS HERE...") | ||
| val loadStart = System.currentTimeMillis() | ||
| loadContent() | ||
| android.util.Log.d("AI_TIMING", "✅ STEP 13 DONE: loadContent() initiated in ${System.currentTimeMillis() - loadStart}ms (network request continues in background)") | ||
|
|
||
| android.util.Log.d("AI_TIMING", "✅ STEP 10 DONE: WebViewFragment.onViewCreated() completed in ${System.currentTimeMillis() - startTime}ms total") |
There was a problem hiding this comment.
The extensive timing logs in this method are useful for debugging but should not be part of the production code. Please remove them to improve readability and avoid log spam.
| val startTime = System.currentTimeMillis() | |
| android.util.Log.d("AI_TIMING", "🟦 STEP 10: WebViewFragment.onViewCreated() STARTED") | |
| showLoading() | |
| android.util.Log.d("AI_TIMING", " Showing loading spinner... (${System.currentTimeMillis() - startTime}ms)") | |
| initializedSwipeRefresh() | |
| android.util.Log.d("AI_TIMING", " Initialized swipe refresh (${System.currentTimeMillis() - startTime}ms)") | |
| initializeEmptyViewFragment() | |
| android.util.Log.d("AI_TIMING", " Initialized empty view fragment (${System.currentTimeMillis() - startTime}ms)") | |
| webView = layout.webView | |
| listener?.onWebViewInitializationSuccess() | |
| android.util.Log.d("AI_TIMING", " WebView reference obtained (${System.currentTimeMillis() - startTime}ms)") | |
| android.util.Log.d("AI_TIMING", "🟦 STEP 11: Calling setupWebView()...") | |
| val setupStart = System.currentTimeMillis() | |
| setupWebView() | |
| android.util.Log.d("AI_TIMING", "✅ STEP 11 DONE: setupWebView() completed in ${System.currentTimeMillis() - setupStart}ms") | |
| android.util.Log.d("AI_TIMING", "🟦 STEP 12: Calling populateInstituteSettings()...") | |
| val settingsStart = System.currentTimeMillis() | |
| populateInstituteSettings() | |
| android.util.Log.d("AI_TIMING", "✅ STEP 12 DONE: populateInstituteSettings() completed in ${System.currentTimeMillis() - settingsStart}ms") | |
| android.util.Log.d("AI_TIMING", "🟦 STEP 13: Calling loadContent() - NETWORK REQUEST STARTS HERE...") | |
| val loadStart = System.currentTimeMillis() | |
| loadContent() | |
| android.util.Log.d("AI_TIMING", "✅ STEP 13 DONE: loadContent() initiated in ${System.currentTimeMillis() - loadStart}ms (network request continues in background)") | |
| android.util.Log.d("AI_TIMING", "✅ STEP 10 DONE: WebViewFragment.onViewCreated() completed in ${System.currentTimeMillis() - startTime}ms total") | |
| showLoading() | |
| initializedSwipeRefresh() | |
| initializeEmptyViewFragment() | |
| webView = layout.webView | |
| listener?.onWebViewInitializationSuccess() | |
| setupWebView() | |
| populateInstituteSettings() | |
| loadContent() |
| class CustomWebViewClient(val fragment: WebViewFragment) : WebViewClient() { | ||
|
|
||
| private var errorList = linkedMapOf<WebResourceRequest?,WebResourceResponse?>() | ||
| private var pageLoadStartTime: Long = 0 |
| pageLoadStartTime = System.currentTimeMillis() | ||
| android.util.Log.d("AI_TIMING", "🟦 STEP 14: WebView.onPageStarted() - URL loading started") | ||
| android.util.Log.d("AI_TIMING", " Loading URL: $url") |
| val totalLoadTime = System.currentTimeMillis() - pageLoadStartTime | ||
| android.util.Log.d("AI_TIMING", "✅ STEP 14 DONE: WebView.onPageFinished() - Page loaded!") | ||
| android.util.Log.d("AI_TIMING", " Loaded URL: $url") | ||
| android.util.Log.d("AI_TIMING", " ⏱️ TOTAL PAGE LOAD TIME: ${totalLoadTime}ms") | ||
| android.util.Log.d("AI_TIMING", "") | ||
| android.util.Log.d("AI_TIMING", "========================================") | ||
| android.util.Log.d("AI_TIMING", "🎉 AI WEBVIEW FULLY LOADED AND VISIBLE!") | ||
| android.util.Log.d("AI_TIMING", "⏱️ Total time from button click: ${totalLoadTime}ms") | ||
| android.util.Log.d("AI_TIMING", "========================================") | ||
|
|
| val startTime = System.currentTimeMillis() | ||
| android.util.Log.d("AI_TIMING", "🟦 STEP 4: AIChatPdfFragment.onCreateView() STARTED") | ||
|
|
||
| val view = inflater.inflate(R.layout.ai_pdf_fragment, container, false) | ||
|
|
||
| android.util.Log.d("AI_TIMING", "✅ STEP 4 DONE: AIChatPdfFragment.onCreateView() completed in ${System.currentTimeMillis() - startTime}ms") | ||
| return view |
There was a problem hiding this comment.
Please remove the debug timing logs and revert to the original concise implementation.
| val startTime = System.currentTimeMillis() | |
| android.util.Log.d("AI_TIMING", "🟦 STEP 4: AIChatPdfFragment.onCreateView() STARTED") | |
| val view = inflater.inflate(R.layout.ai_pdf_fragment, container, false) | |
| android.util.Log.d("AI_TIMING", "✅ STEP 4 DONE: AIChatPdfFragment.onCreateView() completed in ${System.currentTimeMillis() - startTime}ms") | |
| return view | |
| return inflater.inflate(R.layout.ai_pdf_fragment, container, false) |
| val startTime = System.currentTimeMillis() | ||
| android.util.Log.d("AI_TIMING", "🟦 STEP 5: AIChatPdfFragment.onViewCreated() STARTED") | ||
|
|
||
| val contentId = requireArguments().getLong(ARG_CONTENT_ID, -1L) | ||
| val courseId = requireArguments().getLong(ARG_COURSE_ID, -1L) | ||
|
|
||
| if (contentId == -1L || courseId == -1L) { | ||
| throw IllegalArgumentException("Required arguments (contentId, courseId) are missing or invalid.") | ||
| } | ||
|
|
||
| android.util.Log.d("AI_TIMING", "🟦 STEP 6: Creating WebViewFragment...") | ||
| val webViewCreateStart = System.currentTimeMillis() | ||
|
|
||
| val webViewFragment = WebViewFragment() | ||
|
|
||
| val pdfUrl = getPdfUrl(courseId, contentId) | ||
| android.util.Log.d("AI_TIMING", " URL to load: $pdfUrl") | ||
|
|
||
| webViewFragment.arguments = Bundle().apply { | ||
| putString(URL_TO_OPEN, pdfUrl) | ||
| putBoolean(IS_AUTHENTICATION_REQUIRED, true) | ||
| } | ||
|
|
||
| android.util.Log.d("AI_TIMING", "✅ STEP 6 DONE: WebViewFragment created in ${System.currentTimeMillis() - webViewCreateStart}ms") | ||
|
|
||
| android.util.Log.d("AI_TIMING", "🟦 STEP 7: Committing WebViewFragment transaction...") | ||
| val transactionStart = System.currentTimeMillis() | ||
|
|
||
| childFragmentManager.beginTransaction() | ||
| .replace(R.id.aiPdf_view_fragment, webViewFragment) | ||
| .commit() | ||
|
|
||
| android.util.Log.d("AI_TIMING", "✅ STEP 7 DONE: WebView transaction committed in ${System.currentTimeMillis() - transactionStart}ms") | ||
| android.util.Log.d("AI_TIMING", "✅ STEP 5 DONE: AIChatPdfFragment.onViewCreated() completed in ${System.currentTimeMillis() - startTime}ms total") |
There was a problem hiding this comment.
This extensive debug logging should be removed from the production code. Please revert the body of this method to its original state.
val contentId = requireArguments().getLong(ARG_CONTENT_ID, -1L)
val courseId = requireArguments().getLong(ARG_COURSE_ID, -1L)
if (contentId == -1L || courseId == -1L) {
throw IllegalArgumentException("Required arguments (contentId, courseId) are missing or invalid.")
}
val webViewFragment = WebViewFragment()
val pdfUrl = getPdfUrl(courseId, contentId)
webViewFragment.arguments = Bundle().apply {
putString(URL_TO_OPEN, pdfUrl)
putBoolean(IS_AUTHENTICATION_REQUIRED, true)
}
childFragmentManager.beginTransaction()
.replace(R.id.aiPdf_view_fragment, webViewFragment)
.commit()| val startTime = System.currentTimeMillis() | ||
| android.util.Log.d("AI_TIMING", "🟦 STEP 1: showAIView() STARTED at ${startTime}") | ||
|
|
||
| if (aiChatFragment == null) { | ||
| android.util.Log.d("AI_TIMING", "🟦 STEP 2: Creating AIChatPdfFragment...") | ||
| val fragmentCreateStart = System.currentTimeMillis() | ||
|
|
||
| aiChatFragment = AIChatPdfFragment() | ||
| val args = Bundle() | ||
| args.putLong("contentId", contentId) | ||
| args.putLong("courseId", content.courseId ?: -1L) | ||
| aiChatFragment?.arguments = args | ||
|
|
||
| android.util.Log.d("AI_TIMING", "✅ STEP 2 DONE: Fragment created in ${System.currentTimeMillis() - fragmentCreateStart}ms") | ||
| } | ||
|
|
||
| binding.pdfView.visibility = View.GONE | ||
| binding.bottomNavigationFragment.visibility = View.GONE | ||
| binding.askAiFab.visibility = View.GONE | ||
| binding.aiPdfViewFragment.visibility = View.VISIBLE | ||
|
|
||
| android.util.Log.d("AI_TIMING", "🟦 STEP 3: Committing fragment transaction...") | ||
| val transactionStart = System.currentTimeMillis() | ||
|
|
||
| childFragmentManager.beginTransaction() | ||
| .replace(R.id.aiPdf_view_fragment, aiChatFragment!!) | ||
| .commit() | ||
|
|
||
| android.util.Log.d("AI_TIMING", "✅ STEP 3 DONE: Transaction committed in ${System.currentTimeMillis() - transactionStart}ms") | ||
| android.util.Log.d("AI_TIMING", "✅ showAIView() COMPLETED in ${System.currentTimeMillis() - startTime}ms total") |
There was a problem hiding this comment.
Please remove the debug logging from this method and restore its original implementation.
| val startTime = System.currentTimeMillis() | |
| android.util.Log.d("AI_TIMING", "🟦 STEP 1: showAIView() STARTED at ${startTime}") | |
| if (aiChatFragment == null) { | |
| android.util.Log.d("AI_TIMING", "🟦 STEP 2: Creating AIChatPdfFragment...") | |
| val fragmentCreateStart = System.currentTimeMillis() | |
| aiChatFragment = AIChatPdfFragment() | |
| val args = Bundle() | |
| args.putLong("contentId", contentId) | |
| args.putLong("courseId", content.courseId ?: -1L) | |
| aiChatFragment?.arguments = args | |
| android.util.Log.d("AI_TIMING", "✅ STEP 2 DONE: Fragment created in ${System.currentTimeMillis() - fragmentCreateStart}ms") | |
| } | |
| binding.pdfView.visibility = View.GONE | |
| binding.bottomNavigationFragment.visibility = View.GONE | |
| binding.askAiFab.visibility = View.GONE | |
| binding.aiPdfViewFragment.visibility = View.VISIBLE | |
| android.util.Log.d("AI_TIMING", "🟦 STEP 3: Committing fragment transaction...") | |
| val transactionStart = System.currentTimeMillis() | |
| childFragmentManager.beginTransaction() | |
| .replace(R.id.aiPdf_view_fragment, aiChatFragment!!) | |
| .commit() | |
| android.util.Log.d("AI_TIMING", "✅ STEP 3 DONE: Transaction committed in ${System.currentTimeMillis() - transactionStart}ms") | |
| android.util.Log.d("AI_TIMING", "✅ showAIView() COMPLETED in ${System.currentTimeMillis() - startTime}ms total") | |
| if (aiChatFragment == null) { | |
| aiChatFragment = AIChatPdfFragment() | |
| val args = Bundle() | |
| args.putLong("contentId", contentId) | |
| args.putLong("courseId", content.courseId ?: -1L) | |
| aiChatFragment?.arguments = args | |
| } | |
| binding.pdfView.visibility = View.GONE | |
| binding.bottomNavigationFragment.visibility = View.GONE | |
| binding.askAiFab.visibility = View.GONE | |
| binding.aiPdfViewFragment.visibility = View.VISIBLE | |
| childFragmentManager.beginTransaction() | |
| .replace(R.id.aiPdf_view_fragment, aiChatFragment!!) | |
| .commit() |
Changes done
Reason for the changes
Fixes # .