add a viewpager into the day activity

This commit is contained in:
tibbi 2016-09-16 23:01:46 +02:00
parent 475dff59d8
commit dddab1c6ac
4 changed files with 51 additions and 44 deletions

View File

@ -1,15 +1,9 @@
package com.simplemobiletools.calendar.activities; package com.simplemobiletools.calendar.activities;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
import android.util.SparseBooleanArray;
import android.view.ActionMode; import android.view.ActionMode;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
@ -17,37 +11,27 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.AbsListView; import android.widget.AbsListView;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.DatePicker;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.simplemobiletools.calendar.Constants; import com.simplemobiletools.calendar.Constants;
import com.simplemobiletools.calendar.DBHelper; import com.simplemobiletools.calendar.DBHelper;
import com.simplemobiletools.calendar.Formatter; import com.simplemobiletools.calendar.Formatter;
import com.simplemobiletools.calendar.R; import com.simplemobiletools.calendar.R;
import com.simplemobiletools.calendar.Utils; import com.simplemobiletools.calendar.Utils;
import com.simplemobiletools.calendar.adapters.EventsAdapter;
import com.simplemobiletools.calendar.models.Event; import com.simplemobiletools.calendar.models.Event;
import org.joda.time.DateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import butterknife.BindDimen; import butterknife.BindDimen;
import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick;
public class DayActivity extends SimpleActivity public class DayActivity extends SimpleActivity
implements DBHelper.DBOperationsListener, AdapterView.OnItemClickListener, AbsListView.MultiChoiceModeListener { implements DBHelper.DBOperationsListener, AdapterView.OnItemClickListener, AbsListView.MultiChoiceModeListener {
@BindView(R.id.month_value) TextView mDateTV; /*@BindView(R.id.month_value) TextView mDateTV;
@BindView(R.id.day_events) ListView mEventsList; @BindView(R.id.day_events) ListView mEventsList;
@BindView(R.id.day_coordinator) CoordinatorLayout mCoordinatorLayout; @BindView(R.id.day_coordinator) CoordinatorLayout mCoordinatorLayout;
@BindView(R.id.top_left_arrow) ImageView mLeftArrow; @BindView(R.id.top_left_arrow) ImageView mLeftArrow;
@BindView(R.id.top_right_arrow) ImageView mRightArrow; @BindView(R.id.top_right_arrow) ImageView mRightArrow;*/
@BindDimen(R.dimen.activity_margin) int mActivityMargin; @BindDimen(R.dimen.activity_margin) int mActivityMargin;
@ -75,19 +59,19 @@ public class DayActivity extends SimpleActivity
return; return;
final String date = Formatter.getEventDate(getApplicationContext(), mDayCode); final String date = Formatter.getEventDate(getApplicationContext(), mDayCode);
mDateTV.setText(date); //mDateTV.setText(date);
mToBeDeleted = new ArrayList<>(); mToBeDeleted = new ArrayList<>();
final int baseColor = mConfig.getIsDarkTheme() ? Color.WHITE : Color.BLACK; final int baseColor = mConfig.getIsDarkTheme() ? Color.WHITE : Color.BLACK;
final int textColor = Utils.adjustAlpha(baseColor, Constants.HIGH_ALPHA); final int textColor = Utils.adjustAlpha(baseColor, Constants.HIGH_ALPHA);
mLeftArrow.getDrawable().mutate().setColorFilter(textColor, PorterDuff.Mode.SRC_ATOP); /*mLeftArrow.getDrawable().mutate().setColorFilter(textColor, PorterDuff.Mode.SRC_ATOP);
mRightArrow.getDrawable().mutate().setColorFilter(textColor, PorterDuff.Mode.SRC_ATOP); mRightArrow.getDrawable().mutate().setColorFilter(textColor, PorterDuff.Mode.SRC_ATOP);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mLeftArrow.getLayoutParams(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mLeftArrow.getLayoutParams();
params.setMargins(mActivityMargin, params.topMargin, params.rightMargin, params.bottomMargin); params.setMargins(mActivityMargin, params.topMargin, params.rightMargin, params.bottomMargin);
params = (RelativeLayout.LayoutParams) mRightArrow.getLayoutParams(); params = (RelativeLayout.LayoutParams) mRightArrow.getLayoutParams();
params.setMargins(params.leftMargin, params.topMargin, mActivityMargin, params.bottomMargin); params.setMargins(params.leftMargin, params.topMargin, mActivityMargin, params.bottomMargin);*/
} }
@Override @Override
@ -102,7 +86,7 @@ public class DayActivity extends SimpleActivity
checkDeleteEvents(); checkDeleteEvents();
} }
@OnClick(R.id.day_fab) /*@OnClick(R.id.day_fab)
public void fabClicked(View view) { public void fabClicked(View view) {
final Intent intent = new Intent(getApplicationContext(), EventActivity.class); final Intent intent = new Intent(getApplicationContext(), EventActivity.class);
intent.putExtra(Constants.DAY_CODE, mDayCode); intent.putExtra(Constants.DAY_CODE, mDayCode);
@ -147,7 +131,7 @@ public class DayActivity extends SimpleActivity
}); });
alertDialog.show(); alertDialog.show();
} }*/
private void switchToDay(String dayCode) { private void switchToDay(String dayCode) {
final Intent intent = new Intent(getApplicationContext(), DayActivity.class); final Intent intent = new Intent(getApplicationContext(), DayActivity.class);
@ -171,11 +155,11 @@ public class DayActivity extends SimpleActivity
private void updateEvents(List<Event> events) { private void updateEvents(List<Event> events) {
mEvents = new ArrayList<>(events); mEvents = new ArrayList<>(events);
final List<Event> eventsToShow = getEventsToShow(events); /*final List<Event> eventsToShow = getEventsToShow(events);
final EventsAdapter adapter = new EventsAdapter(this, eventsToShow); final EventsAdapter adapter = new EventsAdapter(this, eventsToShow);
mEventsList.setAdapter(adapter); mEventsList.setAdapter(adapter);
mEventsList.setOnItemClickListener(this); mEventsList.setOnItemClickListener(this);
mEventsList.setMultiChoiceModeListener(this); mEventsList.setMultiChoiceModeListener(this);*/
} }
private List<Event> getEventsToShow(List<Event> events) { private List<Event> getEventsToShow(List<Event> events) {
@ -298,7 +282,7 @@ public class DayActivity extends SimpleActivity
} }
private void prepareDeleteEvents() { private void prepareDeleteEvents() {
final SparseBooleanArray checked = mEventsList.getCheckedItemPositions(); /*final SparseBooleanArray checked = mEventsList.getCheckedItemPositions();
for (int i = 0; i < mEvents.size(); i++) { for (int i = 0; i < mEvents.size(); i++) {
if (checked.get(i)) { if (checked.get(i)) {
final Event event = mEvents.get(i); final Event event = mEvents.get(i);
@ -306,17 +290,17 @@ public class DayActivity extends SimpleActivity
} }
} }
notifyEventDeletion(mToBeDeleted.size()); notifyEventDeletion(mToBeDeleted.size());*/
} }
private void notifyEventDeletion(int cnt) { private void notifyEventDeletion(int cnt) {
final Resources res = getResources(); /*final Resources res = getResources();
final String msg = res.getQuantityString(R.plurals.events_deleted, cnt, cnt); final String msg = res.getQuantityString(R.plurals.events_deleted, cnt, cnt);
mSnackbar = Snackbar.make(mCoordinatorLayout, msg, Snackbar.LENGTH_INDEFINITE); mSnackbar = Snackbar.make(mCoordinatorLayout, msg, Snackbar.LENGTH_INDEFINITE);
mSnackbar.setAction(res.getString(R.string.undo), undoDeletion); mSnackbar.setAction(res.getString(R.string.undo), undoDeletion);
mSnackbar.setActionTextColor(Color.WHITE); mSnackbar.setActionTextColor(Color.WHITE);
mSnackbar.show(); mSnackbar.show();
updateEvents(mEvents); updateEvents(mEvents);*/
} }
@Override @Override

View File

@ -0,0 +1,16 @@
package com.simplemobiletools.calendar.fragments
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.simplemobiletools.calendar.R
class DayFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater!!.inflate(R.layout.day_fragment, container, false)
return view
}
}

View File

@ -7,22 +7,10 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginTop="@dimen/activity_margin"> android:layout_marginTop="@dimen/activity_margin">
<RelativeLayout <com.simplemobiletools.calendar.views.MyViewPager
android:id="@+id/day_holder" android:id="@+id/view_pager"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="match_parent"/>
<include layout="@layout/top_navigation"/>
<ListView
android:id="@+id/day_events"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/month_value"
android:choiceMode="multipleChoiceModal"
android:clipToPadding="false"
android:paddingLeft="@dimen/activity_margin"/>
</RelativeLayout>
<android.support.design.widget.FloatingActionButton <android.support.design.widget.FloatingActionButton
android:id="@+id/day_fab" android:id="@+id/day_fab"

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/day_holder"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/top_navigation"/>
<ListView
android:id="@+id/day_events"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/month_value"
android:choiceMode="multipleChoiceModal"
android:clipToPadding="false"
android:paddingLeft="@dimen/activity_margin"/>
</RelativeLayout>