implement the Calendar at monthfragments

This commit is contained in:
tibbi 2016-09-15 19:36:57 +02:00
parent 37e03e959f
commit 0da07ee79d
7 changed files with 26 additions and 22 deletions

View File

@ -15,15 +15,15 @@ public class CalendarImpl implements DBHelper.DBOperationsListener {
private static final String YEAR_PATTERN = "YYYY";
private final Calendar mCallback;
private final String mToday;
private final String mDay;
private final Context mContext;
private DateTime mTargetDate;
private List<Event> mEvents;
public CalendarImpl(Calendar callback, Context context) {
public CalendarImpl(Calendar callback, Context context, String day) {
mCallback = callback;
mContext = context;
mToday = new DateTime().toString(Formatter.DAYCODE_PATTERN);
mDay = day;
}
public void updateCalendar(DateTime targetDate) {
@ -90,7 +90,7 @@ public class CalendarImpl implements DBHelper.DBOperationsListener {
}
private boolean isToday(DateTime targetDate, int curDayInMonth) {
return targetDate.withDayOfMonth(curDayInMonth).toString(Formatter.DAYCODE_PATTERN).equals(mToday);
return targetDate.withDayOfMonth(curDayInMonth).toString(Formatter.DAYCODE_PATTERN).equals(mDay);
}
private String getMonthName() {

View File

@ -73,7 +73,8 @@ public class MyWidgetProvider extends AppWidgetProvider implements Calendar {
final int bgColor = prefs.getInt(Constants.WIDGET_BG_COLOR, Color.BLACK);
mRemoteViews.setInt(R.id.calendar_holder, "setBackgroundColor", bgColor);
mCalendar = new CalendarImpl(this, mContext);
final String today = new DateTime().toString(Formatter.DAYCODE_PATTERN);
mCalendar = new CalendarImpl(this, mContext, today);
mCalendar.updateCalendar(new DateTime());
}

View File

@ -12,8 +12,6 @@ import android.widget.LinearLayout;
import android.widget.NumberPicker;
import android.widget.TextView;
import com.simplemobiletools.calendar.Calendar;
import com.simplemobiletools.calendar.CalendarImpl;
import com.simplemobiletools.calendar.Config;
import com.simplemobiletools.calendar.Constants;
import com.simplemobiletools.calendar.Formatter;
@ -34,7 +32,7 @@ import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class MainActivity extends SimpleActivity implements Calendar {
public class MainActivity extends SimpleActivity {
/*@BindView(R.id.top_left_arrow) ImageView mLeftArrow;
@BindView(R.id.top_right_arrow) ImageView mRightArrow;
@BindView(R.id.top_text) TextView mMonthTV;
@ -46,7 +44,6 @@ public class MainActivity extends SimpleActivity implements Calendar {
private static final int PREFILLED_MONTHS = 73;
private CalendarImpl mCalendar;
private Resources mRes;
private String mPackageName;
@ -77,18 +74,16 @@ public class MainActivity extends SimpleActivity implements Calendar {
mTodayTextSize /= mRes.getDisplayMetrics().density;
setupLabels();
mCalendar = new CalendarImpl(this, getApplicationContext());
final String today = new DateTime().toString(Formatter.DAYCODE_PATTERN);
final List<String> codes = getMonths(today);
final MyPagerAdapter adapter = new MyPagerAdapter(getSupportFragmentManager(), codes);
mPager.setAdapter(adapter);
mPager.setCurrentItem(codes.size() / 2);
}
@Override
protected void onResume() {
super.onResume();
mCalendar.updateCalendar(new DateTime());
if (mConfig.getIsSundayFirst() != mSundayFirst) {
mSundayFirst = mConfig.getIsSundayFirst();
setupLabels();
@ -224,12 +219,6 @@ public class MainActivity extends SimpleActivity implements Calendar {
dayPicker.setVisibility(View.GONE);
}
@Override
public void updateCalendar(String month, List<Day> days) {
/*updateMonth(month);
updateDays(days);*/
}
private void updateMonth(String month) {
//mMonthTV.setText(month);
}

View File

@ -16,6 +16,7 @@ import android.widget.TextView;
import com.simplemobiletools.calendar.Calendar;
import com.simplemobiletools.calendar.CalendarImpl;
import com.simplemobiletools.calendar.Constants;
import com.simplemobiletools.calendar.Formatter;
import com.simplemobiletools.calendar.MyWidgetProvider;
import com.simplemobiletools.calendar.R;
import com.simplemobiletools.calendar.Utils;
@ -98,7 +99,8 @@ public class WidgetConfigureActivity extends AppCompatActivity implements Calend
mBgSeekBar.setProgress((int) (mBgAlpha * 100));
updateBgColor();
mCalendar = new CalendarImpl(this, getApplicationContext());
final String today = new DateTime().toString(Formatter.DAYCODE_PATTERN);
mCalendar = new CalendarImpl(this, getApplicationContext(), today);
mCalendar.updateCalendar(new DateTime());
mFab.setVisibility(View.GONE);

View File

@ -6,17 +6,29 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.simplemobiletools.calendar.Calendar;
import com.simplemobiletools.calendar.CalendarImpl;
import com.simplemobiletools.calendar.Constants;
import com.simplemobiletools.calendar.R;
import com.simplemobiletools.calendar.models.Day;
public class MonthFragment extends Fragment {
import java.util.List;
public class MonthFragment extends Fragment implements Calendar {
private CalendarImpl mCalendar;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.calendar_layout, container, false);
final String code = getArguments().getString(Constants.DAY_CODE);
mCalendar = new CalendarImpl(this, getActivity().getApplicationContext(), code);
return view;
}
@Override
public void updateCalendar(String month, List<Day> days) {
}
}

View File

@ -9,7 +9,6 @@
<com.simplemobiletools.calendar.views.MyViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_margin="@dimen/activity_margin"
android:layout_height="match_parent"/>
<android.support.design.widget.FloatingActionButton

View File

@ -3,7 +3,8 @@
android:id="@+id/calendar_holder"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:padding="@dimen/activity_margin">
<include layout="@layout/top_navigation"/>