Skip to content

Commit a783196

Browse files
committed
topbar changes
1 parent f817cc8 commit a783196

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ and its easy to add new language see
6969
# todo
7070
1. <s>fix year picker</s>
7171
2. add dialog mode
72-
3. jitpack realse
72+
3. make jar
7373

7474
# LICENCE
7575
under [MIT](https://github.com/hooshkar/AndroidMultiCalenderTools/blob/master/LICENSE) licence

app/src/main/java/com/ali/universaldatetools/MainActivity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ protected void onCreate(Bundle savedInstanceState) {
4141
}
4242
});
4343

44-
4544
lang.setOnClickListener(v -> {
4645
if (getString(R.string.LangId).equals("en")) {
4746
setLocale("fa");

uneversaldatetools/src/main/java/com/ali/uneversaldatetools/date/DateSystem.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class DateSystem implements IDate, Comparable<IDate> {
2424
public DateSystem(Date date, Calendar calendar) {
2525
Calendar = calendar;
2626

27+
if (date.getMonth() == 0) throw new IllegalArgumentException("month cant be 0");
2728
switch (Calendar) {
2829
case Jalali: {
2930
Date_SD = new JalaliDateTime(date);
@@ -48,6 +49,7 @@ public DateSystem(Date date, Calendar calendar) {
4849
public DateSystem(int year, int month, int day, Calendar calendar) {
4950
Calendar = calendar;
5051

52+
if (month == 0) throw new IllegalArgumentException("month cant be 0");
5153
switch (Calendar) {
5254
case Jalali: {
5355
Date_SD = new JalaliDateTime(year, month, day);
@@ -247,10 +249,7 @@ public boolean equals(DateSystem other) {
247249

248250
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
249251
public boolean equals(Object obj) {
250-
if (null == obj) {
251-
return false;
252-
}
253-
return obj instanceof DateSystem && equals((DateSystem) obj);
252+
return null != obj && obj instanceof DateSystem && equals((DateSystem) obj);
254253
}
255254

256255
public int hashCode() {
@@ -260,11 +259,7 @@ public int hashCode() {
260259
@Override
261260
public long getUnixTime() {
262261

263-
GregorianDateTime g = getGregorianDateTime();
264262
long from = DateConverter.GregorianToDays(1970, 1, 1);
265-
long d = g.getDays() - from;
266-
long s = d * 86400;
267-
return s;
263+
return (getGregorianDateTime().getDays() - from) * 86400;
268264
}
269-
270265
}

uneversaldatetools/src/main/java/com/ali/uneversaldatetools/datePicker/UDatePicker.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ private void SetupYearPicker(int selectedYear) {
127127

128128
LinearLayout topbarMonth = findViewById(R.id.linear_top_bar_month);
129129
LinearLayout topbarYear = findViewById(R.id.linear_top_bar_year);
130-
131130
TextView topbarYearText = findViewById(R.id.text_top_bar_year);
132-
133131
TextView topbarMonthTitle = findViewById(R.id.text_top_bar_month_title);
134132
TextView topbarYearTitle = findViewById(R.id.text_top_bar_year_title);
135133
ListView yearListview = findViewById(R.id.list_year_picker);
134+
ImageView arrowLeft = findViewById(R.id.img_calender_arrow_left);
135+
ImageView arrowRight = findViewById(R.id.img_calender_arrow_right);
136136
View yearPickerView = this.getChildAt(1);
137137

138138

@@ -146,8 +146,10 @@ private void SetupYearPicker(int selectedYear) {
146146
topbarMonth.setOnClickListener(v -> {
147147
if (yearPickerView.getVisibility() == View.GONE) return;
148148

149-
topbarMonth.setAlpha(1);
150-
topbarYear.setAlpha((float) 0.6);
149+
arrowLeft.animate().alpha( 1).setDuration(200).start();
150+
arrowRight.animate().alpha(1).setDuration(200).start();
151+
topbarMonth.animate().alpha(1).setDuration(200).start();
152+
topbarYear.animate().alpha((float) 0.6).setDuration(200).start();
151153
postDelayed(() -> yearPickerView.setVisibility(GONE), 300);
152154
yearPickerView.animate().alpha(0).setDuration(300).start();
153155
ExpandAndCollapseAnimation.Collapse(topbarYearTitle);
@@ -169,8 +171,10 @@ private void SetupYearPicker(int selectedYear) {
169171
topbarYear.setOnClickListener(v -> {
170172
if (yearPickerView.getVisibility() == VISIBLE) return;
171173

172-
topbarMonth.setAlpha((float) 0.6);
173-
topbarYear.setAlpha(1);
174+
arrowLeft.animate().alpha((float) 0.6).setDuration(200).start();
175+
arrowRight.animate().alpha((float) 0.6).setDuration(200).start();
176+
topbarMonth.animate().alpha((float) 0.6).setDuration(200).start();
177+
topbarYear.animate().alpha(1).setDuration(200).start();
174178
yearPickerView.setVisibility(VISIBLE);
175179
yearPickerView.animate().alpha(1).setDuration(300).start();
176180
ExpandAndCollapseAnimation.Collapse(topbarMonthTitle);
@@ -219,7 +223,6 @@ public void onScrollStateChanged(AbsListView view, int scrollState) {
219223

220224
if (scrollState == SCROLL_STATE_IDLE) {
221225
yearListview.setSelection(currentSelectedYear - 3);
222-
//yearListview.scrollTo(0, yearListview.getScrollY() + Convert.DpToPixel(22));
223226
}
224227
}
225228

0 commit comments

Comments
 (0)