|
@@ -15,6 +15,8 @@ import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.widget.ImageView;
|
|
import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
|
|
|
+import android.widget.ProgressBar;
|
|
|
|
|
+import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
@@ -23,6 +25,7 @@ import com.jcodecraeer.xrecyclerview.XRecyclerView;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.base.BaseActivity;
|
|
import com.sheep.jiuyan.samllsheep.base.BaseActivity;
|
|
|
|
|
+import com.sheep.jiuyan.samllsheep.floatwindow.FloatService;
|
|
|
import com.sheep.jiuyan.samllsheep.floatwindow.FloatWindow;
|
|
import com.sheep.jiuyan.samllsheep.floatwindow.FloatWindow;
|
|
|
import com.sheep.jiuyan.samllsheep.net.NetManager;
|
|
import com.sheep.jiuyan.samllsheep.net.NetManager;
|
|
|
import com.sheep.jiuyan.samllsheep.net.SheepCallback;
|
|
import com.sheep.jiuyan.samllsheep.net.SheepCallback;
|
|
@@ -61,7 +64,6 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
|
|
|
private TextView mTvWithdraw;
|
|
private TextView mTvWithdraw;
|
|
|
private TextView mTitle;
|
|
private TextView mTitle;
|
|
|
private TextView mMoney;
|
|
private TextView mMoney;
|
|
|
- private TextView mHostry;
|
|
|
|
|
private TextView mToday;
|
|
private TextView mToday;
|
|
|
private ImageView mDown;
|
|
private ImageView mDown;
|
|
|
private AlertDialog mDialog;
|
|
private AlertDialog mDialog;
|
|
@@ -72,28 +74,83 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
|
|
|
private TextView mTvTime;
|
|
private TextView mTvTime;
|
|
|
private TextView mTvCount;
|
|
private TextView mTvCount;
|
|
|
private TextView mTvMoney;
|
|
private TextView mTvMoney;
|
|
|
|
|
+ private TextView mTvBouns;
|
|
|
private TextView mTvGuide;
|
|
private TextView mTvGuide;
|
|
|
private LinearLayout mTlDoing;
|
|
private LinearLayout mTlDoing;
|
|
|
|
|
|
|
|
|
|
|
|
|
- private LinearLayout mLlNewTask;
|
|
|
|
|
|
|
+ private LinearLayout mLlNewTask;
|
|
|
|
|
|
|
|
- private LinearLayout mll_progress;
|
|
|
|
|
|
|
+ private RelativeLayout mll_progress;
|
|
|
|
|
|
|
|
|
|
|
|
|
- private MutiProgress mMp1;
|
|
|
|
|
|
|
+ private ProgressBar mMp1;
|
|
|
|
|
|
|
|
- private WXTask mWXTask;
|
|
|
|
|
|
|
+ private WXTask mWXTask;
|
|
|
|
|
+ private TextView mNewTaskTitle;
|
|
|
|
|
+ private TextView mTvNewTaskDesc;
|
|
|
|
|
+ private TextView mTvNewTaskMoney;
|
|
|
|
|
+ private TextView mTvNewTaskBouns;
|
|
|
|
|
+ private final int INTENT_GET_PERMISSION = 1;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
super.onCreate(savedInstanceState);
|
|
|
- requestPermission();
|
|
|
|
|
- Intent intent = new Intent(MainActivity.this, FloatWindow.class);
|
|
|
|
|
|
|
+ Intent intent = new Intent(this, FloatWindow.class);
|
|
|
startActivity(intent);
|
|
startActivity(intent);
|
|
|
|
|
|
|
|
|
|
+ getSA();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 申请读写权限6.0
|
|
|
|
|
+ */
|
|
|
|
|
+ private void getSA() {
|
|
|
|
|
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ boolean has = PremissUtils.hasPermission(this);
|
|
|
|
|
+ if (!has) {
|
|
|
|
|
+ PremissUtils.openUsageAccessPage(this);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<String> sa = new ArrayList<>();
|
|
|
|
|
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE)
|
|
|
|
|
+ != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
+ sa.add(Manifest.permission.READ_PHONE_STATE);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.SYSTEM_ALERT_WINDOW)
|
|
|
|
|
+ != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
+ sa.add(Manifest.permission.READ_PHONE_STATE);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
|
|
|
|
|
+ != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
+ sa.add(Manifest.permission.READ_EXTERNAL_STORAGE);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (sa.size() < 1) {//如果都已经授权了,不能空列表去请求,否则报异常
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ ActivityCompat.requestPermissions(this, sa.toArray(new String[]{}), INTENT_GET_PERMISSION);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
|
|
|
|
+ if (requestCode == INTENT_GET_PERMISSION) {
|
|
|
|
|
+ boolean isOk = true;
|
|
|
|
|
+ for (int result : grantResults) {
|
|
|
|
|
+ if (result == PackageManager.PERMISSION_DENIED) {
|
|
|
|
|
+ isOk = false;
|
|
|
|
|
+ break;//只要有一个拒绝,就退出并提示
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!isOk) {
|
|
|
|
|
+ Toast.makeText(MainActivity.this, "权限获取失败,部分功能可能无法正常工作。", Toast.LENGTH_SHORT).show();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
protected int getLayoutId() {
|
|
protected int getLayoutId() {
|
|
|
return R.layout.main_activity;
|
|
return R.layout.main_activity;
|
|
@@ -107,31 +164,33 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void initData() {
|
|
public void initData() {
|
|
|
|
|
+ requestNewPeopleTask();
|
|
|
HashMap<String, String> map = new HashMap<>();
|
|
HashMap<String, String> map = new HashMap<>();
|
|
|
map.put("wx_open_id", SpUtils.getOpenId(this));
|
|
map.put("wx_open_id", SpUtils.getOpenId(this));
|
|
|
NetManager.get(Url.PUBLISH_TASKS, map, getApplicationContext(), new SheepCallback<List<TaskPublish>>(this) {
|
|
NetManager.get(Url.PUBLISH_TASKS, map, getApplicationContext(), new SheepCallback<List<TaskPublish>>(this) {
|
|
|
@Override
|
|
@Override
|
|
|
public void success(List<TaskPublish> tasks) {
|
|
public void success(List<TaskPublish> tasks) {
|
|
|
- mAdapter.setData(tasks);
|
|
|
|
|
- mAdapter.notifyDataSetChanged();
|
|
|
|
|
|
|
+ if (tasks != null && tasks.size() > 0) {
|
|
|
|
|
+ mAdapter.setData(tasks);
|
|
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
NetManager.get(Url.USER_INFO, map, getApplicationContext(), new SheepCallback<User>(this) {
|
|
NetManager.get(Url.USER_INFO, map, getApplicationContext(), new SheepCallback<User>(this) {
|
|
|
@Override
|
|
@Override
|
|
|
public void success(User user) {
|
|
public void success(User user) {
|
|
|
- mMoney.setText(user.getBalance());
|
|
|
|
|
- if (!MainActivity.this.isDestroyed())
|
|
|
|
|
- Glide.with(MainActivity.this)
|
|
|
|
|
- .load(user.getIcon())
|
|
|
|
|
- .placeholder(R.drawable.icon)
|
|
|
|
|
- .dontAnimate()
|
|
|
|
|
- .into(mImgUser);
|
|
|
|
|
- mToday.setText(String.format("今日收入:%s", user.getToday()));
|
|
|
|
|
|
|
+ if (user != null) {
|
|
|
|
|
+ mMoney.setText(user.getBalance());
|
|
|
|
|
+ if (!MainActivity.this.isDestroyed())
|
|
|
|
|
+ Glide.with(MainActivity.this)
|
|
|
|
|
+ .load(user.getIcon())
|
|
|
|
|
+ .placeholder(R.drawable.icon)
|
|
|
|
|
+ .dontAnimate()
|
|
|
|
|
+ .into(mImgUser);
|
|
|
|
|
+ mToday.setText(String.format("今日收入:%s", user.getToday()));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
NetManager.get(Url.USER_PULL_TASK, map, getApplicationContext(), new SheepCallback<TaskPublish>(this) {
|
|
NetManager.get(Url.USER_PULL_TASK, map, getApplicationContext(), new SheepCallback<TaskPublish>(this) {
|
|
@@ -157,6 +216,15 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+ mTvBouns.setText(taskPublish.getTask().getBonus());
|
|
|
|
|
+ mTvGuide.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+ Intent intent = new Intent(MainActivity.this, WebActivity.class);
|
|
|
|
|
+ intent.putExtra("url", taskPublish.getTask().getGuide());
|
|
|
|
|
+ startActivity(intent);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
} else {
|
|
} else {
|
|
|
mTlDoing.setVisibility(View.GONE);
|
|
mTlDoing.setVisibility(View.GONE);
|
|
|
}
|
|
}
|
|
@@ -261,26 +329,15 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
|
|
|
intent.putExtra("task", mClickItem.getTask());
|
|
intent.putExtra("task", mClickItem.getTask());
|
|
|
startActivity(intent);
|
|
startActivity(intent);
|
|
|
}
|
|
}
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- private void requestPermission() {
|
|
|
|
|
- boolean has = PremissUtils.hasPermission(this);
|
|
|
|
|
- if (!has) {
|
|
|
|
|
- PremissUtils.openUsageAccessPage(this);
|
|
|
|
|
- }
|
|
|
|
|
- if (Build.VERSION.SDK_INT >= 23)
|
|
|
|
|
- if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
|
- ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_PHONE_STATE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void findViewHead(View head) {
|
|
private void findViewHead(View head) {
|
|
|
mTvWithdraw = (TextView) head.findViewById(R.id.tv_withdraw);
|
|
mTvWithdraw = (TextView) head.findViewById(R.id.tv_withdraw);
|
|
|
mTitle = (TextView) head.findViewById(R.id.title);
|
|
mTitle = (TextView) head.findViewById(R.id.title);
|
|
|
mMoney = (TextView) head.findViewById(R.id.money);
|
|
mMoney = (TextView) head.findViewById(R.id.money);
|
|
|
- mHostry = (TextView) head.findViewById(R.id.hostry);
|
|
|
|
|
mToday = (TextView) head.findViewById(R.id.today);
|
|
mToday = (TextView) head.findViewById(R.id.today);
|
|
|
mDown = head.findViewById(R.id.img_down);
|
|
mDown = head.findViewById(R.id.img_down);
|
|
|
|
|
|
|
@@ -289,48 +346,43 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
|
|
|
mTvTime = (TextView) head.findViewById(R.id.tv_time);
|
|
mTvTime = (TextView) head.findViewById(R.id.tv_time);
|
|
|
mTvCount = (TextView) head.findViewById(R.id.tv_count);
|
|
mTvCount = (TextView) head.findViewById(R.id.tv_count);
|
|
|
mTvMoney = (TextView) head.findViewById(R.id.tv_money);
|
|
mTvMoney = (TextView) head.findViewById(R.id.tv_money);
|
|
|
|
|
+ mTvBouns = (TextView) head.findViewById(R.id.tv_bouns);
|
|
|
mTvGuide = (TextView) head.findViewById(R.id.tv_guide);
|
|
mTvGuide = (TextView) head.findViewById(R.id.tv_guide);
|
|
|
mTlDoing = (LinearLayout) head.findViewById(R.id.ll_doing);
|
|
mTlDoing = (LinearLayout) head.findViewById(R.id.ll_doing);
|
|
|
mImgUser = head.findViewById(R.id.img_user);
|
|
mImgUser = head.findViewById(R.id.img_user);
|
|
|
- mMp1=(MutiProgress)head.findViewById(R.id.mp_1);
|
|
|
|
|
- mLlNewTask=(LinearLayout)head.findViewById(R.id.ll_new_task);
|
|
|
|
|
- mll_progress=(LinearLayout) head.findViewById(R.id.ll_progress);
|
|
|
|
|
|
|
+ mMp1 = (ProgressBar) head.findViewById(R.id.pb_commit);
|
|
|
|
|
+ mNewTaskTitle = head.findViewById(R.id.tv_new_title);
|
|
|
|
|
+ mTvNewTaskDesc = head.findViewById(R.id.tv_new_desc);
|
|
|
|
|
+ mTvNewTaskMoney = head.findViewById(R.id.tv_new_money);
|
|
|
|
|
+ mTvNewTaskBouns = head.findViewById(R.id.tv_new_bouns);
|
|
|
|
|
+ mLlNewTask = (LinearLayout) head.findViewById(R.id.ll_new_task);
|
|
|
|
|
+ mll_progress = head.findViewById(R.id.ll_progress);
|
|
|
mll_progress.setOnClickListener(this);
|
|
mll_progress.setOnClickListener(this);
|
|
|
- requestNewPeopleTask();
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
private void requestNewPeopleTask() {
|
|
private void requestNewPeopleTask() {
|
|
|
final HashMap<String, String> map = new HashMap<>();
|
|
final HashMap<String, String> map = new HashMap<>();
|
|
|
map.put("wx_open_id", SpUtils.getOpenId(this));
|
|
map.put("wx_open_id", SpUtils.getOpenId(this));
|
|
|
NetManager.get(Url.WXTASK, map, this, new SheepCallback<WXTask>(this) {
|
|
NetManager.get(Url.WXTASK, map, this, new SheepCallback<WXTask>(this) {
|
|
|
@Override
|
|
@Override
|
|
|
public void success(WXTask o) {
|
|
public void success(WXTask o) {
|
|
|
-// if(mMp1)
|
|
|
|
|
- mWXTask=o;
|
|
|
|
|
- mMp1.setVisibility(View.VISIBLE);
|
|
|
|
|
- mMp1.setCurrNodeNO(o.getCommitCount());
|
|
|
|
|
-
|
|
|
|
|
|
|
+ // if(mMp1)
|
|
|
|
|
+ mWXTask = o;
|
|
|
|
|
+ mLlNewTask.setVisibility(View.VISIBLE);
|
|
|
|
|
+ mMp1.setProgress((int) (((float) mWXTask.getCommitCount()) / 4 * 100));
|
|
|
|
|
+ mNewTaskTitle.setText(mWXTask.getTitle());
|
|
|
|
|
+ mTvNewTaskBouns.setText(mWXTask.getBonus());
|
|
|
|
|
+ mTvNewTaskDesc.setText(mWXTask.getTaskDesc());
|
|
|
|
|
+ mTvNewTaskMoney.setText(mWXTask.getPrice());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void otherCode(int code, String string) {
|
|
public void otherCode(int code, String string) {
|
|
|
-
|
|
|
|
|
- mMp1.setVisibility(View.GONE);
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ mLlNewTask.setVisibility(View.GONE);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
private void findviews() {
|
|
private void findviews() {
|
|
|
mRecyclerView = (XRecyclerView) findViewById(R.id.tasks);
|
|
mRecyclerView = (XRecyclerView) findViewById(R.id.tasks);
|
|
|
}
|
|
}
|
|
@@ -359,43 +411,20 @@ public class MainActivity extends BaseActivity implements View.OnClickListener {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
Intent intent;
|
|
Intent intent;
|
|
|
- switch (v.getId()) {
|
|
|
|
|
- case R.id.tv_withdraw:
|
|
|
|
|
- if (SpUtils.isLogin(getApplicationContext())) {
|
|
|
|
|
- intent = new Intent(MainActivity.this, WithdrawActivity.class);
|
|
|
|
|
- } else {
|
|
|
|
|
- intent = new Intent(MainActivity.this, LoginActivity.class);
|
|
|
|
|
- }
|
|
|
|
|
- startActivity(intent);
|
|
|
|
|
- break;
|
|
|
|
|
- case R.id.img_down:
|
|
|
|
|
- if (SpUtils.isLogin(getApplicationContext())) {
|
|
|
|
|
- intent = new Intent(MainActivity.this, DownloadActivity.class);
|
|
|
|
|
- } else {
|
|
|
|
|
- intent = new Intent(MainActivity.this, LoginActivity.class);
|
|
|
|
|
- }
|
|
|
|
|
- startActivity(intent);
|
|
|
|
|
- break;
|
|
|
|
|
- case R.id.img_user:
|
|
|
|
|
- if (SpUtils.isLogin(getApplicationContext())) {
|
|
|
|
|
- intent = new Intent(MainActivity.this, UserCenterActivity.class);
|
|
|
|
|
- } else {
|
|
|
|
|
- intent = new Intent(MainActivity.this, LoginActivity.class);
|
|
|
|
|
- }
|
|
|
|
|
- startActivity(intent);
|
|
|
|
|
- break;
|
|
|
|
|
-
|
|
|
|
|
- case R.id.ll_progress:
|
|
|
|
|
-
|
|
|
|
|
- if (SpUtils.isLogin(getApplicationContext())) {
|
|
|
|
|
- intent = new Intent(MainActivity.this, InputWXAccountActivity.class);
|
|
|
|
|
- intent.putExtra("count",mWXTask.getCommitCount());
|
|
|
|
|
- } else {
|
|
|
|
|
- intent = new Intent(MainActivity.this, LoginActivity.class);
|
|
|
|
|
- }
|
|
|
|
|
- startActivity(intent);
|
|
|
|
|
-
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ int i = v.getId();
|
|
|
|
|
+ if (i == R.id.tv_withdraw) {
|
|
|
|
|
+ intent = new Intent(MainActivity.this, WithdrawActivity.class);
|
|
|
|
|
+ startActivity(intent);
|
|
|
|
|
+ } else if (i == R.id.img_down) {
|
|
|
|
|
+ intent = new Intent(MainActivity.this, DownloadActivity.class);
|
|
|
|
|
+ startActivity(intent);
|
|
|
|
|
+ } else if (i == R.id.img_user) {
|
|
|
|
|
+ intent = new Intent(MainActivity.this, UserCenterActivity.class);
|
|
|
|
|
+ startActivity(intent);
|
|
|
|
|
+ } else if (i == R.id.ll_progress) {
|
|
|
|
|
+ intent = new Intent(MainActivity.this, InputWXAccountActivity.class);
|
|
|
|
|
+ intent.putExtra("count", mWXTask.getCommitCount());
|
|
|
|
|
+ startActivity(intent);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|