Skip to content

Commit

Permalink
更新readme文档
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchong211 committed Mar 12, 2019
1 parent f919295 commit 756f0aa
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 3 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,21 @@
android.enableD8=false
android.enableD8.desugaring = false
```
- kotlin和realm数据库配置问题
- 错误配置【参考方案:https://github.com/realm/realm-java/issues/3139】
```
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
```
- 正确配置【注意:realm-android要在kotlin配置之后】
```
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'realm-android'
```
- 出现其他编译类错误,可以直接谷歌搜索解决


Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
package com.ns.yc.lifehelper.ui.guide.view.activity;

import android.content.res.TypedArray;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;

import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.SizeUtils;
import com.blankj.utilcode.util.Utils;
import com.ns.yc.lifehelper.R;
import com.ycbjie.library.base.mvp.BaseActivity;
import com.ycbjie.library.constant.Constant;
import com.yc.cn.ycbannerlib.banner.BannerView;
import com.yc.cn.ycbannerlib.banner.adapter.AbsDynamicPagerAdapter;
import com.ycbjie.library.base.mvp.BaseActivity;
import com.ycbjie.library.constant.Constant;
import com.ycbjie.library.model.HomeBlogEntity;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import cn.ycbjie.ycstatusbarlib.bar.StateAppBar;


Expand Down Expand Up @@ -84,7 +94,8 @@ public void initListener() {

@Override
public void initData() {

cacheFindNewsData();
cacheFindBottomNewsData();
}


Expand Down Expand Up @@ -124,4 +135,56 @@ public int getCount() {
}


@SuppressWarnings("ResultOfMethodCallIgnored")
private void cacheFindNewsData() {
Constant.findNews.clear();
try {
InputStream in = Utils.getApp().getAssets().open("findNews.config");
int size = in.available();
byte[] buffer = new byte[size];
in.read(buffer);
String jsonStr = new String(buffer, "UTF-8");
JSONObject jsonObject = new JSONObject(jsonStr);
JSONArray jsonArray = jsonObject.optJSONArray("result");
if (null != jsonArray) {
int len = jsonArray.length();
for (int j = 0; j < 3; j++) {
for (int i = 0; i < len; i++) {
JSONObject itemJsonObject = jsonArray.getJSONObject(i);
HomeBlogEntity itemEntity = new HomeBlogEntity(itemJsonObject);
Constant.findNews.add(itemEntity);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

@SuppressWarnings("ResultOfMethodCallIgnored")
private void cacheFindBottomNewsData() {
Constant.findBottomNews.clear();
try {
InputStream in = Utils.getApp().getAssets().open("findBottomNews.config");
int size = in.available();
byte[] buffer = new byte[size];
in.read(buffer);
String jsonStr = new String(buffer, "UTF-8");
JSONObject jsonObject = new JSONObject(jsonStr);
JSONArray jsonArray = jsonObject.optJSONArray("result");
if (null != jsonArray) {
int len = jsonArray.length();
for (int j = 0; j < 3; j++) {
for (int i = 0; i < len; i++) {
JSONObject itemJsonObject = jsonArray.getJSONObject(i);
HomeBlogEntity itemEntity = new HomeBlogEntity(itemJsonObject);
Constant.findBottomNews.add(itemEntity);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}

}

0 comments on commit 756f0aa

Please sign in to comment.