diff --git a/app/src/main/java/com/simplemobiletools/calendar/CalendarImpl.java b/app/src/main/java/com/simplemobiletools/calendar/CalendarImpl.java index ff7024f19..88a9c0fbb 100644 --- a/app/src/main/java/com/simplemobiletools/calendar/CalendarImpl.java +++ b/app/src/main/java/com/simplemobiletools/calendar/CalendarImpl.java @@ -15,15 +15,15 @@ public class CalendarImpl implements DBHelper.DBOperationsListener { private static final String YEAR_PATTERN = "YYYY"; private final Calendar mCallback; - private final String mDay; + private final String mToday; private final Context mContext; private DateTime mTargetDate; private List mEvents; - public CalendarImpl(Calendar callback, Context context, String day) { + public CalendarImpl(Calendar callback, Context context) { mCallback = callback; mContext = context; - mDay = day; + mToday = new DateTime().toString(Formatter.DAYCODE_PATTERN); } 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(mDay); + return targetDate.withDayOfMonth(curDayInMonth).toString(Formatter.DAYCODE_PATTERN).equals(mToday); } private String getMonthName() { diff --git a/app/src/main/java/com/simplemobiletools/calendar/MyWidgetProvider.java b/app/src/main/java/com/simplemobiletools/calendar/MyWidgetProvider.java index ee4eff9fa..d7c132b77 100644 --- a/app/src/main/java/com/simplemobiletools/calendar/MyWidgetProvider.java +++ b/app/src/main/java/com/simplemobiletools/calendar/MyWidgetProvider.java @@ -73,8 +73,7 @@ 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); - final String today = new DateTime().toString(Formatter.DAYCODE_PATTERN); - mCalendar = new CalendarImpl(this, mContext, today); + mCalendar = new CalendarImpl(this, mContext); mCalendar.updateCalendar(new DateTime()); } diff --git a/app/src/main/java/com/simplemobiletools/calendar/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/calendar/activities/MainActivity.java index f2d2219b9..78b5c8b59 100644 --- a/app/src/main/java/com/simplemobiletools/calendar/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/calendar/activities/MainActivity.java @@ -35,7 +35,6 @@ import butterknife.OnClick; 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; @BindView(R.id.calendar_holder) View mCalendarHolder;*/ @BindView(R.id.view_pager) MyViewPager mPager; @@ -219,10 +218,6 @@ public class MainActivity extends SimpleActivity { dayPicker.setVisibility(View.GONE); } - private void updateMonth(String month) { - //mMonthTV.setText(month); - } - private void setupLabels() { int letters[] = Utils.getLetterIDs(); diff --git a/app/src/main/java/com/simplemobiletools/calendar/activities/WidgetConfigureActivity.java b/app/src/main/java/com/simplemobiletools/calendar/activities/WidgetConfigureActivity.java index 4f907a2a4..788169aa5 100644 --- a/app/src/main/java/com/simplemobiletools/calendar/activities/WidgetConfigureActivity.java +++ b/app/src/main/java/com/simplemobiletools/calendar/activities/WidgetConfigureActivity.java @@ -16,7 +16,6 @@ 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; @@ -99,8 +98,7 @@ public class WidgetConfigureActivity extends AppCompatActivity implements Calend mBgSeekBar.setProgress((int) (mBgAlpha * 100)); updateBgColor(); - final String today = new DateTime().toString(Formatter.DAYCODE_PATTERN); - mCalendar = new CalendarImpl(this, getApplicationContext(), today); + mCalendar = new CalendarImpl(this, getApplicationContext()); mCalendar.updateCalendar(new DateTime()); mFab.setVisibility(View.GONE); diff --git a/app/src/main/java/com/simplemobiletools/calendar/fragments/MonthFragment.java b/app/src/main/java/com/simplemobiletools/calendar/fragments/MonthFragment.java index 2ab76b313..2fb5bffb6 100644 --- a/app/src/main/java/com/simplemobiletools/calendar/fragments/MonthFragment.java +++ b/app/src/main/java/com/simplemobiletools/calendar/fragments/MonthFragment.java @@ -5,30 +5,38 @@ import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +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.R; import com.simplemobiletools.calendar.models.Day; import java.util.List; +import butterknife.BindView; +import butterknife.ButterKnife; + public class MonthFragment extends Fragment implements Calendar { + @BindView(R.id.top_text) TextView mMonthTV; private CalendarImpl mCalendar; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.calendar_layout, container, false); + ButterKnife.bind(this, view); final String code = getArguments().getString(Constants.DAY_CODE); - mCalendar = new CalendarImpl(this, getActivity().getApplicationContext(), code); + mCalendar = new CalendarImpl(this, getActivity().getApplicationContext()); + mCalendar.updateCalendar(Formatter.getDateTimeFromCode(code)); return view; } @Override public void updateCalendar(String month, List days) { - + mMonthTV.setText(month); } }