├── .gitignore ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── accmobile │ │ └── httpcapturedemo │ │ ├── App.java │ │ ├── activity │ │ ├── GetSingleActivity.java │ │ ├── MainActivity.java │ │ ├── PostVideoListActivity.java │ │ └── WebViewActivity.java │ │ ├── adapter │ │ └── VideoItemAdapter.java │ │ ├── entity │ │ ├── SingleBean.java │ │ └── VideoBean.java │ │ ├── http │ │ ├── APIS.java │ │ ├── AccOkHttpUtil.java │ │ ├── BaseOkGoUtils.java │ │ ├── HttpLoggingInterceptor.java │ │ └── StringResultCallBack.java │ │ └── util │ │ ├── DateUtil.java │ │ └── IOUtils.java │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ └── ic_launcher_background.xml │ ├── layout │ ├── activity_get_single.xml │ ├── activity_main.xml │ ├── activity_video_list.xml │ ├── activity_web_view.xml │ └── item_video_list.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-mdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── mipmap-xxxhdpi │ ├── ic_launcher.png │ └── ic_launcher_round.png │ ├── values-night │ └── themes.xml │ ├── values │ ├── colors.xml │ ├── strings.xml │ └── themes.xml │ └── xml │ └── network_security_config.xml ├── build.gradle ├── build └── intermediates │ └── lint-cache │ ├── api-versions-15-31.0.1.bin │ ├── sdk-registry.xml │ └── sdk-registry.xml │ └── typos-en.txt-2.bin ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── httpcapturelibrary ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── cdel │ │ └── accmobile │ │ └── httpcapture │ │ ├── activity │ │ ├── HttpCaptureDetailActivity.java │ │ ├── HttpCaptureHomeActivity.java │ │ ├── HttpCaptureJsonActivity.java │ │ └── HttpCaptureListActivity.java │ │ ├── adapter │ │ └── CaptureInterfaceItemAdapter.java │ │ ├── base │ │ ├── BaseActivity.java │ │ └── BaseInterface.java │ │ ├── manager │ │ ├── CaptureConstants.java │ │ ├── HttpCaptureData.java │ │ └── HttpCaptureManager.java │ │ ├── model │ │ └── CaptureInterfaceItemBean.java │ │ ├── receiver │ │ └── NetworkConnectChangedReceiver.java │ │ ├── util │ │ ├── HttpCaptureGsonUtil.java │ │ ├── HttpCaptureSPUtil.java │ │ ├── JsonUtil.java │ │ ├── KeyboardUtil.java │ │ ├── ListUtils.java │ │ ├── ViewUtil.java │ │ └── WifiUtil.java │ │ └── widget │ │ ├── JsonViewer.java │ │ ├── SearchView.java │ │ ├── SelectableTextView.java │ │ └── floatwindow │ │ ├── FloatPhone.java │ │ ├── FloatToast.java │ │ ├── FloatView.java │ │ ├── FloatWindow.java │ │ ├── FloatWindowManager.java │ │ ├── HttpCaptureOverlayWindow.java │ │ ├── IFloatWindow.java │ │ ├── IFloatWindowImpl.java │ │ ├── Miui.java │ │ ├── MoveType.java │ │ ├── PermissionListener.java │ │ ├── PermissionUtil.java │ │ ├── Rom.java │ │ ├── Screen.java │ │ ├── ScreenUtil.java │ │ ├── ViewStateListener.java │ │ └── rom │ │ ├── HuaweiUtils.java │ │ ├── MeizuUtils.java │ │ ├── MiuiUtils.java │ │ ├── OppoUtils.java │ │ ├── QikuUtils.java │ │ └── RomUtils.java │ └── res │ ├── drawable-xhdpi │ ├── dl_btn_delete.png │ ├── icon_nav_btn_back.png │ ├── icon_toggle_off.png │ ├── icon_toggle_on.png │ ├── searchbar_clean.png │ └── searchbar_icon_search.png │ ├── drawable │ ├── background.xml │ ├── bg_log_float_window.xml │ ├── edit_dialog_bg.xml │ ├── news_checkbox_button.xml │ └── search_title_bg.xml │ ├── layout │ ├── activity_debug_detail.xml │ ├── activity_debug_home.xml │ ├── activity_debug_json.xml │ ├── activity_debug_list.xml │ ├── debug_float_window.xml │ ├── dialog_edit_name.xml │ ├── include_jsonview.xml │ ├── item_debug_request_list.xml │ ├── search_view_layout.xml │ └── toolbar_layout.xml │ └── values │ ├── attrs.xml │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ ├── styles.xml │ └── themes.xml ├── images ├── 图片1.png ├── 图片10.png ├── 图片2.png ├── 图片3.png ├── 图片4.png ├── 图片5.png ├── 图片6.png ├── 图片7.png ├── 图片8.png └── 图片9.png ├── readme.md └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | /.gradle 2 | /.idea 3 | local.properties 4 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | compileSdkVersion 30 7 | buildToolsVersion "30.0.2" 8 | 9 | defaultConfig { 10 | applicationId "com.accmobile.androidhttpcapture" 11 | minSdkVersion 21 12 | targetSdkVersion 30 13 | versionCode 1 14 | versionName "1.0" 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | compileOptions { 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | } 28 | 29 | dependencies { 30 | // implementation project(':httpcapturelibrary') 31 | implementation 'com.cdel.acc:httpcapture:1.0.0' 32 | implementation 'androidx.appcompat:appcompat:1.2.0' 33 | implementation 'com.google.android.material:material:1.2.1' 34 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 35 | implementation 'com.google.code.gson:gson:2.8.5' 36 | // 网络框架 37 | implementation 'com.squareup.okhttp3:okhttp:4.3.0' 38 | implementation 'com.lzy.net:okhttputils:1.8.1' 39 | // glide 40 | implementation 'com.github.bumptech.glide:glide:4.12.0' 41 | annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' 42 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | #glide 23 | -keep public class * implements com.bumptech.glide.module.GlideModule 24 | -keep class * extends com.bumptech.glide.module.AppGlideModule { 25 | (...); 26 | } 27 | -keep public enum com.bumptech.glide.load.ImageHeaderParser$** { 28 | **[] $VALUES; 29 | public *; 30 | } 31 | -keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder { 32 | *** rewind(); 33 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/accmobile/httpcapturedemo/App.java: -------------------------------------------------------------------------------- 1 | package com.accmobile.httpcapturedemo; 2 | 3 | import android.app.Application; 4 | 5 | import com.accmobile.httpcapturedemo.http.BaseOkGoUtils; 6 | import com.cdel.accmobile.httpcapture.manager.HttpCaptureManager; 7 | 8 | 9 | /** 10 | * @author zhangbaoyu 11 | * @time 2/19/21 2:33 PM 12 | */ 13 | public class App extends Application { 14 | private static Application application; 15 | 16 | @Override 17 | public void onCreate() { 18 | super.onCreate(); 19 | application = this; 20 | BaseOkGoUtils.init(this); 21 | HttpCaptureManager.getInstance().init(this); 22 | } 23 | 24 | /** 25 | * 获取Application上下文 26 | * 27 | * @author zhangbaoyu 28 | * @time 2/26/21 11:27 AM 29 | */ 30 | public static Application getApplication() { 31 | return application; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/accmobile/httpcapturedemo/activity/GetSingleActivity.java: -------------------------------------------------------------------------------- 1 | package com.accmobile.httpcapturedemo.activity; 2 | 3 | import android.view.View; 4 | import android.widget.TextView; 5 | 6 | import com.accmobile.httpcapturedemo.R; 7 | import com.accmobile.httpcapturedemo.entity.SingleBean; 8 | import com.accmobile.httpcapturedemo.http.AccOkHttpUtil; 9 | import com.accmobile.httpcapturedemo.http.StringResultCallBack; 10 | import com.cdel.accmobile.httpcapture.base.BaseActivity; 11 | import com.cdel.accmobile.httpcapture.util.HttpCaptureGsonUtil; 12 | 13 | public class GetSingleActivity extends BaseActivity { 14 | 15 | private TextView mTvSingleStr; 16 | 17 | @Override 18 | public int setLayoutId() { 19 | return R.layout.activity_get_single; 20 | } 21 | 22 | @Override 23 | public void initViews() { 24 | mTvSingleStr = findViewById(R.id.tv_single); 25 | } 26 | 27 | @Override 28 | public void initToolBar() { 29 | getTitleView().setText(R.string.get_agent); 30 | } 31 | 32 | @Override 33 | public void setListeners() { 34 | getLeftView().setOnClickListener(new View.OnClickListener() { 35 | @Override 36 | public void onClick(View v) { 37 | finish(); 38 | } 39 | }); 40 | } 41 | 42 | @Override 43 | public void initData() { 44 | AccOkHttpUtil.getPoetryOne(new StringResultCallBack() { 45 | @Override 46 | public void onStringResult(String sResult) { 47 | SingleBean singleBean = HttpCaptureGsonUtil.jsonToObject(sResult, SingleBean.class); 48 | if (singleBean != null && singleBean.getCode() == 200) { 49 | runOnUiThread(new Runnable() { 50 | @Override 51 | public void run() { 52 | mTvSingleStr.setText(singleBean.getResult()); 53 | } 54 | }); 55 | } 56 | } 57 | 58 | @Override 59 | public void onStringError() { 60 | 61 | } 62 | }); 63 | 64 | } 65 | } -------------------------------------------------------------------------------- /app/src/main/java/com/accmobile/httpcapturedemo/activity/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.accmobile.httpcapturedemo.activity; 2 | 3 | import android.view.View; 4 | import android.widget.Button; 5 | 6 | import com.accmobile.httpcapturedemo.R; 7 | import com.cdel.accmobile.httpcapture.activity.HttpCaptureHomeActivity; 8 | import com.cdel.accmobile.httpcapture.base.BaseActivity; 9 | import com.cdel.accmobile.httpcapture.util.HttpCaptureSPUtil; 10 | 11 | public class MainActivity extends BaseActivity { 12 | 13 | private Button mBtDebugEnter, mBtDebugGet, mBtDebugPost, mBtDebugH5; 14 | 15 | private boolean isOpen; 16 | 17 | @Override 18 | public int setLayoutId() { 19 | return R.layout.activity_main; 20 | } 21 | 22 | @Override 23 | public void initViews() { 24 | getLeftView().setVisibility(View.GONE); 25 | mBtDebugEnter = findViewById(R.id.bt_debug_enter); 26 | mBtDebugGet = findViewById(R.id.bt_debug_get); 27 | mBtDebugPost = findViewById(R.id.bt_debug_post); 28 | mBtDebugH5 = findViewById(R.id.bt_debug_h5); 29 | } 30 | 31 | @Override 32 | public void initToolBar() { 33 | 34 | } 35 | 36 | @Override 37 | protected void onResume() { 38 | super.onResume(); 39 | isOpen = HttpCaptureSPUtil.getIsOpenCapture(); 40 | } 41 | 42 | @Override 43 | public void setListeners() { 44 | mBtDebugEnter.setOnClickListener(new View.OnClickListener() { 45 | @Override 46 | public void onClick(View v) { 47 | HttpCaptureHomeActivity.start(MainActivity.this); 48 | } 49 | }); 50 | mBtDebugGet.setOnClickListener(new View.OnClickListener() { 51 | @Override 52 | public void onClick(View v) { 53 | if (isOpen) { 54 | startActivity(GetSingleActivity.class); 55 | } else { 56 | showShortToast("请先开启抓包入口"); 57 | } 58 | } 59 | }); 60 | mBtDebugPost.setOnClickListener(new View.OnClickListener() { 61 | @Override 62 | public void onClick(View v) { 63 | if (isOpen) { 64 | startActivity(PostVideoListActivity.class); 65 | } else { 66 | showShortToast("请先开启抓包入口"); 67 | } 68 | } 69 | }); 70 | mBtDebugH5.setOnClickListener(new View.OnClickListener() { 71 | @Override 72 | public void onClick(View v) { 73 | if (isOpen) { 74 | startActivity(WebViewActivity.class); 75 | } else { 76 | showShortToast("请先开启抓包入口"); 77 | } 78 | } 79 | }); 80 | } 81 | 82 | @Override 83 | public void initData() { 84 | } 85 | 86 | } -------------------------------------------------------------------------------- /app/src/main/java/com/accmobile/httpcapturedemo/activity/PostVideoListActivity.java: -------------------------------------------------------------------------------- 1 | package com.accmobile.httpcapturedemo.activity; 2 | 3 | import android.view.View; 4 | 5 | import androidx.recyclerview.widget.LinearLayoutManager; 6 | import androidx.recyclerview.widget.RecyclerView; 7 | 8 | import com.accmobile.httpcapturedemo.R; 9 | import com.accmobile.httpcapturedemo.adapter.VideoItemAdapter; 10 | import com.accmobile.httpcapturedemo.http.AccOkHttpUtil; 11 | import com.accmobile.httpcapturedemo.http.StringResultCallBack; 12 | import com.accmobile.httpcapturedemo.entity.VideoBean; 13 | import com.cdel.accmobile.httpcapture.base.BaseActivity; 14 | import com.cdel.accmobile.httpcapture.util.HttpCaptureGsonUtil; 15 | import com.lzy.okhttputils.model.HttpParams; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * @author zhangbaoyu 21 | * @time 2/19/21 5:58 PM 22 | */ 23 | public class PostVideoListActivity extends BaseActivity { 24 | 25 | private RecyclerView videoRecyclerView; 26 | 27 | private VideoItemAdapter videoItemAdapter; 28 | 29 | @Override 30 | public int setLayoutId() { 31 | return R.layout.activity_video_list; 32 | } 33 | 34 | @Override 35 | public void initViews() { 36 | videoRecyclerView = findViewById(R.id.video_recyclerview); 37 | videoRecyclerView.setLayoutManager(new LinearLayoutManager(this)); 38 | videoItemAdapter = new VideoItemAdapter(); 39 | videoRecyclerView.setAdapter(videoItemAdapter); 40 | } 41 | 42 | @Override 43 | public void initToolBar() { 44 | getTitleView().setText(R.string.post_agent); 45 | } 46 | 47 | @Override 48 | public void setListeners() { 49 | getLeftView().setOnClickListener(new View.OnClickListener() { 50 | @Override 51 | public void onClick(View v) { 52 | finish(); 53 | } 54 | }); 55 | } 56 | 57 | @Override 58 | public void initData() { 59 | HttpParams httpParams = new HttpParams(); 60 | httpParams.put("id", 14); 61 | AccOkHttpUtil.postVideoList(httpParams, new StringResultCallBack() { 62 | @Override 63 | public void onStringResult(String sResult) { 64 | VideoBean videoBean = HttpCaptureGsonUtil.jsonToObject(sResult, VideoBean.class); 65 | List videoList = videoBean.getResult(); 66 | videoItemAdapter.setList(videoList); 67 | videoItemAdapter.notifyDataSetChanged(); 68 | } 69 | 70 | @Override 71 | public void onStringError() { 72 | 73 | } 74 | }); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/com/accmobile/httpcapturedemo/activity/WebViewActivity.java: -------------------------------------------------------------------------------- 1 | package com.accmobile.httpcapturedemo.activity; 2 | 3 | import android.text.TextUtils; 4 | import android.util.Log; 5 | import android.view.View; 6 | import android.webkit.WebChromeClient; 7 | import android.webkit.WebView; 8 | 9 | import com.accmobile.httpcapturedemo.R; 10 | import com.accmobile.httpcapturedemo.util.DateUtil; 11 | import com.cdel.accmobile.httpcapture.base.BaseActivity; 12 | import com.cdel.accmobile.httpcapture.manager.HttpCaptureData; 13 | 14 | import java.util.Date; 15 | import java.util.concurrent.TimeUnit; 16 | import java.util.concurrent.atomic.AtomicBoolean; 17 | 18 | public class WebViewActivity extends BaseActivity { 19 | 20 | private WebView mWebView; 21 | 22 | private String url = "https://www.baidu.com/"; 23 | 24 | private long startNs; 25 | 26 | private long tookMs; 27 | 28 | @Override 29 | public int setLayoutId() { 30 | return R.layout.activity_web_view; 31 | } 32 | 33 | @Override 34 | public void initViews() { 35 | mWebView = findViewById(R.id.webview); 36 | } 37 | 38 | @Override 39 | public void initToolBar() { 40 | getTitleView().setText(R.string.h5_agent); 41 | } 42 | 43 | @Override 44 | public void setListeners() { 45 | getLeftView().setOnClickListener(new View.OnClickListener() { 46 | @Override 47 | public void onClick(View v) { 48 | finish(); 49 | } 50 | }); 51 | } 52 | 53 | @Override 54 | public void initData() { 55 | loadUrl(mWebView, url, new OnLoadFinishListener() { 56 | @Override 57 | public void onLoadFinish() { 58 | String dateStr = DateUtil.getString(new Date(), DateUtil.PATTERN_HMS); 59 | HttpCaptureData.getSingleton().create() 60 | .setCaptureUrl(url) 61 | .setCaptureHost("h5-") 62 | .setCaptureTime(tookMs + "ms") 63 | .setCaptureDate(dateStr) 64 | .add(); 65 | } 66 | }); 67 | } 68 | 69 | private void loadUrl(final WebView webView, String url, final OnLoadFinishListener listener) { 70 | if (TextUtils.isEmpty(url)) 71 | return; 72 | // 启用javascript 73 | webView.getSettings().setJavaScriptEnabled(true); 74 | //用这个方法判断是否加载完成,不过会触发多次,就是会出现多次newProgress==100的情况 75 | webView.setWebChromeClient(new WebChromeClient() { 76 | private AtomicBoolean mIsLoadFinish = new AtomicBoolean(false); 77 | 78 | @Override 79 | public void onProgressChanged(WebView view, int newProgress) { 80 | super.onProgressChanged(view, newProgress); 81 | Log.e("onProgressChanged", newProgress + ""); 82 | if (newProgress == 10) { 83 | startNs = System.nanoTime(); 84 | } 85 | if (newProgress == 100) { 86 | if (!mIsLoadFinish.compareAndSet(false, true)) { 87 | return; 88 | } 89 | if (listener != null) { 90 | tookMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNs); 91 | listener.onLoadFinish(); 92 | } 93 | } 94 | } 95 | }); 96 | webView.loadUrl(url); 97 | } 98 | 99 | private interface OnLoadFinishListener { 100 | void onLoadFinish(); 101 | } 102 | } -------------------------------------------------------------------------------- /app/src/main/java/com/accmobile/httpcapturedemo/adapter/VideoItemAdapter.java: -------------------------------------------------------------------------------- 1 | package com.accmobile.httpcapturedemo.adapter; 2 | 3 | import android.view.View; 4 | import android.view.ViewGroup; 5 | import android.widget.ImageView; 6 | import android.widget.TextView; 7 | 8 | import androidx.annotation.NonNull; 9 | import androidx.recyclerview.widget.RecyclerView; 10 | 11 | import com.accmobile.httpcapturedemo.R; 12 | import com.accmobile.httpcapturedemo.entity.VideoBean; 13 | import com.bumptech.glide.Glide; 14 | import com.cdel.accmobile.httpcapture.util.ListUtils; 15 | import com.cdel.accmobile.httpcapture.util.ViewUtil; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * @author zhangbaoyu 21 | * @time 2/19/21 6:12 PM 22 | */ 23 | public class VideoItemAdapter extends RecyclerView.Adapter { 24 | private List mList; 25 | 26 | public void setList(List list) { 27 | mList = list; 28 | } 29 | 30 | @NonNull 31 | @Override 32 | public VideoItemHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { 33 | View itemView = ViewUtil.getItemView(parent.getContext(), R.layout.item_video_list, null); 34 | return new VideoItemHolder(itemView); 35 | } 36 | 37 | @Override 38 | public void onBindViewHolder(@NonNull VideoItemHolder holder, int position) { 39 | VideoBean.Result result = mList.get(position); 40 | if (result != null) { 41 | holder.mTvVideoTitle.setText(result.getData().getHeader().getTitle()); 42 | Glide.with(holder.mIvIcon.getContext()).load(result.getData().getHeader().getIcon()).into(holder.mIvIcon); 43 | } 44 | } 45 | 46 | @Override 47 | public int getItemCount() { 48 | if (ListUtils.isEmpty(mList)) { 49 | return 0; 50 | } 51 | return mList.size(); 52 | } 53 | 54 | static class VideoItemHolder extends RecyclerView.ViewHolder { 55 | 56 | private final TextView mTvVideoTitle; 57 | 58 | private final ImageView mIvIcon; 59 | 60 | VideoItemHolder(View itemView) { 61 | super(itemView); 62 | mTvVideoTitle = itemView.findViewById(R.id.tv_video_title); 63 | mIvIcon = itemView.findViewById(R.id.iv_video_icon); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /app/src/main/java/com/accmobile/httpcapturedemo/entity/SingleBean.java: -------------------------------------------------------------------------------- 1 | package com.accmobile.httpcapturedemo.entity; 2 | 3 | /** 4 | * @author zhangbaoyu 5 | * @time 2/23/21 7:30 PM 6 | */ 7 | public class SingleBean { 8 | 9 | /** 10 | * code : 200 11 | * message : 成功! 12 | * result : 因有人恶意刷接口,导致接口调用频繁,接口已经不能稳定运行,所以计划近期下线,积德吧朋友,如果长期如此,所有接口将面临关闭。 13 | */ 14 | 15 | private int code; 16 | 17 | private String message; 18 | 19 | private String result; 20 | 21 | public int getCode() { 22 | return code; 23 | } 24 | 25 | public void setCode(int code) { 26 | this.code = code; 27 | } 28 | 29 | public String getMessage() { 30 | return message; 31 | } 32 | 33 | public void setMessage(String message) { 34 | this.message = message; 35 | } 36 | 37 | public String getResult() { 38 | return result; 39 | } 40 | 41 | public void setResult(String result) { 42 | this.result = result; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/com/accmobile/httpcapturedemo/http/APIS.java: -------------------------------------------------------------------------------- 1 | package com.accmobile.httpcapturedemo.http; 2 | 3 | /** 4 | * @author zhangbaoyu 5 | * @time 2/19/21 3:19 PM 6 | */ 7 | public class APIS { 8 | public static String baseUrl = "https://api.apiopen.top"; 9 | 10 | public static String getPoetryUrl = baseUrl + "/singlePoetry"; 11 | 12 | public static String postVideoUrl = baseUrl + "/videoCategoryDetails"; 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/accmobile/httpcapturedemo/http/AccOkHttpUtil.java: -------------------------------------------------------------------------------- 1 | package com.accmobile.httpcapturedemo.http; 2 | 3 | import com.lzy.okhttputils.OkHttpUtils; 4 | import com.lzy.okhttputils.model.HttpParams; 5 | 6 | public class AccOkHttpUtil { 7 | 8 | public static void getPoetryOne(StringResultCallBack stringResultCallBack) { 9 | OkHttpUtils.get(APIS.getPoetryUrl).execute(stringResultCallBack); 10 | } 11 | 12 | public static void postVideoList(HttpParams httpParams, StringResultCallBack stringResultCallBack) { 13 | OkHttpUtils.post(APIS.postVideoUrl) 14 | .params(httpParams) 15 | .execute(stringResultCallBack); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /app/src/main/java/com/accmobile/httpcapturedemo/http/BaseOkGoUtils.java: -------------------------------------------------------------------------------- 1 | package com.accmobile.httpcapturedemo.http; 2 | 3 | import android.app.Application; 4 | 5 | import com.lzy.okhttputils.OkHttpUtils; 6 | import com.lzy.okhttputils.cookie.store.MemoryCookieStore; 7 | 8 | import java.util.logging.Level; 9 | 10 | /** 11 | * OkHttp初始化类 12 | * 13 | * @author zhangbaoyu 14 | * @time 2/19/21 2:40 PM 15 | */ 16 | public class BaseOkGoUtils { 17 | 18 | public static void init(Application application) { 19 | //必须调用初始化 20 | OkHttpUtils.init(application); 21 | HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor("OkHttp"); 22 | interceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY); //log打印级别,决定了log显示的详细程度 23 | interceptor.setColorLevel(Level.INFO); 24 | OkHttpUtils.getInstance().addInterceptor(interceptor); 25 | OkHttpUtils.getInstance().setCookieStore(new MemoryCookieStore()); 26 | OkHttpUtils.getInstance().setConnectTimeout(10000); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/accmobile/httpcapturedemo/http/StringResultCallBack.java: -------------------------------------------------------------------------------- 1 | package com.accmobile.httpcapturedemo.http; 2 | 3 | import com.lzy.okhttputils.callback.StringCallback; 4 | 5 | import okhttp3.Call; 6 | import okhttp3.Response; 7 | 8 | 9 | /** 10 | * Created by ${USER_NAME} on 2018/10/28. 11 | */ 12 | public abstract class StringResultCallBack extends StringCallback { 13 | 14 | public abstract void onStringResult(String sResult); 15 | 16 | public abstract void onStringError(); 17 | 18 | @Override 19 | public void onSuccess(final String s, Call call, Response response) { 20 | onStringResult(s); 21 | } 22 | 23 | @Override 24 | public void onError(Call call, Response response, Exception e) { 25 | super.onError(call, response, e); 26 | onStringError(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/accmobile/httpcapturedemo/util/DateUtil.java: -------------------------------------------------------------------------------- 1 | package com.accmobile.httpcapturedemo.util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | /** 7 | * @author zhangbaoyu 8 | * @time 2/19/21 4:23 PM 9 | */ 10 | public class DateUtil { 11 | public static final String PATTERN_HMS = "HH:mm:ss"; 12 | 13 | public DateUtil() { 14 | } 15 | 16 | public static String getString(Date date, String pattern) { 17 | try { 18 | SimpleDateFormat format = new SimpleDateFormat(pattern); 19 | return format.format(date); 20 | } catch (Exception var3) { 21 | var3.printStackTrace(); 22 | return ""; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_get_single.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 |