|
@@ -1,5 +1,6 @@
|
|
|
package com.sheep.gamegroup.view.fragment;
|
|
package com.sheep.gamegroup.view.fragment;
|
|
|
|
|
|
|
|
|
|
+import android.graphics.Color;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
@@ -14,16 +15,18 @@ import com.haibin.calendarview.CalendarLayout;
|
|
|
import com.haibin.calendarview.CalendarView;
|
|
import com.haibin.calendarview.CalendarView;
|
|
|
import com.haibin.calendarviewproject.custom.CustomMonthView;
|
|
import com.haibin.calendarviewproject.custom.CustomMonthView;
|
|
|
import com.haibin.calendarviewproject.custom.CustomWeekView;
|
|
import com.haibin.calendarviewproject.custom.CustomWeekView;
|
|
|
-import com.kfzs.appstore.utils.adapter.recyclerview.RecyclerViewAdapter;
|
|
|
|
|
-import com.kfzs.appstore.utils.adapter.recyclerview.ViewHolder;
|
|
|
|
|
import com.sheep.gamegroup.model.api.ApiService;
|
|
import com.sheep.gamegroup.model.api.ApiService;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
|
|
+import com.sheep.gamegroup.model.entity.FootprintCountRespons;
|
|
|
import com.sheep.gamegroup.model.entity.UserFootprint;
|
|
import com.sheep.gamegroup.model.entity.UserFootprint;
|
|
|
|
|
+import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
import com.sheep.gamegroup.util.ListUtil;
|
|
|
|
|
+import com.sheep.gamegroup.util.TestUtil;
|
|
|
import com.sheep.gamegroup.util.TimeUtil;
|
|
import com.sheep.gamegroup.util.TimeUtil;
|
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
import com.sheep.gamegroup.util.ViewUtil;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
|
|
|
|
|
import org.afinal.simplecache.ApiKey;
|
|
import org.afinal.simplecache.ApiKey;
|
|
@@ -35,6 +38,9 @@ import java.util.Map;
|
|
|
|
|
|
|
|
import butterknife.BindView;
|
|
import butterknife.BindView;
|
|
|
import io.reactivex.Observable;
|
|
import io.reactivex.Observable;
|
|
|
|
|
+import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
|
|
+import io.reactivex.schedulers.Schedulers;
|
|
|
|
|
+import rx.functions.Action1;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Created by realicing on 2018/9/17.
|
|
* Created by realicing on 2018/9/17.
|
|
@@ -67,6 +73,7 @@ public class FgtFootprint extends BaseListFragment4<UserFootprint> {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void initView() {
|
|
public void initView() {
|
|
|
|
|
+ per_page = 1;
|
|
|
CustomMonthView.class.getSimpleName();
|
|
CustomMonthView.class.getSimpleName();
|
|
|
CustomWeekView.class.getSimpleName();
|
|
CustomWeekView.class.getSimpleName();
|
|
|
TitleBarUtils
|
|
TitleBarUtils
|
|
@@ -75,9 +82,9 @@ public class FgtFootprint extends BaseListFragment4<UserFootprint> {
|
|
|
.setTitle(getView(), "足迹");
|
|
.setTitle(getView(), "足迹");
|
|
|
|
|
|
|
|
view_list = mRecyclerView;
|
|
view_list = mRecyclerView;
|
|
|
-
|
|
|
|
|
|
|
+ initAdapter();
|
|
|
mRecyclerView.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
mRecyclerView.setLayoutManager(new LinearLayoutManager(SheepApp.getInstance()));
|
|
|
- mRecyclerView.setAdapter(getAdapter());
|
|
|
|
|
|
|
+ mRecyclerView.setAdapter(adapter);
|
|
|
|
|
|
|
|
int maxYear = mCalendarView.getCurYear();
|
|
int maxYear = mCalendarView.getCurYear();
|
|
|
int maxYearMonth = mCalendarView.getCurMonth();
|
|
int maxYearMonth = mCalendarView.getCurMonth();
|
|
@@ -100,6 +107,23 @@ public class FgtFootprint extends BaseListFragment4<UserFootprint> {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ protected void initAdapter() {
|
|
|
|
|
+ adapter = new BaseQuickAdapter<UserFootprint, BaseViewHolder>(R.layout.item_my_focus, list) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void convert(BaseViewHolder holder, UserFootprint item) {
|
|
|
|
|
+ ImageView item_my_focus_iv = holder.itemView.findViewById(R.id.item_my_focus_iv);
|
|
|
|
|
+ TextView item_my_focus_info_tv = holder.itemView.findViewById(R.id.item_my_focus_info_tv);
|
|
|
|
|
+ TextView item_my_focus_tv = holder.itemView.findViewById(R.id.item_my_focus_tv);
|
|
|
|
|
+ ViewUtil.setVisibility(item_my_focus_tv, false);
|
|
|
|
|
+
|
|
|
|
|
+ ViewUtil.setAvatar(item_my_focus_iv, item.getPic());
|
|
|
|
|
+ ViewUtil.setText(item_my_focus_info_tv, item.getInfo());
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ View headerView = LayoutInflater.from(SheepApp.getInstance()).inflate(R.layout.header_foot_print, null);
|
|
|
|
|
+ adapter.addHeaderView(headerView);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void checkHeaderView(int year, int month) {
|
|
private void checkHeaderView(int year, int month) {
|
|
|
ViewUtil.setText(header_foot_print_date_tv, String.format(Locale.CHINA, "%d年%d月", year, month));
|
|
ViewUtil.setText(header_foot_print_date_tv, String.format(Locale.CHINA, "%d年%d月", year, month));
|
|
|
Calendar firstCalendar = new Calendar();
|
|
Calendar firstCalendar = new Calendar();
|
|
@@ -112,7 +136,8 @@ public class FgtFootprint extends BaseListFragment4<UserFootprint> {
|
|
|
lastCalendar.setDay(TimeUtil.getTotalDay(month));
|
|
lastCalendar.setDay(TimeUtil.getTotalDay(month));
|
|
|
checkHeaderView(firstCalendar, lastCalendar);
|
|
checkHeaderView(firstCalendar, lastCalendar);
|
|
|
}
|
|
}
|
|
|
- private void checkHeaderView(Calendar firstCalendar, Calendar lastCalendar){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private void checkHeaderView(Calendar firstCalendar, Calendar lastCalendar) {
|
|
|
Calendar minCalendar = mCalendarView.getMinRangeCalendar();
|
|
Calendar minCalendar = mCalendarView.getMinRangeCalendar();
|
|
|
Calendar maxCalendar = mCalendarView.getMaxRangeCalendar();
|
|
Calendar maxCalendar = mCalendarView.getMaxRangeCalendar();
|
|
|
boolean canScrollToPre = minCalendar.compareTo(firstCalendar) < 0;
|
|
boolean canScrollToPre = minCalendar.compareTo(firstCalendar) < 0;
|
|
@@ -122,10 +147,11 @@ public class FgtFootprint extends BaseListFragment4<UserFootprint> {
|
|
|
ViewUtil.setEnabled(header_foot_print_next_iv, canScrollToNext);
|
|
ViewUtil.setEnabled(header_foot_print_next_iv, canScrollToNext);
|
|
|
ViewUtil.setEnabled(header_foot_print_next_v, canScrollToNext);
|
|
ViewUtil.setEnabled(header_foot_print_next_v, canScrollToNext);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
private void checkHeaderView(List<Calendar> weekCalendars) {
|
|
private void checkHeaderView(List<Calendar> weekCalendars) {
|
|
|
Calendar firstCalendar = ListUtil.getItem(weekCalendars, 0);
|
|
Calendar firstCalendar = ListUtil.getItem(weekCalendars, 0);
|
|
|
Calendar lastCalendar = ListUtil.getLast(weekCalendars);
|
|
Calendar lastCalendar = ListUtil.getLast(weekCalendars);
|
|
|
- if(firstCalendar != null && lastCalendar != null) {
|
|
|
|
|
|
|
+ if (firstCalendar != null && lastCalendar != null) {
|
|
|
int year = firstCalendar.getYear();
|
|
int year = firstCalendar.getYear();
|
|
|
int month = firstCalendar.getMonth();
|
|
int month = firstCalendar.getMonth();
|
|
|
ViewUtil.setText(header_foot_print_date_tv, String.format(Locale.CHINA, "%d年%d月", year, month));
|
|
ViewUtil.setText(header_foot_print_date_tv, String.format(Locale.CHINA, "%d年%d月", year, month));
|
|
@@ -140,6 +166,7 @@ public class FgtFootprint extends BaseListFragment4<UserFootprint> {
|
|
|
@Override
|
|
@Override
|
|
|
public void onMonthChange(int year, int month) {
|
|
public void onMonthChange(int year, int month) {
|
|
|
checkHeaderView(year, month);
|
|
checkHeaderView(year, month);
|
|
|
|
|
+ initFootprintCountRespons(year, month);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
mCalendarView.setOnWeekChangeListener(new CalendarView.OnWeekChangeListener() {
|
|
mCalendarView.setOnWeekChangeListener(new CalendarView.OnWeekChangeListener() {
|
|
@@ -151,7 +178,7 @@ public class FgtFootprint extends BaseListFragment4<UserFootprint> {
|
|
|
mCalendarView.setOnViewChangeListener(new CalendarView.OnViewChangeListener() {
|
|
mCalendarView.setOnViewChangeListener(new CalendarView.OnViewChangeListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onViewChange(boolean isMonthView) {
|
|
public void onViewChange(boolean isMonthView) {
|
|
|
- if(isMonthView){
|
|
|
|
|
|
|
+ if (isMonthView) {
|
|
|
checkHeaderView(mCalendarView.getCurYear(), mCalendarView.getCurMonth());
|
|
checkHeaderView(mCalendarView.getCurYear(), mCalendarView.getCurMonth());
|
|
|
} else {
|
|
} else {
|
|
|
checkHeaderView(mCalendarView.getCurrentWeekCalendars());
|
|
checkHeaderView(mCalendarView.getCurrentWeekCalendars());
|
|
@@ -172,68 +199,56 @@ public class FgtFootprint extends BaseListFragment4<UserFootprint> {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public void initData() {
|
|
|
|
|
- super.initData();
|
|
|
|
|
|
|
+ //初始化足迹数量
|
|
|
|
|
+ private void initFootprintCountRespons(final int year, final int month) {
|
|
|
|
|
+ String start_date = String.format(Locale.CHINA, "%d-%02d-%02d", year, month, 1);
|
|
|
|
|
+ String end_date = String.format(Locale.CHINA, "%d-%02d-%02d", year, month, TimeUtil.getTotalDay(month));
|
|
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService().getUserFootPrintDateCount(start_date, end_date)
|
|
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
|
|
+ List<FootprintCountRespons> newList = baseMessage.getDataList(FootprintCountRespons.class);
|
|
|
|
|
+ if(!ListUtil.isEmpty(newList)){
|
|
|
|
|
+ loadFootprintCountList(year, month, newList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- int year = mCalendarView.getCurYear();
|
|
|
|
|
- int month = mCalendarView.getCurMonth();
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
|
|
+ if(TestUtil.isDev())
|
|
|
|
|
+ G.showToast(baseMessage);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- Map<String, Calendar> map = new HashMap<>();
|
|
|
|
|
- map.put(getSchemeCalendar(year, month, 3, 0xFF40db25, "假").toString(),
|
|
|
|
|
- getSchemeCalendar(year, month, 3, 0xFF40db25, "假"));
|
|
|
|
|
- map.put(getSchemeCalendar(year, month, 6, 0xFFe69138, "事").toString(),
|
|
|
|
|
- getSchemeCalendar(year, month, 6, 0xFFe69138, "事"));
|
|
|
|
|
- map.put(getSchemeCalendar(year, month, 9, 0xFFdf1356, "议").toString(),
|
|
|
|
|
- getSchemeCalendar(year, month, 9, 0xFFdf1356, "议"));
|
|
|
|
|
- map.put(getSchemeCalendar(year, month, 13, 0xFFedc56d, "记").toString(),
|
|
|
|
|
- getSchemeCalendar(year, month, 13, 0xFFedc56d, "记"));
|
|
|
|
|
- map.put(getSchemeCalendar(year, month, 14, 0xFFedc56d, "记").toString(),
|
|
|
|
|
- getSchemeCalendar(year, month, 14, 0xFFedc56d, "记"));
|
|
|
|
|
- map.put(getSchemeCalendar(year, month, 15, 0xFFaacc44, "假").toString(),
|
|
|
|
|
- getSchemeCalendar(year, month, 15, 0xFFaacc44, "假"));
|
|
|
|
|
- map.put(getSchemeCalendar(year, month, 18, 0xFFbc13f0, "记").toString(),
|
|
|
|
|
- getSchemeCalendar(year, month, 18, 0xFFbc13f0, "记"));
|
|
|
|
|
- map.put(getSchemeCalendar(year, month, 25, 0xFF13acf0, "假").toString(),
|
|
|
|
|
- getSchemeCalendar(year, month, 25, 0xFF13acf0, "假"));
|
|
|
|
|
- map.put(getSchemeCalendar(year, month, 27, 0xFF13acf0, "多").toString(),
|
|
|
|
|
- getSchemeCalendar(year, month, 27, 0xFF13acf0, "多"));
|
|
|
|
|
|
|
+ private void loadFootprintCountList(final int year, final int month, List<FootprintCountRespons> newList) {
|
|
|
|
|
+ final Map<String, Calendar> map = new HashMap<>();
|
|
|
|
|
+ ListUtil.forEach(newList, new Action1<FootprintCountRespons>() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void call(FootprintCountRespons item) {
|
|
|
|
|
+ if(item != null && item.getCount() > 0) {
|
|
|
|
|
+ Calendar calendar = getSchemeCalendar(year, month, item.getDay(), String.valueOf(item.getCount()));
|
|
|
|
|
+ map.put(calendar.toString(), calendar);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
//此方法在巨大的数据量上不影响遍历性能,推荐使用
|
|
//此方法在巨大的数据量上不影响遍历性能,推荐使用
|
|
|
mCalendarView.setSchemeDate(map);
|
|
mCalendarView.setSchemeDate(map);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private Calendar getSchemeCalendar(int year, int month, int day, int color, String text) {
|
|
|
|
|
|
|
+ private Calendar getSchemeCalendar(int year, int month, int day, String text) {
|
|
|
Calendar calendar = new Calendar();
|
|
Calendar calendar = new Calendar();
|
|
|
calendar.setYear(year);
|
|
calendar.setYear(year);
|
|
|
calendar.setMonth(month);
|
|
calendar.setMonth(month);
|
|
|
calendar.setDay(day);
|
|
calendar.setDay(day);
|
|
|
- calendar.setSchemeColor(color);//如果单独标记颜色、则会使用这个颜色
|
|
|
|
|
|
|
+ calendar.setSchemeColor(Color.RED);//如果单独标记颜色、则会使用这个颜色
|
|
|
calendar.setScheme(text);
|
|
calendar.setScheme(text);
|
|
|
- calendar.addScheme(new Calendar.Scheme());
|
|
|
|
|
- calendar.addScheme(0xFF008800, "假");
|
|
|
|
|
- calendar.addScheme(0xFF008800, "节");
|
|
|
|
|
return calendar;
|
|
return calendar;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- protected RecyclerView.Adapter getAdapter() {
|
|
|
|
|
- BaseQuickAdapter<UserFootprint, BaseViewHolder> adapter = new BaseQuickAdapter<UserFootprint, BaseViewHolder>(R.layout.item_my_focus, list) {
|
|
|
|
|
- @Override
|
|
|
|
|
- protected void convert(BaseViewHolder holder, UserFootprint item) {
|
|
|
|
|
- ImageView item_my_focus_iv = holder.itemView.findViewById(R.id.item_my_focus_iv);
|
|
|
|
|
- TextView item_my_focus_info_tv = holder.itemView.findViewById(R.id.item_my_focus_info_tv);
|
|
|
|
|
- TextView item_my_focus_tv = holder.itemView.findViewById(R.id.item_my_focus_tv);
|
|
|
|
|
- ViewUtil.setVisibility(item_my_focus_tv, false);
|
|
|
|
|
-
|
|
|
|
|
- ViewUtil.setAvatar(item_my_focus_iv, item.getPic());
|
|
|
|
|
- ViewUtil.setText(item_my_focus_info_tv, item.getInfo());
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
- View headerView = LayoutInflater.from(SheepApp.getInstance()).inflate(R.layout.header_foot_print, null);
|
|
|
|
|
- adapter.addHeaderView(headerView);
|
|
|
|
|
- return adapter;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
private String date;
|
|
private String date;
|
|
|
|
|
|
|
@@ -252,8 +267,4 @@ public class FgtFootprint extends BaseListFragment4<UserFootprint> {
|
|
|
return UserFootprint.class;
|
|
return UserFootprint.class;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Override
|
|
|
|
|
- public int refreshDataType() {
|
|
|
|
|
- return REFRESH_ON_YOURSELF;
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|