parent
3458d9bf93
commit
d91d8b5b22
@ -1,14 +1,105 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.HorizontalScrollView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import com.example.leudaemialikeme.R;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
public class APNActivity extends BaseActivity {
|
||||
import com.example.leudaemialikeme.Adapter.APNPageActivityAdapter;
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
public class APNActivity extends BaseActivity implements ViewPager.OnPageChangeListener{
|
||||
private static final String ARG_CHANNEL_LIST = "channel_list";
|
||||
private View view=null; // 碎片的布局实例
|
||||
private ViewPager viewPager; //内导航的碎片的容器
|
||||
private RadioGroup rgChannel=null; // 内导航由单选按钮组构成
|
||||
private HorizontalScrollView hvChannel=null; //单选按钮组可滚动动
|
||||
private ImageView apn_back;
|
||||
private String[] channelList = {"回答","帖子"}; //默认的内导航栏目
|
||||
private APNPageActivityAdapter adapter; //viewPager 的适配器
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_apn);
|
||||
viewPager = findViewById(R.id.vpNewsList);
|
||||
initViewPager(); //设置 ViewPager
|
||||
rgChannel = findViewById(R.id.rgChannel);
|
||||
hvChannel = findViewById(R.id.hvChannel);
|
||||
initTab(getLayoutInflater());
|
||||
rgChannel.setOnCheckedChangeListener(
|
||||
new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
viewPager.setCurrentItem(checkedId);
|
||||
}
|
||||
}
|
||||
);
|
||||
apn_back = findViewById(R.id.apn_back);
|
||||
apn_back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void initViewPager() {
|
||||
FragmentManager fragmentManager = getSupportFragmentManager();
|
||||
adapter = new APNPageActivityAdapter(fragmentManager, channelList);
|
||||
//参数 channelList 将被适配器用来在动态切换碎片的时候实时创建碎片 //设置 ViewPager 的适配器
|
||||
viewPager.setAdapter(adapter);
|
||||
viewPager.setOffscreenPageLimit(2);
|
||||
//设置显示第 1 个碎片
|
||||
viewPager.setCurrentItem(0);
|
||||
//设置 ViewPager 的切换监听
|
||||
viewPager.addOnPageChangeListener(this);
|
||||
}
|
||||
|
||||
private void initTab(LayoutInflater inflater) {
|
||||
for(int i=0;i<channelList.length;i++){
|
||||
RadioButton rb=(RadioButton)inflater.inflate(R.layout.invitation_tab_rb,null);
|
||||
rb.setId(i);
|
||||
rb.setText(channelList[i]);
|
||||
RadioGroup.LayoutParams params = new
|
||||
RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT,
|
||||
RadioGroup.LayoutParams.WRAP_CONTENT);
|
||||
rgChannel.addView(rb,params);
|
||||
}
|
||||
rgChannel.check(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
setTab(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrollStateChanged(int state) {
|
||||
|
||||
}
|
||||
|
||||
private void setTab(int idx){
|
||||
RadioButton rb=(RadioButton)rgChannel.getChildAt(idx);
|
||||
rb.setChecked(true);
|
||||
int left=rb.getLeft();
|
||||
int width=rb.getMeasuredWidth();
|
||||
DisplayMetrics metrics=new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
int screenWidth=metrics.widthPixels;
|
||||
int len=left+width/2-screenWidth/2;
|
||||
hvChannel.smoothScrollTo(len,0);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,131 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.leudaemialikeme.CallAlarm;
|
||||
import com.example.leudaemialikeme.Model.Clock;
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import static com.example.leudaemialikeme.Activity.MdctRmdActivity.list;
|
||||
import static com.example.leudaemialikeme.Activity.MdctRmdActivity.timeAdapter;
|
||||
|
||||
public class AddClock extends BaseActivity implements View.OnClickListener {
|
||||
|
||||
private Calendar calendar;
|
||||
private TextView show_hour;
|
||||
private TextView show_minute;
|
||||
private EditText content_name;
|
||||
private EditText content_dosage;
|
||||
private Button set;
|
||||
private Button save;
|
||||
private ImageView back;
|
||||
String hourformat;
|
||||
String minuteformat;
|
||||
Clock clock = new Clock();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_add_clock);
|
||||
show_hour = findViewById(R.id.hour);
|
||||
show_minute = findViewById(R.id.minute);
|
||||
content_name = findViewById(R.id.content_name);
|
||||
content_dosage = findViewById(R.id.content_dosage);
|
||||
set = findViewById(R.id.set_time);
|
||||
set.setOnClickListener(this);
|
||||
save = findViewById(R.id.save);
|
||||
back = findViewById(R.id.back_list_clock);
|
||||
back.setImageResource(R.drawable.ic_back);
|
||||
back.setOnClickListener(this);
|
||||
save.setOnClickListener(this);
|
||||
calendar = Calendar.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.set_time:
|
||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
int mhour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int mminute = calendar.get(Calendar.MINUTE);
|
||||
new TimePickerDialog(AddClock.this, new TimePickerDialog.OnTimeSetListener() {
|
||||
@Override
|
||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||
//calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
|
||||
calendar.set(Calendar.MINUTE, minute);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
|
||||
hourformat = format(hourOfDay);
|
||||
minuteformat = format(minute);
|
||||
Toast.makeText(AddClock.this, "" + hourformat + ":" + minuteformat, Toast.LENGTH_SHORT).show();
|
||||
show_hour.setText(hourformat);
|
||||
show_minute.setText(minuteformat);
|
||||
|
||||
|
||||
}
|
||||
}, mhour, mminute, true).show();
|
||||
break;
|
||||
case R.id.save:
|
||||
Intent intent = new Intent(AddClock.this, CallAlarm.class);
|
||||
PendingIntent sender = PendingIntent.getBroadcast(
|
||||
AddClock.this, 0, intent, 0);
|
||||
AlarmManager am;
|
||||
am = (AlarmManager) getSystemService(ALARM_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (System.currentTimeMillis()>calendar.getTimeInMillis()+40000){
|
||||
//加24小时
|
||||
am.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis()+86400000, sender);
|
||||
}else {
|
||||
am.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);
|
||||
}
|
||||
}
|
||||
clock.setHour(hourformat);
|
||||
clock.setMinute(minuteformat);
|
||||
clock.setName("" + content_name.getText().toString());
|
||||
clock.setDosage("" + content_dosage.getText().toString());
|
||||
clock.setClockType(Clock.clock_open);
|
||||
if (clock.getHour()!=null&&clock.getMinute()!=null) {
|
||||
clock.save();
|
||||
list.add(clock);
|
||||
timeAdapter.notifyDataSetChanged();
|
||||
Log.e("Listnumber======",list.size()+"");
|
||||
finish();
|
||||
}else {
|
||||
Toast.makeText(this, "请选择闹钟时间", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
break;
|
||||
case R.id.back_list_clock:
|
||||
finish();
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private String format(int x) {
|
||||
String s = "" + x;
|
||||
if (s.length() == 1) {
|
||||
s = "0" + s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
@ -0,0 +1,203 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.DatePickerDialog;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.leudaemialikeme.Model.Event;
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
import org.litepal.LitePal;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
public class AddEventActivity extends BaseActivity {
|
||||
|
||||
public static final String EVENT_DAY = "event_day";
|
||||
public static final String EVENT_MONTH= "event_month";
|
||||
public static final String EVENT_INFO = "event_info";
|
||||
public static final String EVENT_PLACE = "event_place";
|
||||
public static final String EVENT_DOCTOR_NAME = "event_doctor_name";
|
||||
public static final String EVENT_TIME = "event_time";
|
||||
public static final String EVENT_CREATE_TIME = "event_create_time";
|
||||
private TextView event_day,event_month,event_info;
|
||||
private TextView event_place,event_doctor_name,event_time,event_create_time;
|
||||
private String show_event_day,show_event_month,show_event_info;
|
||||
private String show_event_place,show_event_doctor_name,show_event_time,show_event_create_time;
|
||||
private ImageView delete,save;
|
||||
private Button add_date,add_time;
|
||||
private ImageView back;
|
||||
|
||||
DateFormat format= DateFormat.getDateTimeInstance();
|
||||
Calendar calendar= Calendar.getInstance(Locale.CHINA);
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_add_event);
|
||||
event_day = findViewById(R.id.add_event_day);
|
||||
event_month = findViewById(R.id.add_event_month);
|
||||
event_info = findViewById(R.id.add_event_info);
|
||||
event_place = findViewById(R.id.add_event_place);
|
||||
event_doctor_name = findViewById(R.id.add_event_doctor_name);
|
||||
event_time = findViewById(R.id.add_event_time);
|
||||
event_create_time = findViewById(R.id.show_time);
|
||||
delete = findViewById(R.id.delete_event);
|
||||
save = findViewById(R.id.save_event);
|
||||
add_date = findViewById(R.id.add_date);
|
||||
add_time = findViewById(R.id.add_time);
|
||||
back = findViewById(R.id.back_event_list);
|
||||
|
||||
Intent intent = getIntent();
|
||||
show_event_day = intent.getStringExtra(EVENT_DAY);
|
||||
show_event_month = intent.getStringExtra(EVENT_MONTH);
|
||||
show_event_info = intent.getStringExtra(EVENT_INFO);
|
||||
show_event_place = intent.getStringExtra(EVENT_PLACE);
|
||||
show_event_doctor_name = intent.getStringExtra(EVENT_DOCTOR_NAME);
|
||||
show_event_time = intent.getStringExtra(EVENT_TIME);
|
||||
show_event_create_time = intent.getStringExtra(EVENT_CREATE_TIME);
|
||||
|
||||
event_day.setText(show_event_day);
|
||||
event_month.setText(show_event_month);
|
||||
event_info.setText(show_event_info);
|
||||
event_place.setText(show_event_place);
|
||||
event_doctor_name.setText(show_event_doctor_name);
|
||||
event_time.setText(show_event_time);
|
||||
event_create_time.setText(show_event_create_time);
|
||||
|
||||
//点击事项
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent intent = new Intent(AddEventActivity.this,EventActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
delete.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String deleteContent=event_info.getText().toString();
|
||||
LitePal.deleteAll(Event.class,"event_info=?",deleteContent);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
save.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
//创建时间不为空,表明为修改
|
||||
if(show_event_create_time!=null){
|
||||
String inputDay = event_day.getText().toString();
|
||||
String inputMonth = event_month.getText().toString();
|
||||
String inputInfo = event_info.getText().toString();
|
||||
String inputPlace = event_place.getText().toString();
|
||||
String inputName = event_doctor_name.getText().toString();
|
||||
String inputTime = event_time.getText().toString();
|
||||
Event event = new Event();
|
||||
event.setEvent_day(inputDay);
|
||||
event.setEvent_month(inputMonth);
|
||||
event.setEvent_info(inputInfo);
|
||||
event.setEvent_place(inputPlace);
|
||||
event.setEvent_doctor_name(inputName);
|
||||
event.setEvent_time(inputTime);
|
||||
// LitePal.where("ownerNetId = ?", String.valueOf(ownerNetId)).find(Friend.class);
|
||||
event.updateAll("event_create_time=?",show_event_create_time);
|
||||
finish();
|
||||
}else{
|
||||
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
|
||||
Date date=new Date(System.currentTimeMillis());
|
||||
String inputDay = event_day.getText().toString();
|
||||
String inputMonth = event_month.getText().toString();
|
||||
String inputInfo = event_info.getText().toString();
|
||||
String inputPlace = event_place.getText().toString();
|
||||
String inputName = event_doctor_name.getText().toString();
|
||||
String inputTime = event_time.getText().toString();
|
||||
Event event = new Event();
|
||||
event.setEvent_day(inputDay);
|
||||
event.setEvent_month(inputMonth);
|
||||
event.setEvent_info(inputInfo);
|
||||
event.setEvent_place(inputPlace);
|
||||
event.setEvent_doctor_name(inputName);
|
||||
event.setEvent_time(inputTime);
|
||||
event.setEvent_create_time(simpleDateFormat.format(date));
|
||||
if(inputInfo.equals(LitePal.find(Event.class,3))){
|
||||
Toast.makeText(AddEventActivity.this,"该大事记已存在",Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
event.save();
|
||||
Toast.makeText(AddEventActivity.this,"保存成功",Toast.LENGTH_SHORT).show();
|
||||
finish();//操作完成结束当前活动
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//获取选择的月,日
|
||||
add_date.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showDatePickerDialog(AddEventActivity.this, 4, event_month,event_day, calendar);;
|
||||
}
|
||||
});
|
||||
|
||||
//获取选择的时间
|
||||
add_time.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showTimePickerDialog(AddEventActivity.this, 4, event_time, calendar);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void showTimePickerDialog(Activity activity,int themeResId, final TextView event_time, Calendar calendar) {
|
||||
new TimePickerDialog( activity,themeResId,
|
||||
// 绑定监听器
|
||||
new TimePickerDialog.OnTimeSetListener() {
|
||||
@Override
|
||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||
// event_time.setText("您选择了:" + hourOfDay + "时" + minute + "分");
|
||||
event_time.setText(hourOfDay+"时"+minute+"分");
|
||||
}
|
||||
}
|
||||
// 设置初始时间
|
||||
, calendar.get(Calendar.HOUR_OF_DAY)
|
||||
, calendar.get(Calendar.MINUTE)
|
||||
// true表示采用24小时制
|
||||
,true).show();
|
||||
}
|
||||
|
||||
|
||||
public static void showDatePickerDialog(Activity activity, int themeResId, final TextView event_month,final TextView event_day, Calendar calendar) {
|
||||
new DatePickerDialog(activity, themeResId, new DatePickerDialog.OnDateSetListener() {
|
||||
// 绑定监听器(How the parent is notified that the date is set.)
|
||||
@Override
|
||||
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
|
||||
// 此处得到选择的时间,可以进行你想要的操作
|
||||
// tv.setText("您选择了:" + year + "年" + (monthOfYear + 1) + "月" + dayOfMonth + "日");
|
||||
event_day.setText(String.valueOf(dayOfMonth));
|
||||
event_month.setText(String.valueOf(monthOfYear+1));
|
||||
}
|
||||
}
|
||||
// 设置初始日期
|
||||
, calendar.get(Calendar.YEAR)
|
||||
, calendar.get(Calendar.MONTH)
|
||||
, calendar.get(Calendar.DAY_OF_MONTH)).show();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.media.MediaPlayer;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
public class AlarmAlert extends BaseActivity {
|
||||
private MediaPlayer mediaPlayer;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
int position = getIntent().getIntExtra("position",-1);
|
||||
mediaPlayer = MediaPlayer.create(this,R.raw.clockmusic2);
|
||||
mediaPlayer.start();
|
||||
new AlertDialog.Builder(AlarmAlert.this)
|
||||
.setIcon(R.drawable.clock)
|
||||
.setTitle("闹钟响了")
|
||||
.setCancelable(false)
|
||||
.setMessage("时间到了!")
|
||||
.setPositiveButton("关掉"
|
||||
, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
AlarmAlert.this.finish();
|
||||
mediaPlayer.stop();
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.OkHttpUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class AnswerActivity extends AppCompatActivity {
|
||||
private TextView text_answer_cancel;
|
||||
private TextView text_answer_commit;
|
||||
private TextView text_question_name;
|
||||
private EditText edit_answer_detail;
|
||||
private int qid;
|
||||
private String qtitle;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
Intent intent = getIntent();
|
||||
qid = intent.getIntExtra("qid", -1);
|
||||
qtitle = intent.getStringExtra("qtitle");
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_answer);
|
||||
|
||||
text_answer_cancel = findViewById(R.id.text_answer_cancel);
|
||||
text_answer_commit = findViewById(R.id.text_answer_commit);
|
||||
text_question_name = findViewById(R.id.text_question_name);
|
||||
edit_answer_detail = findViewById(R.id.text_answer_detail);
|
||||
text_question_name.setText(qtitle);
|
||||
|
||||
text_answer_cancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
text_answer_commit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(edit_answer_detail.getText().toString().equals("")){
|
||||
Toast.makeText(AnswerActivity.this, "请输入回答内容", Toast.LENGTH_SHORT).show();
|
||||
}else{
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(AnswerActivity.this);
|
||||
builder.setTitle("是否确认提交回答?");
|
||||
builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Toast.makeText(AnswerActivity.this, "已取消回答", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String content = edit_answer_detail.getText().toString();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("answerContent", content);
|
||||
sendAnswer(params);
|
||||
}
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void sendAnswer(final Map params){
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
String url = LoginActivity.SERVER_URL+"/main-servlet?action=sendAnswer&iduser="+ BaseActivity.owner.getNetId()+"&qid="+qid;
|
||||
OkHttpUtil.asyPost(url, params,new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
final String jsonStr = response.body().string();
|
||||
runOnUiThread(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
if(jsonStr.equals("success")){
|
||||
Toast.makeText(getApplicationContext(), "回答成功", Toast.LENGTH_SHORT).show();
|
||||
finish();
|
||||
}else {
|
||||
Toast.makeText(getApplicationContext(), "回答失败", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
}
|
@ -0,0 +1,332 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.example.leudaemialikeme.Adapter.CommentAdapter;
|
||||
import com.example.leudaemialikeme.Model.Blog;
|
||||
import com.example.leudaemialikeme.Model.Comment;
|
||||
import com.example.leudaemialikeme.Model.User;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.OkHttpUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class BlogDetailActivity extends BaseActivity {
|
||||
TextView bTitleView;
|
||||
TextView bAuthorNameView;
|
||||
TextView bContentView;
|
||||
TextView bViewNumView;
|
||||
TextView bColNumView;
|
||||
TextView bComNumView;
|
||||
EditText comEditView;
|
||||
TextView comComView;
|
||||
ImageView detail_to;
|
||||
ImageView search;
|
||||
ImageView bColImage;
|
||||
Blog blog=new Blog();
|
||||
User author;
|
||||
List<Comment> commentList=new ArrayList<>();
|
||||
CommentAdapter commentAdapter=new CommentAdapter();
|
||||
RecyclerView recyclerView;
|
||||
LinearLayout detailColView;
|
||||
|
||||
private static ViewPager viewPager; //内导航的碎片的容器
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_blogdetail);
|
||||
Intent intent=getIntent();//新增bid
|
||||
|
||||
blog.setBid(Integer.parseInt(intent.getStringExtra("bid")));//新增bid
|
||||
blog.setBcontent(intent.getStringExtra("bContent"));
|
||||
blog.setBtittle(intent.getStringExtra("bTitle"));
|
||||
Log.e("传输后的bid",String.valueOf(blog.getBid()));
|
||||
blog.setBcollectNum(Integer.parseInt(intent.getStringExtra("bColNum")));
|
||||
blog.setBbrowse((Integer.parseInt(intent.getStringExtra("bViewNum"))));
|
||||
blog.setUid(Integer.parseInt(intent.getStringExtra("uid")));
|
||||
|
||||
|
||||
initView();
|
||||
setData();
|
||||
initClick();
|
||||
recyclerView=(RecyclerView)findViewById(R.id.comment_recyclerView);
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
recyclerView.setLayoutManager(layoutManager);
|
||||
commentAdapter=new CommentAdapter();
|
||||
initComments();
|
||||
Log.e("commentList",String.valueOf(commentList));
|
||||
commentAdapter.setMCommentList(commentList);
|
||||
recyclerView.setAdapter(commentAdapter);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void initComments() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String url=BaseActivity.SERVER_URL+"/comment-servlet?action=getCommentByBid";
|
||||
Map<String,String> paramMap=new HashMap<String,String>();
|
||||
paramMap.put("bid",String.valueOf(blog.getBid()));
|
||||
OkHttpUtil.asyPost(url, paramMap, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String jsonStr=response.body().string();
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Gson gson=new Gson();
|
||||
Log.e("comment",jsonStr);
|
||||
Type listType=new TypeToken<List<Comment>>(){}.getType();
|
||||
commentList = gson.fromJson(jsonStr,listType);
|
||||
Log.e("onResponse:commentList",String.valueOf(commentList));
|
||||
bComNumView.setText("("+String.valueOf(commentList.size())+")");
|
||||
commentAdapter.setMCommentList(commentList);
|
||||
recyclerView.setAdapter(commentAdapter);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void setBlogAuthorName(String uid){
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
String url = BaseActivity.SERVER_URL + "/main-servlet?action=getUserById";
|
||||
Map<String,String> paramMap = new HashMap<String,String>();
|
||||
paramMap.put("uid", String.valueOf(blog.getUid()));
|
||||
Log.e("设置帖子的作者uid",uid);
|
||||
OkHttpUtil.asyPost(url, paramMap, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String jsonStr = response.body().string();
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Gson gson = new Gson(); // 使用 gson 库解析 JSON 数据
|
||||
// 创建一个 TypeToken 的匿名子类对象,并调用对象的 getType()方法
|
||||
// Log.e("Blog's Str",jsonStr);
|
||||
Type listType = new TypeToken<User>() {}.getType();
|
||||
author = gson.fromJson(jsonStr, listType);
|
||||
// bAuthorNameView=findViewById(R.id.author);
|
||||
bAuthorNameView.setText(author.getUsername());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void initView(){
|
||||
bTitleView=findViewById(R.id.detail_theme);
|
||||
bAuthorNameView=findViewById(R.id.author);
|
||||
bContentView=findViewById(R.id.bContent);
|
||||
bViewNumView=findViewById(R.id.detail_view_num);
|
||||
bColNumView=findViewById(R.id.detail_col_num);
|
||||
bComNumView=findViewById(R.id.comment_num);
|
||||
comEditView=findViewById(R.id.comment_edit);
|
||||
comComView=findViewById(R.id.comment_commit);
|
||||
detail_to=findViewById(R.id.detail_to);
|
||||
search=findViewById(R.id.detail_to_search);
|
||||
detailColView=findViewById(R.id.detail_like);
|
||||
detailColView=findViewById(R.id.detail_col);
|
||||
bColImage=findViewById(R.id.imageView15);
|
||||
}
|
||||
|
||||
private void setData(){
|
||||
setBlogAuthorName(String.valueOf(blog.getUid()));
|
||||
// setBColNumViewImage(blog.getBid(),BaseActivity.owner.getNetId()); 需要传入登录用户的id
|
||||
setBColNumViewImage(blog.getBid(),BaseActivity.owner.getNetId(),2);
|
||||
bViewNumView.setText(String.valueOf(blog.getBbrowse()));
|
||||
bTitleView.setText(blog.getBtittle());
|
||||
bContentView.setText(blog.getBcontent());
|
||||
bColNumView.setText(String.valueOf(blog.getBcollectNum()));
|
||||
}
|
||||
|
||||
private void setBColNumViewImage(int bid,int uid,int type){
|
||||
Map<String,Integer> paramMap=new HashMap<String, Integer>();
|
||||
paramMap.put("bid",bid);
|
||||
paramMap.put("uid", uid);
|
||||
paramMap.put("type",type);
|
||||
String url_collect=BaseActivity.SERVER_URL+"/collect-servlet?action=JudgeCollect";
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String jsonStr=OkHttpUtil.synPost(url_collect,paramMap);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.e("ColNumViewImage-jsonStr",jsonStr);
|
||||
if(!jsonStr.contains("not")){
|
||||
bColImage.setImageResource(R.drawable.collect_pick);
|
||||
bColImage.setTag(R.drawable.collect_pick);
|
||||
}else{
|
||||
bColImage.setImageResource(R.drawable.collect);
|
||||
bColImage.setTag(R.drawable.collect);
|
||||
}
|
||||
}
|
||||
});
|
||||
System.out.println("更新collect表成功");
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void initClick(){
|
||||
detail_to.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
search.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent=new Intent(BlogDetailActivity.this,BlogSearchActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
comComView.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String cont = comEditView.getText().toString();
|
||||
|
||||
User user=new User();
|
||||
user.setIduser(BaseActivity.owner.getNetId());
|
||||
user.setUsername(BaseActivity.owner.getUsername());
|
||||
|
||||
long timeCurrent = System.currentTimeMillis();
|
||||
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
|
||||
Timestamp time = Timestamp.valueOf(sdf.format(timeCurrent));
|
||||
Comment comment=new Comment(blog.getBid(),user.getUsername(),time,user.getIduser(),
|
||||
cont,2);
|
||||
Map<String,Comment> paramMap=new HashMap<String,Comment>();
|
||||
paramMap.put("comment",comment);
|
||||
String url=BaseActivity.SERVER_URL+"/comment-servlet?action=insertComment";
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
OkHttpUtil.asyPost(url, paramMap, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String jsonStr = response.body().string();
|
||||
// Log.e("提交评论",jsonStr);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
commentList.add(comment);
|
||||
commentAdapter.setMCommentList(commentList);
|
||||
recyclerView.setAdapter(commentAdapter);
|
||||
comEditView.setText("");
|
||||
bComNumView.setText("("+String.valueOf(commentList.size())+")");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
detailColView.setOnClickListener(new View.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Map<String,Integer> paramMap=new HashMap<String, Integer>();
|
||||
paramMap.put("bid",blog.getBid());
|
||||
paramMap.put("uid", BaseActivity.owner.getNetId());
|
||||
paramMap.put("type",2);
|
||||
String url_collect=BaseActivity.SERVER_URL+"/collect-servlet?action=InsertCollect";
|
||||
|
||||
int imageId=getDrawableId(bColImage);
|
||||
if(imageId==R.drawable.collect) {
|
||||
bColImage.setImageResource(R.drawable.collect_pick);
|
||||
bColImage.setTag(R.drawable.collect_pick);
|
||||
}else {
|
||||
bColImage.setImageResource(R.drawable.collect);
|
||||
bColImage.setTag(R.drawable.collect);
|
||||
}
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String jsonStr=OkHttpUtil.synPost(url_collect,paramMap);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(jsonStr.contains("insert")){
|
||||
bColNumView.setText(String.valueOf(Integer.parseInt(bColNumView.getText().toString())+1));
|
||||
Toast.makeText(BlogDetailActivity.this,
|
||||
"已收藏",Toast.LENGTH_SHORT).show();
|
||||
}else{
|
||||
bColNumView.setText(String.valueOf(Integer.parseInt(bColNumView.getText().toString())-1));
|
||||
Toast.makeText(BlogDetailActivity.this,
|
||||
"取消收藏",Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
System.out.println("更新collect表成功");
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private int getDrawableId(ImageView iv) {
|
||||
return (Integer) iv.getTag();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
public class BlogSearchActivity extends AppCompatActivity {
|
||||
ImageView back;
|
||||
EditText blogSearchEdit;
|
||||
TextView blogSearchCommit;
|
||||
TextView recView;
|
||||
TextView foView;
|
||||
TextView poView;
|
||||
TextView meView;
|
||||
TextView stView;
|
||||
TextView exView;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_blog_search);
|
||||
|
||||
initView();
|
||||
initClick();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initView(){
|
||||
back = (ImageView)findViewById(R.id.search_back);
|
||||
blogSearchEdit = (EditText)findViewById(R.id.blog_search_edit);
|
||||
blogSearchCommit = (TextView) findViewById(R.id.blog_search_commit);
|
||||
recView=(TextView)findViewById(R.id.recView);
|
||||
foView=(TextView)findViewById(R.id.foView);
|
||||
poView=(TextView)findViewById(R.id.poView);
|
||||
meView=(TextView)findViewById(R.id.meView);
|
||||
stView=(TextView)findViewById(R.id.stView);
|
||||
exView=(TextView)findViewById(R.id.exView);
|
||||
}
|
||||
|
||||
private void initClick(){
|
||||
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
blogSearchCommit.setOnClickListener(new View.OnClickListener(){
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String text = blogSearchEdit.getText().toString();
|
||||
if(text.length() != 0){
|
||||
Intent intent=new Intent(BlogSearchActivity.this,BlogSearchResultActivity.class);
|
||||
Log.e("onClick-text",text);
|
||||
intent.putExtra("text",text);
|
||||
startActivity(intent);}
|
||||
else{
|
||||
Toast.makeText(BlogSearchActivity.this, "请输入搜索的内容", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
recView.setOnClickListener(new View.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
skip(recView);
|
||||
}
|
||||
});
|
||||
|
||||
foView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
skip(foView);
|
||||
}
|
||||
});
|
||||
|
||||
poView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
skip(poView);
|
||||
}
|
||||
});
|
||||
|
||||
meView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
skip(meView);
|
||||
}
|
||||
});
|
||||
|
||||
stView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
skip(stView);
|
||||
}
|
||||
});
|
||||
|
||||
exView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
skip(exView);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
private void skip(TextView view){
|
||||
String text = view.getText().toString();
|
||||
Intent intent=new Intent(BlogSearchActivity.this,BlogSearchResultActivity.class);
|
||||
// Log.e("onClick-text",text);
|
||||
intent.putExtra("text",text);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
}
|
@ -1,39 +1,103 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Adapter.HistoryQuestionAdapter;
|
||||
import com.example.leudaemialikeme.Adapter.QuestionAdapter;
|
||||
import com.example.leudaemialikeme.Model.Question;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.OkHttpUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class ConcernedProblemActivity extends BaseActivity {
|
||||
|
||||
private List<Question> mData = new ArrayList<>();
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
private boolean isPause;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_concerned_problem);
|
||||
getData();//获得数据
|
||||
RecyclerView recycleView = (RecyclerView) findViewById(R.id.questionList);//获得视图
|
||||
recyclerView = (RecyclerView) findViewById(R.id.questionList);//获得视图
|
||||
ImageView back_concerned = findViewById(R.id.back_concerned);
|
||||
LinearLayoutManager layoutManager;
|
||||
layoutManager = new LinearLayoutManager(this);
|
||||
recycleView.setLayoutManager(layoutManager);//建立线性布局
|
||||
QuestionAdapter adapter = new QuestionAdapter(mData);//创建适配器
|
||||
recycleView.setAdapter(adapter);//将视图与适配器连接起来
|
||||
recyclerView.setLayoutManager(layoutManager);//建立线性布局
|
||||
QuestionAdapter adapter = new QuestionAdapter(mData, ConcernedProblemActivity.this);//创建适配器
|
||||
recyclerView.setAdapter(adapter);//将视图与适配器连接起来
|
||||
getData();//获得数据
|
||||
back_concerned.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getData() {
|
||||
Question q1 = new Question("白血病的早期症状和前兆有什么","24浏览","10:24");
|
||||
mData.add(q1);
|
||||
Question q2 = new Question("白血病是什么原因引起的","112浏览","15:11");
|
||||
mData.add(q2);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
String url = ConcernedProblemActivity.SERVER_URL+"/my-servlet?action=concernedQuestion&uid="+ BaseActivity.owner.getNetId()+"&type="+3;
|
||||
Callback callback = new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
System.out.println("-----ERROR----");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String jsonStr = response.body().string();
|
||||
Gson gson = new Gson();
|
||||
Map<String, String> jsonMap= gson.fromJson(jsonStr, new TypeToken<Map<String, String>>() {}.getType());
|
||||
final String message=(String) jsonMap.get("message");
|
||||
if (message.equals("success")) {
|
||||
List<Question> questionList = gson.fromJson(jsonMap.get("questionList"), new TypeToken <List<Question>>(){}.getType());
|
||||
mData = questionList;
|
||||
QuestionAdapter adapter = new QuestionAdapter(mData, ConcernedProblemActivity.this);//创建适配器
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
}
|
||||
};
|
||||
OkHttpUtil.asyGet(url,callback);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
isPause = true; //记录页面已经被暂停
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (isPause){ //判断是否暂停
|
||||
isPause = false;
|
||||
getData();
|
||||
HistoryQuestionAdapter adapter = new HistoryQuestionAdapter(mData, ConcernedProblemActivity.this);//创建适配器
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.EditText;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.example.leudaemialikeme.Model.User;
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
public class MyInfoActivity extends AppCompatActivity {
|
||||
private User user;
|
||||
private EditText edit_id;
|
||||
private EditText edit_username;
|
||||
private EditText edit_password;
|
||||
private EditText edit_confirm_password;
|
||||
private EditText phone;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_my_info);
|
||||
Intent intent = getIntent();
|
||||
user = (User)intent.getSerializableExtra("user");
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,37 +1,103 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Adapter.MyQuestionAdapter;
|
||||
import com.example.leudaemialikeme.Model.MyQuestion;
|
||||
import com.example.leudaemialikeme.Model.Question;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.OkHttpUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class MyQuestionActivity extends BaseActivity {
|
||||
|
||||
private List<MyQuestion> mData = new ArrayList<>();
|
||||
private List<Question> questionList = new ArrayList<>();
|
||||
RecyclerView recycleView;
|
||||
private boolean isPause = false;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_my_question);
|
||||
getData();//获得数据
|
||||
RecyclerView recycleView = (RecyclerView) findViewById(R.id.myQuestionList);//获得视图
|
||||
recycleView = findViewById(R.id.my_question_list);//获得视图
|
||||
LinearLayoutManager layoutManager;
|
||||
layoutManager = new LinearLayoutManager(this);
|
||||
recycleView.setLayoutManager(layoutManager);//建立线性布局
|
||||
MyQuestionAdapter adapter = new MyQuestionAdapter(mData);//创建适配器
|
||||
MyQuestionAdapter adapter = new MyQuestionAdapter(questionList, MyQuestionActivity.this);//创建适配器
|
||||
recycleView.setAdapter(adapter);//将视图与适配器连接起来
|
||||
getMyQustionList();
|
||||
ImageView my_question_back = findViewById(R.id.my_question_back);
|
||||
my_question_back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getMyQustionList() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
String url = LoginActivity.SERVER_URL+"/my-servlet?action=getMyQuestionList&iduser="+ BaseActivity.owner.getNetId();
|
||||
OkHttpUtil.asyGet(url, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String jsonStr = response.body().string();
|
||||
Gson gson = new Gson();
|
||||
questionList = gson.fromJson(jsonStr, new TypeToken<List<Question>>() {}.getType());
|
||||
runOnUiThread(new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
MyQuestionAdapter adapter = new MyQuestionAdapter(questionList, MyQuestionActivity.this);//创建适配器
|
||||
recycleView.setAdapter(adapter);//将视图与适配器连接起来
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void getData() {
|
||||
MyQuestion q1 = new MyQuestion("成人白血病的早期症状有什么?","2浏览","22:24");
|
||||
mData.add(q1);
|
||||
MyQuestion q2 = new MyQuestion("幼儿易得白血病吗?","56浏览","09:11");
|
||||
mData.add(q2);
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
isPause = true; //记录页面已经被暂停
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (isPause){ //判断是否暂停
|
||||
isPause = false;
|
||||
getMyQustionList();
|
||||
MyQuestionAdapter adapter = new MyQuestionAdapter(questionList, MyQuestionActivity.this);//创建适配器
|
||||
recycleView.setAdapter(adapter);//将视图与适配器连接起来
|
||||
Log.d("添加一条浏览记录","刷新完成");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,102 +0,0 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.leudaemialikeme.Model.News;
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
public class NewsDetailActivity extends BaseActivity {
|
||||
TextView sTitleView;
|
||||
TextView sAuthorNameView;
|
||||
TextView sContentView;
|
||||
TextView sLikeNumView;
|
||||
TextView sColNumView;
|
||||
private int nid;
|
||||
private String nTitle;
|
||||
private String nContent;
|
||||
private String nBrowse;
|
||||
// TextView bComNumView;
|
||||
// EditText comEditView;
|
||||
// TextView comComView;//评论的部分
|
||||
ImageView detail_to;
|
||||
ImageView search;
|
||||
News news;
|
||||
// User author;//资讯不需要显示作者
|
||||
// List<Comment> commentList;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_news_detail);//显示详情页的布局
|
||||
|
||||
Intent intent = getIntent();
|
||||
nid = intent.getIntExtra("nid",-1);
|
||||
nTitle = intent.getStringExtra("nTitle");//获取帖子标题
|
||||
nContent = intent.getStringExtra("nContent");//获取内容
|
||||
nBrowse = intent.getStringExtra("nBrowseNum") ;//获取浏览量
|
||||
|
||||
initView();//初始布局
|
||||
initClick();//初始化点击
|
||||
|
||||
// EventBus.getDefault().register(this);//进行EvenBus的注册
|
||||
// Log.e("news:EventBus", news.getStittle());
|
||||
// if (news != null) {
|
||||
// Log.i("NewsDetailActivity", "news not null");
|
||||
// } else
|
||||
// Log.i("NewsDetailActivity", "news is null");
|
||||
setNewsDetail();//设置资讯子项的对应内容
|
||||
Log.e("传输后资讯编号nid是",String.valueOf(nid));
|
||||
Log.e("传输后资讯标题是",nTitle);
|
||||
Log.e("传输后资讯内容是",nContent);
|
||||
Log.e("传输后在详情页的资讯的浏览量是",nBrowse);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// protected void onDestroy() {
|
||||
// super.onDestroy();
|
||||
// EventBus.getDefault().unregister(this);
|
||||
// }
|
||||
|
||||
// @Subscribe(sticky = true)//标记和发送消息的标记一样
|
||||
// public void onEvent(News news) {//接受消息
|
||||
// this.news = news;
|
||||
// Log.e("接受的消息是",news.getScontent());
|
||||
// }
|
||||
|
||||
private void initView() {//初始化视图
|
||||
sTitleView = findViewById(R.id.detail_theme);
|
||||
sAuthorNameView = findViewById(R.id.author);
|
||||
sContentView = findViewById(R.id.sContent);
|
||||
sLikeNumView = findViewById(R.id.detail_like_num);//资讯点赞数
|
||||
sColNumView = findViewById(R.id.detail_col_num);//资讯收藏数
|
||||
detail_to = findViewById(R.id.detail_to);
|
||||
search = findViewById(R.id.detail_to_search);
|
||||
}
|
||||
|
||||
private void setNewsDetail() {//显示单个子项的资讯
|
||||
sTitleView.setText(nTitle);
|
||||
sContentView.setText(nContent);
|
||||
sLikeNumView.setText(nBrowse);//设置资讯的浏览量
|
||||
// updateNewsBrowse();//更新资讯浏览量
|
||||
// sLikeNumView.setText(String.valueOf(news.getSbrowseNum()));//其实是点赞量,但是显示资讯浏览量
|
||||
// sColNumView.setText(String.valueOf(news.getBcollectNum()));
|
||||
}
|
||||
|
||||
private void initClick() {
|
||||
detail_to.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
//搜索的点击事件去掉了
|
||||
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
public class NewsSearchActivity extends BaseActivity {
|
||||
ImageView back;
|
||||
EditText newsSearchEdit;
|
||||
TextView newsSearchCommit;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_news_search);
|
||||
initView();
|
||||
initClick();
|
||||
}
|
||||
|
||||
private void initView(){
|
||||
back = findViewById(R.id.search_back);
|
||||
newsSearchEdit = findViewById(R.id.news_search_edit);
|
||||
newsSearchCommit = findViewById(R.id.news_search_commit);
|
||||
}
|
||||
|
||||
private void initClick(){
|
||||
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
newsSearchCommit.setOnClickListener(new View.OnClickListener(){
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String text = newsSearchEdit.getText().toString();
|
||||
Intent intent=new Intent(NewsSearchActivity.this,NewsSearchResultActivity.class);
|
||||
Log.e("传递到result页的text = ",text);
|
||||
intent.putExtra("text",text);//把搜索的值传递到显示搜索结果的活动中
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
public class RegisterActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_register);
|
||||
}
|
||||
}
|
@ -1,74 +1,24 @@
|
||||
package com.example.leudaemialikeme.Activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
public class SearchActivity extends BaseActivity {
|
||||
private EditText nEditText;
|
||||
private ImageView back;
|
||||
Context context;
|
||||
Cursor cursor;
|
||||
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_search);
|
||||
context = this ;
|
||||
initView();
|
||||
// ImageView back;
|
||||
// back =findViewById(R.id.search_to_index);
|
||||
//
|
||||
// back.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) { //回到首页的跳转
|
||||
// Intent i = new Intent(SearchActivity.this, MainActivity.class);
|
||||
// i.putExtra("flag",1);
|
||||
// startActivity(i);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
ImageView back;
|
||||
back =findViewById(R.id.search_to_index);
|
||||
|
||||
private void initView(){
|
||||
back=(ImageView)findViewById(R.id.search_to_index);
|
||||
nEditText = (EditText)findViewById(R.id.EditText);//搜索栏
|
||||
//设置回首页跳转的点击事件
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) { //回到首页的跳转
|
||||
Intent i = new Intent(SearchActivity.this, MainActivity.class);
|
||||
i.putExtra("flag",1);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
|
||||
//搜索栏EditText添加监听
|
||||
nEditText.addTextChangedListener(new TextWatcher() {
|
||||
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}//文本改变之前执行
|
||||
|
||||
@Override
|
||||
//文本改变的时候执行
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
//如果长度为0
|
||||
if (s.length() == 0) {
|
||||
// //隐藏“删除”图片
|
||||
// mImageView.setVisibility(View.GONE);
|
||||
} else {//长度不为0
|
||||
//显示“删除图片”
|
||||
// mImageView.setVisibility(View.VISIBLE);
|
||||
//显示ListView
|
||||
// showListView();显示搜索项
|
||||
}
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
|
||||
public void afterTextChanged(Editable s) { }//文本改变之后执行
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AdapterClock extends BaseAdapter {
|
||||
|
||||
private String[] names={"甘露聚糖肽胶囊","消癌平糖浆"};
|
||||
private String[] time={"每天 8:00 14:00 19:00","每天 8:00 14:00 19:00"};
|
||||
private List<Switch> list_switch;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private TextView tv1,tv2;
|
||||
private Switch aSwitch;
|
||||
|
||||
public AdapterClock(Context context) {
|
||||
mContext=context;
|
||||
list_switch=new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
public Switch getaSwitch(int position){
|
||||
|
||||
return list_switch.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return names.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int i) {
|
||||
return names[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
|
||||
view= LayoutInflater.from(mContext).inflate(R.layout.list_item,null);
|
||||
tv1=(TextView)view.findViewById(R.id.md_name);
|
||||
tv2=(TextView)view.findViewById(R.id.md_time);
|
||||
aSwitch=(Switch)view.findViewById(R.id.sw);
|
||||
|
||||
list_switch.add(aSwitch);
|
||||
|
||||
tv1.setText(names[i]);
|
||||
tv2.setText(time[i]);
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Model.Collect;
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CollectAdapter extends RecyclerView.Adapter<CollectAdapter.ViewHolder>{
|
||||
private List<Collect> collectList;
|
||||
|
||||
//重写构造方法
|
||||
public CollectAdapter(List<Collect> collectList){
|
||||
this.collectList = collectList;
|
||||
}
|
||||
public int getItemCount(){
|
||||
return collectList.size();
|
||||
}
|
||||
//内部类
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView collectTitle,collectName,collectContent,collectRead;
|
||||
ImageView collectIcon,collectImg;
|
||||
|
||||
public ViewHolder(@NonNull View itemView){
|
||||
super(itemView);
|
||||
this.collectTitle = (TextView)itemView.findViewById(R.id.collectTitle);
|
||||
this.collectIcon = (ImageView)itemView.findViewById(R.id.collectIcon);
|
||||
this.collectName = (TextView)itemView.findViewById(R.id.collectName);
|
||||
this.collectContent = (TextView)itemView.findViewById(R.id.collectContent);
|
||||
this.collectImg = (ImageView)itemView.findViewById(R.id.collectImg);
|
||||
this.collectRead = (TextView)itemView.findViewById(R.id.collectRead);
|
||||
}
|
||||
}
|
||||
//重写 onCreateViewHolder()方法
|
||||
@Override
|
||||
public CollectAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.collect_item,parent,false);
|
||||
CollectAdapter.ViewHolder holder=new CollectAdapter.ViewHolder(view);
|
||||
return holder;
|
||||
}
|
||||
//重写onBindViewHolder()方法
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder,int position){
|
||||
Collect collect = collectList.get(position);
|
||||
holder.collectTitle.setText(collect.getCollectTitle());
|
||||
holder.collectName.setText(collect.getCollectName());
|
||||
holder.collectContent.setText(collect.getCollectContent());
|
||||
holder.collectRead.setText(collect.getCollectRead());
|
||||
holder.collectIcon.setImageResource(collect.getCollectIconId());
|
||||
holder.collectImg.setImageResource(collect.getCollectImgId());
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Model.Blog;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.TimeUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CollectBlogAdapter extends RecyclerView.Adapter<CollectBlogAdapter.ViewHolder>{
|
||||
private List<Blog> collectBlogList;
|
||||
|
||||
//重写构造方法
|
||||
public CollectBlogAdapter(List<Blog> collectBlogList){
|
||||
this.collectBlogList = collectBlogList;
|
||||
}
|
||||
public int getItemCount(){
|
||||
return collectBlogList.size();
|
||||
}
|
||||
//内部类
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView blog_title,blog_info,blog_read,blog_time;
|
||||
public ViewHolder(@NonNull View itemView){
|
||||
super(itemView);
|
||||
this.blog_title = itemView.findViewById(R.id.blog_title);
|
||||
this.blog_info = itemView.findViewById(R.id.blog_info);
|
||||
this.blog_read = itemView.findViewById(R.id.blog_read);
|
||||
this.blog_time = itemView.findViewById(R.id.blog_time);
|
||||
}
|
||||
}
|
||||
//重写 onCreateViewHolder()方法
|
||||
@Override
|
||||
public CollectBlogAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.collect_blog_item,parent,false);
|
||||
CollectBlogAdapter.ViewHolder holder=new CollectBlogAdapter.ViewHolder(view);
|
||||
return holder;
|
||||
}
|
||||
//重写onBindViewHolder()方法
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder,int position){
|
||||
Blog blog = collectBlogList.get(position);
|
||||
holder.blog_title.setText(blog.getBtittle());
|
||||
holder.blog_info.setText(blog.getBcontent());
|
||||
holder.blog_read.setText(String.valueOf(blog.getBbrowse()));
|
||||
holder.blog_time.setText(TimeUtil.timeToString(blog.getBtime()));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Model.News;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.TimeUtil;
|
||||
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CollectNewsAdapter extends RecyclerView.Adapter<CollectNewsAdapter.ViewHolder>{
|
||||
private List<News> collectNewsList;
|
||||
|
||||
//重写构造方法
|
||||
public CollectNewsAdapter(List<News> collectNewsList){
|
||||
this.collectNewsList = collectNewsList;
|
||||
}
|
||||
public int getItemCount(){
|
||||
return collectNewsList.size();
|
||||
}
|
||||
//内部类
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView news_title,news_info,news_read,news_time;
|
||||
|
||||
public ViewHolder(@NonNull View itemView){
|
||||
super(itemView);
|
||||
this.news_title = (TextView)itemView.findViewById(R.id.News_title);
|
||||
this.news_info = (TextView)itemView.findViewById(R.id.News_info);
|
||||
this.news_read = (TextView)itemView.findViewById(R.id.News_read);
|
||||
this.news_time = (TextView)itemView.findViewById(R.id.News_time);
|
||||
}
|
||||
}
|
||||
//重写 onCreateViewHolder()方法
|
||||
@Override
|
||||
public CollectNewsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.collect_news_item,parent,false);
|
||||
CollectNewsAdapter.ViewHolder holder=new CollectNewsAdapter.ViewHolder(view);
|
||||
return holder;
|
||||
}
|
||||
//重写onBindViewHolder()方法
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder,int position){
|
||||
News news = collectNewsList.get(position);
|
||||
holder.news_title.setText(news.getStittle());
|
||||
holder.news_info.setText(news.getScontent());
|
||||
holder.news_read.setText(String.valueOf(news.getSbrowseNum()));
|
||||
holder.news_time.setText(TimeUtil.timeToString(news.getStime()));
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Model.Comment;
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.ViewHolder>{
|
||||
List<Comment> mCommentList;
|
||||
Comment comment;
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder{
|
||||
TextView comName;
|
||||
TextView comContent;
|
||||
TextView comTime;
|
||||
public ViewHolder(View view){
|
||||
super(view);
|
||||
comName=(TextView) view.findViewById(R.id.comment_user_name);
|
||||
comContent=(TextView)view.findViewById(R.id.comment_content);
|
||||
comTime=(TextView)view.findViewById(R.id.comment_time);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMCommentList(List<Comment> commentList){
|
||||
mCommentList=commentList;
|
||||
}
|
||||
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.comment_item,parent,false);
|
||||
CommentAdapter.ViewHolder holder = new CommentAdapter.ViewHolder(view);
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CommentAdapter.ViewHolder holder, int position) {
|
||||
comment=mCommentList.get(position);
|
||||
holder.comName.setText(comment.getUName());
|
||||
holder.comContent.setText(comment.getContent());
|
||||
holder.comTime.setText(String.valueOf(comment.getTime()).substring(0,19));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mCommentList.size();
|
||||
}
|
||||
}
|
@ -1,54 +1,94 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.text.Layout;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Activity.AddEventActivity;
|
||||
import com.example.leudaemialikeme.Model.Event;
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder>{
|
||||
private List<Event> meventList;
|
||||
// private List<Event> meventList;
|
||||
private List<Map<String,String>> mcontentList;
|
||||
|
||||
//重写构造方法
|
||||
public EventAdapter(List<Event> meventList){
|
||||
this.meventList = meventList;
|
||||
public EventAdapter(List<Map<String,String>> contentList){
|
||||
this.mcontentList = contentList;
|
||||
}
|
||||
public int getItemCount(){
|
||||
return meventList.size();
|
||||
return mcontentList.size();
|
||||
}
|
||||
//内部类
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
View eventView;
|
||||
TextView event_day,event_month,event_info,event_time;
|
||||
TextView event_place,event_doctor_name,event_create_time;
|
||||
LinearLayout event_item_layout;
|
||||
|
||||
public ViewHolder(@NonNull View itemView){
|
||||
super(itemView);
|
||||
eventView = itemView;
|
||||
this.event_day = (TextView)itemView.findViewById(R.id.event_day);
|
||||
this.event_month = (TextView)itemView.findViewById(R.id.event_month);
|
||||
this.event_info = (TextView)itemView.findViewById(R.id.event_info);
|
||||
this.event_time = (TextView)itemView.findViewById(R.id.event_time);
|
||||
this.event_place = itemView.findViewById(R.id.event_place);
|
||||
this.event_doctor_name = itemView.findViewById(R.id.event_doctor_name);
|
||||
this.event_create_time = itemView.findViewById(R.id.event_create_time);
|
||||
this.event_item_layout = itemView.findViewById(R.id.event_item_layout);
|
||||
}
|
||||
}
|
||||
//重写 onCreateViewHolder()方法
|
||||
@Override
|
||||
public EventAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
public EventAdapter.ViewHolder onCreateViewHolder(final ViewGroup parent, int viewType) {
|
||||
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.event_item,parent,false);
|
||||
EventAdapter.ViewHolder holder=new EventAdapter.ViewHolder(view);
|
||||
// EventAdapter.ViewHolder holder=new EventAdapter.ViewHolder(view);
|
||||
final ViewHolder holder = new ViewHolder(view);
|
||||
holder.eventView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
int position = holder.getAdapterPosition();
|
||||
String event_day = mcontentList.get(position).get("event_day");
|
||||
String event_month = mcontentList.get(position).get("event_month");
|
||||
String event_info = mcontentList.get(position).get("event_info");
|
||||
String event_place = mcontentList.get(position).get("event_place");
|
||||
String event_doctor_name = mcontentList.get(position).get("event_doctor_name");
|
||||
String event_time = mcontentList.get(position).get("event_time");
|
||||
String event_create_time = mcontentList.get(position).get("event_create_time");
|
||||
Intent intent = new Intent(parent.getContext(), AddEventActivity.class);
|
||||
intent.putExtra(AddEventActivity.EVENT_DAY,event_day);
|
||||
intent.putExtra(AddEventActivity.EVENT_MONTH,event_month);
|
||||
intent.putExtra(AddEventActivity.EVENT_INFO,event_info);
|
||||
intent.putExtra(AddEventActivity.EVENT_PLACE,event_place);
|
||||
intent.putExtra(AddEventActivity.EVENT_DOCTOR_NAME,event_doctor_name);
|
||||
intent.putExtra(AddEventActivity.EVENT_TIME,event_time);
|
||||
intent.putExtra(AddEventActivity.EVENT_CREATE_TIME,event_create_time);
|
||||
parent.getContext().startActivity(intent);
|
||||
}
|
||||
});
|
||||
return holder;
|
||||
}
|
||||
//重写onBindViewHolder()方法
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder,int position){
|
||||
Event event = meventList.get(position);
|
||||
holder.event_day.setText(event.getEvent_day());
|
||||
holder.event_month.setText(event.getEvent_month());
|
||||
holder.event_info.setText(event.getEvent_info());
|
||||
holder.event_time.setText(event.getEvent_time());
|
||||
holder.event_day.setText(mcontentList.get(position).get("event_day"));
|
||||
holder.event_month.setText(mcontentList.get(position).get("event_month"));
|
||||
holder.event_info.setText(mcontentList.get(position).get("event_info"));
|
||||
holder.event_time.setText(mcontentList.get(position).get("event_time"));
|
||||
holder.event_place.setText(mcontentList.get(position).get("event_place"));
|
||||
holder.event_doctor_name.setText(mcontentList.get(position).get("event_doctor_name"));
|
||||
holder.event_create_time.setText(mcontentList.get(position).get("event_create_time"));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,56 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Model.Blog;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.TimeUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HistoryBlogAdapter extends RecyclerView.Adapter<HistoryBlogAdapter.ViewHolder>{
|
||||
private List<Blog> historyBlogList;
|
||||
|
||||
//重写构造方法
|
||||
public HistoryBlogAdapter(List<Blog> historyBlogList){
|
||||
this.historyBlogList = historyBlogList;
|
||||
}
|
||||
public int getItemCount(){
|
||||
return historyBlogList.size();
|
||||
}
|
||||
//内部类
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView blog_title,blog_info,blog_read,blog_time;
|
||||
public ViewHolder(@NonNull View itemView){
|
||||
super(itemView);
|
||||
this.blog_title = itemView.findViewById(R.id.blog_title);
|
||||
this.blog_info = itemView.findViewById(R.id.blog_info);
|
||||
this.blog_read = itemView.findViewById(R.id.blog_read);
|
||||
this.blog_time = itemView.findViewById(R.id.blog_time);
|
||||
}
|
||||
}
|
||||
//重写 onCreateViewHolder()方法
|
||||
@Override
|
||||
public HistoryBlogAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.collect_blog_item,parent,false);
|
||||
HistoryBlogAdapter.ViewHolder holder=new HistoryBlogAdapter.ViewHolder(view);
|
||||
return holder;
|
||||
}
|
||||
//重写onBindViewHolder()方法
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder,int position){
|
||||
Blog blog = historyBlogList.get(position);
|
||||
holder.blog_title.setText(blog.getBtittle());
|
||||
holder.blog_info.setText(blog.getBcontent());
|
||||
holder.blog_read.setText(String.valueOf(blog.getBbrowse()));
|
||||
holder.blog_time.setText(TimeUtil.timeToString(blog.getBtime()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,57 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Model.News;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.TimeUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HistoryNewsAdapter extends RecyclerView.Adapter<HistoryNewsAdapter.ViewHolder>{
|
||||
private List<News> historyNewsList;
|
||||
|
||||
//重写构造方法
|
||||
public HistoryNewsAdapter(List<News> historyNewsList){
|
||||
this.historyNewsList = historyNewsList;
|
||||
}
|
||||
public int getItemCount(){
|
||||
return historyNewsList.size();
|
||||
}
|
||||
//内部类
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView news_title,news_info,news_read,news_time;
|
||||
|
||||
public ViewHolder(@NonNull View itemView){
|
||||
super(itemView);
|
||||
this.news_title = (TextView)itemView.findViewById(R.id.News_title);
|
||||
this.news_info = (TextView)itemView.findViewById(R.id.News_info);
|
||||
this.news_read = (TextView)itemView.findViewById(R.id.News_read);
|
||||
this.news_time = (TextView)itemView.findViewById(R.id.News_time);
|
||||
}
|
||||
}
|
||||
//重写 onCreateViewHolder()方法
|
||||
@Override
|
||||
public HistoryNewsAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.collect_news_item,parent,false);
|
||||
HistoryNewsAdapter.ViewHolder holder=new HistoryNewsAdapter.ViewHolder(view);
|
||||
return holder;
|
||||
}
|
||||
//重写onBindViewHolder()方法
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder,int position){
|
||||
News news = historyNewsList.get(position);
|
||||
holder.news_title.setText(news.getStittle());
|
||||
holder.news_info.setText(news.getScontent());
|
||||
holder.news_read.setText(String.valueOf(news.getSbrowseNum()));
|
||||
holder.news_time.setText(TimeUtil.timeToString(news.getStime()));
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,36 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
|
||||
import com.example.leudaemialikeme.Fragment.BlogHistoryFragment;
|
||||
import com.example.leudaemialikeme.Fragment.NewsHistoryFragment;
|
||||
import com.example.leudaemialikeme.Fragment.QuestionHistoryFragment;
|
||||
|
||||
public class HistoryPageFragmentAdapter extends FragmentPagerAdapter {
|
||||
private String[] channelList;
|
||||
private FragmentManager fm;
|
||||
|
||||
public HistoryPageFragmentAdapter(FragmentManager fm, String[] channelList) {
|
||||
super(fm);
|
||||
this.channelList = channelList;
|
||||
this.fm=fm;
|
||||
}
|
||||
@Override
|
||||
public Fragment getItem(int idx) {
|
||||
String collectCategoryTitle = channelList[idx];
|
||||
if(collectCategoryTitle.equals(" 资讯 "))
|
||||
{
|
||||
return NewsHistoryFragment.newInstance(collectCategoryTitle);
|
||||
}
|
||||
else if(collectCategoryTitle.equals(" 问题 ")){
|
||||
return QuestionHistoryFragment.newInstance(collectCategoryTitle);
|
||||
}else{
|
||||
return BlogHistoryFragment.newInstance(collectCategoryTitle);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int getCount() {
|
||||
return channelList.length;
|
||||
} }
|
@ -0,0 +1,91 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Activity.BaseActivity;
|
||||
import com.example.leudaemialikeme.Activity.LoginActivity;
|
||||
import com.example.leudaemialikeme.Activity.QuestionDetailActivity;
|
||||
import com.example.leudaemialikeme.Model.Question;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.OkHttpUtil;
|
||||
import com.example.leudaemialikeme.Utils.TimeUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HistoryQuestionAdapter extends RecyclerView.Adapter<HistoryQuestionAdapter.ViewHolder>{
|
||||
private List<Question> historyQuestionList;
|
||||
private Context context;
|
||||
|
||||
//重写构造方法
|
||||
public HistoryQuestionAdapter(List<Question> historyQuestionList, Context context){
|
||||
this.historyQuestionList = historyQuestionList;
|
||||
this.context = context;
|
||||
}
|
||||
public int getItemCount(){
|
||||
return historyQuestionList.size();
|
||||
}
|
||||
//内部类
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView questionTitle,questionInfo,questionRead,questionTime,question_id;
|
||||
public ViewHolder(@NonNull View itemView){
|
||||
super(itemView);
|
||||
this.question_id = itemView.findViewById(R.id.question_id);
|
||||
this.questionTitle = itemView.findViewById(R.id.questionTitle);
|
||||
this.questionInfo = itemView.findViewById(R.id.questionInfo);
|
||||
this.questionRead = itemView.findViewById(R.id.questionRead);
|
||||
this.questionTime = itemView.findViewById(R.id.questionTime);
|
||||
}
|
||||
}
|
||||
//重写 onCreateViewHolder()方法
|
||||
@Override
|
||||
public HistoryQuestionAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.question_item,parent,false);
|
||||
HistoryQuestionAdapter.ViewHolder holder=new HistoryQuestionAdapter.ViewHolder(view);
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int qid = Integer.parseInt(holder.question_id.getText().toString());
|
||||
addQuestionBrowse(qid);
|
||||
Intent intent = new Intent(context, QuestionDetailActivity.class);
|
||||
intent.putExtra("qid", qid);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
return holder;
|
||||
}
|
||||
|
||||
private void addQuestionBrowse(int qid) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
String url = LoginActivity.SERVER_URL+"/main-servlet?action=addQuestionBrowse&qid="+qid+"&iduser="+ BaseActivity.owner.getNetId();
|
||||
OkHttpUtil.synGet(url);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
//重写onBindViewHolder()方法
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder,int position){
|
||||
Question question = historyQuestionList.get(position);
|
||||
holder.question_id.setText(String.valueOf(question.getQid()));
|
||||
holder.questionTitle.setText(question.getQtittle());
|
||||
holder.questionInfo.setText(question.getQcontent());
|
||||
holder.questionRead.setText(String.valueOf(question.getQbrowseNum()));
|
||||
holder.questionTime.setText(TimeUtil.timeToString(question.getQtime()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,72 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Activity.QuestionDetailActivity;
|
||||
import com.example.leudaemialikeme.Model.MyAnswerItemView;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.TimeUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MyAnswerAdapter extends RecyclerView.Adapter<MyAnswerAdapter.ViewHolder>{
|
||||
private List<MyAnswerItemView> answerList;
|
||||
private Context context;
|
||||
|
||||
public MyAnswerAdapter(List<MyAnswerItemView> answerList, Context context) {
|
||||
this.answerList = answerList;
|
||||
this.context = context;
|
||||
}
|
||||
static class ViewHolder extends RecyclerView.ViewHolder{
|
||||
private TextView text_answer_qid;
|
||||
private TextView text_my_answer_title;
|
||||
private TextView text_my_answer;
|
||||
private TextView text_answer_time;
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
text_answer_qid = itemView.findViewById(R.id.text_answer_qid);
|
||||
text_my_answer_title = itemView.findViewById(R.id.text_my_answer_title);
|
||||
text_my_answer = itemView.findViewById(R.id.text_my_answer);
|
||||
text_answer_time = itemView.findViewById(R.id.text_answer_time);
|
||||
}
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.my_answer_item,parent,false);
|
||||
final MyAnswerAdapter.ViewHolder holder=new MyAnswerAdapter.ViewHolder(view);
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(context, QuestionDetailActivity.class);
|
||||
intent.putExtra("qid", Integer.parseInt(holder.text_answer_qid.getText().toString()));
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
MyAnswerItemView answer = answerList.get(position);
|
||||
holder.text_answer_qid.setText(String.valueOf(answer.getQid()));
|
||||
holder.text_my_answer_title.setText(answer.getQtitle());
|
||||
holder.text_my_answer.setText(answer.getAcontent());
|
||||
holder.text_answer_time.setText(TimeUtil.timeToString(answer.getAnswerTime()));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return answerList.size();
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Model.Blog;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.TimeUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MyBlogAdapter extends RecyclerView.Adapter<MyBlogAdapter.ViewHolder>{
|
||||
List<Blog> blogList = new ArrayList<>();
|
||||
|
||||
public MyBlogAdapter(List<Blog> blogList){
|
||||
this.blogList = blogList;
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder{
|
||||
private TextView text_my_blog_id;
|
||||
private TextView text_my_blog_title;
|
||||
private TextView text_my_blog_content;
|
||||
private TextView text_my_blog_browse;
|
||||
private TextView text_my_blog_time;
|
||||
private TextView text_my_blog_flag;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
text_my_blog_id = itemView.findViewById(R.id.text_my_blog_id);
|
||||
text_my_blog_title = itemView.findViewById(R.id.text_my_blog_title);
|
||||
text_my_blog_content = itemView.findViewById(R.id.text_my_blog_content);
|
||||
text_my_blog_browse = itemView.findViewById(R.id.text_my_blog_browse);
|
||||
text_my_blog_time = itemView.findViewById(R.id.text_my_blog_time);
|
||||
text_my_blog_flag = itemView.findViewById(R.id.text_my_blog_flag);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyBlogAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.my_blog_item,parent,false);
|
||||
MyBlogAdapter.ViewHolder holder = new MyBlogAdapter.ViewHolder(view);
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//TODO 跳转到帖子的详情页
|
||||
}
|
||||
});
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MyBlogAdapter.ViewHolder holder, int position) {
|
||||
Blog blog = blogList.get(position);
|
||||
holder.text_my_blog_id.setText(String.valueOf(blog.getBid()));
|
||||
holder.text_my_blog_title.setText(blog.getBtittle());
|
||||
holder.text_my_blog_content.setText(blog.getBcontent());
|
||||
holder.text_my_blog_browse.setText(String.valueOf(blog.getBbrowse()));
|
||||
holder.text_my_blog_time.setText(TimeUtil.timeToString(blog.getBtime()));
|
||||
if(blog.getFlag()==1)
|
||||
holder.text_my_blog_flag.setText("已审核");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return blogList.size();
|
||||
}
|
||||
}
|
@ -1,55 +1,96 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Activity.BaseActivity;
|
||||
import com.example.leudaemialikeme.Activity.LoginActivity;
|
||||
import com.example.leudaemialikeme.Activity.QuestionDetailActivity;
|
||||
import com.example.leudaemialikeme.Model.Question;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.OkHttpUtil;
|
||||
import com.example.leudaemialikeme.Utils.TimeUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class QuestionAdapter extends RecyclerView.Adapter<QuestionAdapter.ViewHolder>{
|
||||
private List<Question> questionList;
|
||||
|
||||
private Context context;
|
||||
//重写构造方法
|
||||
public QuestionAdapter(List<Question> questionList){
|
||||
public QuestionAdapter(List<Question> questionList, Context context){
|
||||
this.questionList = questionList;
|
||||
this.context = context;
|
||||
}
|
||||
public QuestionAdapter(){
|
||||
|
||||
}
|
||||
|
||||
public int getItemCount(){
|
||||
return questionList.size();
|
||||
}
|
||||
//内部类
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView questionInfo,questionRead,questionTime;
|
||||
LinearLayout questionMore;
|
||||
private TextView questionId, questiontitle,questionInfo,questionRead,questionTime;
|
||||
|
||||
public ViewHolder(@NonNull View itemView){
|
||||
super(itemView);
|
||||
this.questionId = itemView.findViewById(R.id.question_id);
|
||||
this.questiontitle = itemView.findViewById(R.id.questionTitle);
|
||||
this.questionInfo = (TextView)itemView.findViewById(R.id.questionInfo);
|
||||
this.questionRead = (TextView)itemView.findViewById(R.id.questionRead);
|
||||
this.questionTime = (TextView)itemView.findViewById(R.id.questionTime);
|
||||
this.questionMore = (LinearLayout) itemView.findViewById(R.id.questionMore);
|
||||
}
|
||||
}
|
||||
|
||||
public void setQuestionList(List<Question> questionList){
|
||||
this.questionList=questionList;
|
||||
}
|
||||
//重写 onCreateViewHolder()方法
|
||||
@Override
|
||||
public QuestionAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.question_item,parent,false);
|
||||
QuestionAdapter.ViewHolder holder=new QuestionAdapter.ViewHolder(view);
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int qid = Integer.parseInt(holder.questionId.getText().toString());
|
||||
addQuestionBrowse(qid);
|
||||
Intent intent = new Intent(context, QuestionDetailActivity.class);
|
||||
intent.putExtra("qid", qid);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
return holder;
|
||||
}
|
||||
|
||||
private void addQuestionBrowse(int qid) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
String url = LoginActivity.SERVER_URL+"/main-servlet?action=addQuestionBrowse&qid="+qid+"&iduser="+ BaseActivity.owner.getNetId();
|
||||
OkHttpUtil.synGet(url);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
//重写onBindViewHolder()方法
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull QuestionAdapter.ViewHolder holder, int position){
|
||||
Question question = questionList.get(position);
|
||||
holder.questionInfo.setText(question.getQuestionInfo());
|
||||
holder.questionRead.setText(question.getQuestionRead());
|
||||
holder.questionTime.setText(question.getQuestionTime());
|
||||
holder.questionId.setText(String.valueOf(question.getQid()));
|
||||
holder.questiontitle.setText(question.getQtittle());
|
||||
holder.questionInfo.setText(question.getQcontent());
|
||||
holder.questionRead.setText(String.valueOf(question.getQbrowseNum()));
|
||||
holder.questionTime.setText(TimeUtil.timeToString(question.getQtime()));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,57 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Model.AnswerItemView;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.TimeUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class QuestionDetailAdapter extends RecyclerView.Adapter<QuestionDetailAdapter.ViewHolder>{
|
||||
List<AnswerItemView> answerList = new ArrayList<>();
|
||||
public QuestionDetailAdapter(List<AnswerItemView> answerList){
|
||||
this.answerList = answerList;
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
private TextView text_answer_username;
|
||||
private TextView text_answer_content;
|
||||
private TextView text_answer_time;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
text_answer_username = itemView.findViewById(R.id.text_answer_username);
|
||||
text_answer_content = itemView.findViewById(R.id.text_answer_content);
|
||||
text_answer_time = itemView.findViewById(R.id.text_answer_time);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public QuestionDetailAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.answer_item,parent,false);
|
||||
QuestionDetailAdapter.ViewHolder holder = new QuestionDetailAdapter.ViewHolder(view);
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull QuestionDetailAdapter.ViewHolder holder, int position) {
|
||||
AnswerItemView answer = answerList.get(position);
|
||||
holder.text_answer_username.setText(answer.getAnswerAuthor());
|
||||
holder.text_answer_content.setText(answer.getAnswerContent());
|
||||
holder.text_answer_time.setText(TimeUtil.timeToString(answer.getAnswerTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return answerList.size();
|
||||
}
|
||||
}
|
@ -0,0 +1,176 @@
|
||||
package com.example.leudaemialikeme.Adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.CallAlarm;
|
||||
import com.example.leudaemialikeme.ClockDetail;
|
||||
import com.example.leudaemialikeme.Model.Clock;
|
||||
import com.example.leudaemialikeme.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import static android.content.Context.ALARM_SERVICE;
|
||||
|
||||
public class TimeAdapter extends RecyclerView.Adapter<TimeAdapter.ViewHolder> {
|
||||
List<Clock> list;
|
||||
LayoutInflater layoutInflater;
|
||||
Context context;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
public static int pos;
|
||||
|
||||
|
||||
|
||||
public TimeAdapter(List<Clock> list, Context context) {
|
||||
this.list = list;
|
||||
this.context = context;
|
||||
layoutInflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimeAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||
View view = layoutInflater.inflate(R.layout.list_item, null);
|
||||
ViewHolder viewHolder = new ViewHolder(view);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@SuppressLint({"ResourceAsColor", "SetTextI18n"})
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final TimeAdapter.ViewHolder viewHolder, final int i) {
|
||||
final Clock clock = list.get(i);
|
||||
System.out.println(i+"闹钟的位置");
|
||||
pos = i;
|
||||
|
||||
Log.e("i=======",i+" "+clock.getClockType());
|
||||
if (clock.getClockType() == Clock.clock_open){
|
||||
viewHolder.aSwitch.setChecked(true);
|
||||
viewHolder.hour.setTextColor(context.getResources().getColor(R.color.colorBlack));
|
||||
viewHolder.minute.setTextColor(context.getResources().getColor(R.color.colorBlack));
|
||||
viewHolder.net.setTextColor(context.getResources().getColor(R.color.colorBlack));
|
||||
viewHolder.content_name.setTextColor(context.getResources().getColor(R.color.colorBlack));
|
||||
viewHolder.content_dosage.setTextColor(context.getResources().getColor(R.color.colorBlack));
|
||||
}else if (clock.getClockType() == Clock.clock_close){
|
||||
viewHolder.aSwitch.setChecked(false);
|
||||
viewHolder.hour.setTextColor(context.getResources().getColor(R.color.colorGray));
|
||||
viewHolder.minute.setTextColor(context.getResources().getColor(R.color.colorGray));
|
||||
viewHolder.net.setTextColor(context.getResources().getColor(R.color.colorGray));
|
||||
viewHolder.content_name.setTextColor(context.getResources().getColor(R.color.colorGray));
|
||||
viewHolder.content_dosage.setTextColor(context.getResources().getColor(R.color.colorGray));
|
||||
}
|
||||
viewHolder.hour.setText(clock.getHour()+"");
|
||||
viewHolder.minute.setText(clock.getMinute()+"");
|
||||
|
||||
viewHolder.content_name.setText(clock.getName());
|
||||
viewHolder.content_dosage.setText(clock.getDosage());
|
||||
viewHolder.todetail.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.e("TODETAIL",clock.getClockType()+"");
|
||||
Intent intent = new Intent(context, ClockDetail.class);
|
||||
intent.putExtra("position", i);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
viewHolder.aSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@SuppressLint("ResourceAsColor")
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (isChecked) {
|
||||
clock.setClockType(Clock.clock_open);
|
||||
//clock.updateAll();
|
||||
clock.save();
|
||||
Toast.makeText(context, "开启闹钟", Toast.LENGTH_SHORT).show();
|
||||
viewHolder.hour.setTextColor(context.getResources().getColor(R.color.colorBlack));
|
||||
viewHolder.minute.setTextColor(context.getResources().getColor(R.color.colorBlack));
|
||||
viewHolder.net.setTextColor(context.getResources().getColor(R.color.colorBlack));
|
||||
viewHolder.content_name.setTextColor(context.getResources().getColor(R.color.colorBlack));
|
||||
viewHolder.content_dosage.setTextColor(context.getResources().getColor(R.color.colorBlack));
|
||||
Intent intent = new Intent(context, CallAlarm.class);
|
||||
PendingIntent sender = PendingIntent.getBroadcast(
|
||||
context, 0, intent, 0);
|
||||
AlarmManager am;
|
||||
am = (AlarmManager) context.getSystemService(ALARM_SERVICE);
|
||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(clock.getHour()));
|
||||
calendar.set(Calendar.MINUTE, Integer.parseInt(clock.getMinute()));
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
Log.e("TAG",calendar.getTimeInMillis()+"");
|
||||
Log.e("TAG",System.currentTimeMillis()+"");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (System.currentTimeMillis()>calendar.getTimeInMillis()+40000){
|
||||
//加24小时
|
||||
am.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis()+86400000, sender);
|
||||
}else {
|
||||
am.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);
|
||||
}
|
||||
}
|
||||
} else if (!isChecked){
|
||||
clock.setClockType(Clock.clock_close);
|
||||
//clock.updateAll();
|
||||
clock.save();
|
||||
Log.e("status------",clock.getHour()+clock.getMinute()+clock.getMinute()+clock.getClockType()+"");
|
||||
|
||||
Log.e("关闭闹钟",clock.getClockType()+"");
|
||||
Intent intent = new Intent(context, CallAlarm.class);
|
||||
PendingIntent sender=PendingIntent.getBroadcast(
|
||||
context,0, intent, 0);
|
||||
AlarmManager am;
|
||||
am =(AlarmManager)context.getSystemService(ALARM_SERVICE);
|
||||
am.cancel(sender);
|
||||
Toast.makeText(context, "关闭闹钟", Toast.LENGTH_SHORT).show();
|
||||
viewHolder.hour.setTextColor(context.getResources().getColor(R.color.colorGray));
|
||||
viewHolder.minute.setTextColor(context.getResources().getColor(R.color.colorGray));
|
||||
viewHolder.net.setTextColor(context.getResources().getColor(R.color.colorGray));
|
||||
viewHolder.content_name.setTextColor(context.getResources().getColor(R.color.colorGray));
|
||||
viewHolder.content_dosage.setTextColor(context.getResources().getColor(R.color.colorGray));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView hour;
|
||||
TextView minute;
|
||||
TextView content_name,content_dosage;
|
||||
TextView net;
|
||||
Switch aSwitch;
|
||||
LinearLayout todetail;
|
||||
|
||||
public ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
hour = itemView.findViewById(R.id.hour);
|
||||
minute = itemView.findViewById(R.id.minute);
|
||||
net = itemView.findViewById(R.id.net);
|
||||
content_name = itemView.findViewById(R.id.content_name);
|
||||
content_dosage = itemView.findViewById(R.id.content_dosage);
|
||||
aSwitch = itemView.findViewById(R.id.switch_control);
|
||||
todetail = itemView.findViewById(R.id.todetail);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.example.leudaemialikeme;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.example.leudaemialikeme.Activity.AlarmAlert;
|
||||
|
||||
public class CallAlarm extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Intent intent1 = new Intent(context, AlarmAlert.class);
|
||||
Bundle bundle = new Bundle();
|
||||
//String content = intent.getStringExtra("content");
|
||||
//Log.e("content===sadsad",content);
|
||||
bundle.putString("STR_CALLER","");
|
||||
intent1.putExtras(bundle);
|
||||
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent1);
|
||||
}
|
||||
}
|
@ -0,0 +1,174 @@
|
||||
package com.example.leudaemialikeme;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.TimePickerDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TimePicker;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.example.leudaemialikeme.Model.Clock;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import static com.example.leudaemialikeme.Activity.MdctRmdActivity.list;
|
||||
import static com.example.leudaemialikeme.Activity.MdctRmdActivity.timeAdapter;
|
||||
|
||||
public class ClockDetail extends Activity implements View.OnClickListener{
|
||||
private Calendar calendar;
|
||||
private TextView show_hour;
|
||||
private TextView show_minute;
|
||||
private EditText content_name;
|
||||
private EditText content_dosage;
|
||||
private ImageView back;
|
||||
private TextView title;
|
||||
private Button set;
|
||||
private Button save;
|
||||
private Button delete;
|
||||
Clock clock;
|
||||
int position;
|
||||
String hourformat;
|
||||
String minuteformat;
|
||||
Context context = ClockDetail.this;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_clock_detail);
|
||||
show_hour = findViewById(R.id.hour);
|
||||
show_minute = findViewById(R.id.minute);
|
||||
content_name = findViewById(R.id.content_name);
|
||||
content_dosage = findViewById(R.id.content_dosage);
|
||||
set = findViewById(R.id.set_time);
|
||||
set.setOnClickListener(this);
|
||||
save = findViewById(R.id.save);
|
||||
save.setOnClickListener(this);
|
||||
delete = findViewById(R.id.delete);
|
||||
delete.setOnClickListener(this);
|
||||
back = findViewById(R.id.back_list_clock);
|
||||
back.setOnClickListener(this);
|
||||
back.setImageResource(R.drawable.ic_back);
|
||||
title = findViewById(R.id.title);
|
||||
title.setText("服药提醒详情");
|
||||
calendar = Calendar.getInstance();
|
||||
initView();
|
||||
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void initView() {
|
||||
position = getIntent().getIntExtra("position", -1);
|
||||
clock = list.get(position);
|
||||
Log.e("position", position + "");
|
||||
if (clock.getHour() != null && clock.getMinute() != null) {
|
||||
hourformat = formatString(clock.getHour());
|
||||
minuteformat = formatString(clock.getMinute());
|
||||
}
|
||||
content_name.setText(clock.getName());
|
||||
content_dosage.setText(clock.getDosage());
|
||||
show_hour.setText(clock.getHour() + "");
|
||||
show_minute.setText(clock.getMinute() + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.set_time:
|
||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
int mhour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int mminute = calendar.get(Calendar.MINUTE);
|
||||
new TimePickerDialog(ClockDetail.this, new TimePickerDialog.OnTimeSetListener() {
|
||||
@Override
|
||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||
//calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
|
||||
calendar.set(Calendar.MINUTE, minute);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
hourformat = format(hourOfDay);
|
||||
minuteformat = format(minute);
|
||||
Toast.makeText(ClockDetail.this, "" + hourformat + ":" + minuteformat, Toast.LENGTH_SHORT).show();
|
||||
show_hour.setText(hourformat);
|
||||
show_minute.setText(minuteformat);
|
||||
|
||||
|
||||
}
|
||||
}, mhour, mminute, true).show();
|
||||
break;
|
||||
case R.id.save:
|
||||
clock.setHour(hourformat);
|
||||
clock.setMinute(minuteformat);
|
||||
clock.setName("" + content_name.getText().toString());
|
||||
clock.setDosage("" + content_dosage.getText().toString());
|
||||
clock.setClockType(Clock.clock_open);
|
||||
clock.save();
|
||||
Intent intent = new Intent(ClockDetail.this, CallAlarm.class);
|
||||
// intent.putExtra("content",clock.getContent());
|
||||
//sendBroadcast(intent);
|
||||
PendingIntent sender = PendingIntent.getBroadcast(
|
||||
ClockDetail.this, 0, intent, 0);
|
||||
AlarmManager am;
|
||||
am = (AlarmManager) getSystemService(ALARM_SERVICE);
|
||||
Log.e("gethour",clock.getHour());
|
||||
Log.e("gethour",clock.getMinute());
|
||||
calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(clock.getHour()));
|
||||
calendar.set(Calendar.MINUTE, Integer.parseInt(clock.getMinute()));
|
||||
Log.e("TAG",calendar.getTimeInMillis()+"");
|
||||
Log.e("TAG",System.currentTimeMillis()+"");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
if (System.currentTimeMillis()>calendar.getTimeInMillis()+60000){
|
||||
//加24小时
|
||||
am.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis()+86400000, sender);
|
||||
}else {
|
||||
am.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), sender);
|
||||
}
|
||||
}
|
||||
|
||||
timeAdapter.notifyDataSetChanged();
|
||||
finish();
|
||||
break;
|
||||
case R.id.delete:
|
||||
clock.delete();
|
||||
timeAdapter.notifyDataSetChanged();
|
||||
Intent intent1 = new Intent(context, CallAlarm.class);
|
||||
PendingIntent sender1=PendingIntent.getBroadcast(
|
||||
context,0, intent1, 0);
|
||||
am =(AlarmManager)context.getSystemService(ALARM_SERVICE);
|
||||
am.cancel(sender1);
|
||||
finish();
|
||||
break;
|
||||
case R.id.back_list_clock:
|
||||
finish();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private String format(int x) {
|
||||
String s = "" + x;
|
||||
if (s.length() == 1) {
|
||||
s = "0" + s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
private String formatString(String x) {
|
||||
String s = x;
|
||||
if (s.length() == 1) {
|
||||
s = "0" + s;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
package com.example.leudaemialikeme.Dao;
|
||||
|
||||
import com.example.leudaemialikeme.Model.Friend;
|
||||
|
||||
import org.litepal.LitePal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class FriendDao extends BaseDao{
|
||||
|
||||
public ArrayList<Friend> findFriendListByOwnerNetId(int ownerNetId){
|
||||
ArrayList<Friend> friendList=(ArrayList<Friend>)LitePal.where("ownerNetId = ?", String.valueOf(ownerNetId)).find(Friend.class);
|
||||
return friendList;
|
||||
}
|
||||
|
||||
public ArrayList<Friend> findChatFriendList(int ownerNetId){
|
||||
ArrayList<Friend> friendList=(ArrayList<Friend>)LitePal.where("ownerNetId = ? AND isChat = ?", String.valueOf(ownerNetId),"1").find(Friend.class);
|
||||
return friendList;
|
||||
}
|
||||
|
||||
public Friend findByNetId(int netId,int ownerNetId){
|
||||
ArrayList<Friend> friendList=(ArrayList<Friend>)LitePal.where("netId = ? and ownerNetId = ?", String.valueOf(netId),String.valueOf(ownerNetId)).find(Friend.class);
|
||||
if (friendList.size()==0){
|
||||
return null;
|
||||
}
|
||||
return friendList.get(0);
|
||||
}
|
||||
|
||||
public void changeChatStatus(Friend friend, int netId, int ownerNetId){
|
||||
friend.updateAll("netId = ? and ownerNetId = ?",String.valueOf(netId),String.valueOf(ownerNetId));
|
||||
}
|
||||
|
||||
// public ArrayList<Friend> findByKeyword(String keyword,int ownerNetId){
|
||||
// String keywordCop="%"+keyword+"%";
|
||||
// ArrayList<Friend> friends=(ArrayList<Friend>) LitePal.where("name like ? AND isfriend=1 AND ownerNetId=?",keywordCop,String.valueOf(ownerNetId)).find(Friend.class);
|
||||
// return friends;
|
||||
// }
|
||||
|
||||
// public ArrayList<Friend> findNewFriendList(int ownerNetId){
|
||||
// ArrayList<Friend> friendList=(ArrayList<Friend>)LitePal.where("ownerNetId = ? AND isfriend=0", String.valueOf(ownerNetId)).find(Friend.class);
|
||||
// return friendList;
|
||||
// }
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
package com.example.leudaemialikeme.Fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.leudaemialikeme.Activity.BaseActivity;
|
||||
import com.example.leudaemialikeme.Adapter.MyAnswerAdapter;
|
||||
import com.example.leudaemialikeme.Adapter.MyBlogAdapter;
|
||||
import com.example.leudaemialikeme.Model.Blog;
|
||||
import com.example.leudaemialikeme.Model.MyAnswerItemView;
|
||||
import com.example.leudaemialikeme.R;
|
||||
import com.example.leudaemialikeme.Utils.OkHttpUtil;
|
||||
import com.example.leudaemialikeme.Utils.TimeUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.Call;
|
||||
import okhttp3.Callback;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class APNChannelFragment extends Fragment {
|
||||
private static final String ARG_CATEGORY_TITLE = "category_title";
|
||||
private String APNCategoryTitle = "Default";
|
||||
private List<MyAnswerItemView> answerList = new ArrayList<>();
|
||||
private List<Blog> blogList = new ArrayList<>();
|
||||
private RecyclerView answerRecyclerview;
|
||||
private RecyclerView blogRecyclerview;
|
||||
public APNChannelFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static APNChannelFragment newInstance(String APNCategoryTitle) {
|
||||
APNChannelFragment fragment = new APNChannelFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString(ARG_CATEGORY_TITLE, APNCategoryTitle);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
try {
|
||||
APNCategoryTitle = getArguments().getString(ARG_CATEGORY_TITLE);
|
||||
} catch (java.lang.NullPointerException e) {
|
||||
System.out.println("TesFragment getArg error!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view;
|
||||
if (APNCategoryTitle.equals("回答")) {
|
||||
view = inflater.inflate(R.layout.recyclerview, container, false);
|
||||
answerRecyclerview = view.findViewById(R.id.list_community);
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
|
||||
answerRecyclerview.setLayoutManager(layoutManager);
|
||||
MyAnswerAdapter adapter = new MyAnswerAdapter(answerList, getContext());
|
||||
answerRecyclerview.setAdapter(adapter);
|
||||
getMyAnswerList();
|
||||
} else if (APNCategoryTitle.equals("帖子")) {
|
||||
view = inflater.inflate(R.layout.recyclerview, container, false);
|
||||
blogRecyclerview = view.findViewById(R.id.list_community);
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
|
||||
blogRecyclerview.setLayoutManager(layoutManager);
|
||||
MyBlogAdapter adapter = new MyBlogAdapter(blogList);
|
||||
blogRecyclerview.setAdapter(adapter);
|
||||
getMyBlogList();
|
||||
} else {
|
||||
view = inflater.inflate(R.layout.fragment_a_p_n_channel, container, false);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
private void getMyBlogList() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
String url = BaseActivity.SERVER_URL+"/my-servlet?action=getMyBlogList&iduser="+BaseActivity.owner.getNetId();
|
||||
OkHttpUtil.asyGet(url, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String jsonStr = response.body().string();
|
||||
Gson gson = new Gson();
|
||||
final List<Blog> blogList = gson.fromJson(jsonStr, new TypeToken<List<Blog>>() {}.getType());
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MyBlogAdapter adapter = new MyBlogAdapter(blogList);
|
||||
blogRecyclerview.setAdapter(adapter);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void getMyAnswerList() {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try{
|
||||
String url = BaseActivity.SERVER_URL+"/my-servlet?action=getMyAnswerList&iduser="+BaseActivity.owner.getNetId();
|
||||
OkHttpUtil.asyGet(url, new Callback() {
|
||||
@Override
|
||||
public void onFailure(Call call, IOException e) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onResponse(Call call, Response response) throws IOException {
|
||||
String jsonStr = response.body().string();
|
||||
Gson gson = new Gson();
|
||||
List<Map<String,String>> list = gson.fromJson(jsonStr, new TypeToken<List<Map<String, String>>>() {}.getType());
|
||||
for(int i=0; i<list.size(); i++){
|
||||
Map<String, String> jsonMap = list.get(i);
|
||||
MyAnswerItemView myAnswerItemView = new MyAnswerItemView();
|
||||
myAnswerItemView.setQid(Integer.parseInt(jsonMap.get("qid")));
|
||||
myAnswerItemView.setQtitle(jsonMap.get("qtitle"));
|
||||
myAnswerItemView.setAcontent(jsonMap.get("content"));
|
||||
myAnswerItemView.setAnswerTime(TimeUtil.stringToTime(jsonMap.get("answerTime")));
|
||||
answerList.add(myAnswerItemView);
|
||||
}
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MyAnswerAdapter adapter = new MyAnswerAdapter(answerList, getContext());
|
||||
answerRecyclerview.setAdapter(adapter);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.example.leudaemialikeme.Model;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class AnswerItemView {
|
||||
private String answerAuthor;
|
||||
private String answerContent;
|
||||
private Timestamp answerTime;
|
||||
|
||||
public AnswerItemView(){
|
||||
|
||||
}
|
||||
|
||||
public AnswerItemView(String answerAuthor, String answerContent, Timestamp answerTime) {
|
||||
this.answerAuthor = answerAuthor;
|
||||
this.answerContent = answerContent;
|
||||
this.answerTime = answerTime;
|
||||
}
|
||||
|
||||
public String getAnswerAuthor() {
|
||||
return answerAuthor;
|
||||
}
|
||||
|
||||
public void setAnswerAuthor(String answerAuthor) {
|
||||
this.answerAuthor = answerAuthor;
|
||||
}
|
||||
|
||||
public String getAnswerContent() {
|
||||
return answerContent;
|
||||
}
|
||||
|
||||
public void setAnswerContent(String answerContent) {
|
||||
this.answerContent = answerContent;
|
||||
}
|
||||
|
||||
public Timestamp getAnswerTime() {
|
||||
return answerTime;
|
||||
}
|
||||
|
||||
public void setAnswerTime(Timestamp answerTime) {
|
||||
this.answerTime = answerTime;
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package com.example.leudaemialikeme.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class Blog implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int bid;
|
||||
private int uid;
|
||||
private String btype;
|
||||
private String btittle;
|
||||
private String bcontent;
|
||||
private Timestamp btime;
|
||||
private int blikeNum;
|
||||
private int bcollectNum;
|
||||
private int bbrowse;
|
||||
private int flag;
|
||||
|
||||
public Blog() {
|
||||
|
||||
}
|
||||
|
||||
public Blog(int bid,int uid,String btype,String btittle,String bcontent,Timestamp btime,int blikeNum,
|
||||
int bcollectNum,int bbrowse,int flag) {
|
||||
this.bid=bid;
|
||||
this.uid=uid;
|
||||
this.btype=btype;
|
||||
this.btittle=btittle;
|
||||
this.bcontent=bcontent;
|
||||
this.btime=btime;
|
||||
this.blikeNum=blikeNum;
|
||||
this.bcollectNum=bcollectNum;
|
||||
this.bbrowse=bbrowse;
|
||||
this.flag=flag;
|
||||
|
||||
}
|
||||
|
||||
public Blog(int uid,String btype,String btittle,String bcontent,Timestamp btime,int blikeNum,
|
||||
int bcollectNum,int bbrowse,int flag) {
|
||||
this.uid=uid;
|
||||
this.btype=btype;
|
||||
this.btittle=btittle;
|
||||
this.bcontent=bcontent;
|
||||
this.btime=btime;
|
||||
this.blikeNum=blikeNum;
|
||||
this.bcollectNum=bcollectNum;
|
||||
this.bbrowse=bbrowse;
|
||||
this.flag=flag;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid=uid;
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setBid(int bid) {
|
||||
this.bid=bid;
|
||||
}
|
||||
|
||||
public int getBid() {
|
||||
return bid;
|
||||
}
|
||||
|
||||
public void setBtype(String btype) {
|
||||
this.btype=btype;
|
||||
}
|
||||
|
||||
public String getBtype() {
|
||||
return btype;
|
||||
}
|
||||
|
||||
public void setBtittle(String btittle) {
|
||||
this.btittle=btittle;
|
||||
}
|
||||
|
||||
public String getBtittle() {
|
||||
return btittle;
|
||||
}
|
||||
|
||||
public void setBcontent(String bcontent) {
|
||||
this.bcontent=bcontent;
|
||||
}
|
||||
|
||||
public String getBcontent() {
|
||||
return bcontent;
|
||||
}
|
||||
|
||||
public Timestamp getBtime() {
|
||||
return btime;
|
||||
}
|
||||
|
||||
public void setBtime(Timestamp btime) {
|
||||
this.btime=btime;
|
||||
}
|
||||
|
||||
public void setBlikeNum(int blikeNum) {
|
||||
this.blikeNum=blikeNum;
|
||||
}
|
||||
|
||||
public int getBlikeNum() {
|
||||
return blikeNum;
|
||||
}
|
||||
|
||||
public void setBcollectNum(int bcollectNum) {
|
||||
this.bcollectNum=bcollectNum;
|
||||
}
|
||||
|
||||
public int getBcollectNum() {
|
||||
return bcollectNum;
|
||||
}
|
||||
|
||||
public void setBbrowse(int bbrowse) {
|
||||
this.bbrowse=bbrowse;
|
||||
}
|
||||
|
||||
public int getBbrowse() {
|
||||
return bbrowse;
|
||||
}
|
||||
|
||||
public int getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
public void setFlag(int flag) {
|
||||
this.flag=flag;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.example.leudaemialikeme.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Browse implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int id;
|
||||
private int uid;
|
||||
private int type;
|
||||
|
||||
public void setId(int id) {
|
||||
this.id=id;
|
||||
}
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setUid(int uid) {
|
||||
this.uid=uid;
|
||||
}
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
public void setType(int type) {
|
||||
this.type=type;
|
||||
}
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Browse(int id,int uid,int type) {
|
||||
this.id=id;
|
||||
this.uid=uid;
|
||||
this.type=type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,63 @@
|
||||
package com.example.leudaemialikeme.Model;
|
||||
|
||||
import org.litepal.crud.LitePalSupport;
|
||||
|
||||
public class Clock extends LitePalSupport {
|
||||
public static final int clock_open = 1;
|
||||
public static final int clock_close = 0;
|
||||
|
||||
String hour;
|
||||
String minute;
|
||||
String name;
|
||||
String dosage;
|
||||
int ClockType;
|
||||
|
||||
public Clock(String hour, String minute, String name, String dosage, int clockType) {
|
||||
this.hour = hour;
|
||||
this.minute = minute;
|
||||
this.name = name;
|
||||
this.dosage = dosage;
|
||||
ClockType = clockType;
|
||||
}
|
||||
|
||||
public Clock(){}
|
||||
public String getMinute() {
|
||||
return minute;
|
||||
}
|
||||
|
||||
public String getHour() {
|
||||
return hour;
|
||||
}
|
||||
|
||||
public void setHour(String hour) {
|
||||
this.hour = hour;
|
||||
}
|
||||
|
||||
public void setMinute(String minute) {
|
||||
this.minute = minute;
|
||||
}
|
||||
|
||||
public int getClockType() {
|
||||
return ClockType;
|
||||
}
|
||||
|
||||
public void setClockType(int clockType) {
|
||||
ClockType = clockType;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDosage() {
|
||||
return dosage;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDosage(String dosage) {
|
||||
this.dosage = dosage;
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package com.example.leudaemialikeme.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Collect implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String collectTitle;
|
||||
private int collectIconId;
|
||||
private String collectName;
|
||||
private String collectContent;
|
||||
private int collectImgId;
|
||||
private String collectRead;
|
||||
|
||||
public Collect(String collectTitle, int collectIconId, String collectName,
|
||||
String collectContent, int collectImgId, String collectRead){
|
||||
this.collectTitle = collectTitle;
|
||||
this.collectIconId = collectIconId;
|
||||
this.collectName = collectName;
|
||||
this.collectContent = collectContent;
|
||||
this.collectRead = collectRead;
|
||||
this.collectImgId = collectImgId;
|
||||
}
|
||||
|
||||
public String getCollectTitle() {
|
||||
return collectTitle;
|
||||
}
|
||||
|
||||
public void setCollectTitle(String collectTitle) {
|
||||
this.collectTitle = collectTitle;
|
||||
}
|
||||
|
||||
public int getCollectIconId() {
|
||||
return collectIconId;
|
||||
}
|
||||
|
||||
public void setCollectIconId(int collectIconId) {
|
||||
this.collectIconId = collectIconId;
|
||||
}
|
||||
|
||||
public String getCollectName() {
|
||||
return collectName;
|
||||
}
|
||||
|
||||
public void setCollectName(String collectName) {
|
||||
this.collectName = collectName;
|
||||
}
|
||||
|
||||
public String getCollectContent() {
|
||||
return collectContent;
|
||||
}
|
||||
|
||||
public void setCollectContent(String collectContent) {
|
||||
this.collectContent = collectContent;
|
||||
}
|
||||
|
||||
public int getCollectImgId() {
|
||||
return collectImgId;
|
||||
}
|
||||
|
||||
public void setCollectImgId(int collectImgId) {
|
||||
this.collectImgId = collectImgId;
|
||||
}
|
||||
|
||||
public String getCollectRead() {
|
||||
return collectRead;
|
||||
}
|
||||
|
||||
public void setCollectRead(String collectRead) {
|
||||
this.collectRead = collectRead;
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.example.leudaemialikeme.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class Comment implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private int cid;
|
||||
private int id;
|
||||
private String uName;
|
||||
private int uid;
|
||||
private String content;
|
||||
private Timestamp time;
|
||||
private int type; //评论1/回答2
|
||||
|
||||
public Comment(){
|
||||
}
|
||||
public Comment(int id,int cid,String name,int uid,String content,Timestamp time,int type){
|
||||
this.id=id;
|
||||
this.cid=cid;
|
||||
this.uName=name;
|
||||
this.uid=uid;
|
||||
this.content=content;
|
||||
this.time=time;
|
||||
this.type=type;
|
||||
}
|
||||
public Comment(int id,String name,Timestamp time,int uid,String content,int type){
|
||||
this.time=time;
|
||||
this.id=id;
|
||||
this.uName=name;
|
||||
this.uid=uid;
|
||||
this.content=content;
|
||||
this.type=type;
|
||||
}
|
||||
public int getId(){
|
||||
return id;
|
||||
}
|
||||
public void setId(int id){
|
||||
this.id=id;
|
||||
}
|
||||
public int getCid(){
|
||||
return cid;
|
||||
}
|
||||
public void setCid(int cid){
|
||||
this.cid=cid;
|
||||
}
|
||||
public String getUName(){
|
||||
return uName;
|
||||
}
|
||||
public void setUName(String name){
|
||||
this.uName=name;
|
||||
}
|
||||
public int getUid(){
|
||||
return uid;
|
||||
}
|
||||
public void setUid(int uid){
|
||||
this.uid=uid;
|
||||
}
|
||||
public String getContent(){
|
||||
return content;
|
||||
}
|
||||
public void setContent(String content){
|
||||
this.content=content;
|
||||
}
|
||||
public Timestamp getTime(){
|
||||
return time;
|
||||
}
|
||||
public void setTime(Timestamp time){
|
||||
this.time=time;
|
||||
}
|
||||
public int getType(){
|
||||
return type;
|
||||
}
|
||||
public void setType(int type){
|
||||
this.type=type;
|
||||
}
|
||||
public static long getSerialversionuid() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.example.leudaemialikeme.Model;
|
||||
|
||||
import org.litepal.crud.LitePalSupport;
|
||||
|
||||
public class Friend extends LitePalSupport {
|
||||
private int id;
|
||||
private String username;
|
||||
private int netId;
|
||||
private int ownerNetId;
|
||||
private Boolean isChat;
|
||||
|
||||
public Friend(){
|
||||
super();
|
||||
}
|
||||
public Friend(int netId, String username){
|
||||
this.netId = netId;
|
||||
this.username = username;
|
||||
this.isChat=true;
|
||||
}
|
||||
public Friend(int netId, String username, int ownerNetId){
|
||||
this.netId = netId; //聊天人的ID
|
||||
this.username = username; //聊天人的用户名
|
||||
this.ownerNetId = ownerNetId; //本机用户的ID
|
||||
this.isChat=true;
|
||||
}
|
||||
|
||||
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 getNetId() {
|
||||
return netId;
|
||||
}
|
||||
|
||||
public void setNetId(int netId) {
|
||||
this.netId = netId;
|
||||
}
|
||||
|
||||
public int getOwnerNetId() {
|
||||
return ownerNetId;
|
||||
}
|
||||
|
||||
public void setOwnerNetId(int ownerNetId) {
|
||||
this.ownerNetId = ownerNetId;
|
||||
}
|
||||
|
||||
public Boolean getChat() {
|
||||
return isChat;
|
||||
}
|
||||
|
||||
public void setChat(Boolean chat) {
|
||||
isChat = chat;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.example.leudaemialikeme.Model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MessageItemView {
|
||||
public Friend friend;
|
||||
public Owner owner;
|
||||
public ArrayList<Message> messages;
|
||||
|
||||
public MessageItemView(Friend friend,Owner owner,ArrayList<Message> messages){
|
||||
this.friend=friend;
|
||||
this.owner=owner;
|
||||
this.messages=messages;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.example.leudaemialikeme.Model;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class MyAnswerItemView {
|
||||
private int qid;
|
||||
private String qtitle;
|
||||
private String acontent;
|
||||
private Timestamp answerTime;
|
||||
|
||||
public MyAnswerItemView(){
|
||||
|
||||
}
|
||||
|
||||
public MyAnswerItemView(int qid, String qtitle, String acontent, Timestamp answerTime) {
|
||||
this.qid = qid;
|
||||
this.qtitle = qtitle;
|
||||
this.acontent = acontent;
|
||||
this.answerTime = answerTime;
|
||||
}
|
||||
|
||||
public int getQid() {
|
||||
return qid;
|
||||
}
|
||||
|
||||
public void setQid(int qid) {
|
||||
this.qid = qid;
|
||||
}
|
||||
|
||||
public String getQtitle() {
|
||||
return qtitle;
|
||||
}
|
||||
|
||||
public void setQtitle(String qtitle) {
|
||||
this.qtitle = qtitle;
|
||||
}
|
||||
|
||||
public String getAcontent() {
|
||||
return acontent;
|
||||
}
|
||||
|
||||
public void setAcontent(String acontent) {
|
||||
this.acontent = acontent;
|
||||
}
|
||||
|
||||
public Timestamp getAnswerTime() {
|
||||
return answerTime;
|
||||
}
|
||||
|
||||
public void setAnswerTime(Timestamp answerTime) {
|
||||
this.answerTime = answerTime;
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
package com.example.leudaemialikeme.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class MyQuestion implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
//声明所有变量
|
||||
private String MyQuestionInfo;
|
||||
private String MyQuestionRead;
|
||||
private String MyQuestionTime;
|
||||
|
||||
public MyQuestion(String MyQuestionInfo,String MyQuestionRead,String MyQuestionTime){
|
||||
this. MyQuestionInfo = MyQuestionInfo;
|
||||
this.MyQuestionRead = MyQuestionRead;
|
||||
this.MyQuestionTime = MyQuestionTime;
|
||||
}
|
||||
|
||||
public String getMyQuestionInfo() {
|
||||
return MyQuestionInfo;
|
||||
}
|
||||
|
||||
public void setMyQuestionInfo(String myQuestionInfo) {
|
||||
MyQuestionInfo = myQuestionInfo;
|
||||
}
|
||||
|
||||
public String getMyQuestionRead() {
|
||||
return MyQuestionRead;
|
||||
}
|
||||
|
||||
public void setMyQuestionRead(String myQuestionRead) {
|
||||
MyQuestionRead = myQuestionRead;
|
||||
}
|
||||
|
||||
public String getMyQuestionTime() {
|
||||
return MyQuestionTime;
|
||||
}
|
||||
|
||||
public void setMyQuestionTime(String myQuestionTime) {
|
||||
MyQuestionTime = myQuestionTime;
|
||||
}
|
||||
}
|
@ -1,41 +1,98 @@
|
||||
package com.example.leudaemialikeme.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class Question implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
//声明所有变量
|
||||
private String questionInfo;
|
||||
private String questionRead;
|
||||
private String questionTime;
|
||||
private int qid;
|
||||
private int uid;
|
||||
private String qtittle;
|
||||
private String qcontent;
|
||||
private Timestamp qtime;
|
||||
private int qfollowNum;
|
||||
private int qanswerNum;
|
||||
private int qbrowseNum;
|
||||
private int flag;
|
||||
|
||||
public Question(String questionInfo,String questionRead,String questionTime){
|
||||
this. questionInfo = questionInfo;
|
||||
this.questionRead = questionRead;
|
||||
this.questionTime = questionTime;
|
||||
public Question() {}
|
||||
public Question(int uid,String qtitle,String qcontent,Timestamp qtime,
|
||||
int qfollowNum,int qanswerNum,int qbrowseNum,int flag) {
|
||||
this.uid=uid;
|
||||
this.qtittle=qtitle;
|
||||
this.qcontent=qcontent;
|
||||
this.qtime=qtime;
|
||||
this.qfollowNum=qfollowNum;
|
||||
this.qanswerNum=qanswerNum;
|
||||
this.qbrowseNum=qbrowseNum;
|
||||
this.flag=flag;
|
||||
}
|
||||
|
||||
public String getQuestionInfo() {
|
||||
return questionInfo;
|
||||
public Question(int qid, int uid, String qtittle, String qcontent, Timestamp timestamp, int qfollowNum, int qanswerNum,
|
||||
int qbrowseNum, int flag) {
|
||||
super();
|
||||
this.qid = qid;
|
||||
this.uid = uid;
|
||||
this.qtittle = qtittle;
|
||||
this.qcontent = qcontent;
|
||||
this.qtime = timestamp;
|
||||
this.qfollowNum = qfollowNum;
|
||||
this.qanswerNum = qanswerNum;
|
||||
this.qbrowseNum = qbrowseNum;
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public void setQuestionInfo(String questionInfo) {
|
||||
this.questionInfo = questionInfo;
|
||||
public int getQid() {
|
||||
return qid;
|
||||
}
|
||||
|
||||
public String getQuestionRead() {
|
||||
return questionRead;
|
||||
public void setQid(int qid) {
|
||||
this.qid = qid;
|
||||
}
|
||||
|
||||
public void setQuestionRead(String questionRead) {
|
||||
this.questionRead = questionRead;
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public String getQuestionTime() {
|
||||
return questionTime;
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public void setQuestionTime(String questionTime) {
|
||||
this.questionTime = questionTime;
|
||||
public String getQtittle() {
|
||||
return qtittle;
|
||||
}
|
||||
public void setQtittle(String qtittle) {
|
||||
this.qtittle = qtittle;
|
||||
}
|
||||
public String getQcontent() {
|
||||
return qcontent;
|
||||
}
|
||||
public void setQcontent(String qcontent) {
|
||||
this.qcontent = qcontent;
|
||||
}
|
||||
public Timestamp getQtime() {
|
||||
return qtime;
|
||||
}
|
||||
public void setQtime(Timestamp qtime) {
|
||||
this.qtime = qtime;
|
||||
}
|
||||
public int getQfollowNum() {
|
||||
return qfollowNum;
|
||||
}
|
||||
public void setQfollowNum(int qfollowNum) {
|
||||
this.qfollowNum = qfollowNum;
|
||||
}
|
||||
public int getQanswerNum() {
|
||||
return qanswerNum;
|
||||
}
|
||||
public void setQanswerNum(int qanswerNum) {
|
||||
this.qanswerNum = qanswerNum;
|
||||
}
|
||||
public int getQbrowseNum() {
|
||||
return qbrowseNum;
|
||||
}
|
||||
public void setQbrowseNum(int qbrowseNum) {
|
||||
this.qbrowseNum = qbrowseNum;
|
||||
}
|
||||
public int getFlag() {
|
||||
return flag;
|
||||
}
|
||||
public void setFlag(int flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,16 @@
|
||||
package com.example.leudaemialikeme.Utils;
|
||||
|
||||
import com.example.leudaemialikeme.Model.News;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.example.leudaemialikeme.Model.User;
|
||||
|
||||
public class Data extends android.app.Application {
|
||||
public int uid=1;
|
||||
public String id="430481200101220131";
|
||||
public String name="abc";
|
||||
|
||||
public int getUid(){
|
||||
return uid;
|
||||
private User user=new User(1,"123","123","13877673546","女");
|
||||
// private User user;
|
||||
public void setUser(User user){
|
||||
this.user=user;
|
||||
}
|
||||
public void setUid(int uid){
|
||||
this.uid= uid;
|
||||
public User getUser(){
|
||||
return user;
|
||||
}
|
||||
|
||||
public String getId(){
|
||||
return this.id;
|
||||
}
|
||||
public void setId(String id){
|
||||
this.id= id;
|
||||
}
|
||||
|
||||
//1.6下午两点加的
|
||||
private List<News> newsList =new ArrayList<>();
|
||||
public void setNewsList(List<News> newsList){
|
||||
this.newsList=newsList;
|
||||
}
|
||||
|
||||
//下午五点加的
|
||||
public List<News> getNewsList() {
|
||||
return this.newsList ;
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 209 KiB |
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<gradient
|
||||
|
||||
android:startColor="#fe6969"
|
||||
|
||||
android:centerColor="#fb7a6a"
|
||||
|
||||
android:endColor="#ff976d"
|
||||
|
||||
android:angle="45"
|
||||
|
||||
/>
|
||||
<corners
|
||||
android:radius="15dp"/>
|
||||
|
||||
</shape>
|
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
|
||||
</vector>
|
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M4,8h4L8,4L4,4v4zM10,20h4v-4h-4v4zM4,20h4v-4L4,16v4zM4,14h4v-4L4,10v4zM10,14h4v-4h-4v4zM16,4v4h4L20,4h-4zM10,8h4L14,4h-4v4zM16,14h4v-4h-4v4zM16,20h4v-4h-4v4z"/>
|
||||
</vector>
|
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 391 B |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue