Skip to content

Commit

Permalink
Chore - Getter Activity (#826)
Browse files Browse the repository at this point in the history
  • Loading branch information
quentin41500 committed Jul 25, 2018
1 parent dd0a443 commit 771b655
Show file tree
Hide file tree
Showing 4 changed files with 221 additions and 39 deletions.
94 changes: 56 additions & 38 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
>

<application
android:supportsRtl="true"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
>
<activity
android:name="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:name=".MainActivity"
android:label="@string/app_name"
>
<intent-filter>
Expand All @@ -22,14 +22,14 @@
</activity>

<activity
android:name="com.prolificinteractive.materialcalendarview.sample.OldCalendarViewActivity"
android:name=".OldCalendarViewActivity"
android:label="@string/title_activity_old_calendar"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
Expand All @@ -40,14 +40,14 @@
</activity>

<activity
android:name="com.prolificinteractive.materialcalendarview.sample.BasicActivity"
android:name=".BasicActivity"
android:label="@string/title_activity_basic"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
Expand All @@ -60,12 +60,12 @@
<activity
android:name=".SelectionModesActivity"
android:label="@string/title_activity_selections"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
Expand All @@ -76,14 +76,14 @@
</activity>

<activity
android:name="com.prolificinteractive.materialcalendarview.sample.BasicActivityDecorated"
android:name=".BasicActivityDecorated"
android:label="@string/title_activity_decorators"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
Expand All @@ -94,14 +94,14 @@
</activity>

<activity
android:name="com.prolificinteractive.materialcalendarview.sample.SwappableBasicActivityDecorated"
android:name=".SwappableBasicActivityDecorated"
android:label="@string/title_activity_basic_modes"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
Expand All @@ -114,12 +114,12 @@
<activity
android:name=".DisableDaysActivity"
android:label="@string/title_activity_disable"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
Expand All @@ -130,14 +130,14 @@
</activity>

<activity
android:name="com.prolificinteractive.materialcalendarview.sample.CustomizeXmlActivity"
android:name=".CustomizeXmlActivity"
android:label="@string/title_activity_customize_xml"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
Expand All @@ -148,14 +148,14 @@
</activity>

<activity
android:name="com.prolificinteractive.materialcalendarview.sample.CustomizeCodeActivity"
android:name=".CustomizeCodeActivity"
android:label="@string/title_activity_customize_code"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
Expand All @@ -166,14 +166,14 @@
</activity>

<activity
android:name="com.prolificinteractive.materialcalendarview.sample.DynamicSettersActivity"
android:name=".DynamicSettersActivity"
android:label="@string/title_activity_dynamic_setters"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
Expand All @@ -186,12 +186,12 @@
<activity
android:name=".CustomTileDimensions"
android:label="@string/title_activity_custom_tile_size"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
Expand All @@ -202,14 +202,14 @@
</activity>

<activity
android:name="com.prolificinteractive.materialcalendarview.sample.DialogsActivity"
android:name=".DialogsActivity"
android:label="@string/title_activity_dialogs"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
Expand All @@ -220,14 +220,14 @@
</activity>

<activity
android:name="com.prolificinteractive.materialcalendarview.sample.MultipleViewActivity"
android:name=".MultipleViewActivity"
android:label="@string/title_activity_multiple_view"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
Expand All @@ -237,20 +237,38 @@
</activity>

<activity
android:name="com.prolificinteractive.materialcalendarview.sample.MultipleSizeActivity"
android:name=".MultipleSizeActivity"
android:label="@string/title_activity_multiple_size"
android:parentActivityName="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"
/>

<intent-filter>
<action android:name="android.intent.action.RUN"/>
<category android:name="com.prolificinteractive.materialcalendarview.sample.SAMPLE"/>
</intent-filter>
</activity>

<activity
android:name=".GettersActivity"
android:label="@string/title_activity_getters"
android:parentActivityName=".MainActivity"
>

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.prolificinteractive.materialcalendarview.sample.MainActivity"
android:value=".MainActivity"
/>

<intent-filter>
<action android:name="android.intent.action.RUN"/>
<category android:name="com.prolificinteractive.materialcalendarview.sample.SAMPLE"/>
</intent-filter>

</activity>

</application>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package com.prolificinteractive.materialcalendarview.sample;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnCheckedChanged;
import butterknife.OnClick;
import com.prolificinteractive.materialcalendarview.CalendarDay;
import com.prolificinteractive.materialcalendarview.CalendarMode;
import com.prolificinteractive.materialcalendarview.MaterialCalendarView;
import java.util.List;

/**
* Because the calendar has a lot of getters method, this activity is here to demonstrate what each
* getter is returning. For more information, make sure to check the documentation.
*/
public class GettersActivity extends AppCompatActivity {
public static final CharSequence[] ITEMS =
new CharSequence[] { "NONE", "SINGLE", "MULTIPLE", "RANGE" };

@BindView(R.id.calendarView) MaterialCalendarView widget;

@Override protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_getters);
ButterKnife.bind(this);
}

@OnCheckedChanged(R.id.calendar_mode)
void onCalendarModeChanged(boolean checked) {
final CalendarMode mode = checked ? CalendarMode.WEEKS : CalendarMode.MONTHS;
widget.state().edit().setCalendarDisplayMode(mode).commit();
}

@OnClick(R.id.button_selection_mode) void onChangeSelectionMode() {
new AlertDialog.Builder(this)
.setTitle("Selection Mode")
.setSingleChoiceItems(ITEMS, widget.getSelectionMode(), (dialog, which) -> {
widget.setSelectionMode(which);
dialog.dismiss();
})
.show();
}

@OnClick(R.id.get_current_date) public void getCurrentDatesClick(final View v) {
Toast.makeText(this, widget.getCurrentDate().toString(), Toast.LENGTH_SHORT).show();
Log.e("GettersActivity", widget.getCurrentDate().toString());
}

@OnClick(R.id.get_selected_date) public void getSelectedDatesClick(final View v) {
final CalendarDay selectedDate = widget.getSelectedDate();
if (selectedDate != null) {
Toast.makeText(this, selectedDate.toString(), Toast.LENGTH_SHORT).show();
Log.e("GettersActivity", selectedDate.toString());
} else {
Toast.makeText(this, "No Selection", Toast.LENGTH_SHORT).show();
}
}

@OnClick(R.id.get_selected_dates) public void getSelectedDateClick(final View v) {
final List<CalendarDay> selectedDates = widget.getSelectedDates();
if (!selectedDates.isEmpty()) {
Toast.makeText(this, selectedDates.toString(), Toast.LENGTH_SHORT).show();
Log.e("GettersActivity", selectedDates.toString());
} else {
Toast.makeText(this, "No Selection", Toast.LENGTH_SHORT).show();
}
}

@OnClick(R.id.get_selection_mode) public void getSelectionModeClick(final View v) {
Toast.makeText(this, ITEMS[widget.getSelectionMode()], Toast.LENGTH_SHORT).show();
Log.e("GettersActivity", ITEMS[widget.getSelectionMode()].toString());
}
}
Loading

0 comments on commit 771b655

Please sign in to comment.