Hi, I'm trying to use this library in my APP, but I think it returns null instead of the time, The code below is how I used it in my fragment:
public class PrayerFragment extends Fragment {
Date fajr;
Date sunrise;
Date zuhr;
Date maghrib;
Date isha;
public PrayerFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_prayer, container, false);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
GregorianCalendar date = new GregorianCalendar();
PrayerTimes prayerTimes = new TimeCalculator().date(date).location(-6.38043079,106.85337984, 0,7).timeCalculationMethod(EGYPT).calculateTimes();
prayerTimes.setUseSecond(true);
fajr = prayerTimes.getPrayTime(PrayersType.FAJR);
sunrise = prayerTimes.getPrayTime(PrayersType.SUNRISE);
zuhr = prayerTimes.getPrayTime(PrayersType.ZUHR);
maghrib = prayerTimes.getPrayTime(PrayersType.MAGHRIB);
isha = prayerTimes.getPrayTime(PrayersType.ISHA);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (fajr != null) {
TextView textView = (TextView) getView().findViewById(R.id.fajr);
textView.setText((CharSequence) fajr);
}else{
Toast.makeText(getContext().getApplicationContext(), "LOL", Toast.LENGTH_LONG).show();
}
}
}