Skip to content

Commit

Permalink
image
Browse files Browse the repository at this point in the history
  • Loading branch information
loonggg committed Oct 13, 2016
1 parent 4099582 commit 1e0cf6e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# WeekCalendar
周日历,Weekly Calendar。
## 效果图


## 使用方法(usage)
### Step 1. Add the JitPack repository to your build file
Expand All @@ -17,7 +19,7 @@ Add it in your root build.gradle at the end of repositories:
### Step 2. Add the dependency
```java
dependencies {
compile 'com.github.loonggg:WeekCalendar:v1.0'
compile 'com.github.loonggg:WeekCalendar:v1.1'
}
```

Expand Down Expand Up @@ -54,6 +56,23 @@ Add it in your root build.gradle at the end of repositories:
app:nextArrowBg="@mipmap/white_right_arrow"
app:preArrowBg="@mipmap/white_left_arrow" />
```


### Step 4. Impelement Listener
```java
weekCalendar = (WeekCalendar) findViewById(R.id.week_calendar);
List<String> list = new ArrayList<>();
list.add("2016-09-13");
list.add("2016-10-13");
list.add("2016-10-11");
list.add("2016-10-10");
list.add("2016-10-16");
//传入已经预约或者曾经要展示选中的时间列表
weekCalendar.setSelectDates(list);
//设置日历点击事件
weekCalendar.setOnDateClickListener(new WeekCalendar.OnDateClickListener() {
@Override
public void onDateClick(String time) {
Toast.makeText(MainActivity.this, time, Toast.LENGTH_SHORT).show();
}
});
```

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

Expand All @@ -21,7 +20,7 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
weekCalendar = (WeekCalendar) findViewById(R.id.mc_calendar);
weekCalendar = (WeekCalendar) findViewById(R.id.week_calendar);
List<String> list = new ArrayList<>();
list.add("2016-09-13");
list.add("2016-10-13");
Expand All @@ -32,8 +31,8 @@ protected void onCreate(Bundle savedInstanceState) {
//设置日历点击事件
weekCalendar.setOnDateClickListener(new WeekCalendar.OnDateClickListener() {
@Override
public void onDateClick(View view, int position) {
Toast.makeText(MainActivity.this, weekCalendar.getTheDayOfSelected(), Toast.LENGTH_SHORT).show();
public void onDateClick(String time) {
Toast.makeText(MainActivity.this, time, Toast.LENGTH_SHORT).show();
}
});

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:layout_height="match_parent">

<com.loonggg.weekcalendar.view.WeekCalendar
android:id="@+id/mc_calendar"
android:id="@+id/week_calendar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
Expand Down
Binary file added image/ss.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public void onClick(View v) {
theDayForShow = datas.get(position);
notifyDataSetChanged();
if (listener != null) {
listener.onDateClick(dayView, position);
listener.onDateClick(getTheDayOfSelected());
}
}
});
Expand All @@ -383,7 +383,7 @@ public void onClick(View v) {
* 点击选中日期的回调接口
*/
public interface OnDateClickListener {
void onDateClick(View view, int position);
void onDateClick(String time);
}

/**
Expand All @@ -398,7 +398,7 @@ public void setOnDateClickListener(OnDateClickListener listener) {
*
* @return
*/
public String getTheDayOfSelected() {
private String getTheDayOfSelected() {
if (theDayOfSelected != null) {
String sYear = String.valueOf(theDayOfSelected.year);
String sMonth = String.valueOf(theDayOfSelected.month);
Expand Down

0 comments on commit 1e0cf6e

Please sign in to comment.