package com.example.xu.rewardtask;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import android.view.inputmethod.EditorInfo;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
public class MissionDetailActivity extends AppCompatActivity {
private String TAG = "MissionDetailActivity";
private String missionPublisher;
private String missionName;
private TextView PublisherTimeTV;
private TextView tip;
private ListView commentLV;
private EditText commentEdit;
private TextView IsCompletedTip;
private TextView moneyTV;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_mission_detail);
initView();
new getMissionDetailAsyncTask().execute();
}
void initView() {
Intent intent = getIntent();
missionPublisher = intent.getStringExtra("UserName");
missionName = intent.getStringExtra("MissionName");
PublisherTimeTV = (TextView) findViewById(R.id.MissionDetail_UserTime);
tip = (TextView) findViewById(R.id.MissionDetail_Tip);
IsCompletedTip = (TextView) findViewById(R.id.MissionDetail_IsCompleted);
commentEdit = (EditText) findViewById(R.id.MissionDetail_CommentEdit);
commentEdit.setImeOptions(EditorInfo.IME_ACTION_SEND);
commentEdit.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEND || (event != null && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
new sendComment().execute(
new Comment(missionPublisher, missionName,
commentEdit.getText().toString(),
CurrentUser.getInstance().getUserName(),
new Date(System.currentTimeMillis())));
return true;
}
return false;
}
});
// 未登录的话直接不显示评论编辑的部分
if (!CurrentUser.getInstance().isLogin())
findViewById(R.id.MissionDetail_CommentEditPart).setVisibility(View.GONE);
Button button = (Button) findViewById(R.id.MissionDetail_ReleaseButton);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.i(TAG, missionPublisher);
Log.i(TAG, missionName);
Log.i(TAG, commentEdit.getText().toString());
Log.i(TAG, CurrentUser.getInstance().getUserName());
new sendComment().execute(new Comment(missionPublisher, missionName,
commentEdit.getText().toString(),
CurrentUser.getInstance().getUserName(),
new Date(System.currentTimeMillis())));
}
});
((TextView) findViewById(R.id.MissionDetail_MissionName)).setText(missionName);
PublisherTimeTV.setText(missionPublisher);
if (intent.getStringExtra("Date") != null) {
Date date = new Date(intent.getStringExtra("Date"));
DateFormat dateFormat = new SimpleDateFormat("yy-MM-dd HH:mm");
PublisherTimeTV.setText(missionPublisher + "发布于" + dateFormat.format(date));
}
initListView();
}
private List<Comment> CommentList_Data;
private CommentAdapter adapter;
void initListView() {
commentLV = (ListView) findViewById(R.id.MissionDetail_Comment);
commentLV.setVisibility(View.GONE);
CommentList_Data = new LinkedList<>();
adapter = new CommentAdapter(CommentList_Data);
commentLV.setAdapter(adapter);
commentLV.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
// 未登陆点击不会有任何反应
if (!CurrentUser.getInstance().isLogin())
return;
final Comment item = CommentList_Data.get(position);
// 登陆者是任务发布者 且 任务赏金未被领取才会有采纳
if (item.getMissionUsername().equals(CurrentUser.getInstance().getUserName())
&& IsCompletedTip.getText().equals("此任务的赏金尚未被领取")) {
Log.i(TAG, item.getMissionUsername());
Log.i(TAG, CurrentUser.getInstance().getUserName());
AlertDialog.Builder builder = new AlertDialog.Builder(MissionDetailActivity.this);
LayoutInflater inflater = getLayoutInflater();
View dialogView = inflater.inflate(R.layout.activity_mission_detail_dialog, null);
builder.setView(dialogView);
final AlertDialog dialog = builder.create();
Button adoptButton = (Button) dialogView.findViewById(R.id.MissionDetail_AdoptComment);
adoptButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (dialog.isShowing())
dialog.cancel();
new AdoptComment().execute(position);
}
});
Button replyButton = (Button) dialogView.findViewById(R.id.MissionDetail_ReplyComment);
replyButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
commentEdit.setText("回复 " + item.getUsername() + ": ");
commentEdit.setSelection(5+item.getUsername().length());
commentEdit.requestFocus();
if (dialog.isShowing())
dialog.cancel();
}
});
dialog.show();
} else {
commentEdit.setText("回复 " + item.getUsername() + ": ");
commentEdit.setSelection(5+item.getUsername().length());
commentEdit.requestFocus();
}
}
});
}
class CommentAdapter extends BaseAdapter {
private List<Comment> list = null;
CommentAdapter(List<Comment> list_) {
list = list_;
}
@Override
public int getCount()
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
大三上_安卓选修课_大作业_Android_RewardTask.zip (72个子文件)
Android_RewardTask-master
java
com
example
xu
rewardtask
AreaMissionListActivity.java 15KB
MissionAdapter.java 2KB
LoginOrRegisterActivity.java 19KB
MyMissionActivity.java 6KB
Comment.java 2KB
PersonActivity.java 3KB
ReleaseNewMissionActivity.java 10KB
MissionDetailActivity.java 24KB
SettingActivity.java 19KB
MissionListItem.java 1KB
StartActivity.java 7KB
Mission.java 1KB
NoticeService.java 5KB
CurrentUser.java 5KB
BootReceiver.java 641B
MainActivity.java 8KB
NoticeReceiver.java 2KB
res
anim
slide2bottom.xml 207B
slide_from_right.xml 219B
scale2all.xml 320B
roteting.xml 338B
slide2left.xml 220B
slide2right.xml 219B
slide2top.xml 219B
slide_from_bottom.xml 219B
slide_from_left.xml 220B
slide_from_top.xml 220B
scale_from_1o5.xml 282B
mipmap-xxhdpi
ic_launcher.png 8KB
mipmap-hdpi
type_icon_game.png 65KB
mission_icon.png 54KB
type_icon_else.png 45KB
gold_icon.png 114KB
type_icon_feeling.png 23KB
loading.png 1KB
setting.png 107KB
person_icon_unlogin.png 37KB
type_icon_sport.png 63KB
app_icon.png 108KB
type_icon_live.png 80KB
type_icon_pc.png 60KB
right_icon.png 2KB
ic_launcher.png 3KB
left_icon.png 17KB
mipmap-mdpi
ic_launcher.png 2KB
mipmap-xxxhdpi
ic_launcher.png 10KB
mipmap-xhdpi
ic_launcher.png 5KB
values-w820dp
dimens.xml 358B
values
dimens.xml 2KB
array.xml 840B
colors.xml 772B
strings.xml 3KB
styles.xml 380B
layout
dialog_loading.xml 943B
activity_my_mission.xml 439B
activity_mission_detail_dialog.xml 754B
activity_setting_password_dialog.xml 3KB
activity_setting_description_dialog.xml 2KB
activity_area_mission_list_spinner_item.xml 617B
activity_person.xml 6KB
activity_login_or_rigister.xml 3KB
activity_area_mission_list.xml 4KB
activity_main.xml 3KB
activity_start.xml 639B
activity_mission_detail_list_item.xml 1KB
activity_my_mission_list_item.xml 599B
activity_mission_detail.xml 6KB
activity_setting.xml 3KB
activity_main_type_list_item.xml 2KB
activity_release_new_mission.xml 4KB
activity_area_mission_list_item.xml 2KB
AndroidManifest.xml 3KB
共 72 条
- 1
资源评论
好家伙VCC
- 粉丝: 2125
- 资源: 9145
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功