public void setAlaramTime(String timeStrInput, String configNamazSPKey, int configNamazPI) { if (timeStrInput != null) { String[] timeStr = timeStrInput.split(":"); int hours = Integer.parseInt(timeStr[0]); int minute = Integer.parseInt(timeStr[1]); RingBellManager.INSTANCE.sheduleRingBell( namaz.this, hours, minute, configNamazSPKey, configNamazPI); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.namaz); RingBellManager.INSTANCE.init( namaz.this, new RingBellManager.RingBellStateListener() { @Override public void onDissmiss() {} @Override public void onActivate() {} }); dateTv = (TextView) findViewById(R.id.dateTv); fajarTv = (TextView) findViewById(R.id.fajarTv); zuharTv = (TextView) findViewById(R.id.zuharTv); AsarTv = (TextView) findViewById(R.id.AsarTv); magribTv = (TextView) findViewById(R.id.magribTv); IshaTv = (TextView) findViewById(R.id.IshaTv); final int FOR_HOURS = 3600000; final int FOR_MIN = 60000; /* Retrieve a PendingIntent that will perform a broadcast */ // Intent alarmIntent = new Intent(namaz.this, Alarm.class); // pendingIntent = PendingIntent.getBroadcast(namaz.this, 0, alarmIntent, 0); ((ImageButton) findViewById(R.id.ring)) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // setAlaramTime(fajar, Config.FAJAR_SP, Config.FAJAR_PI); // startAt10(); } }); ((ImageButton) findViewById(R.id.ringzohar)) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // startAlaram(); // RingBellManager.INSTANCE.sheduleRingBell(namaz.this,12,55,Config.ZUHAR_SP,Config.ZUHAR_PI); setAlaramTime(Zohar, Config.ZUHAR_SP, Config.ZUHAR_PI); // startAt10(); } }); ((ImageButton) findViewById(R.id.ringasar)) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // startAlaram(); // RingBellManager.INSTANCE.sheduleRingBell(namaz.this, // 3,28,Config.ASAR_SP,Config.ASAR_PI); setAlaramTime(Asar, Config.ASAR_SP, Config.ASAR_PI); // startAt10(); } }); ((ImageButton) findViewById(R.id.ringmagrib)) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // startAlaram(); // RingBellManager.INSTANCE.sheduleRingBell(namaz.this, // 4,45,Config.MAGRIB_SP,Config.MAGRIB_PI); setAlaramTime(Magrib, Config.MAGRIB_SP, Config.MAGRIB_PI); // startAt10(); } }); ((ImageButton) findViewById(R.id.ringisha)) .setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // startAlaram(); // RingBellManager.INSTANCE.sheduleRingBell(namaz.this, // 8,28,Config.ISHA_SP,Config.ISHA_PI); setAlaramTime(Isha, Config.ISHA_SP, Config.ISHA_PI); // startAt10(); } }); ///// webApiAsynTask = new WebApiAsynTask( namaz.this, true, locationUrl, null, new JSONResponseCallback() { @Override public void onCompleteResponse(JSONObject jsonResponse) { city = jsonResponse.optString("city"); country = jsonResponse.optString("country"); countryCode = jsonResponse.optString("countryCode"); lat = jsonResponse.optDouble("lat"); lng = jsonResponse.optDouble("lon"); int gmtOffset = (TimeZone.getDefault().getRawOffset()) / (1000 * 60); // Toast.makeText(namaz.this, "GMT Value in // minutes==>"+gmtOffset, Toast.LENGTH_SHORT).show(); // Log.e("GMT Value in minutes==>","GMT Value in // minutes==>"+gmtOffset); Calendar calendar = Calendar.getInstance(); SimpleDateFormat Sdf = new SimpleDateFormat("yyyy-MM-dd"); // SimpleDateFormat Sdf = new SimpleDateFormat("dd-MM-yyyy"); String currentDate = Sdf.format(calendar.getTime()); dateTv.setText("Date " + currentDate); Date date = new Date(); String dateStrFormatted = Sdf.format(date); String dateString[] = dateStrFormatted.split("-"); String year = dateString[0]; String month = dateString[1]; final String dayName = dateString[2]; final String prayerTimeUrl = "http://praytime.info/getprayertimes.php?lat=" + lat + "&lon=" + lng + "&gmt=" + gmtOffset + "&m=" + month + "&y=" + year; // http://praytime.info/getprayertimes.php?lat=31.488800&lon=74.368599&gmt=300&m=9&y=2015&school=0 prayersAsyncTask = new WebApiAsynTask( namaz.this, true, prayerTimeUrl, null, new JSONResponseCallback() { @Override public void onCompleteResponse(JSONObject result) { // Now write parser to parse json result of prayers. JSONObject prayerTimeObj = result.optJSONObject("" + dayName); fajar = prayerTimeObj.optString("Fajr"); Zohar = prayerTimeObj.optString("Dhuhr"); Asar = prayerTimeObj.optString("Asr"); Magrib = prayerTimeObj.optString("Maghrib"); Isha = prayerTimeObj.optString("Isha"); Sunrise = prayerTimeObj.optString("Sunrise"); Sunset = prayerTimeObj.optString("Sunset"); // Toast.makeText(namaz.this, "" + // prayerTimeObj.toString(), Toast.LENGTH_LONG).show(); fajarTv.setText("Fajar" + convertTimeToAmPm(fajar)); zuharTv.setText("Zohar" + convertTimeToAmPm(Zohar)); AsarTv.setText("Asar" + convertTimeToAmPm(Asar)); magribTv.setText("Magrib" + convertTimeToAmPm(Magrib)); IshaTv.setText("Isha" + convertTimeToAmPm(Isha)); } }); prayersAsyncTask.execute(); // } }); webApiAsynTask.execute(); ////// }