| | |
| | | |
| | | import android.app.Dialog; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.widget.SwipeRefreshLayout; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.dialog.DialogUtil; |
| | | import com.lcjian.library.util.RefreshLayout; |
| | | import com.umeng.analytics.MobclickAgent; |
| | | import com.weikou.beibeivideo.BasicTextHttpResponseHandler; |
| | | import com.weikou.beibeivideo.BeibeiVideoAPI; |
| | |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.entity.vo.WatchHistoryVO; |
| | | import com.weikou.beibeivideo.ui.dialog.LoadingDialogUtil; |
| | | import com.weikou.beibeivideo.util.JsonUtil; |
| | | import com.weikou.beibeivideo.util.UserUtil; |
| | | import com.weikou.beibeivideo.widget.MySwipeRefreshLayout; |
| | | |
| | | import org.apache.http.Header; |
| | | import org.json.JSONObject; |
| | |
| | | |
| | | public class WatchHistoryFragment extends Fragment { |
| | | |
| | | private RefreshLayout srl; |
| | | private MySwipeRefreshLayout srl; |
| | | |
| | | private WatchHistoryAdapter mAdapter; |
| | | |
| | |
| | | getWatchHistory(currentPage); |
| | | } |
| | | }); |
| | | srl.setOnLoadListener(new RefreshLayout.OnLoadListener() { |
| | | srl.setOnLoadListener(new MySwipeRefreshLayout.OnLoadListener() { |
| | | @Override |
| | | public void onLoad() { |
| | | getWatchHistory(currentPage + 1); |
| | |
| | | super.onResume(); |
| | | if (mAdapter != null) |
| | | mAdapter.setSelectedMode(false); |
| | | MobclickAgent.onPageStart("主页面——最近——观看记录"); |
| | | } |
| | | |
| | | @Override |
| | | public void onPause() { |
| | | super.onPause(); |
| | | MobclickAgent.onPageEnd("主页面——最近——观看记录"); |
| | | } |
| | | |
| | | |
| | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | if (jsonObject.optBoolean("IsPost")) { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | .create(); |
| | | |
| | | JSONObject data = jsonObject.optJSONObject("Data"); |
| | | count = data.optLong("count"); |
| | | Type type = new TypeToken<List<WatchHistoryVO>>() { |
| | | }.getType(); |
| | | |
| | | List<WatchHistoryVO> list = gson.fromJson(data.optJSONArray("list").toString(), type); |
| | | List<WatchHistoryVO> list = JsonUtil.videoGson.fromJson(data.optJSONArray("list").toString(), type); |
| | | currentPage = page; |
| | | if (voList == null) |
| | | voList = new ArrayList<>(); |
| | | if (page == 1) |
| | | voList.clear(); |
| | | if (list != null && list.size() > 0) { |