Skip to content

Commit

Permalink
update to v1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhaotailang committed Oct 21, 2016
1 parent 47984b2 commit 5c9d1ef
Showing 1 changed file with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class UserDefineIdsFragment extends Fragment{
private SQLiteDatabase db;
private ArrayList<String> list = new ArrayList<String>();

private TextView tvUserDefine;
private TextView textView;
private FloatingActionButton fab;
private SwipeRefreshLayout refreshLayout;

Expand Down Expand Up @@ -84,10 +84,10 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
cursor.close();

if (list.size() == 0){
tvUserDefine.setVisibility(View.VISIBLE);
textView.setVisibility(View.VISIBLE);
} else {

tvUserDefine.setVisibility(View.GONE);
textView.setVisibility(View.GONE);

refreshLayout.post(new Runnable() {
@Override
Expand Down Expand Up @@ -213,11 +213,10 @@ public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
adapter.remove(viewHolder.getAdapterPosition());
}
});
helper.attachToRecyclerView(recyclerView);


helper.attachToRecyclerView(recyclerView);

tvUserDefine.setVisibility(View.GONE);
textView.setVisibility(View.GONE);

adapter.notifyItemInserted(zhuanlanList.size() - 1);

Expand Down Expand Up @@ -254,8 +253,9 @@ public void onErrorResponse(VolleyError volleyError) {
refreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
if (list.size() != 0) {
list.clear();
if (zhuanlanList.size() != 0) {
zhuanlanList.clear();
adapter.notifyDataSetChanged();
}
requestData();
}
Expand All @@ -266,7 +266,7 @@ public void onRefresh() {

private void initViews(View view) {

tvUserDefine = (TextView) view.findViewById(R.id.tv_user_define);
textView = (TextView) view.findViewById(R.id.tv_user_define);
fab = (FloatingActionButton) view.findViewById(R.id.fab);
recyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
Expand Down Expand Up @@ -297,6 +297,7 @@ private void requestData() {
StringRequest request = new StringRequest(Request.Method.GET, API.BASE_URL + list.get(i), new Response.Listener<String>() {
@Override
public void onResponse(String s) {

Zhuanlan z = gson.fromJson(s, Zhuanlan.class);
zhuanlanList.add(z);

Expand Down Expand Up @@ -332,20 +333,16 @@ public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
adapter.notifyItemInserted(zhuanlanList.size() - 1);
}

refreshLayout.post(new Runnable() {
@Override
public void run() {
refreshLayout.setRefreshing(false);
}
});

refreshLayout.setRefreshing(false);
}

}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {

if (finalI == list.size() - 1) {
refreshLayout.setRefreshing(false);
}
}
});

Expand Down

0 comments on commit 5c9d1ef

Please sign in to comment.