Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.27 KB | None | 0 0
  1. double lat=0;
  2. double lng=0;
  3. double fajr;
  4. double sunrise;
  5. double dhuhr;
  6. double sunset;
  7. double maghrib;
  8. double midnight;
  9. boolean one=false;
  10. boolean one1=false;
  11.  
  12.  
  13. @Override
  14. protected void onCreate(Bundle savedInstanceState) {
  15. super.onCreate(savedInstanceState);
  16. setContentView(R.layout.show_time);
  17.  
  18.  
  19.  
  20.  
  21. final LocationManager locationManager;
  22. String context = Context.LOCATION_SERVICE;
  23. locationManager = (LocationManager)getSystemService(context);
  24.  
  25. final String provider = LocationManager.GPS_PROVIDER;
  26. final Location location =
  27. locationManager.getLastKnownLocation(provider);
  28.  
  29. final String provider2 = LocationManager.NETWORK_PROVIDER;
  30. final Location location2 =
  31. locationManager.getLastKnownLocation(provider2);
  32.  
  33.  
  34.  
  35. Intent in= getIntent();
  36. Integer data2 =in.getIntExtra("key2", 0);
  37.  
  38.  
  39. TextView fajr_time=(TextView) findViewById(R.id.textView9);
  40. TextView sunrise_time=(TextView) findViewById(R.id.textView10);
  41. TextView dhuhr_time=(TextView) findViewById(R.id.textView11);
  42. TextView sunset_time=(TextView) findViewById(R.id.textView13);
  43. TextView maghrib_time=(TextView) findViewById(R.id.textView14);
  44. TextView midnight_time=(TextView) findViewById(R.id.textView16);
  45.  
  46. String[] latitude=getResources().getStringArray(R.array.Latitude);
  47. String[] longetude=getResources().getStringArray(R.array.Longtude);
  48. lat=Float.valueOf(latitude[data2]);
  49. lng=Float.valueOf(longetude[data2]);
  50.  
  51. Time today = new Time(Time.getCurrentTimezone());
  52. today.setToNow();
  53. int year=today.year;
  54. int month=today.month+1;
  55. int day=today.monthDay;
  56.  
  57.  
  58. final pray_time pt=new pray_time() ;
  59. int JD=pt.julianDate(year, month, day);
  60. pt.pray_time(JD);
  61.  
  62.  
  63.  
  64.  
  65. dhuhr=12+3.50-(lng/15)-pt.get_Eqt();
  66. sunrise=dhuhr-pt.cal_time(0.833f,lat);
  67. sunset=dhuhr+pt.cal_time(0.833f,lat);
  68. fajr=dhuhr-pt.cal_time(17.7f,lat);
  69. maghrib=dhuhr+pt.cal_time(4f,lat);
  70. midnight=(sunset+fajr)/2+12;
  71.  
  72.  
  73. fajr_time.setText(pt.floatToTime24(fajr));
  74. sunrise_time.setText(pt.floatToTime24(sunrise));
  75. dhuhr_time.setText(pt.floatToTime24(dhuhr));
  76. sunset_time.setText(pt.floatToTime24(sunset));
  77. maghrib_time.setText(pt.floatToTime24(maghrib));
  78. midnight_time.setText(pt.floatToTime24(midnight));
  79.  
  80. Button show_gheble =(Button) findViewById(R.id.button1);
  81. show_gheble.setOnClickListener(new OnClickListener() {
  82.  
  83. @Override
  84. public void onClick(View arg0) {
  85. // TODO Auto-generated method stub
  86. Intent intent1 = new Intent(ShowTimeActivity.this,Show_gheble.class);
  87.  
  88. if(!one)
  89. {
  90. if (locationManager.isProviderEnabled(provider))
  91. {
  92. startActivity(intent1);
  93. }
  94. else
  95. {
  96. showSettingsAlert("GPS");
  97. }
  98. one=true;
  99. }
  100. else if(!one1)
  101. {
  102. if(locationManager.isProviderEnabled(provider2))
  103. {
  104. startActivity(intent1);
  105. }
  106. else
  107. {
  108. showSettingsAlert("NETWORK");
  109. }
  110. one1=true;
  111. }
  112. else {
  113. startActivity(intent1);
  114. }
  115.  
  116. }
  117. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement