Exemple #1
0
  private void updateParseUserId(String parseId) {

    sessionManager = new SessionManager(Setting.this);
    HashMap<String, String> map = new HashMap<String, String>();
    map = sessionManager.getSetting();

    if (map.get("parse_objectid").isEmpty()) {

      sessionManager.setParseObjectId(parseId);
      Log.d("Setting.java class", "Parse objectId updated in Session:" + parseId);
      // parseObjectId class level variable used to send as a parameter in the actionlist
      // here it is updated during the first run
      parseObjectId = parseId;
    }

    Log.d(
        "Setting.class",
        "Map objectId: " + map.get("parse_objectid") + " fetched objectid:" + parseId);
  }
Exemple #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_setting);

    txtSave = (TextView) findViewById(R.id.txt_save);
    eTxtEmailId = (EditText) findViewById(R.id.etxt_gmail);
    eTxtName = (EditText) findViewById(R.id.etxt_name);
    eTxtPassword = (EditText) findViewById(R.id.etxt_password);
    eTxtNumber = (EditText) findViewById(R.id.etxt_number);
    btnAddEvent = (Button) findViewById(R.id.btn_add_event);
    btnViewEvent = (Button) findViewById(R.id.btn_view_action);
    btnContactUs = (Button) findViewById(R.id.btn_contactus);
    spinnerGlobalService = (Spinner) findViewById(R.id.spinner_detail);
    imgBack = (View) findViewById(R.id.img_logo_back);

    // Spinner click listener
    spinnerGlobalService.setOnItemSelectedListener(this);

    // Spinner Drop down elements
    List<String> categories = new ArrayList<String>();
    categories.add("GYM");
    categories.add("EDUCATION");
    categories.add("MOTOR SERVICE");
    categories.add("INSURANCE");
    categories.add("LEGAL");
    categories.add("COMMUNITY");
    categories.add("MEDICAL");
    categories.add("DIAGNOSTIC CENTER");
    categories.add("HOME");
    categories.add("CABLE/INTERNET SERVICE");
    categories.add("OTHER SUBSCRIPTIONS");

    // Creating adapter for spinner
    ArrayAdapter<String> dataAdapter =
        new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories);

    // Drop down layout style - list view with radio button
    dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    // attaching data adapter to spinner
    spinnerGlobalService.setAdapter(dataAdapter);

    db = new DatabaseHandler();
    cd = new ConnectionDetector(getApplicationContext());
    sessionManager = new SessionManager(Setting.this);
    HashMap<String, String> map = new HashMap<String, String>();
    map = sessionManager.getSetting();

    if (!map.get("parse_objectid").isEmpty()) parseObjectId = map.get("parse_objectid");

    // User settings for parse updateUser failure case
    bname = map.get("name"); // bname
    password = map.get("password");
    email = map.get("gmail"); // username &email
    username = map.get("gmail"); // username &email
    mobile = map.get("number"); // mobile
    service = map.get("service"); // service

    String strName = map.get("name");
    String strGmailId = map.get("gmail");
    String strPassword = map.get("password");
    String strService = map.get("service");
    String strNumber = map.get("number");

    if (strGmailId.length() > 0 && strPassword.length() > 0) {
      eTxtName.setText(strName);
      eTxtEmailId.setText(strGmailId);
      eTxtPassword.setText(strPassword);
      eTxtNumber.setText(strNumber);
      spinnerGlobalService.setSelection(getIndex(spinnerGlobalService, strService));
    }

    // initializing new window parameters
    params =
        new WindowManager.LayoutParams(
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.MATCH_PARENT,
            WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
            WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
            PixelFormat.TRANSLUCENT);
    wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    inflaterDialog = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    eTxtName.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            if (eTxtName.getText().toString().trim().length() > 0) {
              eTxtName.setError(null);
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

          }

          @Override
          public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

          }
        });

    eTxtPassword.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            if (eTxtPassword.getText().toString().trim().length() > 0) {
              eTxtPassword.setError(null);
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

          }

          @Override
          public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

          }
        });

    eTxtEmailId.addTextChangedListener(
        new TextWatcher() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
            if (eTxtEmailId.getText().toString().trim().length() > 0) {
              if (android.util.Patterns.EMAIL_ADDRESS
                  .matcher(eTxtEmailId.getText().toString().trim())
                  .matches()) {
                eTxtEmailId.setError(null);
              } else {
                eTxtEmailId.setError("Enter valid EmailID");
              }
            }
          }

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub

          }

          @Override
          public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub

          }
        });

    txtSave.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View arg0) {
            // TODO Auto-generated method stub

            if (setValidation()) {

              // SAVE ON PARSE HERE METHOD IN THE GETOBJECT METHOD CREATE ANOTHER METHOD TO UPDATE
              // THE OBJECTID IN SETTINGS

              new saveSettingsOnParse().execute();

              /*  if (sessionManager.getTimePeriod().equalsIgnoreCase("installed")) {

                                      Log.d("settings.java", "get timeperiod from session manager:" + sessionManager.getTimePeriod());
                                      calendarSetting = (GregorianCalendar) Calendar.getInstance();
              						Intent myIntent = new Intent(Setting.this, UpdatingService.class);
              						pendingIntentSetting = PendingIntent.getService(Setting.this, 0, myIntent, 0);

              						Log.e("Setting", "calender time in milliseconds:" + calendarSetting.getTimeInMillis());


              						alarmManagerSetting = (AlarmManager) getSystemService(ALARM_SERVICE);
              						alarmManagerSetting.set(AlarmManager.RTC, TimeDifference(), pendingIntentSetting);
              						alarmManagerSetting.setRepeating(AlarmManager.RTC, calendarSetting.getTimeInMillis(), 86400000, pendingIntentSetting);
              						Log.e("Setting", "Alaram manager");
              */
              /*
              						//uncomment above code and comment below  Start
              					    Calendar cal = Calendar.getInstance();
              						cal.set(Calendar.SECOND, 0);
              						cal.set(Calendar.HOUR_OF_DAY, 0);
              						cal.set(Calendar.MINUTE, 0);
              						cal.add(Calendar.DAY_OF_MONTH, 1);

              						alarmManagerSetting = (AlarmManager) getSystemService(ALARM_SERVICE);
              						// alarmManagerSetting.set(AlarmManager.RTC, TimeDifference(), pendingIntentSetting);
              						alarmManagerSetting.setRepeating(AlarmManager.RTC, cal.getTimeInMillis(), 86400000, pendingIntentSetting);

              */
              // end

            }
            // else if (sessionManager.getTimePeriod().)

            Intent mainIntent = new Intent(Setting.this, MainActivity.class);
            startActivity(mainIntent);
            finish();
          }
        });

    imgBack.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            Intent closeIntent = new Intent(Setting.this, MainActivity.class);
            startActivity(closeIntent);
            finish();
          }
        });

    btnAddEvent.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View arg0) {
            // TODO Auto-generated method stub
            if (!screenlock)
              // function to invoke system alert
              setAction();
            // block the user click till the action is completed
            screenlock = true;
          }
        });

    btnViewEvent.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub

            // showAction();
            new ParseAction().execute();
          }
        });

    btnContactUs.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            contactUs();
          }
        });
  }