-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): 插件的LayoutInflater改为总是从Context取单例
由于ShadowLayoutInflater不再只是一个转调壳子,有了状态(mOriginalFactory等), 不能再总是new新的对象了。换了新对象就无法还原Factory了。 fixup! c710a18 fix #614
- Loading branch information
Showing
6 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...androidTest/java/com/tencent/shadow/test/cases/plugin_androidx/AppCompatActivityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making Tencent Shadow available. | ||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* 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. | ||
* | ||
*/ | ||
|
||
package com.tencent.shadow.test.cases.plugin_androidx; | ||
|
||
import android.content.Intent; | ||
|
||
import androidx.test.core.app.ApplicationProvider; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
import androidx.test.filters.LargeTest; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class AppCompatActivityTest extends PluginAndroidxAppTest { | ||
|
||
@Override | ||
protected Intent getLaunchIntent() { | ||
Intent pluginIntent = new Intent(); | ||
String packageName = ApplicationProvider.getApplicationContext().getPackageName(); | ||
pluginIntent.setClassName( | ||
packageName, | ||
"com.tencent.shadow.test.plugin.androidx_cases.lib.AppCompatTestActivity" | ||
); | ||
return pluginIntent; | ||
} | ||
|
||
@Test | ||
public void testFactory2Class() { | ||
matchTextWithViewTag("factory2Class", "androidx.appcompat.app.AppCompatDelegateImpl"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...rc/main/java/com/tencent/shadow/test/plugin/androidx_cases/lib/AppCompatTestActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.tencent.shadow.test.plugin.androidx_cases.lib; | ||
|
||
import android.os.Bundle; | ||
import android.view.LayoutInflater; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.annotation.Nullable; | ||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
public class AppCompatTestActivity extends AppCompatActivity { | ||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
LayoutInflater.Factory2 factory2 = getLayoutInflater().getFactory2(); | ||
String factory2Class; | ||
if (factory2 == null) { | ||
factory2Class = "null"; | ||
} else { | ||
factory2Class = factory2.getClass().getName(); | ||
} | ||
|
||
ViewGroup viewGroup = UiUtil.setActivityContentView(this); | ||
ViewGroup item = UiUtil.makeItem( | ||
this, | ||
"factory2Class", | ||
"factory2Class", | ||
factory2Class | ||
); | ||
|
||
viewGroup.addView(item); | ||
} | ||
} |