• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java FreshNews类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.socks.jiandan.model.FreshNews的典型用法代码示例。如果您正苦于以下问题:Java FreshNews类的具体用法?Java FreshNews怎么用?Java FreshNews使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

FreshNews类属于com.socks.jiandan.model包,在下文中一共展示了FreshNews类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getCacheByPage

点赞 3

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
@Override
public ArrayList<FreshNews> getCacheByPage(int page) {

    QueryBuilder<com.socks.greendao.FreshNewsCache> query = mFreshNewsCacheDao.queryBuilder().where(FreshNewsCacheDao
            .Properties.Page.eq("" + page));

    if (query.list().size() > 0) {
        try {
            return FreshNews.parseCache(new JSONArray(query.list().get(0)
                    .getResult()));
        } catch (JSONException e) {
            e.printStackTrace();
            return new ArrayList<>();
        }
    } else {
        return new ArrayList<>();
    }

}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDan_OkHttpWithVolley,
代码行数:20,
代码来源:FreshNewsCache.java

示例2: loadFromCache

点赞 3

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
private void loadFromCache() {
    Observable.create(new Observable.OnSubscribe<ArrayList<FreshNews>>() {
        @Override
        public void call(Subscriber<? super ArrayList<FreshNews>> subscriber) {
            subscriber.onNext(FreshNewsCache.getInstance(mActivity).getCacheByPage(page));
            subscriber.onCompleted();
        }
    }).compose(JDApi.applySchedulers())
            .doOnNext(freshNewses -> {
                if (page == 1) {
                    mFreshNews.clear();
                    ToastHelper.Short(ConstantString.LOAD_NO_NETWORK);
                }
            })
            .subscribe(freshNewses -> {
                mFreshNews.addAll(freshNewses);
                notifyDataSetChanged();
                mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                mLoadFinisCallBack.loadFinish(null);
            });
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDanRxJava,
代码行数:22,
代码来源:FreshNewsAdapter.java

示例3: parse

点赞 3

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
@Nullable
public ArrayList<FreshNews> parse(Response response) {

    if (!response.isSuccessful())
        return null;

    try {
        String body = response.body().string();
        JSONObject resultObj = new JSONObject(body);
        JSONArray postsArray = resultObj.optJSONArray("posts");
        return FreshNews.parse(postsArray);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDanRxJava,
代码行数:17,
代码来源:FreshNewsParser.java

示例4: getFreshNews

点赞 3

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
public static Observable<ArrayList<FreshNews>> getFreshNews(final int page) {

        return Observable.create(new Observable.OnSubscribe<ArrayList<FreshNews>>() {

            @Override
            public void call(Subscriber<? super ArrayList<FreshNews>> subscriber) {
                String url = FreshNews.getUrlFreshNews(page);
                try {
                    subscriber.onNext(new FreshNewsParser().parse(OkHttpProxy.get()
                            .url(url)
                            .execute()));
                    subscriber.onCompleted();
                } catch (IOException e) {
                    subscriber.onError(e);
                }
            }
        }).compose(JDApi.<ArrayList<FreshNews>>applySchedulers());
    }
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDanRxJava,
代码行数:19,
代码来源:JDApi.java

示例5: parse

点赞 3

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
@Nullable
public ArrayList<FreshNews> parse(Response response) {

    code = wrapperCode(response.code());
    if (!response.isSuccessful())
        return null;

    try {
        String body = response.body().string();
        JSONObject resultObj = new JSONObject(body);
        JSONArray postsArray = resultObj.optJSONArray("posts");
        return FreshNews.parse(postsArray);
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDan_OkHttp,
代码行数:18,
代码来源:FreshNewsParser.java

示例6: getInstance

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
public static FreshNewsDetailFragment getInstance(FreshNews freshNews) {
    Bundle bundle = new Bundle();
    bundle.putSerializable(DATA_FRESH_NEWS, freshNews);
    FreshNewsDetailFragment fragment = new FreshNewsDetailFragment();
    fragment.setArguments(bundle);
    return fragment;
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDan_OkHttpWithVolley,
代码行数:8,
代码来源:FreshNewsDetailFragment.java

示例7: getHtml

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
private static String getHtml(FreshNews freshNews, String content) {
    final StringBuilder sb = new StringBuilder();
    sb.append("<!DOCTYPE html>");
    sb.append("<html dir=\"ltr\" lang=\"zh\">");
    sb.append("<head>");
    sb.append("<meta name=\"viewport\" content=\"width=100%; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;\" />");
    sb.append("<link rel=\"stylesheet\" href='file:///android_asset/style.css' type=\"text/css\" media=\"screen\" />");
    sb.append("</head>");
    sb.append("<body style=\"padding:0px 8px 8px 8px;\">");
    sb.append("<div id=\"pagewrapper\">");
    sb.append("<div id=\"mainwrapper\" class=\"clearfix\">");
    sb.append("<div id=\"maincontent\">");
    sb.append("<div class=\"post\">");
    sb.append("<div class=\"posthit\">");
    sb.append("<div class=\"postinfo\">");
    sb.append("<h2 class=\"thetitle\">");
    sb.append("<a>");
    sb.append(freshNews.getTitle());
    sb.append("</a>");
    sb.append("</h2>");
    sb.append(freshNews.getAuthor().getName() + " @ " + String2TimeUtil
            .dateString2GoodExperienceFormat(freshNews.getDate()));
    sb.append("</div>");
    sb.append("<div class=\"entry\">");
    sb.append(content);
    sb.append("</div>");
    sb.append("</div>");
    sb.append("</div>");
    sb.append("</div>");
    sb.append("</div>");
    sb.append("</div>");
    sb.append("</body>");
    sb.append("</html>");
    return sb.toString();
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDan_OkHttpWithVolley,
代码行数:36,
代码来源:FreshNewsDetailFragment.java

示例8: initData

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
@Override
protected void initData() {
    ArrayList<FreshNews> FreshNews = (ArrayList<FreshNews>) getIntent().getSerializableExtra
            (DATA_FRESH_NEWS);
    int position = getIntent().getIntExtra(DATA_POSITION, 0);
    viewPager.setAdapter(new FreshNewsDetailAdapter(getSupportFragmentManager(), FreshNews));
    viewPager.setCurrentItem(position);
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDan_OkHttpWithVolley,
代码行数:9,
代码来源:FreshNewsDetailActivity.java

示例9: parseNetworkResponse

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
@Override
protected Response<ArrayList<FreshNews>> parseNetworkResponse(NetworkResponse response) {

	try {
		String resultStr = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
		JSONObject resultObj = new JSONObject(resultStr);
		JSONArray postsArray = resultObj.optJSONArray("posts");
		return Response.success(FreshNews.parse(postsArray), HttpHeaderParser.parseCacheHeaders(response));
	} catch (Exception e) {
		e.printStackTrace();
		return Response.error(new ParseError(e));
	}
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDan_OkHttpWithVolley,
代码行数:14,
代码来源:Request4FreshNews.java

示例10: getHtml

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
public static String getHtml(FreshNews freshNews, String content) {
    final StringBuilder sb = new StringBuilder();
    sb.append("<!DOCTYPE html>");
    sb.append("<html dir=\"ltr\" lang=\"zh\">");
    sb.append("<head>");
    sb.append("<meta name=\"viewport\" content=\"width=100%; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;\" />");
    sb.append("<link rel=\"stylesheet\" href='file:///android_asset/style.css' type=\"text/css\" media=\"screen\" />");
    sb.append("</head>");
    sb.append("<body style=\"padding:0px 8px 8px 8px;\">");
    sb.append("<div id=\"pagewrapper\">");
    sb.append("<div id=\"mainwrapper\" class=\"clearfix\">");
    sb.append("<div id=\"maincontent\">");
    sb.append("<div class=\"post\">");
    sb.append("<div class=\"posthit\">");
    sb.append("<div class=\"postinfo\">");
    sb.append("<h2 class=\"thetitle\">");
    sb.append("<a>");
    sb.append(freshNews.title);
    sb.append("</a>");
    sb.append("</h2>");
    sb.append(freshNews.author.getName() + " @ " + String2TimeUtil
            .dateString2GoodExperienceFormat(freshNews.date));
    sb.append("</div>");
    sb.append("<div class=\"entry\">");
    sb.append(content);
    sb.append("</div>");
    sb.append("</div>");
    sb.append("</div>");
    sb.append("</div>");
    sb.append("</div>");
    sb.append("</div>");
    sb.append("</body>");
    sb.append("</html>");
    return sb.toString();
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDanRxJava,
代码行数:36,
代码来源:TextUtil.java

示例11: loadData

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
@Override
protected void loadData() {
    Intent intent = getIntent();
    int position = intent.getIntExtra(DATA_POSITION, 0);
    Serializable serializable = intent.getSerializableExtra(DATA_FRESH_NEWS);
    ArrayList<FreshNews> FreshNews = (ArrayList<FreshNews>) serializable;

    viewPager.setAdapter(new FreshNewsDetailAdapter(getSupportFragmentManager(), FreshNews));
    viewPager.setCurrentItem(position);
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDanRxJava,
代码行数:11,
代码来源:FreshNewsDetailActivity.java

示例12: getFreshDetail

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
public static Observable<String> getFreshDetail(String id) {
    return Observable.create(new Observable.OnSubscribe<String>() {
        @Override
        public void call(Subscriber<? super String> subscriber) {
            String url = FreshNews.getUrlFreshNewsDetail(id);
            try {
                subscriber.onNext(new FreshNewsDetailParser().parse(OkHttpProxy.get().url(url).execute()));
                subscriber.onCompleted();
            } catch (IOException e) {
                subscriber.onError(e);
            }
        }
    }).compose(applySchedulers());
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDanRxJava,
代码行数:15,
代码来源:JDApi.java

示例13: onSuccess

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
@Override
protected void onSuccess(int statusCode, String rawJsonResponse) {

    try {
        JSONObject resultObj = new JSONObject(rawJsonResponse);
        JSONArray postsArray = resultObj.optJSONArray("posts");
        mHttpResponseCallBack.onSuccess(SUCCESS, FreshNews.parse(postsArray));
    } catch (JSONException e) {
        e.printStackTrace();
        onFailure(FAILED_JSON_PARSE, e);
    }

}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDan_AsyncHttpClient,
代码行数:14,
代码来源:Handler4FreshNews.java

示例14: loadDataByNetworkType

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
private void loadDataByNetworkType() {

        if (NetWorkUtil.isNetWorkConnected(mActivity)) {
            RequestManager.addRequest(new Request4FreshNews(FreshNews.getUrlFreshNews(page),
                    new Response.Listener<ArrayList<FreshNews>>() {
                        @Override
                        public void onResponse(ArrayList<FreshNews> response) {

                            mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
                            mLoadFinisCallBack.loadFinish(null);

                            if (page == 1) {
                                mFreshNews.clear();
                                FreshNewsCache.getInstance(mActivity).clearAllCache();
                            }

                            mFreshNews.addAll(response);
                            notifyDataSetChanged();

                            FreshNewsCache.getInstance(mActivity).addResultCache(JSONParser.toString(response),
                                    page);
                        }
                    }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    mLoadResultCallBack.onError(LoadResultCallBack.ERROR_NET, error.getMessage());
                    mLoadFinisCallBack.loadFinish(null);
                }
            }), mActivity);
        } else {
            mLoadResultCallBack.onSuccess(LoadResultCallBack.SUCCESS_OK, null);
            mLoadFinisCallBack.loadFinish(null);

            if (page == 1) {
                mFreshNews.clear();
                ShowToast.Short(ConstantString.LOAD_NO_NETWORK);
            }

            mFreshNews.addAll(FreshNewsCache.getInstance(mActivity).getCacheByPage(page));
            notifyDataSetChanged();
        }

    }
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDan_OkHttpWithVolley,
代码行数:44,
代码来源:FreshNewsAdapter.java

示例15: onActivityCreated

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    setHasOptionsMenu(true);
    freshNews = (FreshNews) getArguments().getSerializable(DATA_FRESH_NEWS);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);
            if (newProgress > 80) {
                loading.stop();
            }
        }
    });
    executeRequest(new Request4FreshNewsDetail(FreshNews.getUrlFreshNewsDetail(freshNews.getId()),
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    webView.loadDataWithBaseURL("", getHtml(freshNews, response), "text/html", "utf-8", "");
                }
            }, new
            Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {

                }
            }));
    loading.start();

    loading.postDelayed(new Runnable() {
        @Override
        public void run() {
            if (loading.isShown()) {
                loading.stop();
            }
        }
    }, 10 * 1000);

}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDan_OkHttpWithVolley,
代码行数:42,
代码来源:FreshNewsDetailFragment.java

示例16: FreshNewsDetailAdapter

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
public FreshNewsDetailAdapter(FragmentManager fm, ArrayList<FreshNews> freshNewses) {
    super(fm);
    this.freshNewses = freshNewses;
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDan_OkHttpWithVolley,
代码行数:5,
代码来源:FreshNewsDetailActivity.java

示例17: Request4FreshNews

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
public Request4FreshNews(String url, Response.Listener<ArrayList<FreshNews>> listener,
                         Response.ErrorListener errorListener) {
	super(Method.GET, url, errorListener);
	this.listener = listener;
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDan_OkHttpWithVolley,
代码行数:6,
代码来源:Request4FreshNews.java

示例18: deliverResponse

点赞 2

import com.socks.jiandan.model.FreshNews; //导入依赖的package包/类
@Override
protected void deliverResponse(ArrayList<FreshNews> response) {
	listener.onResponse(response);
}
 

开发者ID:ZhaoKaiQiang,
项目名称:JianDan_OkHttpWithVolley,
代码行数:5,
代码来源:Request4FreshNews.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)