Skip to content

Commit

Permalink
修改部分跳转逻辑、修改部分命名
Browse files Browse the repository at this point in the history
  • Loading branch information
yannecer committed Mar 26, 2020
1 parent fee5444 commit c61a41f
Show file tree
Hide file tree
Showing 38 changed files with 475 additions and 417 deletions.
4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 16 additions & 4 deletions app/src/main/java/com/necer/ncalendar/TestActivity2.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
import android.os.Bundle;
import android.util.Log;

import com.necer.MyLog;
import com.necer.calendar.BaseCalendar;
import com.necer.calendar.MonthCalendar;
import com.necer.enumeration.DateChangeBehavior;
import com.necer.listener.OnCalendarChangedListener;

import org.joda.time.LocalDate;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

Expand All @@ -17,10 +25,14 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setContentView(R.layout.activity_test2);


float dimension = getResources().getDimension(R.dimen.N_calendarHeight);
float N_pppp = getResources().getInteger(R.integer.N_animationDuration);
MonthCalendar monthCalendar = findViewById(R.id.monthCalendar);
monthCalendar.setOnCalendarChangedListener(new OnCalendarChangedListener() {
@Override
public void onCalendarChange(BaseCalendar baseCalendar, int year, int month, LocalDate localDate, DateChangeBehavior dateChangeBehavior) {
MyLog.d("onCalendarChange:::"+localDate);
}

});

Log.e("float", "float::" + dimension);
Log.e("float", "float::" + N_pppp);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import com.necer.enumeration.SelectedModel;
import com.necer.enumeration.CheckModel;

