version:1.0.1
fix: update:基本跳转对接完成
This commit is contained in:
@@ -23,6 +23,10 @@ import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.hjq.permissions.OnPermissionCallback;
|
||||
import com.hjq.permissions.XXPermissions;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xwad.os.BuildConfig;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.activity.permission.PermissionActivity;
|
||||
@@ -40,16 +44,15 @@ import com.xwad.os.fragment.math.MathFragment;
|
||||
import com.xwad.os.fragment.mine.MineFragment;
|
||||
import com.xwad.os.fragment.read.ReadFragment;
|
||||
import com.xwad.os.fragment.safe.SafeFragment;
|
||||
import com.xwad.os.jxw.JxwPackageConfig;
|
||||
import com.xwad.os.jxw.SPUtils;
|
||||
import com.xwad.os.jxw.StudyRecordAPKInfo;
|
||||
import com.xwad.os.jxw.TabAdapter;
|
||||
import com.xwad.os.jxw.Util;
|
||||
import com.xwad.os.manager.RemoteManager;
|
||||
import com.xwad.os.utils.LenovoCsdkUtil;
|
||||
import com.xwad.os.utils.OpenApkUtils;
|
||||
import com.xwad.os.utils.Utils;
|
||||
import com.xwad.os.view.viewpager.BaseFragmentPagerAdapter;
|
||||
import com.hjq.permissions.OnPermissionCallback;
|
||||
import com.hjq.permissions.XXPermissions;
|
||||
import com.hjq.toast.Toaster;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -497,22 +500,34 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
}
|
||||
|
||||
public void onGoJzx(View view) {
|
||||
// try {
|
||||
// int parseInt = Integer.parseInt(view.getTag().toString().split("\\|")[0]);
|
||||
// String str = view.getTag().toString().split("\\|")[1];
|
||||
// Util.downloadClickListener(this, StudyRecordAPKInfo.PACKAGE_SECOND_LINE_QA, "com.jxw.question.module.ui.activity.ProgramEntryActivity", "string:appoint_subject_name:" + str + "#int:page_navigate:" + parseInt + "#string:appoint_grade_name:" + SPUtils.getGrade() + "#string:appoint_period_name:" + Util.checkGrade(SPUtils.getGrade()), "Ai精准学");
|
||||
// } catch (Exception unused) {
|
||||
// }
|
||||
Log.e(TAG, "onGoJzx: " + view.getTag());
|
||||
try {
|
||||
int parseInt = Integer.parseInt(view.getTag().toString().split("\\|")[0]);
|
||||
String str = view.getTag().toString().split("\\|")[1];
|
||||
Util.downloadClickListener(this, StudyRecordAPKInfo.PACKAGE_SECOND_LINE_QA,
|
||||
JxwPackageConfig.JXW_PRECISION_CLASS_NAME_1,
|
||||
"string:appoint_subject_name:" + str +
|
||||
"#int:page_navigate:" + parseInt +
|
||||
"#string:appoint_grade_name:" + SPUtils.getGrade() +
|
||||
"#string:appoint_period_name:" + Util.checkGrade(SPUtils.getGrade()),
|
||||
"Ai精准学");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onGoJzx: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void onGoSjzx(View view) {
|
||||
// try {
|
||||
// int parseInt = Integer.parseInt(view.getTag().toString().split("\\|")[0]);
|
||||
// String str = view.getTag().toString().split("\\|")[1];
|
||||
// Util.downloadClickListener(this, "com.jxw.sjzx", "com.jxw.sjzx.ui.activity.ExamPagerActivity", "string:subject:" + str + "#int:type:" + parseInt, "试卷中心");
|
||||
// } catch (Exception unused) {
|
||||
//
|
||||
// }
|
||||
Log.e(TAG, "onGoSjzx: " + view.getTag());
|
||||
try {
|
||||
int parseInt = Integer.parseInt(view.getTag().toString().split("\\|")[0]);
|
||||
String str = view.getTag().toString().split("\\|")[1];
|
||||
Util.downloadClickListener(this, "com.jxw.sjzx",
|
||||
"com.jxw.sjzx.ui.activity.ExamPagerActivity",
|
||||
"string:subject:" + str + "#int:type:" + parseInt,
|
||||
"试卷中心");
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "onGoSjzx: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -531,7 +546,7 @@ public class HomeActivity extends BaseMvvmActivity<HomeViewModel, ActivityHomeBi
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int i) {
|
||||
return (Fragment) fragments.get(i);
|
||||
return fragments.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
23
app/src/main/java/com/xwad/os/bean/jxw/BookBean.java
Normal file
23
app/src/main/java/com/xwad/os/bean/jxw/BookBean.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.xwad.os.bean.jxw;
|
||||
|
||||
public class BookBean {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String str) {
|
||||
this.id = str;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String str) {
|
||||
this.name = str;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.xwad.os.bean.jxw;
|
||||
|
||||
public class ItemsBean {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ItemsBean implements Serializable {
|
||||
private String icon;
|
||||
private String learnStage;
|
||||
private String tag;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.xwad.os.bean.jxw;
|
||||
|
||||
public class TabBean {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class TabBean implements Serializable {
|
||||
private String className;
|
||||
private boolean select;
|
||||
private int tab_Color;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.xwad.os.bean.jxw;
|
||||
|
||||
public class TaskBean {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class TaskBean implements Serializable {
|
||||
private String className;
|
||||
private String createTime;
|
||||
private String deviceId;
|
||||
|
||||
44
app/src/main/java/com/xwad/os/bean/jxw/TbddBookBean.java
Normal file
44
app/src/main/java/com/xwad/os/bean/jxw/TbddBookBean.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.xwad.os.bean.jxw;
|
||||
|
||||
public class TbddBookBean {
|
||||
private String bookName;
|
||||
private String coverUrl;
|
||||
private String isbn;
|
||||
private String publisher;
|
||||
|
||||
public String getIsbn() {
|
||||
return this.isbn;
|
||||
}
|
||||
|
||||
public void setIsbn(String str) {
|
||||
this.isbn = str;
|
||||
}
|
||||
|
||||
public String getBookName() {
|
||||
return this.bookName;
|
||||
}
|
||||
|
||||
public void setBookName(String str) {
|
||||
this.bookName = str;
|
||||
}
|
||||
|
||||
public String getPublisher() {
|
||||
return this.publisher;
|
||||
}
|
||||
|
||||
public void setPublisher(String str) {
|
||||
this.publisher = str;
|
||||
}
|
||||
|
||||
public String getCoverUrl() {
|
||||
return this.coverUrl;
|
||||
}
|
||||
|
||||
public void setCoverUrl(String str) {
|
||||
this.coverUrl = str;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "TbddBookBean{isbn='" + this.isbn + "', bookName='" + this.bookName + "', publisher='" + this.publisher + "', coverUrl='" + this.coverUrl + "'}";
|
||||
}
|
||||
}
|
||||
22
app/src/main/java/com/xwad/os/bean/jxw/YdbgBean.java
Normal file
22
app/src/main/java/com/xwad/os/bean/jxw/YdbgBean.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package com.xwad.os.bean.jxw;
|
||||
|
||||
public class YdbgBean {
|
||||
String date;
|
||||
int readTime;
|
||||
|
||||
public String getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public void setDate(String str) {
|
||||
this.date = str;
|
||||
}
|
||||
|
||||
public int getReadTime() {
|
||||
return this.readTime;
|
||||
}
|
||||
|
||||
public void setReadTime(int i) {
|
||||
this.readTime = i;
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,12 @@ import android.widget.RelativeLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.base.mvvm.fragment.BaseMvvmFragment;
|
||||
import com.xwad.os.config.CommonConfig;
|
||||
import com.xwad.os.databinding.FragmentAiBinding;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xwad.os.jxw.Util;
|
||||
import com.youth.banner.adapter.BannerAdapter;
|
||||
import com.youth.banner.listener.OnBannerListener;
|
||||
import com.youth.banner.transformer.ZoomOutPageTransformer;
|
||||
@@ -84,22 +85,13 @@ public class AiFragment extends BaseMvvmFragment<AiViewModel, FragmentAiBinding>
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
|
||||
mViewDataBinding.banner.setOnBannerListener(new OnBannerListener<String>() {
|
||||
@Override
|
||||
public void OnBannerClick(String s, int i) {
|
||||
if (i == 2) {
|
||||
// Util.downloadClickListener(getActivity(), "com.jxw.aikyls", "com.jxw.aiteacher.ui.SplashActivity", null, "ai口语老师");
|
||||
} else if (i == 3) {
|
||||
// Util.downloadClickListener(getActivity(), "com.jxw.aixhb", "com.jxw.aixhb.mvi.ui.activity.MainActivity", null, "AI小伙伴");
|
||||
}
|
||||
}
|
||||
});
|
||||
List<String> arrayList = new ArrayList<String>() {{
|
||||
this.add("1");
|
||||
this.add("1");
|
||||
this.add("1");
|
||||
this.add("1");
|
||||
}};
|
||||
|
||||
List<String> arrayList = new ArrayList<>();
|
||||
arrayList.add("1");
|
||||
arrayList.add("1");
|
||||
arrayList.add("1");
|
||||
arrayList.add("1");
|
||||
mViewDataBinding.banner.addBannerLifecycleObserver(this)
|
||||
.setAdapter(new BannerExampleAdapter(arrayList))
|
||||
.setIndicator(mViewDataBinding.indicator, false)
|
||||
@@ -112,8 +104,20 @@ public class AiFragment extends BaseMvvmFragment<AiViewModel, FragmentAiBinding>
|
||||
.setPageTransformer(new ZoomOutPageTransformer())
|
||||
.isAutoLoop(false)
|
||||
.setBannerGalleryEffect((int) getResources().getDimension(R.dimen.x30), (int) getResources().getDimension(R.dimen.x30));
|
||||
|
||||
mViewDataBinding.banner.setOnBannerListener(new OnBannerListener<String>() {
|
||||
@Override
|
||||
public void OnBannerClick(String s, int position) {
|
||||
if (position == 2) {
|
||||
Util.downloadClickListener(getActivity(), "com.jxw.aikyls", "com.jxw.aiteacher.ui.SplashActivity", null, "ai口语老师");
|
||||
} else if (position == 3) {
|
||||
Util.downloadClickListener(getActivity(), "com.jxw.aixhb", "com.jxw.aixhb.mvi.ui.activity.MainActivity", null, "AI小伙伴");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initData(Bundle savedInstanceState) {
|
||||
|
||||
@@ -144,9 +148,7 @@ public class AiFragment extends BaseMvvmFragment<AiViewModel, FragmentAiBinding>
|
||||
|
||||
|
||||
public class BtnClick {
|
||||
public void openPrecisionHome(View view) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class BannerExampleAdapter extends BannerAdapter<String, BannerExampleAdapter.ImageTitleHolder> {
|
||||
@@ -186,23 +188,23 @@ public class AiFragment extends BaseMvvmFragment<AiViewModel, FragmentAiBinding>
|
||||
}
|
||||
|
||||
public class ImageTitleHolder extends RecyclerView.ViewHolder {
|
||||
public ImageView aijzx;
|
||||
public ImageView fdzy;
|
||||
public ImageView pgkst;
|
||||
public ImageView pgzy;
|
||||
public ImageView pzst;
|
||||
public RelativeLayout rl_root;
|
||||
public ImageView ykyl;
|
||||
RelativeLayout rl_root;
|
||||
ImageView aijzx;
|
||||
ImageView fdzy;
|
||||
ImageView pgkst;
|
||||
ImageView pgzy;
|
||||
ImageView pzst;
|
||||
ImageView ykyl;
|
||||
|
||||
public ImageTitleHolder(View view) {
|
||||
super(view);
|
||||
this.rl_root = view.findViewById(R.id.rl_root);
|
||||
this.fdzy = view.findViewById(R.id.fdzy);
|
||||
this.pgkst = view.findViewById(R.id.pgkst);
|
||||
this.pgzy = view.findViewById(R.id.pgzy);
|
||||
this.ykyl = view.findViewById(R.id.ykyl);
|
||||
this.aijzx = view.findViewById(R.id.aijzx);
|
||||
this.pzst = view.findViewById(R.id.pzst);
|
||||
rl_root = view.findViewById(R.id.rl_root);
|
||||
fdzy = view.findViewById(R.id.fdzy);
|
||||
pgkst = view.findViewById(R.id.pgkst);
|
||||
pgzy = view.findViewById(R.id.pgzy);
|
||||
ykyl = view.findViewById(R.id.ykyl);
|
||||
aijzx = view.findViewById(R.id.aijzx);
|
||||
pzst = view.findViewById(R.id.pzst);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,17 +3,41 @@ package com.xwad.os.fragment.chinese;
|
||||
import android.app.Activity;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.blankj.utilcode.util.NetworkUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.base.mvvm.fragment.BaseMvvmFragment;
|
||||
import com.xwad.os.bean.jxw.ItemsBean;
|
||||
import com.xwad.os.databinding.FragmentChineseBinding;
|
||||
import com.xwad.os.jxw.AssertUtils;
|
||||
import com.xwad.os.jxw.SPUtils;
|
||||
import com.xwad.os.jxw.Util;
|
||||
import com.xwad.os.manager.AmapManager;
|
||||
import com.xwad.os.utils.OpenApkUtils;
|
||||
import com.xwad.os.view.jxw.widget.AppsDialog;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
@@ -22,8 +46,32 @@ import com.xwad.os.manager.AmapManager;
|
||||
*/
|
||||
public class ChineseFragment extends BaseMvvmFragment<ChineseViewModel, FragmentChineseBinding> implements NetworkUtils.OnNetworkStatusChangedListener {
|
||||
private static final String TAG = "ChineseFragment";
|
||||
private static final String FILE_NAME = "app_list_yw";
|
||||
private static final String type = "yw";
|
||||
|
||||
|
||||
private Activity mContext;
|
||||
private List<ItemsBean> appList = new ArrayList();
|
||||
private BaseQuickAdapter<ItemsBean, BaseViewHolder> contentAdapter = new BaseQuickAdapter<ItemsBean, BaseViewHolder>(R.layout.item_yw_app) {
|
||||
@Override
|
||||
public void convert(BaseViewHolder baseViewHolder, final ItemsBean itemsBean) {
|
||||
RelativeLayout relativeLayout = baseViewHolder.getView(R.id.rl_root);
|
||||
ImageView iv_app_icon = baseViewHolder.getView(R.id.iv_app_icon);
|
||||
TextView tv_app_name = baseViewHolder.getView(R.id.tv_app_name);
|
||||
iv_app_icon.setImageResource(mContext.getResources().getIdentifier(itemsBean.getIcon(), "drawable", mContext.getPackageName()));
|
||||
tv_app_name.setText(itemsBean.getText());
|
||||
relativeLayout.setTag(mContext.getResources().getString(mContext.getResources().getIdentifier(itemsBean.getTag(), "string", mContext.getPackageName())));
|
||||
relativeLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.isEmpty(itemsBean.getTag())) {
|
||||
return;
|
||||
}
|
||||
jumpTag(itemsBean, view);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
@@ -125,11 +173,17 @@ public class ChineseFragment extends BaseMvvmFragment<ChineseViewModel, Fragment
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData(Bundle savedInstanceState) {
|
||||
setTag(mViewDataBinding.ivZxts);
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||
mViewDataBinding.rvApps.setLayoutManager(linearLayoutManager);
|
||||
mViewDataBinding.rvApps.setAdapter(contentAdapter);
|
||||
getMyList();
|
||||
contentAdapter.setNewData(appList);
|
||||
|
||||
}
|
||||
|
||||
@@ -169,6 +223,19 @@ public class ChineseFragment extends BaseMvvmFragment<ChineseViewModel, Fragment
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void setTag(View view) {
|
||||
String str;
|
||||
String checkGrade = Util.checkGrade(SPUtils.getGrade());
|
||||
if (checkGrade.equals("小学")) {
|
||||
str = "tag_args_new_ztsp_xxyw";
|
||||
} else {
|
||||
str = checkGrade.equals("初中") ? "tag_args_new_ztsp_czyw" : "tag_args_new_ztsp_gzyw";
|
||||
}
|
||||
if (getActivity() != null) {
|
||||
view.setTag(getResources().getString(getResources().getIdentifier(str, "string", getActivity().getPackageName())));
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
mViewDataBinding.llTbjzx.setVisibility(View.GONE);
|
||||
mViewDataBinding.llDyfx.setVisibility(View.GONE);
|
||||
@@ -181,10 +248,92 @@ public class ChineseFragment extends BaseMvvmFragment<ChineseViewModel, Fragment
|
||||
mViewDataBinding.ivTabJdbk.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
public void getMyList() {
|
||||
File fileStreamPath = mContext.getFileStreamPath(FILE_NAME);
|
||||
if (fileStreamPath.exists()) {
|
||||
try {
|
||||
appList.clear();
|
||||
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileStreamPath));
|
||||
while (true) {
|
||||
String readLine = bufferedReader.readLine();
|
||||
if (readLine == null) {
|
||||
break;
|
||||
}
|
||||
ItemsBean itemsBean = new ItemsBean();
|
||||
itemsBean.setText(readLine.split("\\|")[0]);
|
||||
itemsBean.setIcon(readLine.split("\\|")[1]);
|
||||
itemsBean.setTag(readLine.split("\\|")[2]);
|
||||
appList.add(itemsBean);
|
||||
}
|
||||
bufferedReader.close();
|
||||
if (appList == null || appList.size() != 0) {
|
||||
return;
|
||||
}
|
||||
appList.addAll(getApps());
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
appList.addAll(getApps());
|
||||
}
|
||||
|
||||
private List<ItemsBean> getApps() {
|
||||
Gson gson = new Gson();
|
||||
String jsonString = AssertUtils.getFromAssets(mContext, "script/yw_default_app.json");
|
||||
Type type = new TypeToken<List<ItemsBean>>() {
|
||||
}.getType();
|
||||
List<ItemsBean> itemsBeans = gson.fromJson(jsonString, type);
|
||||
return itemsBeans;
|
||||
}
|
||||
|
||||
public void jumpTag(ItemsBean itemsBean, View view) {
|
||||
String obj = view.getTag().toString();
|
||||
saveTag(itemsBean);
|
||||
contentAdapter.notifyDataSetChanged();
|
||||
// MyApp.getInstance().mBottomBtnOnClickListener.setContext(getActivity());
|
||||
// MyApp.getInstance().mBottomBtnOnClickListener.onClick(obj);
|
||||
OpenApkUtils.getInstance().openJxwApp(obj);
|
||||
}
|
||||
|
||||
private void saveTag(ItemsBean itemsBean) {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (i >= appList.size()) {
|
||||
break;
|
||||
} else if (appList.get(i).getTag().equals(itemsBean.getTag())) {
|
||||
appList.remove(i);
|
||||
break;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
appList.add(0, itemsBean);
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(mContext.getFileStreamPath(FILE_NAME), false);
|
||||
for (int i2 = 0; i2 < appList.size() && i2 <= 2; i2++) {
|
||||
fileOutputStream.write((appList.get(i2).getText() + "|" + appList.get(i2).getIcon() + "|" + appList.get(i2).getTag() + "\n").getBytes());
|
||||
}
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
public void x(View view) {
|
||||
public void openAppsDialog(View view) {
|
||||
AppsDialog appsDialog = new AppsDialog(getActivity(), type);
|
||||
appsDialog.show();
|
||||
appsDialog.setOnCallback(new AppsDialog.Callback() {
|
||||
|
||||
@Override
|
||||
public void onCallback() {
|
||||
getMyList();
|
||||
contentAdapter.setNewData(appList);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,41 @@ package com.xwad.os.fragment.english;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.base.mvvm.fragment.BaseMvvmFragment;
|
||||
import com.xwad.os.bean.jxw.ItemsBean;
|
||||
import com.xwad.os.bean.jxw.TbddBookBean;
|
||||
import com.xwad.os.databinding.FragmentEnglishBinding;
|
||||
import com.xwad.os.jxw.AssertUtils;
|
||||
import com.xwad.os.jxw.SPUtils;
|
||||
import com.xwad.os.jxw.TbddProviderUtil;
|
||||
import com.xwad.os.jxw.Util;
|
||||
import com.xwad.os.utils.OpenApkUtils;
|
||||
import com.xwad.os.view.jxw.widget.AppsDialog;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
@@ -18,8 +45,31 @@ import com.xwad.os.databinding.FragmentEnglishBinding;
|
||||
*/
|
||||
public class EnglishFragment extends BaseMvvmFragment<EnglishViewModel, FragmentEnglishBinding> {
|
||||
private static final String TAG = "EnglishFragment";
|
||||
private static final String FILE_NAME = "app_list_yy";
|
||||
private static final String type = "yy";
|
||||
|
||||
private Activity mContext;
|
||||
private List<ItemsBean> appList = new ArrayList();
|
||||
private BaseQuickAdapter<ItemsBean, BaseViewHolder> contentAdapter = new BaseQuickAdapter<ItemsBean, BaseViewHolder>(R.layout.item_yw_app) {
|
||||
@Override
|
||||
public void convert(BaseViewHolder baseViewHolder, final ItemsBean itemsBean) {
|
||||
RelativeLayout relativeLayout = baseViewHolder.getView(R.id.rl_root);
|
||||
ImageView iv_app_icon = baseViewHolder.getView(R.id.iv_app_icon);
|
||||
TextView tv_app_name = baseViewHolder.getView(R.id.tv_app_name);
|
||||
iv_app_icon.setImageResource(mContext.getResources().getIdentifier(itemsBean.getIcon(), "drawable", mContext.getPackageName()));
|
||||
tv_app_name.setText(itemsBean.getText());
|
||||
relativeLayout.setTag(mContext.getResources().getString(mContext.getResources().getIdentifier(itemsBean.getTag(), "string", mContext.getPackageName())));
|
||||
relativeLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.isEmpty(itemsBean.getTag())) {
|
||||
return;
|
||||
}
|
||||
jumpTag(itemsBean, view);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
@@ -114,12 +164,21 @@ public class EnglishFragment extends BaseMvvmFragment<EnglishViewModel, Fragment
|
||||
|
||||
@Override
|
||||
protected void initData(Bundle savedInstanceState) {
|
||||
setTag(mViewDataBinding.ivZxts);
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||
mViewDataBinding.rvApps.setLayoutManager(linearLayoutManager);
|
||||
mViewDataBinding.rvApps.setAdapter(contentAdapter);
|
||||
getMyList();
|
||||
contentAdapter.setNewData(appList);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fetchData() {
|
||||
Log.e(TAG, "fetchData: ");
|
||||
Log.e("zsj", "lazyLoad");
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -127,6 +186,20 @@ public class EnglishFragment extends BaseMvvmFragment<EnglishViewModel, Fragment
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
|
||||
private void setTag(View view) {
|
||||
String str;
|
||||
String checkGrade = Util.checkGrade(SPUtils.getGrade());
|
||||
if (checkGrade.equals("小学")) {
|
||||
str = "tag_args_new_ztsp_xxyy";
|
||||
} else {
|
||||
str = checkGrade.equals("初中") ? "tag_args_new_ztsp_czyy" : "tag_args_new_ztsp_gzyy";
|
||||
}
|
||||
if (getActivity() != null) {
|
||||
view.setTag(getResources().getString(getResources().getIdentifier(str, "string", getActivity().getPackageName())));
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
mViewDataBinding.llTbjzx.setVisibility(View.GONE);
|
||||
mViewDataBinding.llDyfx.setVisibility(View.GONE);
|
||||
@@ -139,5 +212,107 @@ public class EnglishFragment extends BaseMvvmFragment<EnglishViewModel, Fragment
|
||||
mViewDataBinding.ivTabJdbk.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
private void load() {
|
||||
TbddBookBean tbddData = TbddProviderUtil.getTbddData("英语", "", "");
|
||||
try {
|
||||
if (tbddData != null) {
|
||||
mViewDataBinding.ivZb.setVisibility(View.VISIBLE);
|
||||
Glide.with(mContext).load(tbddData.getCoverUrl()).into(mViewDataBinding.ivCover);
|
||||
} else {
|
||||
mViewDataBinding.ivZb.setVisibility(View.GONE);
|
||||
mViewDataBinding.ivCover.setBackgroundResource(R.drawable.icon_yw_tjsb);
|
||||
}
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
}
|
||||
|
||||
public void getMyList() {
|
||||
File fileStreamPath = mContext.getFileStreamPath(FILE_NAME);
|
||||
if (fileStreamPath.exists()) {
|
||||
try {
|
||||
appList.clear();
|
||||
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileStreamPath));
|
||||
while (true) {
|
||||
String readLine = bufferedReader.readLine();
|
||||
if (readLine == null) {
|
||||
break;
|
||||
}
|
||||
ItemsBean itemsBean = new ItemsBean();
|
||||
itemsBean.setText(readLine.split("\\|")[0]);
|
||||
itemsBean.setIcon(readLine.split("\\|")[1]);
|
||||
itemsBean.setTag(readLine.split("\\|")[2]);
|
||||
appList.add(itemsBean);
|
||||
}
|
||||
bufferedReader.close();
|
||||
if (appList == null || appList.size() != 0) {
|
||||
return;
|
||||
}
|
||||
appList.addAll(getApps());
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
appList.addAll(getApps());
|
||||
}
|
||||
|
||||
private List<ItemsBean> getApps() {
|
||||
Gson gson = new Gson();
|
||||
String jsonString = AssertUtils.getFromAssets(mContext, "script/yy_default_app.json");
|
||||
Type type = new TypeToken<List<ItemsBean>>() {
|
||||
}.getType();
|
||||
List<ItemsBean> itemsBeans = gson.fromJson(jsonString, type);
|
||||
return itemsBeans;
|
||||
}
|
||||
|
||||
public void jumpTag(ItemsBean itemsBean, View view) {
|
||||
String obj = view.getTag().toString();
|
||||
saveTag(itemsBean);
|
||||
contentAdapter.notifyDataSetChanged();
|
||||
// MyApp.getInstance().mBottomBtnOnClickListener.setContext(getActivity());
|
||||
// MyApp.getInstance().mBottomBtnOnClickListener.onClick(obj);
|
||||
OpenApkUtils.getInstance().openJxwApp(obj);
|
||||
}
|
||||
|
||||
private void saveTag(ItemsBean itemsBean) {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (i >= appList.size()) {
|
||||
break;
|
||||
} else if (appList.get(i).getTag().equals(itemsBean.getTag())) {
|
||||
appList.remove(i);
|
||||
break;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
appList.add(0, itemsBean);
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(mContext.getFileStreamPath(FILE_NAME), false);
|
||||
for (int i2 = 0; i2 < appList.size() && i2 <= 2; i2++) {
|
||||
fileOutputStream.write((appList.get(i2).getText() + "|" + appList.get(i2).getIcon() + "|" + appList.get(i2).getTag() + "\n").getBytes());
|
||||
}
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
public void openAppsDialog(View view) {
|
||||
AppsDialog appsDialog = new AppsDialog(getActivity(), type);
|
||||
appsDialog.show();
|
||||
appsDialog.setOnCallback(new AppsDialog.Callback() {
|
||||
|
||||
@Override
|
||||
public void onCallback() {
|
||||
getMyList();
|
||||
contentAdapter.setNewData(appList);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,14 +2,38 @@ package com.xwad.os.fragment.math;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.base.mvvm.fragment.BaseMvvmFragment;
|
||||
import com.xwad.os.bean.jxw.ItemsBean;
|
||||
import com.xwad.os.databinding.FragmentMathBinding;
|
||||
import com.xwad.os.jxw.AssertUtils;
|
||||
import com.xwad.os.jxw.SPUtils;
|
||||
import com.xwad.os.jxw.Util;
|
||||
import com.xwad.os.utils.OpenApkUtils;
|
||||
import com.xwad.os.view.jxw.widget.AppsDialog;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
@@ -18,8 +42,31 @@ import com.xwad.os.databinding.FragmentMathBinding;
|
||||
*/
|
||||
public class MathFragment extends BaseMvvmFragment<MathViewModel, FragmentMathBinding> {
|
||||
private static final String TAG = "MathFragment";
|
||||
private static final String FILE_NAME = "app_list_sx";
|
||||
private static final String type = "sx";
|
||||
|
||||
private Activity mContext;
|
||||
private List<ItemsBean> appList = new ArrayList();
|
||||
private BaseQuickAdapter<ItemsBean, BaseViewHolder> contentAdapter = new BaseQuickAdapter<ItemsBean, BaseViewHolder>(R.layout.item_yw_app) {
|
||||
@Override
|
||||
public void convert(BaseViewHolder baseViewHolder, final ItemsBean itemsBean) {
|
||||
RelativeLayout relativeLayout = baseViewHolder.getView(R.id.rl_root);
|
||||
ImageView iv_app_icon = baseViewHolder.getView(R.id.iv_app_icon);
|
||||
TextView tv_app_name = baseViewHolder.getView(R.id.tv_app_name);
|
||||
iv_app_icon.setImageResource(mContext.getResources().getIdentifier(itemsBean.getIcon(), "drawable", mContext.getPackageName()));
|
||||
tv_app_name.setText(itemsBean.getText());
|
||||
relativeLayout.setTag(mContext.getResources().getString(mContext.getResources().getIdentifier(itemsBean.getTag(), "string", mContext.getPackageName())));
|
||||
relativeLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.isEmpty(itemsBean.getTag())) {
|
||||
return;
|
||||
}
|
||||
jumpTag(itemsBean, view);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
@@ -75,7 +122,7 @@ public class MathFragment extends BaseMvvmFragment<MathViewModel, FragmentMathBi
|
||||
mViewModel.setCtx(getCtx());
|
||||
mViewModel.setLifecycle(getLifecycleSubject());
|
||||
mViewModel.setVDBinding(mViewDataBinding);
|
||||
// mViewDataBinding.setClick(new BtnClick());
|
||||
mViewDataBinding.setClick(new BtnClick());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,6 +162,13 @@ public class MathFragment extends BaseMvvmFragment<MathViewModel, FragmentMathBi
|
||||
|
||||
@Override
|
||||
protected void initData(Bundle savedInstanceState) {
|
||||
setTag(mViewDataBinding.ivZxts);
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||
mViewDataBinding.rvApps.setLayoutManager(linearLayoutManager);
|
||||
mViewDataBinding.rvApps.setAdapter(contentAdapter);
|
||||
getMyList();
|
||||
contentAdapter.setNewData(appList);
|
||||
|
||||
}
|
||||
|
||||
@@ -128,6 +182,19 @@ public class MathFragment extends BaseMvvmFragment<MathViewModel, FragmentMathBi
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
private void setTag(View view) {
|
||||
String str;
|
||||
String checkGrade = Util.checkGrade(SPUtils.getGrade());
|
||||
if (checkGrade.equals("小学")) {
|
||||
str = "tag_args_new_ztsp_xxsx";
|
||||
} else {
|
||||
str = checkGrade.equals("初中") ? "tag_args_new_ztsp_czsx" : "tag_args_new_ztsp_gzsx";
|
||||
}
|
||||
if (getActivity() != null) {
|
||||
view.setTag(getResources().getString(getResources().getIdentifier(str, "string", getActivity().getPackageName())));
|
||||
}
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
mViewDataBinding.llTbjzx.setVisibility(View.GONE);
|
||||
mViewDataBinding.llDyfx.setVisibility(View.GONE);
|
||||
@@ -140,5 +207,94 @@ public class MathFragment extends BaseMvvmFragment<MathViewModel, FragmentMathBi
|
||||
mViewDataBinding.ivTabJdbk.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
public void getMyList() {
|
||||
File fileStreamPath = mContext.getFileStreamPath(FILE_NAME);
|
||||
if (fileStreamPath.exists()) {
|
||||
try {
|
||||
appList.clear();
|
||||
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileStreamPath));
|
||||
while (true) {
|
||||
String readLine = bufferedReader.readLine();
|
||||
if (readLine == null) {
|
||||
break;
|
||||
}
|
||||
ItemsBean itemsBean = new ItemsBean();
|
||||
itemsBean.setText(readLine.split("\\|")[0]);
|
||||
itemsBean.setIcon(readLine.split("\\|")[1]);
|
||||
itemsBean.setTag(readLine.split("\\|")[2]);
|
||||
appList.add(itemsBean);
|
||||
}
|
||||
bufferedReader.close();
|
||||
if (appList == null || appList.size() != 0) {
|
||||
return;
|
||||
}
|
||||
appList.addAll(getApps());
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
appList.addAll(getApps());
|
||||
}
|
||||
|
||||
private List<ItemsBean> getApps() {
|
||||
Gson gson = new Gson();
|
||||
String jsonString = AssertUtils.getFromAssets(mContext, "script/sx_default_app.json");
|
||||
Type type = new TypeToken<List<ItemsBean>>() {
|
||||
}.getType();
|
||||
List<ItemsBean> itemsBeans = gson.fromJson(jsonString, type);
|
||||
return itemsBeans;
|
||||
}
|
||||
|
||||
public void jumpTag(ItemsBean itemsBean, View view) {
|
||||
String obj = view.getTag().toString();
|
||||
saveTag(itemsBean);
|
||||
contentAdapter.notifyDataSetChanged();
|
||||
// MyApp.getInstance().mBottomBtnOnClickListener.setContext(getActivity());
|
||||
// MyApp.getInstance().mBottomBtnOnClickListener.onClick(obj);
|
||||
OpenApkUtils.getInstance().openJxwApp(obj);
|
||||
}
|
||||
|
||||
private void saveTag(ItemsBean itemsBean) {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (i >= appList.size()) {
|
||||
break;
|
||||
} else if (appList.get(i).getTag().equals(itemsBean.getTag())) {
|
||||
appList.remove(i);
|
||||
break;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
appList.add(0, itemsBean);
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(mContext.getFileStreamPath(FILE_NAME), false);
|
||||
for (int i2 = 0; i2 < appList.size() && i2 <= 2; i2++) {
|
||||
fileOutputStream.write((appList.get(i2).getText() + "|" + appList.get(i2).getIcon() + "|" + appList.get(i2).getTag() + "\n").getBytes());
|
||||
}
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class BtnClick {
|
||||
public void openAppsDialog(View view) {
|
||||
AppsDialog appsDialog = new AppsDialog(getActivity(), type);
|
||||
appsDialog.show();
|
||||
appsDialog.setOnCallback(new AppsDialog.Callback() {
|
||||
|
||||
@Override
|
||||
public void onCallback() {
|
||||
getMyList();
|
||||
contentAdapter.setNewData(appList);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,14 +3,31 @@ package com.xwad.os.fragment.read;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.base.mvvm.fragment.BaseMvvmFragment;
|
||||
import com.xwad.os.bean.jxw.YdbgBean;
|
||||
import com.xwad.os.config.CommonConfig;
|
||||
import com.xwad.os.databinding.FragmentReadBinding;
|
||||
import com.tencent.mmkv.MMKV;
|
||||
import com.xwad.os.jxw.fragment.BookFragment;
|
||||
import com.xwad.os.jxw.fragment.BookListFragment;
|
||||
import com.xwad.os.view.jxw.view.VerticalProgressBar;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
@@ -22,6 +39,12 @@ public class ReadFragment extends BaseMvvmFragment<ReadViewModel, FragmentReadBi
|
||||
|
||||
private MMKV mMMKV = MMKV.mmkvWithID(CommonConfig.MMKV_ID, MMKV.MULTI_PROCESS_MODE);
|
||||
|
||||
private MyAdapter adapter;
|
||||
private List<Fragment> mFragment = new ArrayList();
|
||||
int progressBarMax = 0;
|
||||
private List<YdbgBean> ydbgBeanLists;
|
||||
|
||||
|
||||
// TODO: Rename parameter arguments, choose names that match
|
||||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
|
||||
private static final String ARG_PARAM1 = "param1";
|
||||
@@ -72,6 +95,37 @@ public class ReadFragment extends BaseMvvmFragment<ReadViewModel, FragmentReadBi
|
||||
mParam1 = getArguments().getString(ARG_PARAM1);
|
||||
mParam2 = getArguments().getString(ARG_PARAM2);
|
||||
}
|
||||
mViewDataBinding.subjectViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int i) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int i, float f, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int i) {
|
||||
if (i == 0) {
|
||||
mViewDataBinding.tvTitle.setText("最近阅读");
|
||||
} else {
|
||||
mViewDataBinding.tvTitle.setText("我的书架");
|
||||
}
|
||||
mViewDataBinding.indicator.setCurrentPosition(i);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mFragment.add(new BookFragment());
|
||||
mFragment.add(new BookListFragment());
|
||||
adapter = new MyAdapter(getChildFragmentManager());
|
||||
mViewDataBinding.subjectViewPager.setAdapter(adapter);
|
||||
mViewDataBinding.indicator.setCellCount(2);
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
|
||||
mViewDataBinding.rvChart.setLayoutManager(linearLayoutManager);
|
||||
getydbg();
|
||||
|
||||
}
|
||||
|
||||
@@ -88,7 +142,7 @@ public class ReadFragment extends BaseMvvmFragment<ReadViewModel, FragmentReadBi
|
||||
|
||||
@Override
|
||||
public void fetchData() {
|
||||
|
||||
getydbg();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -103,10 +157,119 @@ public class ReadFragment extends BaseMvvmFragment<ReadViewModel, FragmentReadBi
|
||||
|
||||
}
|
||||
|
||||
private void getydbg() {
|
||||
// try {
|
||||
// JSONObject jSONObject = new JSONObject();
|
||||
// jSONObject.put("oprateType", 1);
|
||||
// OkhtttpUtils.getInstance().doPost(getActivity(), Constant.GW_URL + "/report/api/report/learn/libraryDetail", jSONObject, true, new OkhtttpUtils.OkCallback() {
|
||||
// @Override
|
||||
// public void onFailure(Exception exc) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onResponse(String str) {
|
||||
// try {
|
||||
// JSONObject jSONObject2 = new JSONObject(str);
|
||||
// if ("0".equals(jSONObject2.getString("code"))) {
|
||||
// JSONObject jSONObject3 = new JSONObject(jSONObject2.optString("data"));
|
||||
// Type type = new TypeToken<Collection<YdbgBean>>() {
|
||||
// }.getType();
|
||||
// ydbgBeanLists = (List) new Gson().fromJson(jSONObject3.optString("detailList"), type);
|
||||
// initBarChart();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.getMessage();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// } catch (Exception unused) {
|
||||
// }
|
||||
}
|
||||
|
||||
public void initBarChart() {
|
||||
mViewDataBinding.rlNodata.setVisibility(8);
|
||||
mViewDataBinding.rvChart.setVisibility(0);
|
||||
int readTime = (ydbgBeanLists.get(0).getReadTime() / 1000) / 60;
|
||||
for (int i = 1; i < ydbgBeanLists.size(); i++) {
|
||||
if ((ydbgBeanLists.get(i).getReadTime() / 1000) / 60 > readTime) {
|
||||
readTime = (ydbgBeanLists.get(i).getReadTime() / 1000) / 60;
|
||||
}
|
||||
}
|
||||
if (readTime <= 10) {
|
||||
progressBarMax = 10;
|
||||
} else if (readTime <= 100) {
|
||||
progressBarMax = 100;
|
||||
} else if (readTime <= 300) {
|
||||
progressBarMax = 300;
|
||||
} else if (readTime <= 500) {
|
||||
progressBarMax = 500;
|
||||
} else if (readTime <= 700) {
|
||||
progressBarMax = 700;
|
||||
} else if (readTime <= 1000) {
|
||||
progressBarMax = 1000;
|
||||
} else if (readTime <= 1440) {
|
||||
progressBarMax = 1440;
|
||||
}
|
||||
mViewDataBinding.rvChart.setAdapter(new ChartAdapter(ydbgBeanLists));
|
||||
}
|
||||
|
||||
|
||||
class MyAdapter extends FragmentPagerAdapter {
|
||||
public MyAdapter(FragmentManager fragmentManager) {
|
||||
super(fragmentManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int i) {
|
||||
return mFragment.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mFragment.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return mFragment.get(i).hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public class ChartAdapter extends BaseQuickAdapter<YdbgBean, BaseViewHolder> {
|
||||
public ChartAdapter(List<YdbgBean> list) {
|
||||
super(R.layout.item_chart, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void convert(BaseViewHolder baseViewHolder, YdbgBean ydbgBean) {
|
||||
VerticalProgressBar verticalProgressBar = baseViewHolder.getView(R.id.battery_pb);
|
||||
verticalProgressBar.setMaxProgress(progressBarMax);
|
||||
verticalProgressBar.setProgress((ydbgBean.getReadTime() / 1000) / 60);
|
||||
String hexWithAlpha = String.format("#%08X", -11485776);
|
||||
Log.e(TAG, "convert: " + hexWithAlpha);
|
||||
verticalProgressBar.setProgressColor(-11485776);
|
||||
((TextView) baseViewHolder.getView(R.id.tv_data)).setText(getWeekOfDate(ydbgBean.getDate()));
|
||||
}
|
||||
}
|
||||
|
||||
public String getWeekOfDate(String str) {
|
||||
try {
|
||||
String[] strArr = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
|
||||
Date parse = new SimpleDateFormat("yyyy-MM-dd").parse(str);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(parse);
|
||||
int i = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
if (i < 0) {
|
||||
i = 0;
|
||||
}
|
||||
return strArr[i];
|
||||
} catch (Exception unused) {
|
||||
return str.split("-")[1] + "." + str.split("-")[2];
|
||||
}
|
||||
}
|
||||
|
||||
public class BtnClick {
|
||||
public void openPrecisionHome(View view) {
|
||||
public void x(View view) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,15 @@ import android.content.Context;
|
||||
import com.google.gson.Gson;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class AssertUtils {
|
||||
public static final Gson mGson = new Gson();
|
||||
|
||||
public static String getFromAssets(Context context, String str) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
StringBuilder stringBuffer = new StringBuilder();
|
||||
try {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(context.getResources().getAssets().open(str), "utf-8"));
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(context.getResources().getAssets().open(str), StandardCharsets.UTF_8));
|
||||
while (true) {
|
||||
String readLine = bufferedReader.readLine();
|
||||
if (readLine != null) {
|
||||
|
||||
56
app/src/main/java/com/xwad/os/jxw/TbddProviderUtil.java
Normal file
56
app/src/main/java/com/xwad/os/jxw/TbddProviderUtil.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.xwad.os.jxw;
|
||||
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import com.xwad.os.base.BaseApplication;
|
||||
import com.xwad.os.bean.jxw.TbddBookBean;
|
||||
|
||||
public class TbddProviderUtil {
|
||||
private static final String AUTHORITY = "com.jxw.tbddProvider";
|
||||
private static final Uri LAUNCHER_URI = Uri.parse("content://com.jxw.tbddProvider/subject");
|
||||
private static final String TAG = "TbddProviderUtil";
|
||||
|
||||
public static TbddBookBean getTbddData(String str) {
|
||||
return queryBookBean(new String[]{str});
|
||||
}
|
||||
|
||||
public static TbddBookBean getTbddData(String str, String str2) {
|
||||
return queryBookBean(new String[]{str, str2});
|
||||
}
|
||||
|
||||
public static TbddBookBean getTbddData(String str, String str2, String str3) {
|
||||
return queryBookBean(new String[]{str, str2, str3});
|
||||
}
|
||||
|
||||
private static TbddBookBean queryBookBean(String[] strArr) {
|
||||
TbddBookBean tbddBookBean = null;
|
||||
Cursor query = BaseApplication.getInstance().getContentResolver().query(LAUNCHER_URI, strArr, null, null, null, null);
|
||||
if (query != null && query.getCount() > 0) {
|
||||
while (query.moveToNext()) {
|
||||
String string = query.getString(query.getColumnIndex("isbn"));
|
||||
String string2 = query.getString(query.getColumnIndex("bookName"));
|
||||
String string3 = query.getString(query.getColumnIndex("publisher"));
|
||||
String string4 = query.getString(query.getColumnIndex("coverUrl"));
|
||||
TbddBookBean tbddBookBean2 = new TbddBookBean();
|
||||
try {
|
||||
tbddBookBean2.setIsbn(string);
|
||||
tbddBookBean2.setCoverUrl(string4);
|
||||
tbddBookBean2.setPublisher(string3);
|
||||
tbddBookBean2.setBookName(string2);
|
||||
Log.e(TAG, "isbn:" + string + ",bookName:" + string2 + ",publisher:" + string3 + ",coverUrl:" + string4);
|
||||
tbddBookBean = tbddBookBean2;
|
||||
} catch (Exception e) {
|
||||
tbddBookBean = tbddBookBean2;
|
||||
e.printStackTrace();
|
||||
Log.e(TAG, e.getMessage());
|
||||
return tbddBookBean;
|
||||
}
|
||||
}
|
||||
query.close();
|
||||
}
|
||||
|
||||
return tbddBookBean;
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,11 @@ package com.xwad.os.jxw;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.xwad.os.utils.OpenApkUtils;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -13,8 +16,6 @@ public class Util {
|
||||
return new SimpleDateFormat("yyyyMMdd").format(new Date());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static boolean isNetworkAvailable(Context context) {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo[] allNetworkInfo = connectivityManager.getAllNetworkInfo();
|
||||
@@ -53,5 +54,35 @@ public class Util {
|
||||
// }
|
||||
}
|
||||
|
||||
public static void downloadClickListener(Context context, String str, String str2, String str3, String str4) {
|
||||
OpenApkUtils.getInstance().openJxwApp("" + str + "," + str2 + "," + str3 + "," + str.substring(str.lastIndexOf(".") + 1) + "," + str4);
|
||||
}
|
||||
|
||||
public static String checkGrade(String str) {
|
||||
if (TextUtils.isEmpty(str)) {
|
||||
return "初中";
|
||||
}
|
||||
|
||||
switch (str) {
|
||||
case "一年级":
|
||||
case "二年级":
|
||||
case "三年级":
|
||||
case "四年级":
|
||||
case "五年级":
|
||||
case "六年级":
|
||||
return "小学";
|
||||
case "初中六年级":
|
||||
case "七年级":
|
||||
case "八年级":
|
||||
case "九年级":
|
||||
return "初中";
|
||||
case "高一":
|
||||
case "高二":
|
||||
case "高三":
|
||||
return "高中";
|
||||
default:
|
||||
return "初中";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
104
app/src/main/java/com/xwad/os/jxw/fragment/BookFragment.java
Normal file
104
app/src/main/java/com/xwad/os/jxw/fragment/BookFragment.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package com.xwad.os.jxw.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.jxw.BaseNewFragment;
|
||||
import com.xwad.os.jxw.CommonUtil;
|
||||
import com.xwad.os.jxw.Constant;
|
||||
import com.xwad.os.jxw.ToastUtil;
|
||||
import com.xwad.os.jxw.Util;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class BookFragment extends BaseNewFragment {
|
||||
private String bookId;
|
||||
private String bookurl;
|
||||
ImageView iv_book_icon;
|
||||
ImageView iv_ksyd;
|
||||
LinearLayout ll_data;
|
||||
private String showName;
|
||||
TextView tv_book_name;
|
||||
|
||||
@Override
|
||||
protected View createView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
||||
return layoutInflater.inflate(R.layout.fg_content_book, viewGroup, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
this.iv_book_icon = findViewById(R.id.iv_book_icon);
|
||||
this.tv_book_name = findViewById(R.id.tv_book_name);
|
||||
this.iv_ksyd = findViewById(R.id.iv_ksyd);
|
||||
this.ll_data = findViewById(R.id.ll_data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initListener() {
|
||||
super.initListener();
|
||||
findViewById(R.id.iv_ksyd).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (CommonUtil.isFastClick()) {
|
||||
if (!TextUtils.isEmpty(BookFragment.this.bookId)) {
|
||||
FragmentActivity activity = BookFragment.this.getActivity();
|
||||
Util.downloadClickListener(activity, "com.jxwgb.zhtsg", "com.jxw.home.ui.activitys.BookDetailActivity", "int:jump_type:1#int:book_id:" + BookFragment.this.bookId, "智慧图书馆");
|
||||
return;
|
||||
}
|
||||
ToastUtil.showTextToastDia("还没有阅读过书籍,快去挑选书籍吧!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void lazyLoad() {
|
||||
getZjyd();
|
||||
}
|
||||
|
||||
private void getZjyd() {
|
||||
// try {
|
||||
// OkhtttpUtils.getInstance().doGet(getActivity(), Constant.GW_URL + "/rms/api/library/device/read/near/book", true, new OkhtttpUtils.OkCallback() {
|
||||
// @Override
|
||||
// public void onFailure(Exception exc) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onResponse(String str) {
|
||||
// try {
|
||||
// JSONObject jSONObject = new JSONObject(str);
|
||||
// if (jSONObject.optString("code").equals("0")) {
|
||||
// JSONObject jSONObject2 = new JSONObject(jSONObject.optString("data"));
|
||||
// BookFragment.this.bookId = jSONObject2.optString("id");
|
||||
// JSONObject jSONObject3 = new JSONObject(jSONObject2.optString("coverFile"));
|
||||
// BookFragment.this.bookurl = jSONObject3.optString(IjkMediaPlayer.OnNativeInvokeListener.ARG_URL);
|
||||
// BookFragment.this.showName = jSONObject3.optString("showName");
|
||||
// BookFragment.this.tv_book_name.setText(BookFragment.this.showName);
|
||||
// GlideUtils.load(BookFragment.this.getActivity(), BookFragment.this.bookurl, BookFragment.this.iv_book_icon);
|
||||
// if (!TextUtils.isEmpty(BookFragment.this.showName)) {
|
||||
// BookFragment.this.iv_ksyd.setVisibility(0);
|
||||
// BookFragment.this.ll_data.setVisibility(8);
|
||||
// } else {
|
||||
// BookFragment.this.iv_ksyd.setVisibility(8);
|
||||
// BookFragment.this.ll_data.setVisibility(0);
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.getMessage();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// } catch (Exception unused) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
}
|
||||
170
app/src/main/java/com/xwad/os/jxw/fragment/BookListFragment.java
Normal file
170
app/src/main/java/com/xwad/os/jxw/fragment/BookListFragment.java
Normal file
@@ -0,0 +1,170 @@
|
||||
package com.xwad.os.jxw.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.xwad.os.R;
|
||||
import com.xwad.os.bean.jxw.BookBean;
|
||||
import com.xwad.os.jxw.BaseNewFragment;
|
||||
import com.xwad.os.jxw.CommonUtil;
|
||||
import com.xwad.os.jxw.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class BookListFragment extends BaseNewFragment {
|
||||
List<BookBean> bookBeans = new ArrayList();
|
||||
ImageView iv_book_icon;
|
||||
ImageView iv_book_icon1;
|
||||
ImageView iv_book_icon2;
|
||||
ImageView iv_book_icon3;
|
||||
ImageView iv_book_icon4;
|
||||
LinearLayout ll_data;
|
||||
|
||||
@Override
|
||||
protected View createView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
||||
return layoutInflater.inflate(R.layout.fg_content_book_list, viewGroup, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
this.iv_book_icon = findViewById(R.id.iv_book_icon);
|
||||
this.iv_book_icon1 = findViewById(R.id.iv_book_icon1);
|
||||
this.iv_book_icon2 = findViewById(R.id.iv_book_icon2);
|
||||
this.iv_book_icon3 = findViewById(R.id.iv_book_icon3);
|
||||
this.iv_book_icon4 = findViewById(R.id.iv_book_icon4);
|
||||
this.ll_data = findViewById(R.id.ll_data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initListener() {
|
||||
super.initListener();
|
||||
this.iv_book_icon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (CommonUtil.isFastClick()) {
|
||||
try {
|
||||
FragmentActivity activity = BookListFragment.this.getActivity();
|
||||
Util.downloadClickListener(activity, "com.jxwgb.zhtsg", "com.jxw.home.ui.activitys.BookDetailActivity", "int:jump_type:1#int:book_id:" + BookListFragment.this.bookBeans.get(0).getId(), "智慧图书馆");
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.iv_book_icon1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (CommonUtil.isFastClick()) {
|
||||
try {
|
||||
FragmentActivity activity = BookListFragment.this.getActivity();
|
||||
Util.downloadClickListener(activity, "com.jxwgb.zhtsg", "com.jxw.home.ui.activitys.BookDetailActivity", "int:jump_type:1#int:book_id:" + BookListFragment.this.bookBeans.get(1).getId(), "智慧图书馆");
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.iv_book_icon2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (CommonUtil.isFastClick()) {
|
||||
try {
|
||||
FragmentActivity activity = BookListFragment.this.getActivity();
|
||||
Util.downloadClickListener(activity, "com.jxwgb.zhtsg", "com.jxw.home.ui.activitys.BookDetailActivity", "int:jump_type:1#int:book_id:" + BookListFragment.this.bookBeans.get(2).getId(), "智慧图书馆");
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.iv_book_icon3.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (CommonUtil.isFastClick()) {
|
||||
try {
|
||||
FragmentActivity activity = BookListFragment.this.getActivity();
|
||||
Util.downloadClickListener(activity, "com.jxwgb.zhtsg", "com.jxw.home.ui.activitys.BookDetailActivity", "int:jump_type:1#int:book_id:" + BookListFragment.this.bookBeans.get(3).getId(), "智慧图书馆");
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.iv_book_icon4.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (CommonUtil.isFastClick()) {
|
||||
try {
|
||||
FragmentActivity activity = BookListFragment.this.getActivity();
|
||||
Util.downloadClickListener(activity, "com.jxwgb.zhtsg", "com.jxw.home.ui.activitys.BookDetailActivity", "int:jump_type:1#int:book_id:" + BookListFragment.this.bookBeans.get(4).getId(), "智慧图书馆");
|
||||
} catch (Exception unused) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void lazyLoad() {
|
||||
getwdsz();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reseLoad() {
|
||||
super.reseLoad();
|
||||
getwdsz();
|
||||
}
|
||||
|
||||
private void getwdsz() {
|
||||
// try {
|
||||
// OkhtttpUtils.getInstance().doGet(getActivity(), Constant.GW_URL + "/rms/api/library/device/book/read/record/list?isReadFinish=&isCollect=1&pageNo=&pageSize=&thirdUserId=", true, new OkhtttpUtils.OkCallback() { // from class: com.jxw.launcher.fragment.BookListFragment.6
|
||||
// @Override
|
||||
// public void onFailure(Exception exc) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onResponse(String str) {
|
||||
// try {
|
||||
// BookListFragment.this.bookBeans.clear();
|
||||
// JSONObject jSONObject = new JSONObject(str);
|
||||
// if (jSONObject.optString("code").equals("0")) {
|
||||
// JSONArray jSONArray = new JSONObject(jSONObject.optString("data")).getJSONArray("records");
|
||||
// if (jSONArray != null && jSONArray.length() > 0) {
|
||||
// BookListFragment.this.ll_data.setVisibility(8);
|
||||
// } else {
|
||||
// BookListFragment.this.ll_data.setVisibility(0);
|
||||
// }
|
||||
// for (int i = 0; i < jSONArray.length(); i++) {
|
||||
// JSONObject jSONObject2 = new JSONObject(jSONArray.getString(i));
|
||||
// JSONObject jSONObject3 = new JSONObject(jSONObject2.optString("coverFile"));
|
||||
// BookBean bookBean = new BookBean();
|
||||
// bookBean.setId(jSONObject2.optString("id"));
|
||||
// bookBean.setName(jSONObject2.optString("name"));
|
||||
// BookListFragment.this.bookBeans.add(bookBean);
|
||||
// if (i == 0) {
|
||||
// GlideUtils.load(BookListFragment.this.getActivity(), jSONObject3.optString(IjkMediaPlayer.OnNativeInvokeListener.ARG_URL), BookListFragment.this.iv_book_icon);
|
||||
// } else if (i == 1) {
|
||||
// GlideUtils.load(BookListFragment.this.getActivity(), jSONObject3.optString(IjkMediaPlayer.OnNativeInvokeListener.ARG_URL), BookListFragment.this.iv_book_icon1);
|
||||
// } else if (i == 2) {
|
||||
// GlideUtils.load(BookListFragment.this.getActivity(), jSONObject3.optString(IjkMediaPlayer.OnNativeInvokeListener.ARG_URL), BookListFragment.this.iv_book_icon2);
|
||||
// } else if (i == 3) {
|
||||
// GlideUtils.load(BookListFragment.this.getActivity(), jSONObject3.optString(IjkMediaPlayer.OnNativeInvokeListener.ARG_URL), BookListFragment.this.iv_book_icon3);
|
||||
// } else if (i == 4) {
|
||||
// GlideUtils.load(BookListFragment.this.getActivity(), jSONObject3.optString(IjkMediaPlayer.OnNativeInvokeListener.ARG_URL), BookListFragment.this.iv_book_icon4);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.getMessage();
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// } catch (Exception unused) {
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -402,11 +402,7 @@ public class OpenApkUtils {
|
||||
try {
|
||||
BigDecimal version = new BigDecimal("20240527");
|
||||
BigDecimal bigDecimal = new BigDecimal(versionName);
|
||||
if (bigDecimal.compareTo(version) > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return bigDecimal.compareTo(version) > 0;
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "isNewAiApp: " + e.getMessage());
|
||||
return true;
|
||||
@@ -635,77 +631,120 @@ public class OpenApkUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数字符串打开对应页面
|
||||
*
|
||||
* @param paramStr 参数字符串(格式:包名,类名,extra参数,第四项,第五项)
|
||||
*/
|
||||
public void openJxwApp(String paramStr) {
|
||||
if (TextUtils.isEmpty(paramStr)) {
|
||||
Log.e(TAG, "openJxwApp: params is null");
|
||||
Log.e(TAG, "context为空或参数字符串为空");
|
||||
return;
|
||||
}
|
||||
// 分割字符串(使用-1保留空元素,处理连续逗号情况)
|
||||
String[] params = paramStr.split(",", -1);
|
||||
if (params.length < 5) {
|
||||
Log.e(TAG, "参数字符串格式错误,参数数量不足");
|
||||
|
||||
// 1. 按逗号分割整体参数(保留空项,避免丢失字段)
|
||||
String[] totalParts = paramStr.split(",", -1);
|
||||
if (totalParts.length < 2) { // 至少需要包名+类名
|
||||
Log.e(TAG, "参数字符串格式错误:" + paramStr);
|
||||
return;
|
||||
}
|
||||
// 提取各项参数
|
||||
String packageName = params[0];
|
||||
String className = params[1];
|
||||
String extraStr = params[2];
|
||||
String fourthParam = params[3];
|
||||
String fifthParam = params[4];
|
||||
|
||||
try {
|
||||
// 构建Intent
|
||||
Intent intent = new Intent();
|
||||
ComponentName componentName = new ComponentName(packageName, className);
|
||||
intent.setComponent(componentName);
|
||||
// 提取各项基础参数
|
||||
String packageName = totalParts[0]; // 第一项:包名
|
||||
String className = totalParts[1]; // 第二项:类名
|
||||
String extraParamStr = totalParts.length > 2 ? totalParts[2] : ""; // 第三项:Intent Extra参数
|
||||
String fourthParam = totalParts.length > 3 ? totalParts[3] : ""; // 第四项(自定义)
|
||||
String fifthParam = totalParts.length > 4 ? totalParts[4] : ""; // 第五项(自定义)
|
||||
|
||||
// 解析并添加Extra参数
|
||||
if (extraStr != null && !extraStr.isEmpty()) {
|
||||
String[] extraParts = extraStr.split(":", 3);
|
||||
if (extraParts.length == 3) {
|
||||
String type = extraParts[0];
|
||||
String key = extraParts[1];
|
||||
String value = extraParts[2];
|
||||
Log.d(TAG, "包名:" + packageName + "\n类名:" + className
|
||||
+ "\n第四项:" + fourthParam + "\n第五项:" + fifthParam);
|
||||
|
||||
// 根据类型添加Extra
|
||||
switch (type.toLowerCase()) {
|
||||
case "int":
|
||||
intent.putExtra(key, Integer.parseInt(value));
|
||||
break;
|
||||
case "string":
|
||||
intent.putExtra(key, value);
|
||||
break;
|
||||
case "boolean":
|
||||
intent.putExtra(key, Boolean.parseBoolean(value));
|
||||
break;
|
||||
case "long":
|
||||
intent.putExtra(key, Long.parseLong(value));
|
||||
break;
|
||||
// 可扩展支持其他类型(float、double等)
|
||||
default:
|
||||
Log.w(TAG, "不支持的Extra类型:" + type);
|
||||
intent.putExtra(key, value);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Extra参数格式错误:" + extraStr);
|
||||
// 2. 构建Intent并设置Component(包名+类名)
|
||||
Intent intent = new Intent();
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
ComponentName component = new ComponentName(packageName, className);
|
||||
intent.setComponent(component);
|
||||
|
||||
// 3. 解析Extra参数(支持多组,用#分隔;每组格式:类型:key:值)
|
||||
if (!TextUtils.isEmpty(extraParamStr)) {
|
||||
String[] extraGroups = extraParamStr.split("#");
|
||||
for (String extraGroup : extraGroups) {
|
||||
if (TextUtils.isEmpty(extraGroup)) continue;
|
||||
|
||||
// 按冒号分割(最多分3段,避免值中包含冒号)
|
||||
String[] extraParts = extraGroup.split(":", 3);
|
||||
if (extraParts.length != 3) {
|
||||
Log.w(TAG, "Extra参数格式错误:" + extraGroup);
|
||||
continue;
|
||||
}
|
||||
|
||||
String type = extraParts[0]; // 类型(int/String等)
|
||||
String key = extraParts[1]; // Extra的key
|
||||
String value = extraParts[2]; // Extra的value
|
||||
|
||||
// 根据类型设置Extra
|
||||
setExtraByType(intent, type, key, value);
|
||||
}
|
||||
|
||||
// 如需传递第四、五项参数,可根据需求添加
|
||||
// intent.putExtra("fourth_param", fourthParam);
|
||||
// intent.putExtra("fifth_param", fifthParam);
|
||||
|
||||
// 启动Activity(需确保上下文是Activity或添加FLAG_ACTIVITY_NEW_TASK)
|
||||
// if (!(context instanceof android.app.Activity)) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
// }
|
||||
mContext.startActivity(intent);
|
||||
} catch (NumberFormatException e) {
|
||||
Log.e(TAG, "参数类型转换失败", e);
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "启动Activity失败", e);
|
||||
}
|
||||
|
||||
// 4. 启动Activity(处理异常)
|
||||
try {
|
||||
mContext.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof android.content.ActivityNotFoundException) {
|
||||
Log.e(TAG, "未找到目标Activity:" + packageName + "/" + className);
|
||||
} else if (e instanceof SecurityException) {
|
||||
Log.e(TAG, "启动Activity权限不足");
|
||||
} else {
|
||||
Log.e(TAG, "启动Activity失败:" + e.getMessage());
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型为Intent设置Extra参数
|
||||
*
|
||||
* @param intent 目标Intent
|
||||
* @param type 参数类型(int/String/boolean等)
|
||||
* @param key Extra的key
|
||||
* @param value Extra的value字符串
|
||||
*/
|
||||
private static void setExtraByType(Intent intent, String type, String key, String value) {
|
||||
if (TextUtils.isEmpty(type) || TextUtils.isEmpty(key)) return;
|
||||
|
||||
switch (type.toLowerCase()) {
|
||||
case "int":
|
||||
try {
|
||||
int intValue = Integer.parseInt(value);
|
||||
intent.putExtra(key, intValue);
|
||||
} catch (NumberFormatException e) {
|
||||
Log.w(TAG, "int类型转换失败:" + value);
|
||||
}
|
||||
break;
|
||||
case "string":
|
||||
intent.putExtra(key, value);
|
||||
break;
|
||||
case "boolean":
|
||||
try {
|
||||
boolean boolValue = Boolean.parseBoolean(value);
|
||||
intent.putExtra(key, boolValue);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "boolean类型转换失败:" + value);
|
||||
}
|
||||
break;
|
||||
case "long":
|
||||
try {
|
||||
long longValue = Long.parseLong(value);
|
||||
intent.putExtra(key, longValue);
|
||||
} catch (NumberFormatException e) {
|
||||
Log.w(TAG, "long类型转换失败:" + value);
|
||||
}
|
||||
break;
|
||||
// 可扩展其他类型(float/double等)
|
||||
default:
|
||||
Log.w(TAG, "不支持的参数类型:" + type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.xwad.os.view.jxw.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import com.xwad.os.R;
|
||||
|
||||
public class VerticalProgressBar extends View {
|
||||
private Paint mPaint;
|
||||
private int maxProgress;
|
||||
private int minute;
|
||||
private Paint paint;
|
||||
private int progress;
|
||||
private int progressColor;
|
||||
|
||||
public VerticalProgressBar(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
this.minute = 0;
|
||||
init();
|
||||
}
|
||||
|
||||
public VerticalProgressBar(Context context, AttributeSet attributeSet, int i) {
|
||||
super(context, attributeSet, i);
|
||||
this.minute = 0;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
this.progress = 0;
|
||||
this.maxProgress = 100;
|
||||
this.progressColor = -9055101;
|
||||
this.paint = new Paint();
|
||||
this.paint.setColor(this.progressColor);
|
||||
this.paint.setStyle(Paint.Style.FILL);
|
||||
this.paint.setAntiAlias(true);
|
||||
this.mPaint = new Paint();
|
||||
this.mPaint.setColor(-1);
|
||||
this.mPaint.setAntiAlias(true);
|
||||
this.mPaint.setTextSize(getResources().getDimension(R.dimen.x18));
|
||||
this.mPaint.setTextAlign(Paint.Align.CENTER);
|
||||
}
|
||||
|
||||
public void setProgress(int i) {
|
||||
this.progress = i;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setMaxProgress(int i) {
|
||||
this.maxProgress = i;
|
||||
}
|
||||
|
||||
public void setProgressColor(int i) {
|
||||
this.progressColor = i;
|
||||
this.paint.setColor(i);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void setText(int i) {
|
||||
this.minute = i;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
float height = ((int) (getHeight() - getResources().getDimension(R.dimen.x25))) * (this.progress / this.maxProgress);
|
||||
canvas.drawRect(0.0f, getHeight() - height, getWidth(), getHeight(), this.paint);
|
||||
canvas.drawText(this.progress + "分钟", getWidth() / 2.0f, (getHeight() - height) - getResources().getDimension(R.dimen.x10), this.mPaint);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int i, int i2) {
|
||||
super.onMeasure(i, i2);
|
||||
setMeasuredDimension(resolveSize(getPaddingLeft() + getPaddingRight() + getSuggestedMinimumWidth(), i), resolveSize(getPaddingBottom() + getPaddingTop() + getSuggestedMinimumHeight(), i2));
|
||||
}
|
||||
|
||||
private int convertMinutesToHours(int i) {
|
||||
return i / 60;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import com.xwad.os.R;
|
||||
import com.xwad.os.base.BaseApplication;
|
||||
import com.xwad.os.bean.jxw.ItemsBean;
|
||||
import com.xwad.os.jxw.AssertUtils;
|
||||
import com.xwad.os.utils.OpenApkUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@@ -51,11 +52,11 @@ public class AppsDialog extends Dialog {
|
||||
|
||||
public AppsDialog(Context context, String str) {
|
||||
super(context, R.style.ActionSheetDialogStyle);
|
||||
this.appList = new ArrayList();
|
||||
this.FILE_NAME = "app_list_";
|
||||
this.activity = (Activity) context;
|
||||
this.type = str;
|
||||
this.FILE_NAME += str;
|
||||
appList = new ArrayList();
|
||||
FILE_NAME = "app_list_";
|
||||
activity = (Activity) context;
|
||||
type = str;
|
||||
FILE_NAME += str;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,49 +77,49 @@ public class AppsDialog extends Dialog {
|
||||
|
||||
private void initView() {
|
||||
GridLayoutManager gridLayoutManager;
|
||||
this.rv_apps = findViewById(R.id.rv_apps);
|
||||
this.tv_title = findViewById(R.id.tv_title);
|
||||
this.appAdapter = new AppAdapter(getApps());
|
||||
if (this.type.equals("yw")) {
|
||||
this.tv_title.setText("语文学习应用");
|
||||
gridLayoutManager = new GridLayoutManager(this.activity, 5);
|
||||
this.count = 2;
|
||||
} else if (this.type.equals("sx")) {
|
||||
this.tv_title.setText("数学学习应用");
|
||||
gridLayoutManager = new GridLayoutManager(this.activity, 5);
|
||||
this.count = 2;
|
||||
} else if (this.type.equals("yy")) {
|
||||
this.tv_title.setText("英语学习应用");
|
||||
gridLayoutManager = new GridLayoutManager(this.activity, 5);
|
||||
this.count = 2;
|
||||
} else if (this.type.equals("wl")) {
|
||||
this.tv_title.setText("物理学习应用");
|
||||
gridLayoutManager = new GridLayoutManager(this.activity, 4);
|
||||
this.count = 1;
|
||||
} else if (this.type.equals("hx")) {
|
||||
this.tv_title.setText("化学学习应用");
|
||||
gridLayoutManager = new GridLayoutManager(this.activity, 5);
|
||||
this.count = 1;
|
||||
} else if (this.type.equals("sw")) {
|
||||
this.tv_title.setText("生物学习应用");
|
||||
gridLayoutManager = new GridLayoutManager(this.activity, 3);
|
||||
this.count = 1;
|
||||
rv_apps = findViewById(R.id.rv_apps);
|
||||
tv_title = findViewById(R.id.tv_title);
|
||||
appAdapter = new AppAdapter(getApps());
|
||||
if (type.equals("yw")) {
|
||||
tv_title.setText("语文学习应用");
|
||||
gridLayoutManager = new GridLayoutManager(activity, 5);
|
||||
count = 2;
|
||||
} else if (type.equals("sx")) {
|
||||
tv_title.setText("数学学习应用");
|
||||
gridLayoutManager = new GridLayoutManager(activity, 5);
|
||||
count = 2;
|
||||
} else if (type.equals("yy")) {
|
||||
tv_title.setText("英语学习应用");
|
||||
gridLayoutManager = new GridLayoutManager(activity, 5);
|
||||
count = 2;
|
||||
} else if (type.equals("wl")) {
|
||||
tv_title.setText("物理学习应用");
|
||||
gridLayoutManager = new GridLayoutManager(activity, 4);
|
||||
count = 1;
|
||||
} else if (type.equals("hx")) {
|
||||
tv_title.setText("化学学习应用");
|
||||
gridLayoutManager = new GridLayoutManager(activity, 5);
|
||||
count = 1;
|
||||
} else if (type.equals("sw")) {
|
||||
tv_title.setText("生物学习应用");
|
||||
gridLayoutManager = new GridLayoutManager(activity, 3);
|
||||
count = 1;
|
||||
} else {
|
||||
gridLayoutManager = null;
|
||||
}
|
||||
this.rv_apps.setLayoutManager(gridLayoutManager);
|
||||
this.rv_apps.setAdapter(this.appAdapter);
|
||||
rv_apps.setLayoutManager(gridLayoutManager);
|
||||
rv_apps.setAdapter(appAdapter);
|
||||
getMyList();
|
||||
findViewById(R.id.ll_gb).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
AppsDialog.this.dismiss();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setOnCallback(Callback callback) {
|
||||
this.mCallback = callback;
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
public class AppAdapter extends BaseQuickAdapter<ItemsBean, BaseViewHolder> {
|
||||
@@ -129,16 +130,16 @@ public class AppsDialog extends Dialog {
|
||||
@Override
|
||||
public void convert(BaseViewHolder baseViewHolder, final ItemsBean itemsBean) {
|
||||
RelativeLayout relativeLayout = baseViewHolder.getView(R.id.rl_root);
|
||||
((ImageView) baseViewHolder.getView(R.id.iv_app_icon)).setImageResource(this.mContext.getResources().getIdentifier(itemsBean.getIcon(), "drawable", this.mContext.getPackageName()));
|
||||
((ImageView) baseViewHolder.getView(R.id.iv_app_icon)).setImageResource(mContext.getResources().getIdentifier(itemsBean.getIcon(), "drawable", mContext.getPackageName()));
|
||||
((TextView) baseViewHolder.getView(R.id.tv_app_name)).setText(itemsBean.getText());
|
||||
relativeLayout.setTag(AppsDialog.this.activity.getResources().getString(this.mContext.getResources().getIdentifier(itemsBean.getTag(), "string", this.mContext.getPackageName())));
|
||||
relativeLayout.setTag(activity.getResources().getString(mContext.getResources().getIdentifier(itemsBean.getTag(), "string", mContext.getPackageName())));
|
||||
relativeLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (TextUtils.isEmpty(itemsBean.getTag())) {
|
||||
return;
|
||||
}
|
||||
AppsDialog.this.jumpTag(itemsBean, view);
|
||||
jumpTag(itemsBean, view);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -147,7 +148,7 @@ public class AppsDialog extends Dialog {
|
||||
private List<ItemsBean> getApps() {
|
||||
String grade = "一年级";
|
||||
Gson gson = new Gson();
|
||||
String jsonString = AssertUtils.getFromAssets(BaseApplication.getInstance(), "script/" + this.type + "_apps.json");
|
||||
String jsonString = AssertUtils.getFromAssets(BaseApplication.getInstance(), "script/" + type + "_apps.json");
|
||||
Type type = new TypeToken<List<ItemsBean>>() {
|
||||
}.getType();
|
||||
List<ItemsBean> itemsBeans = gson.fromJson(jsonString, type);
|
||||
@@ -166,35 +167,36 @@ public class AppsDialog extends Dialog {
|
||||
}
|
||||
|
||||
public void jumpTag(ItemsBean itemsBean, View view) {
|
||||
if (this.activity != null) {
|
||||
if (activity != null) {
|
||||
String viewTag = view.getTag().toString();
|
||||
saveTag(itemsBean);
|
||||
Callback callback = this.mCallback;
|
||||
Callback callback = mCallback;
|
||||
if (callback != null) {
|
||||
callback.onCallback();
|
||||
}
|
||||
// MyApp.getInstance().mBottomBtnOnClickListener.setContext(this.activity);
|
||||
// MyApp.getInstance().mBottomBtnOnClickListener.setContext(activity);
|
||||
// MyApp.getInstance().mBottomBtnOnClickListener.onClick(viewTag);
|
||||
OpenApkUtils.getInstance().openJxwApp(viewTag);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveTag(ItemsBean itemsBean) {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (i >= this.appList.size()) {
|
||||
if (i >= appList.size()) {
|
||||
break;
|
||||
} else if (this.appList.get(i).getTag().equals(itemsBean.getTag())) {
|
||||
this.appList.remove(i);
|
||||
} else if (appList.get(i).getTag().equals(itemsBean.getTag())) {
|
||||
appList.remove(i);
|
||||
break;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
this.appList.add(0, itemsBean);
|
||||
appList.add(0, itemsBean);
|
||||
try {
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(BaseApplication.getInstance().getFileStreamPath(this.FILE_NAME), false);
|
||||
for (int i2 = 0; i2 < this.appList.size() && i2 <= this.count; i2++) {
|
||||
fileOutputStream.write((this.appList.get(i2).getText() + "|" + this.appList.get(i2).getIcon() + "|" + this.appList.get(i2).getTag() + "\n").getBytes());
|
||||
FileOutputStream fileOutputStream = new FileOutputStream(BaseApplication.getInstance().getFileStreamPath(FILE_NAME), false);
|
||||
for (int i2 = 0; i2 < appList.size() && i2 <= count; i2++) {
|
||||
fileOutputStream.write((appList.get(i2).getText() + "|" + appList.get(i2).getIcon() + "|" + appList.get(i2).getTag() + "\n").getBytes());
|
||||
}
|
||||
fileOutputStream.flush();
|
||||
fileOutputStream.close();
|
||||
@@ -204,7 +206,7 @@ public class AppsDialog extends Dialog {
|
||||
}
|
||||
|
||||
private void getMyList() {
|
||||
File fileStreamPath = BaseApplication.getInstance().getFileStreamPath(this.FILE_NAME);
|
||||
File fileStreamPath = BaseApplication.getInstance().getFileStreamPath(FILE_NAME);
|
||||
if (fileStreamPath.exists()) {
|
||||
try {
|
||||
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileStreamPath));
|
||||
@@ -215,7 +217,7 @@ public class AppsDialog extends Dialog {
|
||||
itemsBean.setText(readLine.split("\\|")[0]);
|
||||
itemsBean.setIcon(readLine.split("\\|")[1]);
|
||||
itemsBean.setTag(readLine.split("\\|")[2]);
|
||||
this.appList.add(itemsBean);
|
||||
appList.add(itemsBean);
|
||||
} else {
|
||||
bufferedReader.close();
|
||||
return;
|
||||
@@ -225,13 +227,13 @@ public class AppsDialog extends Dialog {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
this.appList.addAll(getdefaultApps());
|
||||
appList.addAll(getdefaultApps());
|
||||
}
|
||||
}
|
||||
|
||||
private List<ItemsBean> getdefaultApps() {
|
||||
Gson gson = new Gson();
|
||||
String jsonString = AssertUtils.getFromAssets(BaseApplication.getInstance(), "script/" + this.type + "_default_app.json");
|
||||
String jsonString = AssertUtils.getFromAssets(BaseApplication.getInstance(), "script/" + type + "_default_app.json");
|
||||
Type type = new TypeToken<List<ItemsBean>>() {
|
||||
}.getType();
|
||||
List<ItemsBean> itemsBeans = gson.fromJson(jsonString, type);
|
||||
|
||||
Reference in New Issue
Block a user