para;
13 |
14 | public static class Text2{
15 | public YYNews action;
16 | public YYNews timestamp;
17 | public YYNews token;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/beans/TxNewsClassify.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.beans;
2 |
3 | /**
4 | * @ explain:
5 | * @ author:xujun on 2016/10/28 16:01
6 | * @ email:gdutxiaoxu@163.com
7 | */
8 | public class TxNewsClassify {
9 |
10 | public String type;
11 | public String title;
12 |
13 | public TxNewsClassify(String type, String title) {
14 | this.type = type;
15 | this.title = title;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/beans/YYNews.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.beans;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * @author xujun on 2016/12/23.
7 | * @email gdutxiaoxu@163.com
8 | *
9 | * 易源新闻
10 | */
11 |
12 | public class YYNews {
13 |
14 | public int ret_code;
15 | public PagebeanEntity pagebean;
16 |
17 | public static class PagebeanEntity {
18 |
19 | public int allPages;
20 | public int currentPage;
21 | public int allNum;
22 | public int maxResult;
23 | public List contentlist;
24 |
25 |
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/beans/YiYuanResponse.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.beans;
2 |
3 | /**
4 | * @author xujun on 2016/12/23.
5 | * @email gdutxiaoxu@163.com
6 | */
7 |
8 | public class YiYuanResponse {
9 |
10 | public int showapi_res_code;
11 | public YYNews showapi_res_error;
12 | public T showapi_res_body;
13 | }
14 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/beans/test2.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.beans;
2 |
3 | /**
4 | * @author xujun on 2016/12/25.
5 | * @email gdutxiaoxu@163.com
6 | */
7 |
8 | public class test2 {
9 |
10 |
11 |
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/ActivityCollector.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common;
2 |
3 | import android.app.Activity;
4 | import android.util.Log;
5 |
6 | import java.util.ArrayList;
7 | import java.util.Collections;
8 | import java.util.List;
9 |
10 | /**
11 | * @author xujun on 2016/12/27.
12 | * @email gdutxiaoxu@163.com
13 | */
14 |
15 | public class ActivityCollector {
16 |
17 | public static final String TAG="ActivityCollector";
18 |
19 | private static List mActivitys = new ArrayList<>();
20 |
21 | public static void add(Activity activity) {
22 | mActivitys.add(activity);
23 | }
24 |
25 | public static void remove(Activity activity) {
26 | mActivitys.remove(activity);
27 | }
28 |
29 | public static Activity getTop() {
30 | if (mActivitys.isEmpty()) {
31 | return null;
32 | }
33 | return mActivitys.get(mActivitys.size() - 1);
34 | }
35 |
36 | public static void quit(){
37 | try{
38 | ArrayList activities = new ArrayList<>();
39 | Collections.copy(activities,mActivitys);
40 | for (Activity a:activities) {
41 | if(!a.isFinishing()){
42 | a.finish();
43 | mActivitys.remove(activities);
44 | }
45 |
46 | }
47 | }catch (Exception e){
48 | System.exit(0);
49 | Log.e(TAG, "quit: e=" +e.getMessage() );
50 | }
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/BasePageFragment.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common;
2 |
3 | import android.os.Bundle;
4 | import android.support.v4.app.Fragment;
5 |
6 | /**
7 | * @ explain:
8 | * @ author:xujun on 2016-8-11 16:16
9 | * @ email:gdutxiaoxu@163.com
10 | */
11 | public abstract class BasePageFragment extends Fragment {
12 |
13 | /**
14 | * 表示View是否被初始化
15 | */
16 | protected boolean isViewInitiated;
17 | /**
18 | * 表示对用户是否可见
19 | */
20 | protected boolean isVisibleToUser;
21 | /**
22 | * 表示数据是否初始化
23 | */
24 | protected boolean isDataInitiated;
25 |
26 | @Override
27 | public void onCreate(Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | }
30 |
31 | @Override
32 | public void onActivityCreated(Bundle savedInstanceState) {
33 | super.onActivityCreated(savedInstanceState);
34 | isViewInitiated = true;
35 | prepareFetchData();
36 | }
37 |
38 | @Override
39 | public void setUserVisibleHint(boolean isVisibleToUser) {
40 | super.setUserVisibleHint(isVisibleToUser);
41 | this.isVisibleToUser = isVisibleToUser;
42 | prepareFetchData();
43 | }
44 |
45 | public abstract void fetchData();
46 |
47 | public boolean prepareFetchData() {
48 | return prepareFetchData(false);
49 | }
50 |
51 | public boolean prepareFetchData(boolean forceUpdate) {
52 | if (isVisibleToUser && isViewInitiated && (!isDataInitiated || forceUpdate)) {
53 | fetchData();
54 | isDataInitiated = true;
55 | return true;
56 | }
57 | return false;
58 | }
59 |
60 | }
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/BaseViewPagerFragemnt.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common;
2 |
3 | import android.support.design.widget.TabLayout;
4 | import android.support.v4.view.ViewPager;
5 |
6 | import com.xujun.funapp.R;
7 | import com.xujun.funapp.common.mvp.BasePresenter;
8 | import com.xujun.funapp.databinding.FragmentViewPagerBinding;
9 |
10 | /**
11 | * @ explain:
12 | * @ author:xujun on 2016/10/7 22:51
13 | * @ email:gdutxiaoxu@163.com
14 | */
15 | public abstract class BaseViewPagerFragemnt extends
16 | BindingBaseFragment {
17 |
18 | protected ViewPager mViewPager;
19 |
20 | private BaseFragmentAdapter mFragmentAdapter;
21 | private TabLayout mTabLayout;
22 |
23 | @Override
24 | protected int getContentViewLayoutID() {
25 | return R.layout.fragment_view_pager;
26 | }
27 |
28 | @Override
29 | protected void initView(FragmentViewPagerBinding binding) {
30 | mViewPager = binding.viewPager;
31 | mTabLayout = binding.tabLayout;
32 | mTabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
33 | mFragmentAdapter = getViewPagerAdapter();
34 | mViewPager.setAdapter(mFragmentAdapter);
35 | mViewPager.setOffscreenPageLimit(setOffscreenPageLimit());
36 | mTabLayout.setupWithViewPager(mViewPager);
37 |
38 | }
39 |
40 | /*ViewPager 保存的Fragment的数量*/
41 | protected int setOffscreenPageLimit() {
42 | return 1;
43 | }
44 |
45 | /**
46 | * 这个方式是用来初始化ViewPager的adapter的
47 | *
48 | * @return
49 | */
50 | protected abstract BaseFragmentAdapter getViewPagerAdapter();
51 |
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/Constants.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common;
2 |
3 | import android.os.Environment;
4 |
5 | import java.io.File;
6 |
7 | /**
8 | * Created by xujun、on 2016/5/5.
9 | */
10 | public class Constants {
11 |
12 | public final static String CONFIG = "config";
13 |
14 | public final static String BaseCachePath = Environment.getExternalStoragePublicDirectory
15 | ("Download") + File.separator + APP.getInstance().getPackageName() + File.separator;
16 |
17 |
18 |
19 | public static class IntentConstants {
20 | public static final String DEFAULT_PARCEABLE_NAME = "default_parceable_name";
21 | public static final String DEFAULT_STRING_NAME = "default_string_name";
22 | public static final String TITLE_NAME = "title_name";
23 | public static final int RESULT_CODE_PICK_CITY = 2333;
24 | public static final String KEY_PICKED_CITY = "picked_city";
25 | }
26 |
27 | public static class URLConstants {
28 | public static final String URL_IMAGE_BASE = "http://tnfs.tngou.net/image";
29 | }
30 |
31 | public static class SPConstants {
32 | //表示是否在WiFi的情况下 才加载图片,true表示在WiFi的情况下才加载图片 ,false而表示不是
33 | public static final String isIntelligentNoPic = "isIntelligentNoPic";
34 | public static final String isNightMode = "isNightMode";
35 | // 表示当前城市
36 | public static final String city = "city";
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/DownloadConstants.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common;
2 |
3 | /**
4 | * @ explain:
5 | * @ author:xujun on 2016/6/12 09:13
6 | * @ email:gdutxiaoxu@163.com
7 | */
8 | public class DownloadConstants {
9 |
10 | //定义下载状态常量
11 | public static final int NONE = 0; //无状态 --> 等待
12 | public static final int WAITING = 1; //等待 --> 下载,暂停
13 | public static final int DOWNLOADING = 2; //下载中 --> 暂停,完成,错误
14 | public static final int PAUSE = 3; //暂停 --> 等待,下载
15 | public static final int FINISH = 4; //完成 --> 重新下载
16 | public static final int ERROR = 5; //错误 --> 等待
17 | }
18 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/PermissonListener.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * @author xujun on 2016/12/27.
7 | * @email gdutxiaoxu@163.com
8 | */
9 |
10 | public interface PermissonListener {
11 |
12 | void onGranted();
13 |
14 | void onDenied(List permisons);
15 | }
16 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/RequestResult.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common;
2 |
3 | /**
4 | * @author xujun on 2017/1/3.
5 | * @email gdutxiaoxu@163.com
6 | */
7 |
8 | //记录请求结果的状态,有三种类型,success,onError,empty
9 | public enum RequestResult {
10 | success, error, empty;
11 | }
12 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/UnCatchExceptionHandler.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common;
2 |
3 | import com.orhanobut.logger.Logger;
4 |
5 | /**
6 | * @ explain:
7 | * @ author:xujun on 2016-8-18 15:01
8 | * @ email:gdutxiaoxu@163.com
9 | */
10 | public class UnCatchExceptionHandler implements Thread.UncaughtExceptionHandler{
11 |
12 | private static UnCatchExceptionHandler mInstance;
13 |
14 | @Override
15 | public void uncaughtException(Thread thread, Throwable ex) {
16 | if(ex!=null){
17 | Logger.e(ex.toString());
18 | }
19 |
20 | }
21 |
22 | public static UnCatchExceptionHandler getInstance(){
23 | if(mInstance==null){
24 | mInstance=new UnCatchExceptionHandler();
25 | }
26 | return mInstance;
27 |
28 | }
29 | }
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/YiYuanConstants.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common;
2 |
3 | import android.support.annotation.NonNull;
4 |
5 | import java.util.HashMap;
6 |
7 | /**
8 | * @author xujun on 2016/12/28.
9 | * @email gdutxiaoxu@163.com
10 | */
11 |
12 | public class YiYuanConstants {
13 | public static final String BASE_URL = "http://route.showapi.com/";
14 |
15 | public static final String API_ID = "29571";
16 | public static final String API_ID_KEY = "showapi_appid";
17 | public static final String API_SECRET = "5bf00910e04a46998f6979f6da400f1e";
18 | public static final String API_SIGN_KEY = "showapi_sign";
19 | public static final String API_SIGN = API_SECRET;
20 | // String API_SIGN = MD5.encode(API_SECRET);
21 |
22 | public static final String WECHAT_JING_XUAN = BASE_URL + "582-2/";
23 | public static final String NEWS_GET = BASE_URL + "109-35/";
24 | public static final String NEWS_CLASSIFY = BASE_URL + "109-34/";
25 |
26 | @NonNull
27 | public static HashMap getParamsMap() {
28 | HashMap map = new HashMap<>();
29 | map.put(YiYuanConstants.API_ID_KEY, YiYuanConstants.API_ID);
30 | map.put(YiYuanConstants.API_SIGN_KEY, YiYuanConstants.API_SIGN);
31 | return map;
32 | }
33 |
34 | }
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/mvp/BasePresenter.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.mvp;
2 |
3 | /**
4 | * Created by Domen、on 2016/4/22.
5 | */
6 | public interface BasePresenter {
7 |
8 | void start();
9 |
10 | void stop();
11 | }
12 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/mvp/BaseView.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.mvp;
2 |
3 | /**
4 | * Created by Domen、on 2016/4/22.
5 | */
6 | public interface BaseView {
7 |
8 |
9 |
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/mvp/DefaultContract.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.mvp;
2 |
3 | import org.simple.eventbus.EventBus;
4 |
5 | import java.lang.ref.WeakReference;
6 |
7 |
8 |
9 | /**
10 | * @ explain:
11 | * @ author:xujun on 2016-7-27 11:41
12 | * @ email:gdutxiaoxu@163.com
13 | */
14 | public interface DefaultContract {
15 |
16 | interface View extends BaseView{
17 | public void showProgress();
18 |
19 | public void hideProgress();
20 |
21 | public void onSuccess(T t);
22 |
23 | public void onError(Throwable throwable);
24 |
25 | public void onLocal(T t);
26 | }
27 |
28 |
29 | public static class Presenter implements BasePresenter {
30 |
31 | private final WeakReference mBaseViewWeakReference;
32 |
33 | @Override
34 | public void start() {
35 | EventBus.getDefault().register(this);
36 | }
37 |
38 | @Override
39 | public void stop() {
40 | EventBus.getDefault().unregister(this);
41 | mBaseViewWeakReference.clear();
42 |
43 | }
44 |
45 | public Presenter(V view){
46 | mBaseViewWeakReference = new WeakReference<>(view);
47 | }
48 |
49 | public V getView(){
50 | return mBaseViewWeakReference.get();
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/network/CustomException.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.network;
2 |
3 | /**
4 | * @author meitu.xujun on 2017/4/18 14:07
5 | * @version 0.1
6 | */
7 |
8 | public class CustomException extends Exception {
9 |
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/network/GsonManger.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.network;
2 |
3 | import com.google.gson.Gson;
4 |
5 | import java.lang.reflect.Type;
6 |
7 | /**
8 | * @author xujun on 2016/12/25.
9 | * @email gdutxiaoxu@163.com
10 | */
11 |
12 | public class GsonManger {
13 |
14 | private final Gson mGson;
15 |
16 | private GsonManger() {
17 | mGson = new Gson();
18 | }
19 |
20 | public static GsonManger getInstance() {
21 | return Holder.mInstance;
22 | }
23 |
24 | private static class Holder {
25 | private static final GsonManger mInstance = new GsonManger();
26 | }
27 |
28 | public String toJson(Object src) {
29 | return mGson.toJson(src);
30 | }
31 |
32 | public T fromJson(String json, Class clz) {
33 |
34 | return mGson.fromJson(json, clz);
35 | }
36 |
37 | public T fromJson(String json, Type type) {
38 |
39 | return mGson.fromJson(json, type);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/network/HttpException.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.network;
2 |
3 | /**
4 | * @author meitu.xujun on 2017/4/8 17:26
5 | * @version 0.1
6 | */
7 |
8 | public class HttpException {
9 |
10 | public static final int CUSTOM_ERROR_CODE=100;
11 |
12 | public int code;
13 | public Throwable e;
14 | public String errMsg;
15 |
16 | public HttpException(int code, Throwable e, String errMsg) {
17 | this.code = code;
18 | this.e = e;
19 | this.errMsg = errMsg;
20 | }
21 |
22 | @Override
23 | public String toString() {
24 | return "HttpException{" +
25 | "code=" + code +
26 | ", e=" + e +
27 | ", errMsg='" + errMsg + '\'' +
28 | '}';
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/network/IRequestListener.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.network;
2 |
3 | /**
4 | * @author meitu.xujun on 2017/3/22 16:10
5 | * @version 0.1
6 | */
7 |
8 | public interface IRequestListener {
9 |
10 | void onResponse(String response);
11 | void onFail(HttpException httpException);
12 | }
13 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/network/NetUtils.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.network;
2 |
3 | /**
4 | * @author meitu.xujun on 2017/4/18 14:33
5 | * @version 0.1
6 | */
7 |
8 | public class NetUtils {
9 |
10 | public static boolean isFirstPage(int page){
11 | return page<=1;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/network/RequestListener.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.network;
2 |
3 | /**
4 | * @ explain:
5 | * @ author:xujun on 2016/10/19 23:40
6 | * @ email:gdutxiaoxu@163.com
7 | */
8 | public interface RequestListener {
9 |
10 | public void onSuccess(T t);
11 | public void onError(Throwable throwable);
12 | }
13 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/network/juhe/BaseJuheEntity.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.network.juhe;
2 |
3 | /**
4 | * @author xujun on 2017/1/2.
5 | * @email gdutxiaoxu@163.com
6 | */
7 |
8 | public class BaseJuheEntity {
9 |
10 | public T result;
11 | public String reason;
12 | public int error_code;
13 | }
14 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/network/juhe/JuHeApi.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.network.juhe;
2 |
3 | import java.util.Map;
4 |
5 | import okhttp3.ResponseBody;
6 | import retrofit2.http.FieldMap;
7 | import retrofit2.http.FormUrlEncoded;
8 | import retrofit2.http.POST;
9 | import retrofit2.http.Url;
10 | import rx.Observable;
11 |
12 | /**
13 | * @author xujun on 2017/1/2.
14 | * @email gdutxiaoxu@163.com
15 | */
16 |
17 | public interface JuHeApi {
18 |
19 |
20 | String mBaseUrl="http://api.juheapi.com/";
21 | String url_joke="http://japi.juhe.cn/joke/content/list.from?";
22 |
23 | @FormUrlEncoded
24 | @POST
25 | Observable push(@Url String url, @FieldMap Map paramsMap);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/network/yiyuan/BaseYYEntity.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.network.yiyuan;
2 |
3 | /**
4 | * @author xujun on 2016/12/25.
5 | * @email gdutxiaoxu@163.com
6 | */
7 |
8 | public class BaseYYEntity {
9 |
10 | public int showapi_res_code;
11 | public String showapi_res_error;
12 | public Object showapi_res_body;
13 |
14 | public int getShowapi_res_code() {
15 | return showapi_res_code;
16 | }
17 |
18 | public void setShowapi_res_code(int showapi_res_code) {
19 | this.showapi_res_code = showapi_res_code;
20 | }
21 |
22 | public String getShowapi_res_error() {
23 | return showapi_res_error;
24 | }
25 |
26 | public void setShowapi_res_error(String showapi_res_error) {
27 | this.showapi_res_error = showapi_res_error;
28 | }
29 |
30 | public String getShowapi_res_body() {
31 | return showapi_res_body.toString();
32 | }
33 |
34 | public void setShowapi_res_body(String showapi_res_body) {
35 | this.showapi_res_body = showapi_res_body;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/network/yiyuan/YiYuanApi.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.network.yiyuan;
2 |
3 | import java.util.Map;
4 |
5 | import okhttp3.ResponseBody;
6 | import retrofit2.http.FieldMap;
7 | import retrofit2.http.FormUrlEncoded;
8 | import retrofit2.http.POST;
9 | import retrofit2.http.Url;
10 | import rx.Observable;
11 |
12 | /**
13 | * @author xujun on 2016/12/24.
14 | * @email gdutxiaoxu@163.com
15 | */
16 |
17 | public interface YiYuanApi {
18 |
19 | String API_ID = "29571";
20 | String API_ID_KEY = "showapi_appid";
21 | String API_SECRET = "5bf00910e04a46998f6979f6da400f1e";
22 | String API_SIGN_KEY = "showapi_sign";
23 | // String API_SIGN = MD5.encode(API_SECRET);
24 | String API_SIGN = API_SECRET;
25 |
26 | String mBaseUrl = "https://route.showapi.com/";
27 |
28 | // http://route.showapi
29 | // .com/109-34?showapi_appid=29571&showapi_sign=5bf00910e04a46998f6979f6da400f1e
30 |
31 |
32 | // https://route.showapi.com/109-35?channelId=&channelName=&maxResult=20&needAllList=0
33 | // &needContent=0&needHtml=0&page=1&showapi_appid=29457&showapi_timestamp=20161225101701
34 | // &title=足球&showapi_sign=99af1a0e6ad027c261b8965972b4e42b
35 |
36 | @FormUrlEncoded
37 | @POST()
38 | Observable excutePush(@Url String url, @FieldMap Map paramsMap);
39 |
40 |
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/onRefreshListener.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common;
2 |
3 | import android.view.ViewGroup;
4 |
5 | /**
6 | * @ explain:
7 | * @ author:xujun on 2016/10/17 20:23
8 | * @ email:gdutxiaoxu@163.com
9 | */
10 | public interface onRefreshListener {
11 |
12 | void onRefresh(ViewGroup viewGroup);
13 | void onLoadMore(ViewGroup viewGroup);
14 | }
15 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/recyclerView/LayoutMangerType.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.recyclerView;
2 |
3 | /**
4 | * @ explain:
5 | * @ author:xujun on 2016/11/9 11:24
6 | * @ email:gdutxiaoxu@163.com
7 | */
8 | public enum LayoutMangerType {
9 | Linear, Grid, Strag
10 | }
11 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/recyclerView/MultiItemTypeSupport.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.recyclerView;
2 |
3 | /**
4 | * @author xujun on 2016/12/29.
5 | * @email gdutxiaoxu@163.com
6 | */
7 |
8 | public interface MultiItemTypeSupport {
9 |
10 | public int getItemType(T t,int position);
11 | public int getLayoutId(int itemType);
12 | }
13 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/util/DbUtills.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.util;
2 |
3 | import org.litepal.crud.DataSupport;
4 |
5 | /**
6 | * @ explain:
7 | * @ author:xujun on 2016/5/19 15:48
8 | * @ email:gdutxiaoxu@163.com
9 | */
10 | public class DbUtills {
11 |
12 |
13 | public static void saveAll(String user,String readType,Class clz){
14 | DataSupport.deleteAll(clz,"user=?and readType=?",user,readType);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/util/PinyinUtils.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.util;
2 |
3 | import android.text.TextUtils;
4 |
5 | import java.util.regex.Pattern;
6 |
7 | /**
8 | * author zaaach on 2016/1/28.
9 | */
10 | public class PinyinUtils {
11 | /**
12 | * 获取拼音的首字母(大写)
13 | * @param pinyin
14 | * @return
15 | */
16 | public static String getFirstLetter(final String pinyin){
17 | if (TextUtils.isEmpty(pinyin)) return "定位";
18 | String c = pinyin.substring(0, 1);
19 | Pattern pattern = Pattern.compile("^[A-Za-z]+$");
20 | if (pattern.matcher(c).matches()){
21 | return c.toUpperCase();
22 | } else if ("0".equals(c)){
23 | return "定位";
24 | } else if ("1".equals(c)){
25 | return "热门";
26 | }
27 | return "定位";
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/common/util/ResourceUtils.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.common.util;
2 |
3 | import com.xujun.mylibrary.utils.IOUtils;
4 |
5 | import java.io.BufferedReader;
6 | import java.io.InputStreamReader;
7 |
8 | import static com.xujun.funapp.common.util.UIUtils.getResources;
9 |
10 | /**
11 | * @author xujun on 2016/12/24.
12 | * @email gdutxiaoxu@163.com
13 | */
14 |
15 | public class ResourceUtils {
16 |
17 | public static String getFromAssets(String fileName) {
18 | StringBuffer sb = new StringBuffer();
19 | InputStreamReader inputReader=null;
20 | try {
21 | inputReader = new InputStreamReader(getResources().getAssets().open
22 | (fileName));
23 | BufferedReader bufReader = new BufferedReader(inputReader);
24 | String line = "";
25 | while ((line = bufReader.readLine()) != null) sb.append(line);
26 | return sb.toString();
27 | } catch (Exception e) {
28 | e.printStackTrace();
29 | }finally {
30 | IOUtils.close(inputReader);
31 | }
32 | return sb.toString();
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/image/IimageListener.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.image;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.widget.ImageView;
6 |
7 | /**
8 | * @author xujun on 2016/12/23.
9 | * @email gdutxiaoxu@163.com
10 | */
11 |
12 | public interface IimageListener {
13 |
14 |
15 |
16 | void display(Context context, ImageView imageView, String url, int progressId, int errorId,
17 | Object tag);
18 |
19 | void display(Context context, ImageView imageView, String url, int progressId, int errorId);
20 |
21 | void display(Context context, ImageView imageView, String url, int progressId);
22 |
23 | void display(Context context, ImageView imageView, String url);
24 |
25 | void display(Context context, ImageView imageView, Uri uri);
26 | }
27 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/image/ImageRequestManager.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.image;
2 |
3 | /**
4 | * @author xujun on 2016/12/23.
5 | * @email gdutxiaoxu@163.com
6 | */
7 |
8 | public class ImageRequestManager {
9 |
10 | public static final String type_Glide="Glide";
11 | public static final String type_Picasso="Picasso";
12 | public static final String type_default =type_Glide;
13 |
14 | private ImageRequestManager(){
15 |
16 | }
17 |
18 | public static IimageListener getRequest(){
19 | return getRequest(type_default);
20 |
21 | }
22 |
23 | public static IimageListener getRequest(String type){
24 | switch (type){
25 | case type_Glide:
26 | return new GlideRequest();
27 |
28 | case type_Picasso:
29 | return new PicassoRequest();
30 |
31 | default:
32 | return new GlideRequest();
33 | }
34 |
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/image/PicassoRequest.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.image;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.widget.ImageView;
6 |
7 | /**
8 | * @author xujun on 2017/1/13.
9 | * @email gdutxiaoxu@163.com
10 | */
11 |
12 | public class PicassoRequest implements IimageListener {
13 |
14 | @Override
15 | public void display(Context context, ImageView imageView, String url, int progressId, int
16 | errorId, Object tag) {
17 | // Picasso.with(context).load(url).placeholder(progressId).error(errorId).tag(tag).into(imageView);
18 | }
19 |
20 | @Override
21 | public void display(Context context, ImageView imageView, String url, int progressId, int
22 | errorId) {
23 | // Picasso.with(context).load(url).placeholder(progressId).error(errorId).into(imageView);
24 | }
25 |
26 | @Override
27 | public void display(Context context, ImageView imageView, String url, int progressId) {
28 | // Picasso.with(context).load(url).placeholder(progressId).into(imageView);
29 | }
30 |
31 | @Override
32 | public void display(Context context, ImageView imageView, String url) {
33 | // Picasso.with(context).load(url).into(imageView);
34 | }
35 |
36 | @Override
37 | public void display(Context context, ImageView imageView, Uri uri) {
38 | // Picasso.with(context).load(uri).into(imageView);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/model/PictureDetailMOdel.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.model;
2 |
3 | import com.orhanobut.logger.Logger;
4 | import com.xujun.funapp.beans.PictureDetailBean;
5 | import com.xujun.funapp.network.retrofit.TnGouNet;
6 | import com.xujun.funapp.common.network.RequestListener;
7 | import com.xujun.funapp.network.retrofit.TnGouAPi;
8 |
9 | import rx.Observable;
10 | import rx.android.schedulers.AndroidSchedulers;
11 | import rx.functions.Action1;
12 | import rx.schedulers.Schedulers;
13 |
14 | /**
15 | * @ explain:
16 | * @ author:xujun on 2016/10/19 23:39
17 | * @ email:gdutxiaoxu@163.com
18 | */
19 | public class PictureDetailMOdel {
20 |
21 | public void getPictureList(int id, final RequestListener listener){
22 |
23 | TnGouAPi tnGouAPi = TnGouNet.getInstance().getTnGouAPi();
24 | Observable observable = tnGouAPi.getPictureDetail(id);
25 | observable.subscribeOn(Schedulers.io())
26 | .observeOn(AndroidSchedulers.mainThread())
27 | .subscribe(new Action1() {
28 | @Override
29 | public void call(PictureDetailBean pictureDetailBean) {
30 | if(listener!=null){
31 | listener.onSuccess(pictureDetailBean);
32 | }
33 |
34 | }
35 | }, new Action1() {
36 | @Override
37 | public void call(Throwable throwable) {
38 | Logger.i(throwable.getMessage());
39 | if(listener!=null){
40 | listener.onError(throwable);
41 | }
42 |
43 | }
44 | });
45 |
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/model/PictureModel.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.model;
2 |
3 | import com.xujun.funapp.beans.PictureClassify;
4 | import com.xujun.funapp.network.retrofit.TnGouNet;
5 | import com.xujun.funapp.network.retrofit.TnGouAPi;
6 |
7 | import org.simple.eventbus.EventBus;
8 |
9 | import java.util.List;
10 |
11 | import rx.Observable;
12 | import rx.android.schedulers.AndroidSchedulers;
13 | import rx.functions.Action1;
14 | import rx.schedulers.Schedulers;
15 |
16 | /**
17 | * @ explain:
18 | * @ author:xujun on 2016/9/17 20:24
19 | * @ email:gdutxiaoxu@163.com
20 | */
21 | public class PictureModel {
22 |
23 | public static void getPictureClassify() {
24 | TnGouAPi tnGouAPi = TnGouNet.getInstance().getTnGouAPi();
25 | Observable observable = tnGouAPi.pictureClassify();
26 | observable.subscribeOn(Schedulers.io())
27 | .observeOn(AndroidSchedulers.mainThread())
28 | .subscribe(new Action1() {
29 | @Override
30 | public void call(PictureClassify pictureClassify) {
31 | List tngou = pictureClassify.tngou;
32 | EventBus.getDefault().post(pictureClassify);
33 |
34 | }
35 | }, new Action1() {
36 | @Override
37 | public void call(Throwable throwable) {
38 | EventBus.getDefault().post(throwable);
39 | }
40 | });
41 |
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/model/PreviousLifeDetailModel.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.model;
2 |
3 | import com.xujun.funapp.common.network.juhe.JuHeApiManger;
4 |
5 | import java.util.Map;
6 |
7 | import rx.Subscriber;
8 |
9 | /**
10 | * @author xujun on 2016/12/28.
11 | * @email gdutxiaoxu@163.com
12 | */
13 |
14 | public class PreviousLifeDetailModel {
15 |
16 | public void getData(String url, Map paramsMap, Subscriber subscriber) {
17 | JuHeApiManger.getInstance().excutePushString(url,paramsMap,subscriber);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/model/PreviousLifeModel.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.model;
2 |
3 | import com.xujun.funapp.common.network.juhe.JuHeApiManger;
4 |
5 | import java.util.Map;
6 |
7 | import rx.Subscriber;
8 |
9 | /**
10 | * @author xujun on 2016/12/28.
11 | * @email gdutxiaoxu@163.com
12 | */
13 |
14 | public class PreviousLifeModel {
15 |
16 | public void getData(String url, Map paramsMap, Subscriber subscriber) {
17 | JuHeApiManger.getInstance().excutePushString(url,paramsMap,subscriber);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/model/WeChatModel.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.model;
2 |
3 | import com.xujun.funapp.common.network.yiyuan.YYHttpManger;
4 |
5 | import java.util.Map;
6 |
7 | import rx.Subscriber;
8 |
9 | /**
10 | * @author xujun on 2016/12/28.
11 | * @email gdutxiaoxu@163.com
12 | */
13 |
14 | public class WeChatModel {
15 |
16 | public void getData(String url, Map paramsMap, Subscriber subscriber) {
17 | YYHttpManger.getInstance().push(url,paramsMap,subscriber);
18 |
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/HttpManger.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network;
2 |
3 | import rx.Observable;
4 | import rx.Subscriber;
5 | import rx.Subscription;
6 | import rx.android.schedulers.AndroidSchedulers;
7 | import rx.schedulers.Schedulers;
8 |
9 | /**
10 | * @author xujun on 2016/12/24.
11 | * @email gdutxiaoxu@163.com
12 | */
13 |
14 | public class HttpManger {
15 |
16 | private HttpManger() {
17 |
18 | }
19 |
20 | public static HttpManger getInstance() {
21 | return Holder.mInstance;
22 | }
23 |
24 | private static class Holder {
25 | private static final HttpManger mInstance = new HttpManger();
26 | }
27 |
28 | public Subscription doHttpDeal(Observable observable, Subscriber subscriber) {
29 | return observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
30 | .unsubscribeOn(Schedulers.io()).subscribe(subscriber);
31 | }
32 |
33 | public static class LiftAllTransformer implements Observable.Transformer {
34 |
35 |
36 | @Override
37 | public Observable call(Observable observable) {
38 | return (Observable)observable.subscribeOn(Schedulers.io()).// 指定在IO线程执行耗时操作
39 | unsubscribeOn(Schedulers.io()).
40 | observeOn(AndroidSchedulers.mainThread());//指定Subscrible在主线程回调
41 | }
42 | }
43 |
44 | public LiftAllTransformer getTransformer(){
45 | return new LiftAllTransformer();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/INetwork.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network;
2 |
3 | /**
4 | * @ explain:新增
5 | * @ author:xujun on 2016-7-19 17:54
6 | * @ email:gdutxiaoxu@163.com
7 | */
8 | public interface INetwork {
9 |
10 | /**
11 | * 拿到BaseURl;
12 | * @return
13 | */
14 |
15 | String getBaseUrl();
16 | String getUploadUrl();
17 | String getDownloadUrl();
18 | String getHostName();
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/INetworkListener.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network;
2 |
3 | import com.xujun.funapp.common.network.RequestListener;
4 |
5 | import java.util.Map;
6 |
7 | /**
8 | * @author xujun on 2016/12/23.
9 | * @email gdutxiaoxu@163.com
10 | */
11 |
12 | public interface INetworkListener {
13 |
14 | public void excuteGet(String url, Map paramsMap , final RequestListener requestListener);
15 | public void excutePush(String url, Map paramsMap, final RequestListener requestListener);
16 | public void json(String url,String jsonStr,final RequestListener requestListener);
17 | }
18 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/NetworkManager.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network;
2 |
3 | import com.xujun.funapp.network.retrofitclient.RetrofitClient;
4 |
5 | /**
6 | * @author xujun on 2016/12/23.
7 | * @email gdutxiaoxu@163.com
8 | */
9 |
10 | public class NetworkManager {
11 |
12 | public static INetworkListener getInstance(){
13 | return RetrofitClient.getInstance();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network.exception;
2 |
3 | /**
4 | * @ explain:
5 | * @ author:xujun on 2016-7-19 12:07
6 | * @ email:gdutxiaoxu@163.com
7 | */
8 | public class ApiException extends Exception {
9 |
10 | private final int code;
11 | private String displayMessage;
12 |
13 | public static final int UNKNOWN = 1000;
14 | public static final int PARSE_ERROR = 1001;
15 | public String message;
16 |
17 | public ApiException(Throwable throwable, int code) {
18 | super(throwable);
19 | this.code = code;
20 | }
21 |
22 | public int getCode() {
23 | return code;
24 | }
25 | public String getDisplayMessage() {
26 | return displayMessage;
27 | }
28 | public void setDisplayMessage(String msg) {
29 | this.displayMessage = msg + "(code:" + code + ")";
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/exception/ERROR.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network.exception;
2 |
3 | /**
4 | * @ explain:
5 | * @ author:xujun on 2016-7-19 14:53
6 | * @ email:gdutxiaoxu@163.com
7 | */
8 | /**
9 | * 约定异常
10 | */
11 |
12 | public class ERROR {
13 | /**
14 | * 未知错误
15 | */
16 | public static final int UNKNOWN = 1000;
17 | /**
18 | * 解析错误
19 | */
20 | public static final int PARSE_ERROR = 1001;
21 | /**
22 | * 网络错误
23 | */
24 | public static final int NETWORD_ERROR = 1002;
25 | /**
26 | * 协议出错
27 | */
28 | public static final int HTTP_ERROR = 1003;
29 | }
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/exception/ErrResponse.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network.exception;
2 |
3 | /**
4 | * @ explain:
5 | * @ author:xujun on 2016-7-19 12:01
6 | * @ email:gdutxiaoxu@163.com
7 | */
8 | public class ErrResponse {
9 | String msg;
10 |
11 | public String getMsg() {
12 | return msg;
13 | }
14 |
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/exception/GsonResponseBodyConverter.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network.exception;
2 |
3 | import com.google.gson.Gson;
4 | import com.orhanobut.logger.Logger;
5 |
6 | import java.io.IOException;
7 | import java.lang.reflect.Type;
8 |
9 | import okhttp3.ResponseBody;
10 | import retrofit2.Converter;
11 |
12 | /**
13 | * @ explain:chu
14 | * @ author:xujun on 2016-7-19 11:57
15 | * @ email:gdutxiaoxu@163.com
16 | */
17 | public class GsonResponseBodyConverter implements Converter {
18 | private final Gson gson;
19 | private final Type type;
20 |
21 | public GsonResponseBodyConverter(Gson gson, Type type) {
22 | this.gson = gson;
23 | this.type = type;
24 | }
25 |
26 | @Override
27 | public T convert(ResponseBody value) throws IOException {
28 | String response = value.string();
29 | try {
30 | // 打印出返回的信息,不管是成功还是失败
31 | // Logger.json(response);
32 | Logger.d(response);
33 | //ResultResponse 只解析result字段,Response为我们定义的基类
34 | /* Response resultResponse = gson.fromJson(response, Response.class);
35 | //成功的时候
36 | if (resultResponse.isSuccess()) {
37 | //result==0表示成功返回,继续用本来的Model类解析
38 | return gson.fromJson(response, type_default);
39 | //
40 | } else {
41 | //ErrResponse 将msg解析为异常消息文本
42 | ErrResponse errResponse = gson.fromJson(response, ErrResponse.class);
43 | throw new ResultException(resultResponse.getStatus_code(), errResponse.getMsg());
44 | }*/
45 | } finally {
46 | }
47 | return gson.fromJson(response, type);
48 | }
49 | }
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/exception/ResultException.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network.exception;
2 |
3 | /**
4 | * @ explain:
5 | * @ author:xujun on 2016-7-19 11:54
6 | * @ email:gdutxiaoxu@163.com
7 | */
8 | public class ResultException extends RuntimeException {
9 |
10 | private int errCode = 0;
11 |
12 | public ResultException(int errCode, String msg) {
13 | super(msg);
14 | this.errCode = errCode;
15 | }
16 |
17 | public int getErrCode() {
18 | return errCode;
19 | }
20 | }
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/exception/ServerException.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network.exception;
2 |
3 | /**
4 | * @ explain:
5 | * @ author:xujun on 2016-7-19 14:54
6 | * @ email:gdutxiaoxu@163.com
7 | */
8 | public class ServerException extends RuntimeException {
9 | public int code;
10 | public String message;
11 | }
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/retrofit/BaiDuNewsConfig.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network.retrofit;
2 |
3 | import com.xujun.funapp.beans.TxNewsClassify;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 |
8 | /**
9 | * @ explain:
10 | * @ author:xujun on 2016/10/28 16:03
11 | * @ email:gdutxiaoxu@163.com
12 | */
13 | public class BaiDuNewsConfig {
14 |
15 | static BaiDuNewsConfig mInstance;
16 |
17 | List mList;
18 |
19 | public static BaiDuNewsConfig getInstance(){
20 | if(mInstance==null){
21 | mInstance=new BaiDuNewsConfig();
22 | }
23 | return mInstance;
24 |
25 | }
26 |
27 | public static final String[] mTitles=new String[]{
28 | "世界","科技","体育"
29 | };
30 |
31 | public static final String[] mTypes=new String[]{
32 | "world","keji","tiyu"
33 | };
34 |
35 | public List getList(){
36 | if(mList==null){
37 | mList=new ArrayList<>();
38 | for(int i=0;i downLoadImage();
15 |
16 | @GET("getImg")
17 | Call downLoad(String url);
18 | }
19 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/retrofit/TnGouAPi.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network.retrofit;
2 |
3 | import com.xujun.funapp.beans.PictureClassify;
4 | import com.xujun.funapp.beans.PictureDetailBean;
5 | import com.xujun.funapp.beans.PictureListBean;
6 | import com.xujun.funapp.beans.Test;
7 |
8 | import okhttp3.ResponseBody;
9 | import retrofit2.Call;
10 | import retrofit2.http.Body;
11 | import retrofit2.http.Field;
12 | import retrofit2.http.FormUrlEncoded;
13 | import retrofit2.http.GET;
14 | import retrofit2.http.POST;
15 | import retrofit2.http.Query;
16 | import rx.Observable;
17 |
18 | /**
19 | * Created by xujun、on 2016/4/20.
20 | */
21 | public interface TnGouAPi {
22 | //检验MD5
23 | @GET("checkImg")
24 | Observable checkMD5(@Query("md5") String MD5);
25 |
26 | // 获取图片列表
27 | @GET("tnfs/api/list")
28 | Observable getPictureList(@Query("page") String page,
29 | @Query("rows") String rows,
30 | @Query("id") int id);
31 |
32 | @FormUrlEncoded
33 | @POST("updateGestureCode")
34 | Observable updateGestureCode(@Field("staffNo") String staffNo,
35 | @Field("gestureCode") String gestureCode, @Field
36 | ("state") int state);
37 |
38 | //获取图片分类
39 | @GET("tnfs/api/classify")
40 | Observable pictureClassify();
41 |
42 | @POST("/api.php")
43 | Call getTest(@Body Test test);
44 |
45 | // http://www.tngou.net/tnfs/api/show?id=9
46 |
47 | // 获取图片列表
48 | @GET("tnfs/api/show")
49 | Observable getPictureDetail(@Query("id") int id);
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/retrofit/TxApi.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network.retrofit;
2 |
3 | import com.xujun.funapp.beans.TxNews;
4 |
5 | import retrofit2.http.GET;
6 | import retrofit2.http.Headers;
7 | import retrofit2.http.Path;
8 | import retrofit2.http.Query;
9 | import rx.Observable;
10 |
11 | /**
12 | * @ explain:
13 | * @ author:xujun on 2016/10/28 15:19
14 | * @ email:gdutxiaoxu@163.com
15 | */
16 | public interface TxApi {
17 |
18 | /* http://apis.baidu.com/txapi/social/social*/
19 |
20 |
21 | @GET("txapi/{type_default}/{type_default}")
22 | Observable getNews(@Path("type_default") String type, @Query("num") int num,
23 | @Query("page") int page);
24 |
25 |
26 |
27 | @GET("txapi/tiYu/tiYu")
28 | Observable tiYu(@Query("num") int num, @Query("page") int page);
29 |
30 | @Headers({"apikey:81bf9da930c7f9825a3c3383f1d8d766" ,"Content-Type:application/json"})
31 | @GET("txapi/world/world")
32 | Observable world(@Query("num") int num, @Query("page") int page);
33 |
34 | @Headers({"apikey:81bf9da930c7f9825a3c3383f1d8d766" ,"Content-Type:application/json"})
35 | @GET("txapi/keji/keji")
36 | Observable keji(@Query("num") int num, @Query("page") int page);
37 |
38 | @Headers({"apikey:81bf9da930c7f9825a3c3383f1d8d766" ,"Content-Type:application/json"})
39 | @GET("txapi/social/social")
40 | Observable social(@Query("num") int num, @Query("page") int page);
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/retrofitclient/BaseInterceptor.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network.retrofitclient;
2 | import java.io.IOException;
3 | import java.util.Map;
4 | import java.util.Set;
5 |
6 | import okhttp3.Interceptor;
7 | import okhttp3.Request;
8 | import okhttp3.Response;
9 |
10 | /**
11 | * BaseInterceptor
12 | * Created by LIUYONGKUI726 on 2016-06-30.
13 | * {@link # https://github.com/NeglectedByBoss/RetrofitClient}
14 | */
15 | public class BaseInterceptor implements Interceptor{
16 | private Map headers;
17 | public BaseInterceptor(Map headers) {
18 | this.headers = headers;
19 | }
20 |
21 | @Override
22 | public Response intercept(Chain chain) throws IOException {
23 |
24 |
25 | Request.Builder builder = chain.request()
26 | .newBuilder();
27 |
28 | if (headers != null && headers.size() > 0) {
29 | Set keys = headers.keySet();
30 | for (String headerKey : keys) {
31 | builder.addHeader(headerKey, headers.get(headerKey)).build();
32 | }
33 | }
34 | return chain.proceed(builder.build());
35 |
36 | }
37 | }
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/retrofitclient/CustomIntercept.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network.retrofitclient;
2 |
3 | import com.xujun.funapp.common.util.WriteLogUtil;
4 |
5 | import java.io.IOException;
6 | import java.util.Locale;
7 |
8 | import okhttp3.Interceptor;
9 | import okhttp3.Request;
10 | import okhttp3.Response;
11 |
12 | /**
13 | * @author xujun on 2016/12/23.
14 | * @email gdutxiaoxu@163.com
15 | */
16 |
17 | public class CustomIntercept implements Interceptor {
18 | @Override
19 | public Response intercept(Chain chain) throws IOException {
20 | Response response = null;
21 | Request request = null;
22 | try {
23 | request = chain.request();
24 | response=chain.proceed(request);
25 | WriteLogUtil.i("请求的url是" + request.url());
26 | } catch (IOException e) {
27 | throw new HttpIOException(request, e);
28 | }
29 |
30 |
31 | return response;
32 | }
33 |
34 | private static class HttpIOException extends IOException {
35 |
36 | HttpIOException(final Request request, final IOException e) {
37 | super(String.format(Locale.US, "IOException during http request. Request= %s",
38 | request), e);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Fun/src/main/java/com/xujun/funapp/network/retrofitclient/NetworkApi.java:
--------------------------------------------------------------------------------
1 | package com.xujun.funapp.network.retrofitclient;
2 |
3 | import com.xujun.funapp.beans.YiYuanNewsClassify;
4 | import com.xujun.funapp.beans.YiYuanResponse;
5 |
6 | import java.util.Map;
7 |
8 | import okhttp3.RequestBody;
9 | import okhttp3.ResponseBody;
10 | import retrofit2.http.Body;
11 | import retrofit2.http.GET;
12 | import retrofit2.http.POST;
13 | import retrofit2.http.Path;
14 | import retrofit2.http.QueryMap;
15 | import retrofit2.http.Url;
16 | import rx.Observable;
17 |
18 | /**
19 | * @author xujun on 2016/12/23.
20 | * @email gdutxiaoxu@163.com
21 | */
22 |
23 | public interface NetworkApi {
24 |
25 | public final static String mBaseUrl = "https://route.showapi.com/109-34/";
26 |
27 | @GET
28 | Observable executeGet(@Url String url, @QueryMap Map paramsMap);
29 |
30 | @POST
31 | Observable executePost(@Url String url,
32 | // @Header("") String authorization,
33 | @QueryMap Map maps);
34 |
35 | @POST("./")
36 | Observable json(@Url String url, @Body RequestBody jsonStr);
37 |
38 | @GET("{url}")
39 | Observable