public abstract class BaseActivity extends AppCompatActivity {

protected final static String TAG = "NECER";
protected String title;
protected SelectedModel selectedModel;
protected CheckModel checkModel;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
selectedModel = (SelectedModel) getIntent().getSerializableExtra("selectedModel");
checkModel = (CheckModel) getIntent().getSerializableExtra("selectedModel");
title = getIntent().getStringExtra("title");

ActionBar supportActionBar = getSupportActionBar();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import android.view.View;

import com.necer.calendar.Miui10Calendar;
import com.necer.enumeration.SelectedModel;
import com.necer.enumeration.CheckModel;
import com.necer.ncalendar.R;
import com.necer.ncalendar.painter.LigaturePainter;
import com.necer.ncalendar.painter.TicketPainter;
Expand All @@ -28,7 +28,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom);
miui10Calendar = findViewById(R.id.miui10Calendar);
miui10Calendar.setSelectedMode(SelectedModel.MULTIPLE);
miui10Calendar.setCheckMode(CheckModel.MULTIPLE);
LigaturePainter painter = new LigaturePainter(this);
miui10Calendar.setCalendarPainter(painter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.necer.calendar.ICalendar;
import com.necer.entity.CalendarDate;
import com.necer.enumeration.CalendarType;
import com.necer.enumeration.SelectedModel;
import com.necer.enumeration.DateChangeBehavior;
import com.necer.listener.OnCalendarChangedListener;
import com.necer.ncalendar.R;
import com.necer.painter.CalendarAdapter;
Expand Down Expand Up @@ -41,9 +41,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
// miui10Calendar.setSelectedMode(SelectedModel.MULTIPLE);
miui10Calendar.setOnCalendarChangedListener(new OnCalendarChangedListener() {
@Override
public void onCalendarChange(BaseCalendar baseCalendar, int year, int month, LocalDate localDate) {
public void onCalendarChange(BaseCalendar baseCalendar, int year, int month, LocalDate localDate, DateChangeBehavior dateChangeBehavior) {
Log.e("onCalendarChange", "onCalendarChange:::" + localDate);
}

});

}
Expand Down Expand Up @@ -76,17 +77,17 @@ public void onBindCalendarBackgroundView(ICalendarView iCalendarView, View calen
}

@Override
public void onBindToadyView(View view, LocalDate localDate, List<LocalDate> selectedDateList) {
public void onBindToadyView(View view, LocalDate localDate, List<LocalDate> totalCheckedDateList) {

View ll_content = view.findViewById(R.id.ll_content);

TextView tv_item = view.findViewById(R.id.tv_item);

tv_item.setText(String.valueOf(localDate.getDayOfMonth()));

setLunar(view, localDate, selectedDateList);
setLunar(view, localDate, totalCheckedDateList);

if (selectedDateList.contains(localDate)) {
if (totalCheckedDateList.contains(localDate)) {
tv_item.setTextColor(Color.WHITE);
ll_content.setBackgroundResource(R.drawable.bg_checked_ding);
} else {
Expand All @@ -96,17 +97,17 @@ public void onBindToadyView(View view, LocalDate localDate, List<LocalDate> sele
}

@Override
public void onBindCurrentMonthOrWeekView(View view, LocalDate localDate, List<LocalDate> selectedDateList) {
public void onBindCurrentMonthOrWeekView(View view, LocalDate localDate, List<LocalDate> totalCheckedDateList) {

View ll_content = view.findViewById(R.id.ll_content);

TextView tv_item = view.findViewById(R.id.tv_item);
tv_item.setTextColor(Color.BLACK);
tv_item.setText(String.valueOf(localDate.getDayOfMonth()));

setLunar(view, localDate, selectedDateList);
setLunar(view, localDate, totalCheckedDateList);

if (selectedDateList.contains(localDate)) {
if (totalCheckedDateList.contains(localDate)) {
tv_item.setTextColor(Color.WHITE);
ll_content.setBackgroundResource(R.drawable.bg_checked_ding);
} else {
Expand All @@ -117,12 +118,12 @@ public void onBindCurrentMonthOrWeekView(View view, LocalDate localDate, List<Lo
}

@Override
public void onBindLastOrNextMonthView(View view, LocalDate localDate, List<LocalDate> selectedDateList) {
public void onBindLastOrNextMonthView(View view, LocalDate localDate, List<LocalDate> totalCheckedDateList) {
View ll_content = view.findViewById(R.id.ll_content);
TextView tv_item = view.findViewById(R.id.tv_item);
tv_item.setText(String.valueOf(localDate.getDayOfMonth()));
setLunar(view, localDate, selectedDateList);
if (selectedDateList.contains(localDate)) {
setLunar(view, localDate, totalCheckedDateList);
if (totalCheckedDateList.contains(localDate)) {
tv_item.setTextColor(Color.WHITE);
ll_content.setBackgroundResource(R.drawable.bg_checked_ding_last_next);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.necer.calendar.BaseCalendar;
import com.necer.calendar.ICalendar;
import com.necer.entity.CalendarDate;
import com.necer.enumeration.DateChangeBehavior;
import com.necer.listener.OnCalendarChangedListener;
import com.necer.ncalendar.R;
import com.necer.painter.CalendarAdapter;
Expand Down Expand Up @@ -38,9 +39,10 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

miui10Calendar.setOnCalendarChangedListener(new OnCalendarChangedListener() {
@Override
public void onCalendarChange(BaseCalendar baseCalendar, int year, int month, LocalDate localDate) {
public void onCalendarChange(BaseCalendar baseCalendar, int year, int month, LocalDate localDate, DateChangeBehavior dateChangeBehavior) {
Log.e("onCalendarChange", "onCalendarChange:::" + localDate);
}

});

}
Expand All @@ -53,7 +55,7 @@ public View getCalendarItemView(Context context) {
}

@Override
public void onBindToadyView(View view, LocalDate localDate, List<LocalDate> selectedDateList) {
public void onBindToadyView(View view, LocalDate localDate, List<LocalDate> totalCheckedDateList) {

View ll_content = view.findViewById(R.id.ll_content);

Expand All @@ -62,7 +64,7 @@ public void onBindToadyView(View view, LocalDate localDate, List<LocalDate> sele
tv_item.setText(String.valueOf(localDate.getDayOfMonth()));

setLunar(view, localDate);
if (selectedDateList.contains(localDate)) {
if (totalCheckedDateList.contains(localDate)) {
ll_content.setBackgroundResource(R.drawable.bg_today_checked);
} else {
ll_content.setBackgroundResource(R.drawable.bg_unchecked);
Expand All @@ -71,7 +73,7 @@ public void onBindToadyView(View view, LocalDate localDate, List<LocalDate> sele
}

@Override
public void onBindCurrentMonthOrWeekView(View view, LocalDate localDate, List<LocalDate> selectedDateList) {
public void onBindCurrentMonthOrWeekView(View view, LocalDate localDate, List<LocalDate> totalCheckedDateList) {

View ll_content = view.findViewById(R.id.ll_content);

Expand All @@ -81,7 +83,7 @@ public void onBindCurrentMonthOrWeekView(View view, LocalDate localDate, List<Lo

setLunar(view, localDate);

if (selectedDateList.contains(localDate)) {
if (totalCheckedDateList.contains(localDate)) {
ll_content.setBackgroundResource(R.drawable.bg_checked);
} else {
ll_content.setBackgroundResource(R.drawable.bg_unchecked);
Expand All @@ -90,14 +92,14 @@ public void onBindCurrentMonthOrWeekView(View view, LocalDate localDate, List<Lo
}

@Override
public void onBindLastOrNextMonthView(View view, LocalDate localDate, List<LocalDate> selectedDateList) {
public void onBindLastOrNextMonthView(View view, LocalDate localDate, List<LocalDate> totalCheckedDateList) {
View ll_content = view.findViewById(R.id.ll_content);
TextView tv_item = view.findViewById(R.id.tv_item);
tv_item.setTextColor(Color.GRAY);
tv_item.setText(String.valueOf(localDate.getDayOfMonth()));

setLunar(view, localDate);
if (selectedDateList.contains(localDate)) {
if (totalCheckedDateList.contains(localDate)) {
ll_content.setBackgroundResource(R.drawable.bg_last_next_checked);
} else {
ll_content.setBackgroundResource(R.drawable.bg_unchecked);
Expand Down
38 changes: 18 additions & 20 deletions app/src/main/java/com/necer/ncalendar/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import android.view.View;
import android.widget.TextView;

import com.necer.enumeration.SelectedModel;
import com.necer.enumeration.CheckModel;
import com.necer.ncalendar.R;
import com.necer.ncalendar.TestActivity;

import java.time.LocalDate;


public class MainActivity extends AppCompatActivity {
@Override
Expand All @@ -28,63 +26,63 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {


public void month_selected(View view) {
startActivity(getNewIntent(TestMonthActivity.class, SelectedModel.SINGLE_SELECTED, "月日历默认选中"));
startActivity(getNewIntent(TestMonthActivity.class, CheckModel.SINGLE_DEFAULT_CHECKED, "月日历默认选中"));
}

public void month_unSelected(View view) {
startActivity(getNewIntent(TestMonthActivity.class, SelectedModel.SINGLE_UNSELECTED, "月日历默认不选中"));
startActivity(getNewIntent(TestMonthActivity.class, CheckModel.SINGLE_DEFAULT_UNCHECKED, "月日历默认不选中"));
}

public void month_multiple(View view) {
startActivity(getNewIntent(TestMonthActivity.class, SelectedModel.MULTIPLE, "月日历多选"));
startActivity(getNewIntent(TestMonthActivity.class, CheckModel.MULTIPLE, "月日历多选"));
}

public void week_selected(View view) {
startActivity(getNewIntent(TestWeekActivity.class, SelectedModel.SINGLE_SELECTED, "周日历默认选中"));
startActivity(getNewIntent(TestWeekActivity.class, CheckModel.SINGLE_DEFAULT_CHECKED, "周日历默认选中"));
}

public void week_unSelected(View view) {
startActivity(getNewIntent(TestWeekActivity.class, SelectedModel.SINGLE_UNSELECTED, "周日历默认不选中"));
startActivity(getNewIntent(TestWeekActivity.class, CheckModel.SINGLE_DEFAULT_UNCHECKED, "周日历默认不选中"));
}

public void week_multiple(View view) {
startActivity(getNewIntent(TestWeekActivity.class, SelectedModel.MULTIPLE, "周日历多选"));
startActivity(getNewIntent(TestWeekActivity.class, CheckModel.MULTIPLE, "周日历多选"));
}

public void miui9_selected(View view) {
startActivity(getNewIntent(TestMiui9Activity.class, SelectedModel.SINGLE_SELECTED, "miui9默认选中"));
startActivity(getNewIntent(TestMiui9Activity.class, CheckModel.SINGLE_DEFAULT_CHECKED, "miui9默认选中"));
}

public void miui9_unSelected(View view) {
startActivity(getNewIntent(TestMiui9Activity.class, SelectedModel.SINGLE_UNSELECTED, "miui9默认不选中"));
startActivity(getNewIntent(TestMiui9Activity.class, CheckModel.SINGLE_DEFAULT_UNCHECKED, "miui9默认不选中"));
}

public void miui9_multiple(View view) {
startActivity(getNewIntent(TestMiui9Activity.class, SelectedModel.MULTIPLE, "miui9多选"));
startActivity(getNewIntent(TestMiui9Activity.class, CheckModel.MULTIPLE, "miui9多选"));
}

public void miui10_selected(View view) {
startActivity(getNewIntent(TestMiui10Activity.class, SelectedModel.SINGLE_SELECTED, "miui10默认选中"));
startActivity(getNewIntent(TestMiui10Activity.class, CheckModel.SINGLE_DEFAULT_CHECKED, "miui10默认选中"));
}

public void miui10_unSelected(View view) {
startActivity(getNewIntent(TestMiui10Activity.class, SelectedModel.SINGLE_UNSELECTED, "miui10默认不选中"));
startActivity(getNewIntent(TestMiui10Activity.class, CheckModel.SINGLE_DEFAULT_UNCHECKED, "miui10默认不选中"));
}

public void miui10_multiple(View view) {
startActivity(getNewIntent(TestMiui10Activity.class, SelectedModel.MULTIPLE, "miui10多选"));
startActivity(getNewIntent(TestMiui10Activity.class, CheckModel.MULTIPLE, "miui10多选"));
}

public void emiui_selected(View view) {
startActivity(getNewIntent(TestEmuiActivity.class, SelectedModel.SINGLE_SELECTED, "emiui默认选中"));
startActivity(getNewIntent(TestEmuiActivity.class, CheckModel.SINGLE_DEFAULT_CHECKED, "emiui默认选中"));
}

public void emiui_unSelected(View view) {
startActivity(getNewIntent(TestEmuiActivity.class, SelectedModel.SINGLE_UNSELECTED, "emiui默认不选中"));
startActivity(getNewIntent(TestEmuiActivity.class, CheckModel.SINGLE_DEFAULT_UNCHECKED, "emiui默认不选中"));
}

public void emiui_multiple(View view) {
startActivity(getNewIntent(TestEmuiActivity.class, SelectedModel.MULTIPLE, "emiui多选"));
startActivity(getNewIntent(TestEmuiActivity.class, CheckModel.MULTIPLE, "emiui多选"));
}

public void toHoldWeek(View view) {
Expand Down Expand Up @@ -120,9 +118,9 @@ public void testAdapter(View view) {
}


private Intent getNewIntent(Class<? extends BaseActivity> clazz, SelectedModel selectedModel, String title) {
private Intent getNewIntent(Class<? extends BaseActivity> clazz, CheckModel checkModel, String title) {
Intent intent = new Intent(this, clazz);
intent.putExtra("selectedModel", selectedModel);
intent.putExtra("selectedModel", checkModel);
intent.putExtra("title", title);
return intent;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.necer.calendar.BaseCalendar;
import com.necer.calendar.EmuiCalendar;
import com.necer.enumeration.CalendarState;
import com.necer.enumeration.DateChangeBehavior;
import com.necer.listener.OnCalendarChangedListener;
import com.necer.listener.OnCalendarMultipleChangedListener;
import com.necer.ncalendar.R;
Expand Down Expand Up @@ -37,25 +38,26 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

tv_result = findViewById(R.id.tv_result);

emuiCalendar.setSelectedMode(selectedModel);
emuiCalendar.setDefaultSelectFitst(true);//只在selectedMode==SINGLE_SELECTED有效
emuiCalendar.setCheckMode(checkModel);
emuiCalendar.setDefaultCheckedFirstDate(true);//只在selectedMode==SINGLE_SELECTED有效

emuiCalendar.setOnCalendarChangedListener(new OnCalendarChangedListener() {
@Override
public void onCalendarChange(BaseCalendar baseCalendar, int year, int month, LocalDate localDate) {
public void onCalendarChange(BaseCalendar baseCalendar, int year, int month, LocalDate localDate, DateChangeBehavior dateChangeBehavior) {
tv_result.setText(year + "年" + month + "月" + " 当前页面选中 " + localDate);
Log.d(TAG, "当前页面选中::" + localDate);
}

});
emuiCalendar.setOnCalendarMultipleChangedListener(new OnCalendarMultipleChangedListener() {
@Override
public void onCalendarChange(BaseCalendar baseCalendar, int year, int month, List<LocalDate> currectSelectList, List<LocalDate> allSelectList) {

tv_result.setText(year + "年" + month + "月" + " 当前页面选中 " + currectSelectList.size() + "个 总共选中" + allSelectList.size() + "个");
public void onCalendarChange(BaseCalendar baseCalendar, int year, int month, List<LocalDate> currPagerCheckedList, List<LocalDate> totalCheckedList, DateChangeBehavior dateChangeBehavior) {
tv_result.setText(year + "年" + month + "月" + " 当前页面选中 " + currPagerCheckedList.size() + "个 总共选中" + totalCheckedList.size() + "个");
Log.d(TAG, year + "年" + month + "月");
Log.d(TAG, "当前页面选中::" + currectSelectList);
Log.d(TAG, "全部选中::" + allSelectList);
Log.d(TAG, "当前页面选中::" + currPagerCheckedList);
Log.d(TAG, "全部选中::" + totalCheckedList);
}

});


Expand Down
Loading

0 comments on commit c61a41f

Please sign in to comment.