增加发现页

This commit is contained in:
wds
2021-05-26 17:58:12 +08:00
parent 4b28f19d9a
commit 26d444cbf8
154 changed files with 5933 additions and 99 deletions

View File

@@ -42,9 +42,7 @@ android {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//butterknife依赖
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
//状态栏侵染
// 基础依赖包,必须要依赖
@@ -67,6 +65,9 @@ android {
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
//加载图片的依赖包
//加载图片的依赖包
implementation 'com.github.bumptech.glide:glide:4.8.0'
//xRecyclerview下拉刷新控件
implementation project(':xrecyclerview')
}

View File

@@ -1,15 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<activity android:name=".activity.HomeActivity"></activity>
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme.NoActionBar"
>
<activity android:name=".activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -18,6 +22,8 @@
</intent-filter>
</activity>
<activity android:name=".activity.LoginActivity"></activity>
<activity android:name=".activity.HomeActivity"></activity>
<activity android:name=".activity.ManagementFragment"></activity>
</application>
</manifest>

View File

@@ -54,6 +54,7 @@ public class HomeActivity extends BaseActivity {
fragments.add(new RecordFragment());
fragments.add(new FindFragment());
fragments.add(new MineFragment());
mViewPager.setOffscreenPageLimit(3);
mViewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override
@@ -66,6 +67,8 @@ public class HomeActivity extends BaseActivity {
return fragments.size();
}
});
mViewPager.setCanScroll(true);
mViewPager.setNoScrollAnim(false);
mTab.setupWithViewPager(mViewPager);
mTab.getTabAt(0).setText(name[0]).setIcon(pic[0]);
mTab.getTabAt(1).setText(name[1]).setIcon(pic1[1]);

View File

@@ -1,15 +1,13 @@
package com.example.myapplication.activity;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import android.Manifest;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import com.example.myapplication.R;
import com.example.myapplication.base.BaseActivity;
@@ -41,9 +39,22 @@ public class MainActivity extends BaseActivity {
}.start();
}
private void initPermission() {
String[] pers = {
Manifest.permission.RECORD_AUDIO,
Manifest.permission.CAMERA,
Manifest.permission.INTERNET,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.ACCESS_COARSE_LOCATION
};
ActivityCompat.requestPermissions(this, pers, 100);
}
@Override
protected void initView() {
super.initView();
initPermission();
}
}

View File

@@ -9,6 +9,8 @@ import com.example.myapplication.base.BaseActivity;
import com.example.myapplication.fragment.FindFragment;
import com.example.myapplication.fragment.MineFragment;
import com.example.myapplication.fragment.RecordFragment;
import com.example.myapplication.fragment.TaskExplainFragment;
import com.example.myapplication.fragment.TaskPrefectureFragment;
import com.example.myapplication.fragment.TreasureFragment;
import com.gyf.immersionbar.ImmersionBar;
@@ -28,6 +30,8 @@ public class ManagementFragment extends BaseActivity {
private FindFragment findFragment;//发现的fragment
private RecordFragment recordFragment;//纪录的fragment
private TreasureFragment treasureFragment;//寻宝的fragment
private TaskPrefectureFragment taskPrefectureFragment;//发现-任务专区的fragment
private TaskExplainFragment taskExplainFragment;//发现-任务说明的fragment
@Override
@@ -56,6 +60,10 @@ public class ManagementFragment extends BaseActivity {
fragmentTransaction.hide(recordFragment);
if (treasureFragment != null)
fragmentTransaction.hide(treasureFragment);
if (taskPrefectureFragment!=null)
fragmentTransaction.hide(taskPrefectureFragment);
if (taskExplainFragment!=null)
fragmentTransaction.hide(taskExplainFragment);
}
public void selectorFragment(int i) {
@@ -97,6 +105,22 @@ public class ManagementFragment extends BaseActivity {
fragmentTransaction.show(treasureFragment);
}
break;
case 7:
if (taskPrefectureFragment==null){
taskPrefectureFragment=new TaskPrefectureFragment();
fragmentTransaction.add(R.id.frame_layout,taskPrefectureFragment);
}else {
fragmentTransaction.show(taskPrefectureFragment);
}
break;
case 8:
if (taskExplainFragment==null){
taskExplainFragment=new TaskExplainFragment();
fragmentTransaction.add(R.id.frame_layout,taskExplainFragment);
}else {
fragmentTransaction.show(taskExplainFragment);
}
break;
}
fragmentTransaction.commit();
@@ -118,7 +142,12 @@ public class ManagementFragment extends BaseActivity {
case 4:
treasureFragment.onActivityResult(requestCode, resultCode, data);
break;
case 7:
taskPrefectureFragment.onActivityResult(requestCode, resultCode, data);
break;
case 8:
taskExplainFragment.onActivityResult(requestCode, resultCode, data);
break;
}
}
private void setZtlTextColor() {

View File

@@ -2,6 +2,19 @@ package com.example.myapplication.api;
import android.app.Application;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.cache.CacheEntity;
import com.lzy.okgo.cache.CacheMode;
import com.lzy.okgo.cookie.CookieJarImpl;
import com.lzy.okgo.cookie.store.DBCookieStore;
import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
import com.lzy.okgo.model.HttpHeaders;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import okhttp3.OkHttpClient;
public class UserApplication extends Application {
public static UserApplication userApplication;
@@ -10,11 +23,49 @@ public class UserApplication extends Application {
public void onCreate() {
super.onCreate();
userApplication=this;
initOkGo();
}
public static UserApplication getUserApplication() {
return userApplication;
}
private void initOkGo() {
OkHttpClient.Builder builder = new OkHttpClient.Builder();
//log相关
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor("OkGo");
//log打印级别决定了log显示的详细程度
loggingInterceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY);
//log颜色级别决定了log在控制台显示的颜色
loggingInterceptor.setColorLevel(Level.INFO);
//设置请求头,token值
HttpHeaders headers = new HttpHeaders();
//headers.put("X-Access-Token", SPUtils.get(SpKey.TOKEN, "")+"");
// LogUtils.v("X-Access-Token:" + SPUtils.get(SpKey.TOKEN, ""));
builder.addInterceptor(loggingInterceptor);
//自动管理cookie或者叫session的保持以下几种任选其一就行
//使用sp保持cookie如果cookie不过期则一直有效
//builder.cookieJar(new CookieJarImpl(new SPCookieStore(this)));
//使用数据库保持cookie如果cookie不过期则一直有效
builder.cookieJar(new CookieJarImpl(new DBCookieStore(this)));
//使用内存保持cookieapp退出后cookie消失
//builder.cookieJar(new CookieJarImpl(new MemoryCookieStore()));
//超时时间设置默认60秒
//全局的读取超时时间
builder.readTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS);
//全局的写入超时时间
builder.writeTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS);
//全局的连接超时时间
builder.connectTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS);
OkGo.getInstance().init(this)
.setOkHttpClient(builder.build())
//全局统一缓存模式,默认不使用缓存,可以不传
.setCacheMode(CacheMode.NO_CACHE)
//全局统一缓存时间,默认永不过期,可以不传
.setCacheTime(CacheEntity.CACHE_NEVER_EXPIRE)
//设置公共请求头
.addCommonHeaders(headers)
//全局统一超时重连次数默认为三次那么最差的情况会请求4次(一次原始请求,三次重连请求)不需要可以设置为0;
.setRetryCount(0);
}
}

View File

