Skip to content

Commit

Permalink
Merge pull request prolificinteractive#512 from prolificinteractive/q…
Browse files Browse the repository at this point in the history
…c_feature_title_click_listener

Feature - Title click listener
  • Loading branch information
quentin41500 authored Feb 15, 2017
2 parents 46dbe98 + a97c138 commit 30da68b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ android {
versionCode project.ext.versionCodeInt
versionName version
}

lintOptions {
abortOnError false
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ public void onPageScrolled(int position, float positionOffset, int positionOffse
private OnMonthChangedListener monthListener;
private OnRangeSelectedListener rangeListener;


CharSequence calendarContentDescription;
private int accentColor = 0;
private int arrowColor = Color.BLACK;
Expand Down Expand Up @@ -262,7 +261,6 @@ public MaterialCalendarView(Context context, AttributeSet attrs) {
buttonFuture.setContentDescription(getContext().getString(R.string.next));
pager = new CalendarPager(getContext());

title.setOnClickListener(onClickListener);
buttonPast.setOnClickListener(onClickListener);
buttonFuture.setOnClickListener(onClickListener);

Expand Down Expand Up @@ -1357,6 +1355,15 @@ public void setOnRangeSelectedListener(OnRangeSelectedListener listener) {
this.rangeListener = listener;
}

/**
* Add listener to the title or null to remove it.
*
* @param listener Listener to be notified.
*/
public void setOnTitleClickListener(final OnClickListener listener) {
title.setOnClickListener(listener);
}

/**
* Dispatch date change events to a listener, if set
*
Expand Down
4 changes: 4 additions & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ android {
versionCode project.ext.versionCodeInt
versionName version
}

lintOptions {
abortOnError false
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.support.annotation.NonNull;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.DatePicker;
import android.widget.LinearLayout;
import android.widget.NumberPicker;
Expand Down Expand Up @@ -43,6 +44,14 @@ protected void onCreate(Bundle savedInstanceState) {
currentTileSize = MaterialCalendarView.DEFAULT_TILE_SIZE_DP;
currentTileWidth = MaterialCalendarView.DEFAULT_TILE_SIZE_DP;
currentTileHeight = MaterialCalendarView.DEFAULT_TILE_SIZE_DP;

widget.setOnTitleClickListener(new View.OnClickListener() {
@Override
public void onClick(final View view) {
Toast.makeText(DynamicSettersActivity.this, R.string.today, Toast.LENGTH_SHORT)
.show();
}
});
}

@OnClick(R.id.button_other_dates)
Expand Down
2 changes: 2 additions & 0 deletions sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,6 @@
<string name="label_thin">Tile width and height specified (thin)</string>
<string name="label_wide">Tile width and height specified (wide)</string>


<string name="today">Today is the day</string>
</resources>

0 comments on commit 30da68b

Please sign in to comment.