forked from JessYanCoding/AndroidAutoSize
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
重大更新: 同时兼容 Androidx 和 Support, 框架会根据您项目的依赖情况自动选择对应的 Library
- Loading branch information
1 parent
e2683c0
commit fc595c8
Showing
11 changed files
with
115 additions
and
32 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
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
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
57 changes: 57 additions & 0 deletions
57
autosize/src/main/java/me/jessyan/autosize/FragmentLifecycleCallbacksImplToAndroidx.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,57 @@ | ||
/* | ||
* Copyright 2018 JessYan | ||
* | ||
* 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. | ||
*/ | ||
package me.jessyan.autosize; | ||
|
||
import android.os.Bundle; | ||
import androidx.fragment.app.Fragment; | ||
import androidx.fragment.app.FragmentManager; | ||
|
||
/** | ||
* ================================================ | ||
* {@link FragmentLifecycleCallbacksImplToAndroidx} 可用来代替在 BaseFragment 中加入适配代码的传统方式 | ||
* {@link FragmentLifecycleCallbacksImplToAndroidx} 这种方案类似于 AOP, 面向接口, 侵入性低, 方便统一管理, 扩展性强, 并且也支持适配三方库的 {@link Fragment} | ||
* <p> | ||
* Created by JessYan on 2018/8/25 13:52 | ||
* <a href="mailto:jess.yan.effort@gmail.com">Contact me</a> | ||
* <a href="https://github.com/JessYanCoding">Follow me</a> | ||
* ================================================ | ||
*/ | ||
public class FragmentLifecycleCallbacksImplToAndroidx extends FragmentManager.FragmentLifecycleCallbacks { | ||
/** | ||
* 屏幕适配逻辑策略类 | ||
*/ | ||
private AutoAdaptStrategy mAutoAdaptStrategy; | ||
|
||
public FragmentLifecycleCallbacksImplToAndroidx(AutoAdaptStrategy autoAdaptStrategy) { | ||
mAutoAdaptStrategy = autoAdaptStrategy; | ||
} | ||
|
||
@Override | ||
public void onFragmentCreated(FragmentManager fm, Fragment f, Bundle savedInstanceState) { | ||
if (mAutoAdaptStrategy != null) { | ||
mAutoAdaptStrategy.applyAdapt(f, f.getActivity()); | ||
} | ||
} | ||
|
||
/** | ||
* 设置屏幕适配逻辑策略类 | ||
* | ||
* @param autoAdaptStrategy {@link AutoAdaptStrategy} | ||
*/ | ||
public void setAutoAdaptStrategy(AutoAdaptStrategy autoAdaptStrategy) { | ||
mAutoAdaptStrategy = autoAdaptStrategy; | ||
} | ||
} |
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
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