package de.dhbwloe.campusapp;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.util.Calendar;
+import java.util.Date;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
return decrypted;
}
+ public static void removeAllChildViews(ViewGroup viewGroup) {
+ for (int i = 0; i < viewGroup.getChildCount(); i++) {
+ View child = viewGroup.getChildAt(i);
+ if (child instanceof ViewGroup) {
+ if (child instanceof AdapterView) {
+ viewGroup.removeView(child);
+ return;
+ }
+ removeAllChildViews(((ViewGroup) child));
+ } else {
+ viewGroup.removeView(child);
+ }
+ }
+ }
+
+ public static String getWeekdayString(long date) {
+ return getWeekdayString(date, true);
+ }
+
+ public static String getWeekdayString(long date, boolean fullString) {
+ return getWeekdayString(new Date(date * 1000), fullString);
+ }
+
+ public static String getWeekdayString(Date date) {
+ return getWeekdayString(date, true);
+ }
+
+ public static String getWeekdayString(Date date, boolean fullString) {
+ int weekdayResIds[];
+ if(fullString)
+ weekdayResIds = new int[] { R.string.week_sunday, R.string.week_monday, R.string.week_tuesday, R.string.week_wednesday, R.string.week_thursday, R.string.week_friday, R.string.week_saturday };
+ else
+ weekdayResIds = new int[] { R.string.week_sunday_short, R.string.week_monday_short, R.string.week_tuesday_short, R.string.week_wednesday_short, R.string.week_thursday_short, R.string.week_friday_short, R.string.week_saturday_short };
+ Calendar cal = Calendar.getInstance();
+ cal.setTime(date);
+ int dow = cal.get(Calendar.DAY_OF_WEEK);
+ int weekdayResId = weekdayResIds[dow-1];
+ return CampusAppContext.getInstance().getResString(weekdayResId);
+ }
+
}