コード例 #1
0
ファイル: TaskSelect.java プロジェクト: subahur/Errand-Helper
 // handles events when options menu is clicked
 private boolean MenuChoice(MenuItem item) {
   switch (item.getItemId()) {
     case 0: // if add is pressed
       session.logoutUser();
       return true;
     default:
       return false;
   }
 }
コード例 #2
0
  @Get
  public Representation getUserAccount() {
    String authhoken = getCookies().getValues(Cookies.AUTH_TOKEN);

    if (StringUtils.isNotBlank(authhoken)) {
      UserSession session = sessions.get(UUID.fromString(authhoken));
      if (!Objects.equal(session, UserSession.EMPTY)) {
        getResponse().setStatus(org.restlet.data.Status.SUCCESS_OK);
        return new JsonRepresentation(session.getUser());
      }
    }

    getResponse().setStatus(org.restlet.data.Status.CLIENT_ERROR_FORBIDDEN);
    return new StringRepresentation("");
  }
コード例 #3
0
ファイル: TaskSelect.java プロジェクト: subahur/Errand-Helper
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_task_select);

    session = new UserSessionManager(getApplicationContext());
    HashMap<String, String> user = session.getUserInfo();
    String email = user.get(UserSessionManager.KEY_EMAIL);

    ListView ls = (ListView) findViewById(R.id.lv_tasks);
    String[] from =
        new String[] {
          "name",
          "description",
          "type",
          "creation_time",
          "creator_email",
          "due_time",
          "creator_phone",
          "price"
        };
    int[] to =
        new int[] {
          R.id.tv_task_name,
          R.id.tv_task_description,
          R.id.tv_task_type,
          R.id.tv_created_time,
          R.id.tv_task_creator,
          R.id.tv_due_date,
          R.id.tv_phone_number,
          R.id.tv_price_select
        };
    cursorAdapter =
        new TaskSelectCursorAdapter(
            this,
            R.layout.task_select_entry,
            helper.otherTaskCursor(email),
            from,
            to,
            CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER,
            helper,
            email);

    ls.setAdapter(cursorAdapter);
  }
コード例 #4
0
  public void Updatefbotp() {
    Mobile = Usermobile.getText().toString();
    otp = Faceotp.getText().toString();
    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("firstName", Fname));
    nameValuePairs.add(new BasicNameValuePair("lastName", Lname));
    nameValuePairs.add(new BasicNameValuePair("email", Email));
    nameValuePairs.add(new BasicNameValuePair("mobile", Mobile));
    try {
      String Facebookmobile = "" + Url + "/faceSignUp/?";
      // String Facebookmobile = "http://jaidevcoolcab.cabsaas.in/sandbox/index/faceSignUp/?";
      // String APIKEY="S2AORU-KOXBNK-161JB3-S5HFAV-CI5O47";
      //  String APIKEY = "PVU1ZE-ZE4TPC-5IXWAJ-P2E6ZE-QONPEC-4IUGWD";
      String uri =
          Uri.parse(Facebookmobile)
              .buildUpon()
              .appendQueryParameter("firstName", Fname)
              .appendQueryParameter("lastName", Lname)
              .appendQueryParameter("email", Email)
              .appendQueryParameter("mobile", Mobile)
              .appendQueryParameter("token", token)
              .appendQueryParameter("otp", otp)
              .appendQueryParameter("ApiKey", APIKEY)
              .appendQueryParameter("UserID", "1212")
              .appendQueryParameter("UserIPAddress", IPAddress)
              .appendQueryParameter("UserAgent", "androidApp")
              .appendQueryParameter("responsetype", "2")
              .build()
              .toString();

      HttpClient httpclient = new DefaultHttpClient();
      HttpPost httppost = new HttpPost(uri);
      Log.i("uri", uri);
      httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
      ResponseHandler<String> responseHandler = new BasicResponseHandler();
      final String response = httpclient.execute(httppost, responseHandler);
      //   Toast.makeText(this, "" + response, Toast.LENGTH_LONG).show();
      Log.i("response", "" + response);

      runOnUiThread(
          new Runnable() {
            public void run() {
              dialog.dismiss();
            }
          });

      /*  JSONArray json = new JSONArray(response);
      Log.i("json",""+json);
      JSONObject jsonObject = json.getJSONObject(0);
      final String LoginStatus =jsonObject.getString(Tag_Sign);
      Log.i("LoginStatus", LoginStatus);*/

      final String Str = "1";
      JSONArray json = new JSONArray(response);
      Log.i("json", "" + json);
      JSONObject jsonObject = json.getJSONObject(0);
      String str = "4";
      final String LoginStatus = jsonObject.getString(Tag_Subuserid);
      Log.i("LoginStatus", LoginStatus);

      if (LoginStatus.compareTo(str) == 0) {
        Log.i("str", str);
        session.createUserLoginSession(Email, token);
        uId = jsonObject.getString(Tag_uid);
        Cashwalletbalance = jsonObject.getInt(TagprefernceBalance);
        Useremail = jsonObject.getString(Tagemail);
        mobile = jsonObject.getString(Tagmobile);
        fname = jsonObject.getString(Tagname);
        //  fname = jsonObject.getString(Tagname);
        lname = jsonObject.getString(TagLname);
        Log.i("fname", fname);
        editor = sharedpreferences.edit();
        editor.putString(Email, Useremail);
        editor.putString(Tag_uid, uId);
        editor.putString(Tagname, fname);
        editor.putString(TagLname, lname);
        editor.putInt(TagprefernceBalance, Cashwalletbalance);
        editor.putString(Tagemail, Useremail);
        editor.putString(Tagmobile, mobile);
        editor.apply();
      }

      runOnUiThread(
          new Runnable() {
            @Override
            public void run() {

              if (LoginStatus.equals("4")) {
                AlertDialog.Builder alertDialog = new AlertDialog.Builder(MobileActivity.this);
                alertDialog.setTitle("Confirmed");
                //  alertDialog.setMessage("Please Check your Mail For Login ");
                alertDialog.setPositiveButton(
                    "ok",
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        // Resetlayout.setVisibility(View.VISIBLE);

                        Intent in = new Intent(MobileActivity.this, BaseNavigation.class);
                        startActivity(in);
                        finish();
                      }
                    });
                alertDialog.show();
              } else {
                AlertDialog.Builder alertDialog = new AlertDialog.Builder(MobileActivity.this);
                alertDialog.setTitle("Invalid");
                alertDialog.setMessage("Invalid OTP");
                //   alertDialog.setIcon(R.drawable.fail);
                alertDialog.setPositiveButton(
                    "ok",
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {}
                    });
                alertDialog.show();
              }
            }
          });
    } catch (Exception e) {
      Log.e("Fail 1", e.toString());
      //  Toast.makeText(getApplicationContext(), "Invalid IP Address", Toast.LENGTH_LONG).show();
    }
  }
コード例 #5
0
ファイル: MainActivity.java プロジェクト: AliAliyev/BlueBus
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    session = new UserSessionManager(getApplicationContext());
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle =
        new ActionBarDrawerToggle(
            this,
            drawer,
            toolbar,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    View header = navigationView.getHeaderView(0);
    TextView text = (TextView) header.findViewById(R.id.user);

    if (session.isUserLoggedIn())
      text.setText(session.getUserDetails().get(UserSessionManager.KEY_EMAIL));
    ImageView image = (ImageView) header.findViewById(R.id.imageView);
    TextView textUser = (TextView) header.findViewById(R.id.user);
    if (session.isUserLoggedIn()) {
      navigationView.getMenu().clear();
      navigationView.inflateMenu(R.menu.activity_main_drawer);
      image.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              startActivity(new Intent(getApplicationContext(), UserProfile.class));
              drawer.closeDrawer(GravityCompat.START);
            }
          });
      textUser.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              startActivity(new Intent(getApplicationContext(), UserProfile.class));
              drawer.closeDrawer(GravityCompat.START);
            }
          });
    } else {
      navigationView.getMenu().clear();
      navigationView.inflateMenu(R.menu.activity_log_drawer);
    }

    ImageButton search = (ImageButton) findViewById(R.id.search);
    search.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            startActivity(new Intent(getApplicationContext(), Search.class));
          }
        });
    ImageButton add = (ImageButton) findViewById(R.id.add);
    add.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            startActivity(new Intent(getApplicationContext(), Add.class));
          }
        });

    // if(session.checkLogin())
    //   finish();

  }