зеркало из https://github.com/mozilla/gecko-dev.git
Bug 725932: Use handler messages. [r=mfinkle,blassey]
This commit is contained in:
Родитель
92f302e38f
Коммит
5e22b7de58
|
@ -125,6 +125,14 @@ public class AboutHomeContent extends ScrollView {
|
|||
|
||||
public AboutHomeContent(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public AboutHomeContent(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public void init() {
|
||||
Context context = getContext();
|
||||
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
mInflater.inflate(R.layout.abouthome_content, this);
|
||||
|
||||
|
@ -148,9 +156,6 @@ public class AboutHomeContent extends ScrollView {
|
|||
}
|
||||
}, GeckoAppShell.getHandler(), true);
|
||||
|
||||
setScrollContainer(true);
|
||||
setBackgroundResource(R.drawable.abouthome_bg_repeat);
|
||||
|
||||
mTopSitesGrid = (GridView)findViewById(R.id.top_sites_grid);
|
||||
mTopSitesGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||
|
|
|
@ -77,7 +77,6 @@ public class BrowserToolbar extends LinearLayout {
|
|||
|
||||
final private Context mContext;
|
||||
private Handler mHandler;
|
||||
private boolean mInflated;
|
||||
private int mColor;
|
||||
private int mCounterColor;
|
||||
private int[] mPadding;
|
||||
|
@ -94,7 +93,6 @@ public class BrowserToolbar extends LinearLayout {
|
|||
public BrowserToolbar(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
mContext = context;
|
||||
mInflated = false;
|
||||
mTitleCanExpand = true;
|
||||
|
||||
// Get the device's highlight color
|
||||
|
@ -111,18 +109,7 @@ public class BrowserToolbar extends LinearLayout {
|
|||
typedArray.recycle();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate () {
|
||||
super.onFinishInflate();
|
||||
|
||||
// HACK: Without this, the onFinishInflate is called twice
|
||||
// This issue is due to a bug when Android inflates a layout with a
|
||||
// parent. Fixed in Honeycomb
|
||||
if (mInflated)
|
||||
return;
|
||||
|
||||
mInflated = true;
|
||||
|
||||
public void init() {
|
||||
mAwesomeBar = (Button) findViewById(R.id.awesome_bar);
|
||||
mAwesomeBar.setOnClickListener(new Button.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -124,7 +124,7 @@ abstract public class GeckoApp
|
|||
public static File sGREDir = null;
|
||||
public static Menu sMenu;
|
||||
private static GeckoThread sGeckoThread = null;
|
||||
public Handler mMainHandler;
|
||||
public GeckoAppHandler mMainHandler;
|
||||
private File mProfileDir;
|
||||
public static boolean sIsGeckoReady = false;
|
||||
public static int mOrientation;
|
||||
|
@ -152,6 +152,10 @@ abstract public class GeckoApp
|
|||
public byte[] mLastScreen;
|
||||
public int mOwnActivityDepth = 0;
|
||||
private boolean mRestoreSession = false;
|
||||
private boolean mInitialized = false;
|
||||
|
||||
private static final String HANDLER_MSG_TYPE = "type";
|
||||
private static final int HANDLER_MSG_TYPE_INITIALIZE = 1;
|
||||
|
||||
public interface OnTabsChangedListener {
|
||||
public void onTabsChanged(Tab tab);
|
||||
|
@ -1145,27 +1149,27 @@ abstract public class GeckoApp
|
|||
|
||||
public void run() {
|
||||
mAutoCompletePopup.hide();
|
||||
if (mAboutHomeContent == null && mShow) {
|
||||
mAboutHomeContent = new AboutHomeContent(GeckoApp.mAppContext);
|
||||
mAboutHomeContent.update(GeckoApp.mAppContext, AboutHomeContent.UpdateFlags.ALL);
|
||||
mAboutHomeContent.setUriLoadCallback(new AboutHomeContent.UriLoadCallback() {
|
||||
public void callback(String url) {
|
||||
mBrowserToolbar.setProgressVisibility(true);
|
||||
loadUrl(url, AwesomeBar.Type.EDIT);
|
||||
}
|
||||
});
|
||||
RelativeLayout.LayoutParams lp =
|
||||
new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
|
||||
LayoutParams.FILL_PARENT);
|
||||
mGeckoLayout.addView(mAboutHomeContent, lp);
|
||||
} else if (mAboutHomeContent != null && mShow) {
|
||||
mAboutHomeContent.update(GeckoApp.mAppContext,
|
||||
EnumSet.of(AboutHomeContent.UpdateFlags.TOP_SITES));
|
||||
if (mShow) {
|
||||
if (mAboutHomeContent == null) {
|
||||
mAboutHomeContent = (AboutHomeContent) findViewById(R.id.abouthome_content);
|
||||
mAboutHomeContent.init();
|
||||
mAboutHomeContent.update(GeckoApp.mAppContext, AboutHomeContent.UpdateFlags.ALL);
|
||||
mAboutHomeContent.setUriLoadCallback(new AboutHomeContent.UriLoadCallback() {
|
||||
public void callback(String url) {
|
||||
mBrowserToolbar.setProgressVisibility(true);
|
||||
loadUrl(url, AwesomeBar.Type.EDIT);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mAboutHomeContent.update(GeckoApp.mAppContext,
|
||||
EnumSet.of(AboutHomeContent.UpdateFlags.TOP_SITES));
|
||||
}
|
||||
|
||||
mAboutHomeContent.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
findViewById(R.id.abouthome_content).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (mAboutHomeContent != null)
|
||||
mAboutHomeContent.setVisibility(mShow ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1637,6 +1641,7 @@ abstract public class GeckoApp
|
|||
public void refreshActionBar() {
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
mBrowserToolbar = (BrowserToolbar) getLayoutInflater().inflate(R.layout.browser_toolbar, null);
|
||||
mBrowserToolbar.init();
|
||||
mBrowserToolbar.refresh();
|
||||
GeckoActionBar.setBackgroundDrawable(this, getResources().getDrawable(R.drawable.gecko_actionbar_bg));
|
||||
GeckoActionBar.setDisplayOptions(this, ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM |
|
||||
|
@ -1659,7 +1664,7 @@ abstract public class GeckoApp
|
|||
}
|
||||
|
||||
System.loadLibrary("mozglue");
|
||||
mMainHandler = new Handler();
|
||||
mMainHandler = new GeckoAppHandler();
|
||||
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate");
|
||||
if (savedInstanceState != null) {
|
||||
mLastTitle = savedInstanceState.getString(SAVED_STATE_TITLE);
|
||||
|
@ -1668,6 +1673,30 @@ abstract public class GeckoApp
|
|||
mRestoreSession = savedInstanceState.getBoolean(SAVED_STATE_SESSION);
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mOrientation = getResources().getConfiguration().orientation;
|
||||
|
||||
setContentView(R.layout.gecko_app);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
mBrowserToolbar = (BrowserToolbar) GeckoActionBar.getCustomView(this);
|
||||
} else {
|
||||
mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar);
|
||||
}
|
||||
|
||||
// setup gecko layout
|
||||
mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
|
||||
mMainLayout = (LinearLayout) findViewById(R.id.main_layout);
|
||||
|
||||
mConnectivityFilter = new IntentFilter();
|
||||
mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
mConnectivityReceiver = new GeckoConnectivityReceiver();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
mInitialized = true;
|
||||
|
||||
Intent intent = getIntent();
|
||||
String args = intent.getStringExtra("args");
|
||||
if (args != null && args.contains("-profile")) {
|
||||
|
@ -1686,18 +1715,7 @@ abstract public class GeckoApp
|
|||
checkAndLaunchUpdate();
|
||||
}
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mOrientation = getResources().getConfiguration().orientation;
|
||||
|
||||
setContentView(R.layout.gecko_app);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
mBrowserToolbar = (BrowserToolbar) GeckoActionBar.getCustomView(this);
|
||||
} else {
|
||||
mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar);
|
||||
}
|
||||
|
||||
mBrowserToolbar.init();
|
||||
mBrowserToolbar.setTitle(mLastTitle);
|
||||
|
||||
String passedUri = null;
|
||||
|
@ -1745,23 +1763,7 @@ abstract public class GeckoApp
|
|||
|
||||
mFavicons = new Favicons(this);
|
||||
|
||||
// setup gecko layout
|
||||
mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
|
||||
mMainLayout = (LinearLayout) findViewById(R.id.main_layout);
|
||||
|
||||
mDoorHangerPopup = new DoorHangerPopup(this);
|
||||
mAutoCompletePopup = (AutoCompletePopup) findViewById(R.id.autocomplete_popup);
|
||||
|
||||
Tabs tabs = Tabs.getInstance();
|
||||
Tab tab = tabs.getSelectedTab();
|
||||
if (tab != null) {
|
||||
mBrowserToolbar.setTitle(tab.getDisplayTitle());
|
||||
mBrowserToolbar.setFavicon(tab.getFavicon());
|
||||
mBrowserToolbar.setProgressVisibility(tab.isLoading());
|
||||
mBrowserToolbar.updateTabCountAndAnimate(Tabs.getInstance().getCount());
|
||||
}
|
||||
|
||||
tabs.setContentResolver(getContentResolver());
|
||||
Tabs.getInstance().setContentResolver(getContentResolver());
|
||||
|
||||
if (cameraView == null) {
|
||||
cameraView = new SurfaceView(this);
|
||||
|
@ -1793,6 +1795,9 @@ abstract public class GeckoApp
|
|||
|
||||
mPluginContainer = (AbsoluteLayout) findViewById(R.id.plugin_container);
|
||||
|
||||
mDoorHangerPopup = new DoorHangerPopup(this);
|
||||
mAutoCompletePopup = (AutoCompletePopup) findViewById(R.id.autocomplete_popup);
|
||||
|
||||
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - UI almost up");
|
||||
|
||||
if (!sTryCatchAttached) {
|
||||
|
@ -1840,10 +1845,6 @@ abstract public class GeckoApp
|
|||
GeckoAppShell.registerGeckoEventListener("Tab:HasTouchListener", GeckoApp.mAppContext);
|
||||
GeckoAppShell.registerGeckoEventListener("Session:StatePurged", GeckoApp.mAppContext);
|
||||
|
||||
mConnectivityFilter = new IntentFilter();
|
||||
mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
mConnectivityReceiver = new GeckoConnectivityReceiver();
|
||||
|
||||
IntentFilter batteryFilter = new IntentFilter();
|
||||
batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||
mBatteryReceiver = new GeckoBatteryManager();
|
||||
|
@ -2099,6 +2100,17 @@ abstract public class GeckoApp
|
|||
// Undo whatever we did in onPause.
|
||||
super.onResume();
|
||||
|
||||
/* We load the initial UI and wait until it is shown to the user
|
||||
to continue other initializations and loading about:home (if needed) */
|
||||
if (!mInitialized) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putInt(HANDLER_MSG_TYPE, HANDLER_MSG_TYPE_INITIALIZE);
|
||||
|
||||
Message message = mMainHandler.obtainMessage();
|
||||
message.setData(bundle);
|
||||
mMainHandler.sendMessage(message);
|
||||
}
|
||||
|
||||
int newOrientation = getResources().getConfiguration().orientation;
|
||||
|
||||
if (mOrientation != newOrientation) {
|
||||
|
@ -2712,6 +2724,23 @@ abstract public class GeckoApp
|
|||
layerController.setLayerClient(mSoftwareLayerClient);
|
||||
}
|
||||
|
||||
public class GeckoAppHandler extends Handler {
|
||||
@Override
|
||||
public void handleMessage(Message message) {
|
||||
Bundle bundle = message.getData();
|
||||
if (bundle == null)
|
||||
return;
|
||||
|
||||
int type = bundle.getInt(HANDLER_MSG_TYPE);
|
||||
|
||||
switch (type) {
|
||||
case HANDLER_MSG_TYPE_INITIALIZE:
|
||||
initialize();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PluginLayoutParams extends AbsoluteLayout.LayoutParams
|
||||
|
|
|
@ -21,6 +21,11 @@
|
|||
android:cacheColorHint="#ffffff"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<org.mozilla.gecko.AboutHomeContent android:id="@+id/abouthome_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/abouthome_bg_repeat"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/abouthome_bg_repeat">
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<RelativeLayout android:id="@+id/top_sites"
|
||||
android:layout_width="fill_parent"
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:background="@drawable/address_bar_url_default"
|
||||
android:singleLine="true"
|
||||
android:gravity="center_vertical|left"
|
||||
android:hint="@string/awesomebar_default_text"
|
||||
|
|
|
@ -23,6 +23,11 @@
|
|||
android:cacheColorHint="#ffffff"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<org.mozilla.gecko.AboutHomeContent android:id="@+id/abouthome_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/abouthome_bg_repeat"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Загрузка…
Ссылка в новой задаче