Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void dailyCheckin(final ProgressDialog pDialog) {
- //first getting the values
- final String reg_user_id=String.valueOf(SharedPref.getInstance(getApplicationContext()).getUserID());
- //Call our volley library
- StringRequest stringRequest = new StringRequest(Request.Method.POST, Constant.DAILYCHECKIN,
- new Response.Listener<String>() {
- @Override
- public void onResponse(String response) {
- try {
- JSONObject obj = new JSONObject(response);
- if (obj.getBoolean("error")) {
- pDialog.hide();
- Toast.makeText(getApplicationContext(),
- getString(R.string.newdailyreward)
- +" "+obj.getString("hours")+" "+
- getString(R.string.hours)
- +" "+obj.getString("minutes")+" "+
- getString(R.string.minutes), Toast.LENGTH_SHORT).show();
- } else {
- pDialog.hide();
- Toast.makeText(getApplicationContext(),
- getString(R.string.rewardsuccess)
- +" "+obj.getString("message")+" "+
- getString(R.string.rewardpoints)
- , Toast.LENGTH_SHORT).show();
- }
- } catch (JSONException e) {
- pDialog.hide();
- e.printStackTrace();
- }
- }
- },
- new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- pDialog.hide();
- error.printStackTrace();
- }
- }) {
- @Override
- protected Map<String, String> getParams() throws AuthFailureError {
- Map<String, String> params = new HashMap<>();
- params.put("user_id", reg_user_id);
- return params;
- }
- };
- VolleySingleton.getInstance(FreePointsActivity.this).addToRequestQueue(stringRequest);
- }//dailyCheckin
- elseif (isset($_GET['dailycheckin'])) {
- $id=intval($_POST['user_id']);
- $daily="Daily Checkin";
- $sql='select * from rewardpoints_points where user_id='.$id.' AND app_name="'.$daily.'" ORDER BY date_operation DESC;';
- $res=$cnx->query($sql);
- $data=$res->fetchAll(PDO::FETCH_OBJ)[0];
- if (empty($data)) {
- $s='select daily_chekin_points from rewardpoints_settings';
- $r=$cnx->query($s);
- $d=$r->fetchAll(PDO::FETCH_OBJ)[0];
- $points=$d->daily_chekin_points;
- $sql="insert into rewardpoints_points values(NULL,'".$id."',0,'".$daily."','".$points."',NOW(),0)";
- if($cnx->exec($sql)){
- $response['error'] = false;
- $response['message'] = $points;
- }
- }
- else{
- $newreward= strtotime( $data->date_operation ) + 24 * 3600;
- if ($newreward<=time()) {
- //echo "you can get";
- $s='select daily_chekin_points from rewardpoints_settings';
- $r=$cnx->query($s);
- $d=$r->fetchAll(PDO::FETCH_OBJ)[0];
- $points=$d->daily_chekin_points;
- $sql="insert into rewardpoints_points values(NULL,'".$id."',0,'".$daily."','".$points."',NOW(),0)";
- if($cnx->exec($sql)){
- $response['error'] = false;
- $response['message'] = $points;
- }
- }//$newreward<=time()
- else{
- //echo "you can not";
- $response['error'] = true;
- $time=time()-$newreward;
- $m = floor($time / 60)*-1;
- $hours = floor($m / 60);
- $minutes = ($m % 60);
- $response['hours'] = $hours;
- $response['minutes'] = $minutes;
- }
- }
- }//dailycheckin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement