2012-04-24 17:16:04 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2012 The Android Open Source Project
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-06-05 22:57:57 -04:00
|
|
|
package com.android.launcher3;
|
2012-04-24 17:16:04 -07:00
|
|
|
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
2013-11-14 12:03:58 +01:00
|
|
|
import android.os.AsyncTask;
|
2012-10-02 16:55:54 -07:00
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.util.Log;
|
2012-04-24 17:16:04 -07:00
|
|
|
|
|
|
|
|
public class PreloadReceiver extends BroadcastReceiver {
|
2012-10-02 16:55:54 -07:00
|
|
|
private static final String TAG = "Launcher.PreloadReceiver";
|
|
|
|
|
private static final boolean LOGD = false;
|
|
|
|
|
|
|
|
|
|
public static final String EXTRA_WORKSPACE_NAME =
|
2013-06-05 22:57:57 -04:00
|
|
|
"com.android.launcher3.action.EXTRA_WORKSPACE_NAME";
|
2012-10-02 16:55:54 -07:00
|
|
|
|
2012-04-24 17:16:04 -07:00
|
|
|
@Override
|
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
2013-07-08 18:03:46 -07:00
|
|
|
final LauncherProvider provider = LauncherAppState.getLauncherProvider();
|
2012-04-24 17:16:04 -07:00
|
|
|
if (provider != null) {
|
2012-10-02 16:55:54 -07:00
|
|
|
String name = intent.getStringExtra(EXTRA_WORKSPACE_NAME);
|
|
|
|
|
final int workspaceResId = !TextUtils.isEmpty(name)
|
2013-06-05 22:57:57 -04:00
|
|
|
? context.getResources().getIdentifier(name, "xml", "com.android.launcher3") : 0;
|
2012-10-02 16:55:54 -07:00
|
|
|
if (LOGD) {
|
|
|
|
|
Log.d(TAG, "workspace name: " + name + " id: " + workspaceResId);
|
|
|
|
|
}
|
2013-11-14 12:03:58 +01:00
|
|
|
new AsyncTask<Void, Void, Void>() {
|
|
|
|
|
public Void doInBackground(Void ... args) {
|
2012-10-02 16:55:54 -07:00
|
|
|
provider.loadDefaultFavoritesIfNecessary(workspaceResId);
|
2013-11-14 12:03:58 +01:00
|
|
|
return null;
|
2012-04-24 17:16:04 -07:00
|
|
|
}
|
2013-11-14 12:03:58 +01:00
|
|
|
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void) null);
|
2012-04-24 17:16:04 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|