Skip to content

Commit

Permalink
录音提交后删除本地,刷新列表
Browse files Browse the repository at this point in the history
  • Loading branch information
mikenotIam committed Sep 25, 2020
1 parent 2150f4b commit 437ea89
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ public void onResponse(
} else {
Toast.makeText(context, "拜访记录请求失败", Toast.LENGTH_LONG).show();
}


RecordHistoryDao testDao = AbstractAppDatabase.getDbDateHelper().getRecordHistoryDao();
List<RecordHistoryBean> listBean = testDao.getAllByVisitId(visit_id);
recordFragment.reflesh(listBean);
}

@Override
Expand All @@ -163,6 +168,12 @@ public void onFailure(Call<VisitRecords> call, Throwable t) {
dialog.dismiss();
}
Toast.makeText(context, "拜访记录请求失败", Toast.LENGTH_LONG).show();

RecordHistoryDao testDao = AbstractAppDatabase.getDbDateHelper().getRecordHistoryDao();

List<RecordHistoryBean> listBean = testDao.getAllByVisitId(visit_id);

recordFragment.reflesh(listBean);
}
});
}
Expand Down Expand Up @@ -250,7 +261,7 @@ public void initViewPager(int i) {
bundle.putParcelableArrayList("data", (ArrayList<? extends Parcelable>) itemList2);
bundle.putInt("visitId", visit_id);

RecordFragment recordFragment = new RecordFragment();
recordFragment = new RecordFragment();
recordFragment.setArguments(bundle);
list.add(recordFragment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,14 @@ public void onResponse(
RecordHistoryDao testDao =
AbstractAppDatabase.getDbDateHelper()
.getRecordHistoryDao();
testDao.updateCloudStatus(1, file.getPath());
testDao.updateCloudStatus(0, file.getPath());

toast("提交成功");
try {
file.delete();
} catch (Exception e) {
e.printStackTrace();
}

context.getVisitRecords();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.xiaobao.good.record.fragment;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
Expand All @@ -13,12 +12,14 @@
import com.xiaobao.good.AudioRecordDetailActivity;
import com.xiaobao.good.R;
import com.xiaobao.good.db.AbstractAppDatabase;
import com.xiaobao.good.db.RecordHistoryBean;
import com.xiaobao.good.log.LogUtil;
import com.xiaobao.good.record.RecordDetailItem;
import com.xiaobao.good.record.adapter.OnlineRecordAdpater;
import com.xiaobao.good.ui.MyAlertDialog;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
Expand All @@ -33,6 +34,10 @@ public class RecordFragment extends Fragment {

OnlineRecordAdpater onlineRecordAdpater;

int visitId;

List<RecordDetailItem> list;

@Override
public void onAttach(@NonNull Context context) {

Expand All @@ -49,9 +54,9 @@ public View onCreateView(
listView = view.findViewById(R.id.lv_onlinerecord);
/** 获取数据,展示 */
Bundle bundle = getArguments();
List<RecordDetailItem> list = (List<RecordDetailItem>) bundle.get("data");
list = (List<RecordDetailItem>) bundle.get("data");

int visitId = bundle.getInt("visitId", -1);
visitId = bundle.getInt("visitId", -1);

Log.i("RecordDetailItem", "size :" + list);

Expand Down Expand Up @@ -129,4 +134,30 @@ public void onDestroy() {
onlineRecordAdpater.stopPaly();
Log.i("yxd", "onDestroy");
}


public void reflesh(List<RecordHistoryBean> listBean) {

RecordDetailItem recordDetailItem;
List<RecordDetailItem> itemList2 = new ArrayList<>();
for (RecordHistoryBean r : listBean) {

recordDetailItem = new RecordDetailItem();
recordDetailItem.setFilePath(r.getFile_path());
recordDetailItem.setFile_elpased(r.getFile_elpased());
recordDetailItem.setType(r.getCloud() + "");

if (recordDetailItem.getType().equals("1")) {
itemList2.add(recordDetailItem);
}


}

list = itemList2;

onlineRecordAdpater = new OnlineRecordAdpater(mActivity, list, visitId);
listView.setAdapter(onlineRecordAdpater);
onlineRecordAdpater.notifyDataSetChanged();
}
}

0 comments on commit 437ea89

Please sign in to comment.