Skip to content

Commit

Permalink
应该结束了吧
Browse files Browse the repository at this point in the history
  • Loading branch information
yanbinbin committed Sep 22, 2017
1 parent dd14f2a commit 872ce67
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 35 deletions.
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</activity>
<activity android:name=".activity.MonthAndWeekCalendarActivity"/>
<activity android:name=".activity.NCalendarActivity"/>
<activity android:name=".activity.TestActivity"/>

</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ public void ncanlendar(View view) {
public void monthAndWeek(View view) {
startActivity(new Intent(this, MonthAndWeekCalendarActivity.class));
}

public void test(View view) {
startActivity(new Intent(this, TestActivity.class));
}
}
59 changes: 59 additions & 0 deletions app/src/main/java/necer/ncalendardemo/activity/TestActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package necer.ncalendardemo.activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.necer.ncalendar.calendar.NMonthCalendar;
import com.necer.ncalendar.listener.OnMonthCalendarChangedListener;
import com.necer.ncalendar.utils.MyLog;

import org.joda.time.DateTime;

import java.util.ArrayList;
import java.util.List;

import necer.ncalendardemo.R;

/**
* Created by 闫彬彬 on 2017/9/22.
* QQ:619008099
*/

public class TestActivity extends Activity {


private NMonthCalendar nmonthcalendar;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);

nmonthcalendar = (NMonthCalendar) findViewById(R.id.nmonthcalendar);
nmonthcalendar.post(new Runnable() {
@Override
public void run() {
List<String> list = new ArrayList<>();
list.add("2017-9-21");
list.add("2017-9-21");
list.add("2017-9-23");
list.add("2017-9-26");
nmonthcalendar.setPointList(list);
}
});
nmonthcalendar.setOnMonthCalendarChangedListener(new OnMonthCalendarChangedListener() {
@Override
public void onMonthCalendarChanged(DateTime dateTime) {
MyLog.d("onMonthCalendarChanged::" + dateTime.toLocalDate());
}
});

}

public void aaa(View view) {
nmonthcalendar.setDate("2017-10-01");

}
}
50 changes: 27 additions & 23 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,38 @@


<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp">

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#c1c1c1"
android:layout_centerVertical="true"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请点上面的仿miui日历"
android:textColor="#333333"
android:textSize="16sp"
android:layout_centerInParent="true"
android:background="@color/white"
/>
</RelativeLayout>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp">

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_centerVertical="true"
android:background="#c1c1c1" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@color/white"
android:padding="5dp"
android:text="请点上面的仿miui日历"
android:textColor="#333333"
android:textSize="16sp" />
</RelativeLayout>


<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="老版日历"
android:onClick="monthAndWeek"
/>
android:text="老版日历" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="test"
android:text="test" />

</LinearLayout>
13 changes: 8 additions & 5 deletions app/src/main/res/layout/activity_test.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?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_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<Button
android:id="@+id/aaa"
Expand All @@ -11,11 +12,13 @@

<include layout="@layout/layout_week_num"/>



<com.necer.ncalendar.calendar.NMonthCalendar
android:id="@+id/ncalendar"
android:id="@+id/nmonthcalendar"
android:layout_width="match_parent"
android:layout_height="300dp"></com.necer.ncalendar.calendar.NMonthCalendar>
android:layout_height="500dp"
app:calendarHeight="500dp"
>

</com.necer.ncalendar.calendar.NMonthCalendar>

</LinearLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void setPointList(List<String> pointList) {
if (nCalendarView == null) {
return;
}
nCalendarView.setPointList(pointList);
nCalendarView.setPointList(formatList);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.necer.ncalendar.calendar;

import android.content.Context;
import android.util.AttributeSet;
import android.util.SparseArray;
import android.widget.Toast;

import com.necer.ncalendar.R;
import com.necer.ncalendar.adapter.NCalendarAdapter;
import com.necer.ncalendar.adapter.NMonthAdapter;
Expand All @@ -13,7 +11,6 @@
import com.necer.ncalendar.utils.Utils;
import com.necer.ncalendar.view.NCalendarView;
import com.necer.ncalendar.view.NMonthView;

import org.joda.time.DateTime;
import org.joda.time.Months;

Expand Down Expand Up @@ -56,6 +53,7 @@ protected void initCurrentCalendarView(int position) {
lastPosition = position;
currView.setDateTimeAndPoint(mInitialDateTime,pointList);
mSelectDateTime = mInitialDateTime;

} else if (!isSetDateTime) {
int i = position - lastPosition;
DateTime dateTime = mSelectDateTime.plusMonths(i);
Expand All @@ -66,10 +64,7 @@ protected void initCurrentCalendarView(int position) {
} else if (dateTime.getYear() < startDateTime.getYear()) {
dateTime = startDateTime;
}

//currView.setSelectDateTime(dateTime);
currView.setDateTimeAndPoint(dateTime, pointList);

mSelectDateTime = dateTime;
}
lastPosition = position;
Expand Down

0 comments on commit 872ce67

Please sign in to comment.