forked from yannecer/NCalendar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
155 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/src/main/java/necer/ncalendardemo/activity/TestFragmentActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package necer.ncalendardemo.activity; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import necer.ncalendardemo.R; | ||
import necer.ncalendardemo.fragment.TestFragment; | ||
|
||
/** | ||
* Created by necer on 2017/12/22. | ||
*/ | ||
|
||
public class TestFragmentActivity extends AppCompatActivity { | ||
|
||
|
||
@Override | ||
protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_test_fragment); | ||
|
||
|
||
getSupportFragmentManager().beginTransaction().replace(R.id.fl_, new TestFragment()).commit(); | ||
|
||
|
||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
app/src/main/java/necer/ncalendardemo/fragment/TestFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package necer.ncalendardemo.fragment; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
|
||
import com.necer.ncalendar.calendar.NCalendar; | ||
import com.necer.ncalendar.listener.OnCalendarChangedListener; | ||
|
||
import org.joda.time.DateTime; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import necer.ncalendardemo.R; | ||
import necer.ncalendardemo.adapter.AAAdapter; | ||
|
||
/** | ||
* Created by necer on 2017/12/22. | ||
*/ | ||
|
||
public class TestFragment extends Fragment implements OnCalendarChangedListener { | ||
|
||
|
||
private NCalendar ncalendar; | ||
private RecyclerView recyclerView; | ||
private TextView tv_month; | ||
private TextView tv_date; | ||
|
||
@Nullable | ||
@Override | ||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | ||
|
||
|
||
View view = LayoutInflater.from(getContext()).inflate(R.layout.activity_ncalendar, null); | ||
|
||
|
||
|
||
ncalendar = (NCalendar) view.findViewById(R.id.ncalendarrrr); | ||
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); | ||
tv_month = (TextView) view.findViewById(R.id.tv_month); | ||
tv_date = (TextView) view.findViewById(R.id.tv_date); | ||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); | ||
AAAdapter aaAdapter = new AAAdapter(getContext()); | ||
recyclerView.setAdapter(aaAdapter); | ||
ncalendar.setOnCalendarChangedListener(this); | ||
|
||
ncalendar.post(new Runnable() { | ||
@Override | ||
public void run() { | ||
|
||
List<String> list = new ArrayList<>(); | ||
list.add("2017-09-21"); | ||
list.add("2017-10-21"); | ||
list.add("2017-10-1"); | ||
list.add("2017-10-15"); | ||
list.add("2017-10-18"); | ||
list.add("2017-10-26"); | ||
list.add("2017-11-21"); | ||
|
||
ncalendar.setPoint(list); | ||
} | ||
}); | ||
|
||
return view; | ||
} | ||
|
||
@Override | ||
public void onCalendarChanged(DateTime dateTime) { | ||
tv_month.setText(dateTime.getMonthOfYear() + "月"); | ||
tv_date.setText(dateTime.getYear() + "年" + dateTime.getMonthOfYear() + "月" + dateTime.getDayOfMonth() + "日"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,60 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
|
||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
|
||
<Button | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="仿miui日历" | ||
android:layout_marginTop="20dp" | ||
android:onClick="toMiui"/> | ||
android:onClick="toMiui" | ||
android:text="仿miui日历" /> | ||
|
||
<Button | ||
android:id="@+id/bt" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="默认不选中的月日历" | ||
android:layout_marginTop="20dp" | ||
android:onClick="notDefaultSelect"/> | ||
android:onClick="notDefaultSelect" | ||
android:text="默认不选中的月日历" /> | ||
|
||
|
||
<Button | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="默认选中的月日历" | ||
android:onClick="defaultSelect"/> | ||
android:onClick="defaultSelect" | ||
android:text="默认选中的月日历" /> | ||
|
||
<Button | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="周日历" | ||
android:onClick="week"/> | ||
android:onClick="week" | ||
android:text="周日历" /> | ||
|
||
<Button | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:onClick="fragment" | ||
android:text="Fragment" /> | ||
|
||
|
||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textSize="12sp" | ||
android:layout_margin="15dp" | ||
android:text="注意:1单纯的周日历和月日历使用方法完全相同 | ||
2:单个的周日历和月日历可以设置默认不选中(即是点击才选中,不点击不选中),但是月周切换必须每页都有选中日期,这样才能体现出月周切换日期无缝切换的特点, 该日历不支持月周切换的不选中设置"/> | ||
2:单个的周日历和月日历可以设置默认不选中(即是点击才选中,不点击不选中),但是月周切换必须每页都有选中日期,这样才能体现出月周切换日期无缝切换的特点, 该日历不支持月周切换的不选中设置" | ||
android:textSize="12sp" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_version" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textSize="12sp" | ||
android:layout_margin="15dp" | ||
android:text="版本"/> | ||
|
||
android:text="版本" | ||
android:textSize="12sp" /> | ||
|
||
|
||
</LinearLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:orientation="vertical" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
|
||
<FrameLayout | ||
android:id="@+id/fl_" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"></FrameLayout> | ||
|
||
|
||
|
||
|
||
</LinearLayout> |