@@ -5,9 +5,6 @@ import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
@@ -15,16 +12,12 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.example.myapplication.R;
import com.example.myapplication.api.UserApplication;
import com.gyf.immersionbar.ImmersionBar;
import butterknife.ButterKnife;
import butterknife.Unbinder;
public abstract class BaseActivity extends AppCompatActivity {
private Unbinder bind;
private AlertDialog alertDialog;
@Override
@@ -35,7 +28,7 @@ public abstract class BaseActivity extends AppCompatActivity {
ImmersionBar.with(this).init();
Collector.addActivity(this);
setContentView(getLayout());
bind = ButterKnife.bind(this);
initMVP();
initView();
initData();
@@ -91,7 +84,6 @@ public abstract class BaseActivity extends AppCompatActivity {
protected void onDestroy() {
super.onDestroy();
Collector.removeActivity(this);
bind.unbind();
}
/**
* 设置屏幕横竖屏切换

View File

@@ -13,23 +13,22 @@ import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import butterknife.ButterKnife;
import butterknife.Unbinder;
public abstract class BaseFragment extends Fragment {
private Unbinder bind;
private AlertDialog alertDialog;
public View mView;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View inflate = inflater.inflate(getLayout(), container, false);
bind = ButterKnife.bind(this, inflate);
mView = LayoutInflater.from(getActivity()).inflate(getLayout(), container, false);
initMvp();
initView();
initData();
return inflate;
return mView;
}
protected void initMvp() {
@@ -75,6 +74,5 @@ public abstract class BaseFragment extends Fragment {
@Override
public void onDestroyView() {
super.onDestroyView();
bind.unbind();
}
}

View File

@@ -0,0 +1,38 @@
package com.example.myapplication.bean;
public class ListBean {
/**
* id : 1
* username : kenny
* sex : 6
*/
private int id;
private String username;
private int sex;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
}

View File

@@ -0,0 +1,144 @@
package com.example.myapplication.bean;
import java.util.List;
/**
* 任务说明点击
*/
public class TaskSpecificationBean {
/**
* msg : 成功
* body : {"rownum":0,"data":[{"Subtitle":"","createtime":"","src":"http://10.130.23.166:8080/cbt/img/blue.png","id":11,"title":"标题11"},{"Subtitle":"","createtime":"","src":"http://10.130.23.166:8080/cbt/img/blue.png","id":12,"title":"标题12"},{"Subtitle":"","createtime":"","src":"http://10.130.23.166:8080/cbt/img/blue.png","id":13,"title":"标题13"}],"numFound":100,"rows":10}
* status : 0
*/
private String msg;
private BodyBean body;
private int status;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public BodyBean getBody() {
return body;
}
public void setBody(BodyBean body) {
this.body = body;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public static class BodyBean {
/**
* rownum : 0
* data : [{"Subtitle":"","createtime":"","src":"http://10.130.23.166:8080/cbt/img/blue.png","id":11,"title":"标题11"},{"Subtitle":"","createtime":"","src":"http://10.130.23.166:8080/cbt/img/blue.png","id":12,"title":"标题12"},{"Subtitle":"","createtime":"","src":"http://10.130.23.166:8080/cbt/img/blue.png","id":13,"title":"标题13"}]
* numFound : 100
* rows : 10
*/
private int rownum;
private int numFound;
private int rows;
private List<DataBean> data;
public int getRownum() {
return rownum;
}
public void setRownum(int rownum) {
this.rownum = rownum;
}
public int getNumFound() {
return numFound;
}
public void setNumFound(int numFound) {
this.numFound = numFound;
}
public int getRows() {
return rows;
}
public void setRows(int rows) {
this.rows = rows;
}
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public static class DataBean {
/**
* Subtitle :
* createtime :
* src : http://10.130.23.166:8080/cbt/img/blue.png
* id : 11
* title : 标题11
*/
private String Subtitle;
private String createtime;
private String src;
private int id;
private String title;
public String getSubtitle() {
return Subtitle;
}
public void setSubtitle(String Subtitle) {
this.Subtitle = Subtitle;
}
public String getCreatetime() {
return createtime;
}
public void setCreatetime(String createtime) {
this.createtime = createtime;
}
public String getSrc() {
return src;
}
public void setSrc(String src) {
this.src = src;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
}
}

View File

@@ -0,0 +1,144 @@
package com.example.myapplication.bean;
import java.util.List;
/**
* 任务专区bean
*/
public class TaskZoneBean {
/**
* msg : 成功
* body : {"rownum":0,"data":[{"Subtitle":"说明0","createtime":"2021-05-26 15:33:51","src":"","id":0,"title":"标题0"},{"Subtitle":"说明1","createtime":"2021-05-26 15:33:51","src":"","id":1,"title":"标题1"},{"Subtitle":"说明2","createtime":"2021-05-26 15:33:51","src":"","id":2,"title":"标题2"},{"Subtitle":"说明3","createtime":"2021-05-26 15:33:51","src":"","id":3,"title":"标题3"},{"Subtitle":"说明4","createtime":"2021-05-26 15:33:51","src":"","id":4,"title":"标题4"},{"Subtitle":"说明5","createtime":"2021-05-26 15:33:51","src":"","id":5,"title":"标题5"},{"Subtitle":"说明6","createtime":"2021-05-26 15:33:51","src":"","id":6,"title":"标题6"},{"Subtitle":"说明7","createtime":"2021-05-26 15:33:51","src":"","id":7,"title":"标题7"},{"Subtitle":"说明8","createtime":"2021-05-26 15:33:51","src":"","id":8,"title":"标题8"},{"Subtitle":"说明9","createtime":"2021-05-26 15:33:51","src":"","id":9,"title":"标题9"}],"numFound":100,"rows":10}
* status : 0
*/
private String msg;
private BodyBean body;
private int status;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public BodyBean getBody() {
return body;
}
public void setBody(BodyBean body) {
this.body = body;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public static class BodyBean {
/**
* rownum : 0
* data : [{"Subtitle":"说明0","createtime":"2021-05-26 15:33:51","src":"","id":0,"title":"标题0"},{"Subtitle":"说明1","createtime":"2021-05-26 15:33:51","src":"","id":1,"title":"标题1"},{"Subtitle":"说明2","createtime":"2021-05-26 15:33:51","src":"","id":2,"title":"标题2"},{"Subtitle":"说明3","createtime":"2021-05-26 15:33:51","src":"","id":3,"title":"标题3"},{"Subtitle":"说明4","createtime":"2021-05-26 15:33:51","src":"","id":4,"title":"标题4"},{"Subtitle":"说明5","createtime":"2021-05-26 15:33:51","src":"","id":5,"title":"标题5"},{"Subtitle":"说明6","createtime":"2021-05-26 15:33:51","src":"","id":6,"title":"标题6"},{"Subtitle":"说明7","createtime":"2021-05-26 15:33:51","src":"","id":7,"title":"标题7"},{"Subtitle":"说明8","createtime":"2021-05-26 15:33:51","src":"","id":8,"title":"标题8"},{"Subtitle":"说明9","createtime":"2021-05-26 15:33:51","src":"","id":9,"title":"标题9"}]
* numFound : 100
* rows : 10
*/
private int rownum;
private int numFound;
private int rows;
private List<DataBean> data;
public int getRownum() {
return rownum;
}
public void setRownum(int rownum) {
this.rownum = rownum;
}
public int getNumFound() {
return numFound;
}
public void setNumFound(int numFound) {
this.numFound = numFound;
}
public int getRows() {
return rows;
}
public void setRows(int rows) {
this.rows = rows;
}
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public static class DataBean {
/**
* Subtitle : 说明0
* createtime : 2021-05-26 15:33:51
* src :
* id : 0
* title : 标题0
*/
private String Subtitle;
private String createtime;
private String src;
private int id;
private String title;
public String getSubtitle() {
return Subtitle;
}
public void setSubtitle(String Subtitle) {
this.Subtitle = Subtitle;
}
public String getCreatetime() {
return createtime;
}
public void setCreatetime(String createtime) {
this.createtime = createtime;
}
public String getSrc() {
return src;
}
public void setSrc(String src) {
this.src = src;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
}
}

View File

@@ -1,13 +1,23 @@
package com.example.myapplication.fragment;
import android.content.Intent;
import android.view.View;
import android.widget.LinearLayout;
import com.example.myapplication.R;
import com.example.myapplication.activity.ManagementFragment;
import com.example.myapplication.base.BaseFragment;
import com.gyf.immersionbar.ImmersionBar;
/**
* 发现的Fragment
* 2021-5-25
*/
public class FindFragment extends BaseFragment {
public class FindFragment extends BaseFragment implements View.OnClickListener{
private LinearLayout linear_task_prefecture;//任务专区
private LinearLayout linear_task_explain;//任务说明
@Override
protected int getLayout() {
return R.layout.find_fragment;
@@ -16,10 +26,30 @@ public class FindFragment extends BaseFragment {
@Override
protected void initView() {
super.initView();
linear_task_prefecture = mView.findViewById(R.id.linear_task_prefecture);
linear_task_prefecture.setOnClickListener(this::onClick);
linear_task_explain = mView.findViewById(R.id.linear_task_explain);
linear_task_explain.setOnClickListener(this::onClick);
}
@Override
protected void initData() {
super.initData();
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.linear_task_prefecture:
Intent prefectureIntent = new Intent(getActivity(), ManagementFragment.class);
prefectureIntent.putExtra("tag",7);
startActivity(prefectureIntent);
break;
case R.id.linear_task_explain:
Intent explainIntent = new Intent(getActivity(), ManagementFragment.class);
explainIntent.putExtra("tag",8);
startActivity(explainIntent);
break;
}
}
}

View File

@@ -2,6 +2,7 @@ package com.example.myapplication.fragment;
import com.example.myapplication.R;
import com.example.myapplication.base.BaseFragment;
import com.gyf.immersionbar.ImmersionBar;
/**
* 我的Fragment

View File

@@ -1,12 +1,17 @@
package com.example.myapplication.fragment;
import android.view.Gravity;
import android.util.Log;
import android.widget.Toast;
import com.example.myapplication.R;
import com.example.myapplication.base.BaseFragment;
import com.example.myapplication.bean.ListBean;
import com.example.myapplication.bean.TaskSpecificationBean;
import com.example.myapplication.http.Callback;
import com.example.myapplication.http.HttpInterface;
import com.example.myapplication.http.OkGoBuilder;
import org.json.JSONArray;
import org.json.JSONObject;
/**
@@ -21,26 +26,35 @@ public class RecordFragment extends BaseFragment {
@Override
protected void initView() {
super.initView();
JSONObject jsonObject = new JSONObject();
OkGoBuilder.getInstance().Builder(getActivity()).url("")
.method(OkGoBuilder.PSOT)
.json(jsonObject)
.cls(Gravity.class)
.callback(new Callback() {
@Override
public void onSuccess(Object response, int id) {
}
@Override
public void onError(Throwable e, int id) {
}
}).build();
}
//界面可见时再加载数据
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
OkGoBuilder.getInstance()
.Builder(getActivity())
.url(HttpInterface.listTask)
.method(OkGoBuilder.GET)
.cls(TaskSpecificationBean.class)
.json(new JSONObject())
.callback(new Callback<TaskSpecificationBean>() {
@Override
public void onSuccess(TaskSpecificationBean gl, int id) {
Toast.makeText(getActivity(),gl.getMsg()+"sssssssssssssssssss", Toast.LENGTH_SHORT).show();
}
@Override
public void onError(Throwable e, int id) {
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_SHORT).show();
Log.d("TAG", "onError: "+e.getMessage());
}
}).build();
}
}
@Override
protected void initData() {
super.initData();
}
}
}

View File

@@ -0,0 +1,24 @@
package com.example.myapplication.fragment;
import com.example.myapplication.R;
import com.example.myapplication.base.BaseFragment;
/**
* 发现-任务说明
*/
public class TaskExplainFragment extends BaseFragment {
@Override
protected int getLayout() {
return R.layout.task_explain_fragment;
}
@Override
protected void initView() {
super.initView();
}
@Override
protected void initData() {
super.initData();
}
}

View File

@@ -0,0 +1,44 @@
package com.example.myapplication.fragment;
import android.view.View;
import android.widget.ImageView;
import com.example.myapplication.R;
import com.example.myapplication.base.BaseFragment;
import com.jcodecraeer.xrecyclerview.XRecyclerView;
/**
* 发现-任务专区
*/
public class TaskPrefectureFragment extends BaseFragment implements View.OnClickListener{
private ImageView mIvFindTask;
private XRecyclerView taskRecycler;
@Override
protected int getLayout() {
return R.layout.task_prefecture_fragment;
}
@Override
protected void initView() {
super.initView();
mIvFindTask = mView.findViewById(R.id.iv_find_task);
mIvFindTask.setOnClickListener(this::onClick);
taskRecycler = mView.findViewById(R.id.task_recycler);
}
@Override
protected void initData() {
super.initData();
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.iv_find_task:
getActivity().finish();
break;
}
}
}

View File

@@ -1,5 +1,7 @@
package com.example.myapplication.http;
public class HttpInterface {
//http://172.21.91.160:8000/api/user/list
public static final String IP = "http://172.21.91.160:8000/api/1/";
public static final String listTask = IP + "task/list";//任务专区,活动专区
}

View File

@@ -1,19 +1,21 @@
package com.example.myapplication.http;
import android.app.Activity;
import android.util.Log;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Response;
import com.lzy.okgo.request.PostRequest;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.File;
import java.util.ArrayList;
/**
* Created by yzb_android on 2021 5 25
* Created by yzb_android on 2019/12/30.
* 作用OKGO帮助类-建造者模式
*/
@@ -44,8 +46,9 @@ public class OkGoBuilder<T> {
* 参数
*/
private HttpParams params;
//private String jsonstr;
private String jsonstr;
private JSONObject json;
private JSONArray jsonArray;
/**
* 实体类
*/
@@ -90,6 +93,7 @@ public class OkGoBuilder<T> {
}
public OkGoBuilder url(String url) {
this.url = url;
this.url = url;
return this;
}
@@ -98,12 +102,10 @@ public class OkGoBuilder<T> {
this.file = file;
return this;
}
public OkGoBuilder pdf(String pdf) {
this.pdf = pdf;
return this;
}
public OkGoBuilder method(int methodType) {
this.methodType = methodType;
return this;
@@ -120,16 +122,19 @@ public class OkGoBuilder<T> {
}
// public OkGoBuilder jsonstr(String jsonstr) {
// this.jsonstr = jsonstr;
// return this;
// }
public OkGoBuilder jsonstr(String jsonstr) {
this.jsonstr = jsonstr;
return this;
}
public OkGoBuilder json(JSONObject json) {
this.json = json;
return this;
}
public OkGoBuilder jsonArray(JSONArray json) {
this.jsonArray = json;
return this;
}
public OkGoBuilder cls(Class<T> clazz) {
this.clazz = clazz;
return this;
@@ -223,7 +228,6 @@ public class OkGoBuilder<T> {
}
});
}
/**
* post 发送文件
*/
@@ -236,7 +240,7 @@ public class OkGoBuilder<T> {
request.params("file_" + i, list.get(i));
}
}
if (pdf != null) {
if (pdf!=null){
request.params("pdf", new File(pdf));
}
request.execute(new DialogCallback<T>(clazz) {
@@ -260,7 +264,7 @@ public class OkGoBuilder<T> {
private void postRequestAloneFile() {
PostRequest<T> request = OkGo.<T>post(url).tag(this)
.params("param", json.toString());
if (file != null) {
if (file!=null){
request.params("file", new File(file));
}
request.execute(new DialogCallback<T>(clazz) {

View File

@@ -13,6 +13,8 @@ import androidx.viewpager.widget.ViewPager;
public class NoSlideViewPager extends ViewPager {
// 定义一个是否可以滑动的boolean 值
private boolean isCanScroll = false;
//定义一个是否可以滑动效果的boolean 值
private boolean noScrollAnim = false;
public NoSlideViewPager(@NonNull Context context) {
super(context);
@@ -21,7 +23,20 @@ public class NoSlideViewPager extends ViewPager {
public NoSlideViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
/**
* 设置是否能左右滑动
* @param canScroll true 不能滑动
*/
public void setCanScroll(boolean canScroll) {
isCanScroll = canScroll;
}
/**
* 设置没有滑动动画
* @param noScrollAnim false 无动画
*/
public void setNoScrollAnim(boolean noScrollAnim) {
this.noScrollAnim = noScrollAnim;
}
// 滑动到指定位置
@Override
@@ -29,36 +44,24 @@ public class NoSlideViewPager extends ViewPager {
super.scrollTo(x, y);
}
// 触摸事件
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (isCanScroll) {
return super.onTouchEvent(ev);
} else {
return false;
}
public boolean onTouchEvent(MotionEvent arg0) {
return !isCanScroll && super.onTouchEvent(arg0);
}
// 设置当前显示的布局
@Override
public void setCurrentItem(int item) {
super.setCurrentItem(item);
public boolean onInterceptTouchEvent(MotionEvent arg0) {
return !isCanScroll && super.onInterceptTouchEvent(arg0);
}
// 设置当前显示的布局,并定义滑动方式
@Override
public void setCurrentItem(int item, boolean smoothScroll) {
super.setCurrentItem(item, smoothScroll);
}
// 拦截触摸事件
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (isCanScroll) {
return super.onInterceptTouchEvent(ev);
} else {
return false;
}
public void setCurrentItem(int item) {
super.setCurrentItem(item,noScrollAnim);
}
}

View File

@@ -7,8 +7,8 @@ import org.json.JSONObject;
public class Whetherisempty {
public static String getClfz(String s) throws JSONException {
JSONObject jsonObject = new JSONObject(s);
if (String.valueOf(jsonObject.get("result")).equals("[]") || String.valueOf(jsonObject.get("result")).equals("")) {
jsonObject.put("result", null);
if (String.valueOf(jsonObject.get("body")).equals("[]") || String.valueOf(jsonObject.get("body")).equals("")) {
jsonObject.put("body", null);
return jsonObject.toString();
} else {
return s;

View File

@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M11.67,3.87L9.9,2.1 0,12l9.9,9.9 1.77,-1.77L3.54,12z"/>
</vector>

View File

@@ -19,6 +19,7 @@
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="6dp"
app:tabRippleColor="@android:color/transparent"
app:tabIndicatorHeight="0dp"
app:tabTextColor="#F0686666"

View File

@@ -4,13 +4,177 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
<RelativeLayout
android:id="@+id/rl_find"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="发现的Fragment"
app:layout_constraintBottom_toBottomOf="parent"
android:background="#1BA5F1"
android:paddingTop="@dimen/top_pind_sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/tv_find"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:gravity="center"
android:text="发现"
android:textColor="#ffffff"
android:textSize="17sp"
android:layout_marginLeft="16dp"
android:textStyle="bold" />
</RelativeLayout>
<LinearLayout
android:id="@+id/linear1"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="15dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toBottomOf="@+id/rl_find">
<ImageView
android:layout_width="5dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:background="#4A4A4A" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:text="最新公告" />
</LinearLayout>
<LinearLayout
android:id="@+id/linear2"
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linear1">
<LinearLayout
android:id="@+id/linear_task_prefecture"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="#8E8787"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linear1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="任务专区"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/linear_right"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="150dp"
android:orientation="horizontal"
android:background="#D6BFBF"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linear1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="活动专区"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/linear3"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="15dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linear2">
<ImageView
android:layout_width="5dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:background="#4A4A4A" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="15dp"
android:text="帮助中心" />
</LinearLayout>
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#ACAAAA"
app:layout_constraintBottom_toTopOf="@+id/linear4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linear3" />
<LinearLayout
android:id="@+id/linear4"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/view">
<LinearLayout
android:id="@+id/linear_task_explain"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linear1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="任务说明"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/linear_end"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="100dp"
android:orientation="vertical"
android:gravity="center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linear1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/ic_launcher"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="能力测评"
/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="@mipmap/ic_launcher_round"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/rl_find"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:paddingTop="@dimen/top_pind_sp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/iv_find_task"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="15dp"
android:src="@drawable/ic_baseline_arrow"
/>
<TextView
android:id="@+id/tv_find"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_marginLeft="15dp"
android:layout_toRightOf="@id/iv_find_task"
android:gravity="center"
android:text="任务专区"
android:textColor="#000"
android:textSize="17sp"
android:textStyle="bold" />
</LinearLayout>
<com.jcodecraeer.xrecyclerview.XRecyclerView
android:id="@+id/task_recycler"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/rl_find" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 600 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
</resources>

View File

@@ -1,3 +1,5 @@
<resources>
<!--状态栏-->
<dimen name="top_pind_sp">20dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>