Skip to content

Commit

Permalink
1.crash problem on widget fixed
Browse files Browse the repository at this point in the history
2.day Classes sort problem fixed
3.events sort fixed (add week number) but not tested
  • Loading branch information
ali77gh committed Nov 24, 2018
1 parent c32be64 commit 49bc0ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
public class DateTimeTools {

public static int getCurrentDayOfWeek() {
return new Date().getDay() + 1;
int res= new Date().getDay() + 1;
if (res==7) res =0;
return res ;
}

/**
Expand Down
20 changes: 9 additions & 11 deletions app/src/main/java/com/github/ali77gh/unitools/core/tools/Sort.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ public static void SortClass(List<UClass> classes) {

//todo find better way to add two lists
classes.clear();
for (UClass u : past)
classes.add(u);
for (UClass u : pre)
classes.add(u);
classes.addAll(past);
classes.addAll(pre);
}

public static void SortFriend(List<Friend> friends) {
Expand Down Expand Up @@ -84,15 +82,15 @@ private static void ExchangeSortClass(List<UClass> uClasses) {
}
}

private static void ExchangeSortEvent(List<Event> uClasses) {
private static void ExchangeSortEvent(List<Event> events) {
int i, j;
Event temp;
for (i = 0; i < uClasses.size() - 1; i++) {
for (j = i + 1; j < uClasses.size(); j++) {
if (uClasses.get(i).time.getMins() > uClasses.get(j).time.getMins()) {
temp = uClasses.get(i);
uClasses.set(i, uClasses.get(j));
uClasses.set(j, temp);
for (i = 0; i < events.size() - 1; i++) {
for (j = i + 1; j < events.size(); j++) {
if (events.get(i).WeekNumber > events.get(j).WeekNumber | events.get(i).time.getMins() > events.get(j).time.getMins()) {
temp = events.get(i);
events.set(i, events.get(j));
events.set(j, temp);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class ShowNextClassWidget extends AppWidgetProvider {

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
ContextHolder.initStatics(context);
SetupLang(context);

final int count = appWidgetIds.length;
Expand Down
13 changes: 7 additions & 6 deletions app/src/main/res/layout/widget_show_next_class.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_darker">

android:background="@color/background_darker"
android:alpha=".7">
<TextView
android:id="@+id/tv_widget_next_class"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="کلاس بعدی فلان"
android:textColor="@color/white"
android:background="@color/background_darker"
android:layout_margin="20dp"/>
</LinearLayout>
android:layout_margin="20dp"
android:layout_gravity="center"
android:gravity="center"/>
</FrameLayout>

0 comments on commit 49bc0ba

Please sign in to comment.