Skip to content

Commit 3acc81e

Browse files
committed
Fixed all issues pertaining to Alarm setting and ringing, only weather info left
1 parent dce8a4b commit 3acc81e

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

app/src/main/java/com/walarm/wuasta/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ private void selectFrag(MenuItem item){
9090
}
9191
}
9292

93-
public void createAlarm(int df,int hour,int minute){
93+
public void createAlarm(int df, int hour, int minute){
9494

9595
Calendar calendar = Calendar.getInstance();
9696
calendar.setTimeInMillis(System.currentTimeMillis());
97-
//insert
9897
calendar.set(Calendar.HOUR_OF_DAY,hour);
9998
calendar.set(Calendar.MINUTE,minute);
10099
calendar.set(Calendar.SECOND,0);
100+
calendar.add(Calendar.DATE,df);
101101

102102
Intent intent = new Intent(this, AlarmReceiver.class);
103103
pendingIntent = PendingIntent.getBroadcast(this, 10, intent, 0);

app/src/main/java/com/walarm/wuasta/wuastaFragment.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class wuastaFragment extends Fragment implements View.OnClickListener {
3535
Toast toast;
3636
int dayfactor;
3737
long departureepoch;
38-
Integer tempfd;
38+
Integer tempfd=null;
3939

4040
@Nullable
4141
@Override
@@ -280,18 +280,11 @@ public void onClick(View view) {
280280

281281
case R.id.setalarmbutton:
282282

283-
int df = sp.getInt("dayfactor",1);
283+
int df = sp.getInt("dayfactor",0);
284284
int hur = sp.getInt("phour",0);
285285
int mun = sp.getInt("pminute",0);
286286

287-
long currentepoch = System.currentTimeMillis();
288-
long currentepochdate = (currentepoch+5*60*60*1000+30*60*1000) - (currentepoch+5*60*60*1000+30*60*1000)%86400000;
289-
long timeofalarm = currentepochdate + (sp.getInt("phour",0))*60*60*1000
290-
+ (sp.getInt("pminute",0))*60*1000 + df*86400000;
291-
292-
if(df==0) {
293-
((MainActivity) getActivity()).createAlarm(df, hur, mun);
294-
}
287+
((MainActivity) getActivity()).createAlarm(df, hur, mun);
295288

296289
if(toast != null) toast.cancel();
297290
toast = Toast.makeText(getActivity(), "Alarm Set", Toast.LENGTH_LONG);
@@ -371,6 +364,8 @@ protected Integer doInBackground(URL... params) {
371364

372365
}
373366

367+
if(getTempfd() != null) sd = getTempfd();
368+
374369
int settimeepoch = hr*60 + mn - fd - sharedPref1.getInt("delay",0);
375370

376371
hr = settimeepoch >= 60 ? settimeepoch/60 : 0;

0 commit comments

Comments
 (0)