Commit fb92adad by 宁斌

添加QMUI相關模塊,修改base模塊名稱

parent 8fdd3fee
...@@ -20,7 +20,6 @@ import android.os.Bundle; ...@@ -20,7 +20,6 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.jess.arms.base.delegate.IFragment; import com.jess.arms.base.delegate.IFragment;
import com.jess.arms.integration.cache.Cache; import com.jess.arms.integration.cache.Cache;
import com.jess.arms.integration.cache.CacheType; import com.jess.arms.integration.cache.CacheType;
...@@ -28,9 +27,7 @@ import com.jess.arms.integration.lifecycle.FragmentLifecycleable; ...@@ -28,9 +27,7 @@ import com.jess.arms.integration.lifecycle.FragmentLifecycleable;
import com.jess.arms.mvp.IPresenter; import com.jess.arms.mvp.IPresenter;
import com.jess.arms.utils.ArmsUtils; import com.jess.arms.utils.ArmsUtils;
import com.trello.rxlifecycle2.android.FragmentEvent; import com.trello.rxlifecycle2.android.FragmentEvent;
import javax.inject.Inject; import javax.inject.Inject;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
...@@ -55,6 +52,7 @@ public abstract class BaseFragment<P extends IPresenter> extends Fragment implem ...@@ -55,6 +52,7 @@ public abstract class BaseFragment<P extends IPresenter> extends Fragment implem
@Inject @Inject
@Nullable @Nullable
protected P mPresenter;//如果当前页面逻辑简单, Presenter 可以为 null protected P mPresenter;//如果当前页面逻辑简单, Presenter 可以为 null
private int mBindId = -1;
@NonNull @NonNull
@Override @Override
...@@ -80,6 +78,14 @@ public abstract class BaseFragment<P extends IPresenter> extends Fragment implem ...@@ -80,6 +78,14 @@ public abstract class BaseFragment<P extends IPresenter> extends Fragment implem
mContext = getActivity(); mContext = getActivity();
} }
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
// if(GsaCloudApplication.openSkinMake){
// openSkinMaker();
// }
}
@Nullable @Nullable
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
...@@ -94,6 +100,22 @@ public abstract class BaseFragment<P extends IPresenter> extends Fragment implem ...@@ -94,6 +100,22 @@ public abstract class BaseFragment<P extends IPresenter> extends Fragment implem
return view; return view;
} }
// public void openSkinMaker(){
// if(mBindId < 0){
// mBindId = QMUISkinMaker.getInstance().bind(this);
// }
// }
// public void closeSkinMaker(){
// QMUISkinMaker.getInstance().unBind(mBindId);
// mBindId = -1;
// }
@Override
public void onDestroyView() {
super.onDestroyView();
// closeSkinMaker();
}
@Override @Override
public void onDestroy() { public void onDestroy() {
......
...@@ -2,9 +2,9 @@ package com.gingersoft.gsa.cloud.base.application; ...@@ -2,9 +2,9 @@ package com.gingersoft.gsa.cloud.base.application;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration;
import android.os.Build; import android.os.Build;
import android.os.RemoteException; import android.os.RemoteException;
import com.billy.cc.core.component.CC; import com.billy.cc.core.component.CC;
import com.elvishew.xlog.LogConfiguration; import com.elvishew.xlog.LogConfiguration;
import com.elvishew.xlog.LogLevel; import com.elvishew.xlog.LogLevel;
...@@ -40,9 +40,9 @@ import com.scwang.smartrefresh.layout.api.RefreshHeader; ...@@ -40,9 +40,9 @@ import com.scwang.smartrefresh.layout.api.RefreshHeader;
import com.scwang.smartrefresh.layout.api.RefreshLayout; import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter; import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader; import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import java.util.Locale; import java.util.Locale;
import com.gingersoft.gsa.cloud.base.qmui.manager.QDSkinManager;
import androidx.annotation.NonNull;
import me.jessyan.autosize.AutoSize; import me.jessyan.autosize.AutoSize;
import me.jessyan.autosize.AutoSizeConfig; import me.jessyan.autosize.AutoSizeConfig;
import me.jessyan.autosize.onAdaptListener; import me.jessyan.autosize.onAdaptListener;
...@@ -58,6 +58,9 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -58,6 +58,9 @@ public class GsaCloudApplication extends BaseApplication {
*/ */
private static GsaCloudApplication mAppContext; private static GsaCloudApplication mAppContext;
private Activity mCurrentActivity; private Activity mCurrentActivity;
/**是否開啟皮膚切換*/
public static boolean openSkinMake = false;
/** /**
* 设置请求超时默认15秒钟 * 设置请求超时默认15秒钟
*/ */
...@@ -101,6 +104,8 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -101,6 +104,8 @@ public class GsaCloudApplication extends BaseApplication {
CC.enableVerboseLog(true); CC.enableVerboseLog(true);
CC.enableDebug(true); CC.enableDebug(true);
CC.enableRemoteCC(true); CC.enableRemoteCC(true);
QDSkinManager.install(this);
//初始化上下拉刷新 //初始化上下拉刷新
initRefresh(); initRefresh();
//初始化今日頭條適配方案 //初始化今日頭條適配方案
...@@ -111,7 +116,6 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -111,7 +116,6 @@ public class GsaCloudApplication extends BaseApplication {
initPrint(); initPrint();
//初始化日誌管理庫 //初始化日誌管理庫
initXLog(); initXLog();
initDomainUrl(); initDomainUrl();
//初始化crash記錄 //初始化crash記錄
AppCrashHandler.getInstance().init(this); AppCrashHandler.getInstance().init(this);
...@@ -127,7 +131,6 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -127,7 +131,6 @@ public class GsaCloudApplication extends BaseApplication {
this.mCurrentActivity = mCurrentActivity; this.mCurrentActivity = mCurrentActivity;
} }
private void initRefresh() { private void initRefresh() {
ClassicsHeader.REFRESH_HEADER_PULLING = getString(R.string.srl_header_pulling);//"下拉可以刷新"; ClassicsHeader.REFRESH_HEADER_PULLING = getString(R.string.srl_header_pulling);//"下拉可以刷新";
ClassicsHeader.REFRESH_HEADER_REFRESHING = getString(R.string.srl_header_refreshing);//"正在刷新..."; ClassicsHeader.REFRESH_HEADER_REFRESHING = getString(R.string.srl_header_refreshing);//"正在刷新...";
...@@ -301,8 +304,18 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -301,8 +304,18 @@ public class GsaCloudApplication extends BaseApplication {
} }
private void initGreenDao() { private void initGreenDao() {
DaoManager mManager = DaoManager.getInstance(); DaoManager manager = DaoManager.getInstance();
mManager.init(this); manager.init(this);
}
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if((newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES){
QDSkinManager.changeSkin(QDSkinManager.SKIN_DARK);
}else if(QDSkinManager.getCurrentSkin() == QDSkinManager.SKIN_DARK){
QDSkinManager.changeSkin(QDSkinManager.SKIN_BLUE);
}
} }
@Override @Override
...@@ -310,7 +323,6 @@ public class GsaCloudApplication extends BaseApplication { ...@@ -310,7 +323,6 @@ public class GsaCloudApplication extends BaseApplication {
super.attachBaseContext(base); super.attachBaseContext(base);
} }
/** /**
* 获取系统上下文:用于ToastUtil类 * 获取系统上下文:用于ToastUtil类
*/ */
......
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* 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.gingersoft.gsa.cloud.base.qmui.manager;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
/**
* Created by cgspine on 2018/1/14.
*/
public class QDPreferenceManager {
private static SharedPreferences sPreferences;
private static QDPreferenceManager sQDPreferenceManager = null;
private static final String APP_VERSION_CODE = "app_version_code";
private static final String APP_SKIN_INDEX = "app_skin_index";
private QDPreferenceManager(Context context) {
sPreferences = PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
}
public static final QDPreferenceManager getInstance(Context context) {
if (sQDPreferenceManager == null) {
sQDPreferenceManager = new QDPreferenceManager(context);
}
return sQDPreferenceManager;
}
public void setAppVersionCode(int code) {
final SharedPreferences.Editor editor = sPreferences.edit();
editor.putInt(APP_VERSION_CODE, code);
editor.apply();
}
// public int getVersionCode() {
// return sPreferences.getInt(APP_VERSION_CODE, QDUpgradeManager.INVALIDATE_VERSION_CODE);
// }
public void setSkinIndex(int index) {
SharedPreferences.Editor editor = sPreferences.edit();
editor.putInt(APP_SKIN_INDEX, index);
editor.apply();
}
public int getSkinIndex() {
return sPreferences.getInt(APP_SKIN_INDEX, QDSkinManager.SKIN_BLUE);
}
}
/*
* Tencent is pleased to support the open source community by making QMUI_Android available.
*
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the MIT License (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://opensource.org/licenses/MIT
*
* 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.gingersoft.gsa.cloud.base.qmui.manager;
import android.content.Context;
import android.content.res.Configuration;
import com.gingersoft.gsa.cloud.base.R;
import com.gingersoft.gsa.cloud.base.application.GsaCloudApplication;
import com.qmuiteam.qmui.skin.QMUISkinManager;
public class QDSkinManager {
public static final int SKIN_BLUE = 1;
public static final int SKIN_DARK = 2;
public static final int SKIN_WHITE = 3;
public static void install(Context context) {
QMUISkinManager skinManager = QMUISkinManager.defaultInstance(context);
skinManager.addSkin(SKIN_BLUE, R.style.app_skin_blue);
skinManager.addSkin(SKIN_DARK, R.style.app_skin_dark);
skinManager.addSkin(SKIN_WHITE, R.style.app_skin_white);
boolean isDarkMode = (context.getResources().getConfiguration().uiMode
& Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES;
int storeSkinIndex = QDPreferenceManager.getInstance(context).getSkinIndex();
if (isDarkMode && storeSkinIndex != SKIN_DARK) {
skinManager.changeSkin(SKIN_DARK);
} else if (!isDarkMode && storeSkinIndex == SKIN_DARK) {
skinManager.changeSkin(SKIN_BLUE);
}else{
skinManager.changeSkin(storeSkinIndex);
}
}
public static void changeSkin(int index) {
QMUISkinManager.defaultInstance(GsaCloudApplication.getAppContext()).changeSkin(index);
QDPreferenceManager.getInstance(GsaCloudApplication.getAppContext()).setSkinIndex(index);
}
public static int getCurrentSkin() {
return QMUISkinManager.defaultInstance(GsaCloudApplication.getAppContext()).getCurrentSkin();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment