Esempio n. 1
0
 @Override
 protected void onDestroy() {
   if (receiver != null) {
     unregisterReceiver(receiver);
   }
   super.onDestroy();
 }
Esempio n. 2
0
 @Override
 protected void onResume() {
   // BaseActivity.imageLoader.displayImage(BaseActivity.CurrentUser.getProfileImage(),myAvatorImageView,o);
   // nickNameView.setText(BaseActivity.CurrentAccount.getName());
   InitaializeData();
   super.onResume();
 }
Esempio n. 3
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(getLayout());
   InitializeViews();
   o =
       new DisplayImageOptions.Builder()
           .showStubImage(R.drawable.loading)
           .showImageForEmptyUri(R.drawable.widget_dface)
           .cacheInMemory()
           .cacheOnDisc()
           // .displayer(new RoundedBitmapDisplayer(5))
           .build();
   startReceiver();
   InitaializeData();
   // GetUserFollowingBuildings(Integer.valueOf(CurrentAccount.getId()), buildingsHandler);
 }
Esempio n. 4
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(getLayout());
   savePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/21LINJU/Camera/";
   tmpImageFilePath = savePath + "avator" + System.currentTimeMillis() / 1000L + ".jpeg";
   o =
       new DisplayImageOptions.Builder()
           .showStubImage(R.drawable.loading)
           .showImageForEmptyUri(R.drawable.widget_dface)
           .cacheInMemory()
           .cacheOnDisc()
           // .displayer(new RoundedBitmapDisplayer(5))
           .build();
   InitializeViews();
   LocadLocalData();
   GetUserFollowingBuildings(Integer.valueOf(CurrentAccount.getId()), buildingsHandler);
 }
Esempio n. 5
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.v(TAG, "onActivityResult");
    if (resultCode != RESULT_OK) {
      return;
    }

    if (requestCode == 3) {
      Bundle extras = data.getExtras();
      if (extras != null) {
        Bitmap photo = extras.getParcelable("data");
        try {
          ImageUtils.saveImageToSD(tmpImageFilePath, photo, 100);
          Log.v(TAG, tmpImageFilePath + " is saved");
        } catch (IOException e) {
          Log.v(TAG, e.getMessage());
        }

        File newFile = new File(tmpImageFilePath);
        if (newFile.exists()) {
          progressDialog =
              ProgressDialog.show(
                  UserSettingsActivity.this,
                  "",
                  getResources().getText(R.string.save_loading),
                  true,
                  false);
          new Thread() {
            @Override
            public void run() {
              LinJu openLinJu =
                  new LinJu(
                      BaseActivity.CONSUMER_KEY,
                      BaseActivity.CONSUMER_SECRET,
                      UserSettingsActivity.this);
              openLinJu.setAccess_token(UserSettingsActivity.this.getAccessToken());
              String resString = openLinJu.UploadAvator(tmpImageFilePath, null);
              try {
                if (resString != null && !"".equals(resString)) {
                  JSONObject jObject = new JSONObject(resString);
                  String status = jObject.getString("status");
                  Message message = new Message();
                  if (status.equals("ok")) {
                    String newImageUrl = jObject.getString("face_url");
                    message.what = 1;
                    message.obj = newImageUrl;
                  } else {
                    message.what = -1;
                    message.obj = null;
                  }

                  UploadHandler.sendMessage(message);
                }
              } catch (Exception e) {
                // TODO: handle exception
              }
            }
          }.start();
        }
      }
    }
    if (requestCode == 1) {
      String path = data.getStringExtra("image");
      StartCrop(path);
    }
    if (requestCode == 2) {
      nickTextView.setText(CurrentAccount.getName());
    }
    if (requestCode == 4) {
      OpenArea selectedArea = null;
      Bundle cBundle = data.getExtras();
      if (cBundle != null && cBundle.getSerializable("selected") != null) {
        selectedArea = (OpenArea) cBundle.getSerializable("selected");
      }
      int province_id = 0;
      int city_id = 0;
      int district_id = 0;
      String newLocation = "";
      if (selectedArea != null) {
        province_id = selectedArea.getId();
        newLocation = selectedArea.getText();
        Log.v(TAG, selectedArea.getText());
        if (selectedArea.getSelChild() != null) {
          if (province_id == 1 || province_id == 2 || province_id == 9 || province_id == 22) {
            city_id = province_id;
            district_id = selectedArea.getSelChild().getId();
          } else {
            city_id = selectedArea.getSelChild().getId();
          }
          newLocation += " " + selectedArea.getSelChild().getText();
          Log.v(TAG, selectedArea.getSelChild().getText());
          if (selectedArea.getSelChild().getSelChild() != null) {
            district_id = selectedArea.getSelChild().getSelChild().getId();
            newLocation += " " + selectedArea.getSelChild().getSelChild().getText();
            Log.v(TAG, selectedArea.getSelChild().getSelChild().getText());
          }
        }

        locationTextView.setText(newLocation);
        Log.v(TAG, "P:" + province_id);
        Log.v(TAG, "C:" + city_id);
        Log.v(TAG, "D:" + district_id);

        final int p_id = province_id;
        final int c_id = city_id;
        final int d_id = district_id;
        progressDialog =
            ProgressDialog.show(
                UserSettingsActivity.this,
                "",
                getResources().getText(R.string.save_loading),
                true,
                false);
        new Thread() {
          @Override
          public void run() {
            LinJu openLinJu =
                new LinJu(
                    BaseActivity.CONSUMER_KEY,
                    BaseActivity.CONSUMER_SECRET,
                    UserSettingsActivity.this);
            openLinJu.setAccess_token(UserSettingsActivity.this.getAccessToken());
            OpenResponse response = openLinJu.UpdateLocation(CurrentUser.getId(), p_id, c_id, d_id);
            progressDialog.dismiss();
            if (response.IsOK()) {
              CurrentUser = openLinJu.GetUserFullInfo(CurrentUser.getId(), null);
            }
          }
        }.start();
      }
    }
    if (requestCode == 5) {
      final String dateString = data.getStringExtra("date");
      if (dateString == null || dateString.trim().equals("")) {
        return;
      }
      progressDialog =
          ProgressDialog.show(
              UserSettingsActivity.this,
              "",
              getResources().getText(R.string.save_loading),
              true,
              false);
      UserSettingsActivity.this.birthdayTextView.setText(dateString);
      new Thread() {
        @Override
        public void run() {
          LinJu openLinJu =
              new LinJu(
                  BaseActivity.CONSUMER_KEY,
                  BaseActivity.CONSUMER_SECRET,
                  UserSettingsActivity.this);
          openLinJu.setAccess_token(UserSettingsActivity.this.getAccessToken());
          OpenResponse response =
              openLinJu.UpdateBirthday(Integer.valueOf(CurrentAccount.getId()), dateString);
          progressDialog.dismiss();
          if (response.IsOK()) {
            CurrentUser = openLinJu.GetUserFullInfo(CurrentUser.getId(), null);
          }
        }
      }.start();
    }
    if (requestCode == 6) {
      finish();
    }
    super.onActivityResult(requestCode, resultCode, data);
  }
Esempio n. 6
0
 @Override
 protected void onResume() {
   LocadLocalData();
   super.onResume();
 }