ロードプロセス上のインターフェイスについて話しました
ダッシュボードの例は、データロード処理を構文解析インタフェースルートの点で、この設定部
最初は、この方法は、()launchSettingFragmentを参照し続けます
switchToFragment(DashboardSummary。クラス .getName()、nullを / * 引数* /、偽、偽、 mInitialTitleResId、mInitialTitle、偽);
それは、私たちはこのカテゴリーを開いて、onCreateView方法を参照してくださいここDashboardSummary.javaにこのクラスをロードしている明らかです。
@Override パブリックビューonCreateView(LayoutInflaterインフレータ、容器のViewGroup、バンドルのバンドル){ 長いのstartTime = にSystem.currentTimeMillis(); 最終ビューのルート= inflater.inflate(R.layout.dashboard、コンテナ、偽); mDashboard = root.findViewById(R.id.dashboard_container)。 mLayoutManager = 新しいLinearLayoutManager(のgetContext()); mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL)。 もし(バンドル!= nullの){ int型 scrollPosition = bundle.getInt(STATE_SCROLL_POSITION)。 mLayoutManager.scrollToPosition(scrollPosition)。 } mDashboard.setLayoutManager(mLayoutManager)。 mDashboard.setHasFixedSize(真の); mDashboard.setListener(この); mDashboard.setItemAnimator(新しいDashboardItemAnimator()); mAdapter = 新しいDashboardAdapter(のgetContext()、バンドル、 mConditionManager.getConditions()、mSuggestionControllerMixin、getLifecycle())。 mDashboard.setAdapter(mAdapter)。 mSummaryLoader.setSummaryConsumer(mAdapter)。 ActionBarShadowController.attachToRecyclerView( getActivity()findViewById(R.id.search_bar_container)、getLifecycle()、mDashboard)。 rebuildUI(); もし(DEBUG_TIMING){ (TAG、Log.d "onCreateViewがかかった" -のstartTime)+ "MS" +(のSystem.currentTimeMillis();) } 戻りルート。 }
上記のコードのほとんどを設定するインターフェイスとrecyclerview基本的な一般的なレイアウトは、直接この方法rebuildUIを参照して導入し、この自体は、R.layout.dashboardのdashboard.xml Recyclerview制御レイアウトです。唯一の方法updateCategory rebuildUI()において、コードセグメントを読み出します。
@WorkerThread ボイドupdateCategory(){ 最終 DashboardCategoryカテゴリ= mDashboardFeatureProvider.getTilesForCategory( CategoryKey.CATEGORY_HOMEPAGE)。 mSummaryLoader.updateSummaryToCache(カテゴリ); mStagingCategory = カテゴリ。 Log.d(TAG、 "updateCategory mSuggestionControllerMixin =" + mSuggestionControllerMixin)。 もし(mSuggestionControllerMixin == NULL ){ ThreadUtils.postOnMainThread(() - > mAdapter.setCategory(mStagingCategory))。 リターン; } もし(mSuggestionControllerMixin.isSuggestionLoaded()){ Log.d(TAG、 "提案がロードされた、提案/カテゴリを設定します" )。 ThreadUtils.postOnMainThread(() - > { 場合(mStagingSuggestions!= NULL ){ mAdapter.setSuggestions(mStagingSuggestions); } mAdapter.setCategory(mStagingCategory); }); } 他{ Log.d(TAG、 + MAX_WAIT_MILLIS + "MS" "提案によりsetCategoryを遅らせる、ロードされていません" )。 mHandler.postDelayed(() - >mAdapter.setCategory(mStagingCategory)、MAX_WAIT_MILLIS)。 } }
CategoryKey.CATEGORY_HOMEPAGEは、実際には、カテゴリ解析<メタデータを言うことですcom.android.settings.category.ia.homepageは、AndroidManifestファイルからアンドロイド:名=「com.android.settings.category」属性の値は、COMに対応します。取得するための活動のandroid.settings.category.ia.homepage。
getTilesForCategory下にクラスを実装するコードを読み取るDashboardFeatureProviderImpl.javaする方法は、リターンgetTilesForCategory実際CategoryManager.getTilesByCategoryこの方法の中に発見することができるインターフェースDashboardFeatureProviderでこの方法を、参照。PS:/frameworks/base/packages/SettingsLib/src/com/android/settingslib/drawer/CategoryManager.java
パブリック 同期DashboardCategory getTilesByCategory(コンテキスト・コンテキストは、文字列categoryKey){ 戻りgetTilesByCategoryを(文脈、categoryKey、TileUtils.SETTING_PKG)。 } パブリック 同期DashboardCategory getTilesByCategory(コンテキスト・コンテキスト、文字列categoryKey、 列settingPkg){ tryInitCategories(文脈、settingPkg)。 リターンmCategoryByKeyMap.get(categoryKey)。 } プライベート 同期 のボイドtryInitCategories(コンテキストコンテキスト、文字列settingPkg){ // デフォルトでキャッシュタイルを保管してください。キャッシュは、ときにのみInterestingConfigChange無効化されます // 起こります。 tryInitCategories(コンテキスト、偽 / * forceClearCache * / 、settingPkg)。 } プライベート 同期 ボイド tryInitCategories(コンテキスト・コンテキスト、ブールforceClearCache、 ストリングsettingPkg){ 場合(mCategories == NULL ){ 場合(forceClearCache){ mTileByComponentCache.clear()。 } mCategoryByKeyMap.clear()。 mCategories = TileUtils.getCategories(文脈、mTileByComponentCache、 偽 / *categoryDefinedInManifest * / 、mExtraAction、settingPkg)。 用(DashboardCategoryカテゴリー:mCategories){ mCategoryByKeyMap.put(category.key、カテゴリ)。 } backwardCompatCleanupForCategory(mTileByComponentCache、mCategoryByKeyMap)。 sortCategories(コンテキスト、mCategoryByKeyMap)。 filterDuplicateTiles(mCategoryByKeyMap)。 } }
これは、得られたカテゴリを取得するTileUtils.getCategories()メソッドを使用して、赤コードから分かります。
/ ** * DashboardCategoryのリストを作成します。 * @param categoryDefinedInManifest trueの場合、ダミー活動必見マニフェストに存在する *(例:.Settings $ DeviceSettings)このカテゴリを表す * @param ダッシュボード構築するusetileutildするextraAction追加のインテントフィルタアクション *カテゴリー * / パブリック 静的の一覧を< DashboardCategory> getCategories(コンテキスト・コンテキスト、 地図 <ペア<文字列、文字列>、タイル>キャッシュ、ブールcategoryDefinedInManifest、 文字extraAction、列settingPkg){ 最終 長のstartTime =System.currentTimeMillis(); ブールセットアップ= Global.getInt(context.getContentResolver()、Global.DEVICE_PROVISIONED、0 ) != 0 ; ArrayListの <タイル>タイル= 新しい ArrayListを<> (); UserManagerのUserManager = (のUserManager)context.getSystemService(Context.USER_SERVICE)。 用(UserHandleユーザー:userManager.getUserProfiles()){ // TODO:多くの最適化が必要、あまりにも多くのPMクエリはここで起こっ。 もし(user.getIdentifier()== ActivityManager.getCurrentUser()){ // これだけのユーザーの設定を追加します。 getTilesForAction(コンテキスト、ユーザー、SETTINGS_ACTION、キャッシュ、ヌル、タイル、真、 settingPkg)。 getTilesForAction(コンテキスト、ユーザー、OPERATOR_SETTINGS、キャッシュ、 OPERATOR_DEFAULT_CATEGORY、タイル、偽、真、settingPkg)。 getTilesForAction(コンテキスト、ユーザー、MANUFACTURER_SETTINGS、キャッシュ、 MANUFACTURER_DEFAULT_CATEGORY、タイル、偽、真、settingPkg)。 } もし{(セットアップ) getTilesForAction(コンテキスト、ユーザー、EXTRA_SETTINGS_ACTION、キャッシュ、ヌル、タイル、偽、 settingPkg)。 もし(!categoryDefinedInManifest){ getTilesForAction(コンテキスト、ユーザー、IA_SETTINGS_ACTION、キャッシュ、ヌル、タイル、偽、 settingPkg)。 もし(extraAction!= nullの){ getTilesForAction(コンテキスト、ユーザー、extraAction、キャッシュ、ヌル、タイル、偽、 settingPkg); } } } } のHashMap <文字列、DashboardCategory> categoryMap = 新規 HashMapの<> (); 用(タイルタイル:タイル){ DashboardCategoryカテゴリ = categoryMap.get(tile.category)。 もし(カテゴリー== NULL ){ カテゴリ = createCategory(文脈、tile.category、categoryDefinedInManifest)。 もし(カテゴリー== NULL ){ Log.w(LOG_TAG、+「カテゴリが見つかりませんでした」)tile.categoryを。 続け; } categoryMap.put(category.key、カテゴリ)。 } / * Googleのサウンド設定のためのSPRDの追加* / 場合(tile.intent.getComponent()。getClassNameメソッド()。( "com.android.settings.Settings $ SoundSettingsActivity"に等しい)){ 場合(isSupportGoogleAudio()){ カテゴリ。 addTile(タイル)。 } 他{ 続けます。 } } それ以外 の場合(tile.intent.getComponent()。getClassNameメソッド()。等号( "com.sprd.audioprofile.AudioProfileSettings" )){ 場合(!isSupportGoogleAudio()){ tile.summary = context.getResources()のgetString(R.string .audio_profile_summary); category.addTile(タイル)。 } 他{ 続けます。 } } そう であれば(tile.intent.getComponent()。getClassNameメソッド()。等号( "com.sprd.settings.timerpower.AlarmClock" )){ tile.summary =context.getResources()のgetString(R.string.power_on_off)。 category.addTile(タイル)。 } 他{ category.addTile(タイル)。 } / * Googleのサウンド設定終了のためSPRDアド* / // category.addTile(タイル)。 } のArrayList <DashboardCategory>カテゴリ= 新規のArrayList <> (categoryMap.values())。 用(DashboardCategoryカテゴリー:カテゴリー){ category.sortTiles()。 } Collections.sort(カテゴリ、CATEGORY_COMPARATOR)。 もし(DEBUG_TIMING)Log.d(LOG_TAG、 "getCategoriesがかかった" -のstartTime)+ "MS"を+(のSystem.currentTimeMillis();) リターンカテゴリ; }
変数は、アクションフィールドを解析することによって、実質的にAndroidManifestファイルが追加カテゴリかどうかを判断し、赤い印指摘しました。
これまでのところ、設定データの読み込み処理を終了します。