Commit b004a9e3 authored by 赵鹏翔's avatar 赵鹏翔

换肤开始处理,渠道信息通过本地资源文件进行匹配配置

parent 1e6b3443
[
{
"ChannelId": -1,
"ChannelName": "通用",
"ChannelNameDesc": "common",
"ChannelAccountArray": []
},
{
"ChannelId": 1,
"ChannelName": "匡威",
"ChannelNameDesc": "converse",
"ChannelAccountArray": ["6011","6013","6014","6017","6021"]
}
]
\ No newline at end of file
......@@ -20,6 +20,7 @@ import com.fastcashier.lib_common.util.DateUtils
import com.fastcashier.lib_common.util.LogFileUtils
import com.miya.fastcashier.util.ContextUtils
import com.miya.fastcashier.util.DensityUtils
import com.miya.fastcashier.util.manage.ChannelManageKit
import com.miya.fastcashier.util.manage.LocalKeyDataMKManageKit
import com.miya.print.PrinterManager
import com.sdy.miya.moblie.component.pay.core.net.MiYaPayMobileApiClient
......@@ -203,5 +204,7 @@ class MiyaApplication : BaseApplication() {
OrderRecordManageKit.clearOrderDataYeaterday()
//清除本地个人信息
AccountService.clear()
//清除本地渠道数据信息
ChannelManageKit.clearChannelResData()
}
}
\ No newline at end of file
package com.miya.fastcashier.util.manage;
import android.content.Context;
import android.content.res.AssetManager;
import android.text.TextUtils;
import com.fastcashier.lib_common.function.account.AccountService;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
/**
* 类说明:渠道管理类(用于处理品牌全局设置,以及换肤所需渠道配置)
* 详细描述:目前通过本地资源文件加载 todo 后期能改成接口返回渠道最好
* 创建人:zpxiang
* 创建时间:
* 修改人:
* 修改时间:
*/
public class ChannelManageKit {
private static Map<String, String> channelMap;
private static final long CHANNEL_OFFICIAL_ID = -1;
private static final String CHANNEL_OFFICIAL_NAME = "通用";
/**
* 初始化本地渠道数据
*/
public static void initChannelRes(Context context) {
if (null == context) {
initDefaultChannelRes();
return;
}
String assetsJson = getAssetsJson(context, "channel.json");
if (TextUtils.isEmpty(assetsJson)) {
initDefaultChannelRes();
return;
}
// GsonUtils.fromJson(assetsJson);
}
private static void initDefaultChannelRes() {
}
/**
* 获取渠道名称
*/
public static String getAppChannelName(Context context) {
if (channelMap == null || channelMap.isEmpty()) {
initChannelRes(context);
}
String channelName = channelMap.get(AccountService.INSTANCE.getUserName());
if (TextUtils.isEmpty(channelName)) {
return CHANNEL_OFFICIAL_NAME;
}
return channelName;
}
/**
* 获取App渠道编号
*/
public static long getAppChannelId(Context context) {
if (context == null) {
return CHANNEL_OFFICIAL_ID;
}
if (channelMap == null || channelMap.isEmpty()) {
initChannelRes(context);
}
String channelCode = channelMap.get(getAppChannelName(context));
if (TextUtils.isEmpty(channelCode)) {
return CHANNEL_OFFICIAL_ID;
}
return Long.parseLong(channelCode);
}
public static void clearChannelResData() {
if (null == channelMap) {
return;
}
channelMap.clear();
channelMap = null;
}
/**
* 读取json文件
*
* @param context
* @param fileName
* @return
*/
private static String getAssetsJson(Context context, String fileName) {
StringBuilder stringBuilder = new StringBuilder();
AssetManager assetManager = context.getAssets();
try {
BufferedReader bf = new BufferedReader(new InputStreamReader(assetManager.open(fileName), "UTF-8"));
String line;
while ((line = bf.readLine()) != null) {
stringBuilder.append(line);
}
} catch (IOException e) {
e.printStackTrace();
}
return stringBuilder.toString();
}
}
......@@ -19,7 +19,7 @@ object AccountService {
}
fun getUserName(): String {
return userName.toString();
return userName.toString()
}
fun getAccountPassword(): String {
......
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