// ** Called when the activity is first created. *//* @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); // 隐藏标题 getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // 设置全屏 nameHeaderUrlList = new ArrayList<NameHeaderUrlPair>(); if (apiKey == null || apiSecret == null) { Util.showAlert(this, "警告", "人人应用的apiKey和apiSecret必须提供!"); } setContentView(R.layout.main); ratingBar = (RatingBar) findViewById(R.id.levelBar); ratingBar.setMax(6); ratingBar.setNumStars(3); ratingBar.setStepSize((float) 0.5); ratingBar.setRating((float) 1.5); initialRenRen(); /*Spinner s = (Spinner) findViewById(R.id.friendNumerSpin); String []friendNumber=new String[]{"好友人数:10","好友人数:20","好友人数:50","所有好友"}; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, friendNumber); s.setAdapter(adapter);*/ }
/** * 发布一条状态到人人网 * * @param status 要发布的状态对象 * @return 若状态为空或者发送失败,会抛出异常,否则返回成功 {@link FeedPublishResponseBean}对象 * @throws RenrenException * @throws Throwable */ public StatusSetResponseBean publish(StatusSetRequestParam status) throws RenrenException, Throwable { if (!renren.isSessionKeyValid()) { String errorMsg = "Session key is not valid."; throw new RenrenException(RenrenError.ERROR_CODE_TOKEN_ERROR, errorMsg, errorMsg); } // 参数不能为空 if (status == null) { String errorMsg = "The parameter is null."; throw new RenrenException(RenrenError.ERROR_CODE_NULL_PARAMETER, errorMsg, errorMsg); } // 发布状态 String response; try { Bundle params = status.getParams(); response = renren.requestJSON(params); } catch (RenrenException rre) { Util.logger(rre.getMessage()); throw rre; } catch (RuntimeException re) { Util.logger(re.getMessage()); throw new Throwable(re); } RenrenError rrError = Util.parseRenrenError(response, Renren.RESPONSE_FORMAT_JSON); if (rrError != null) { throw new RenrenException(rrError); } else { try { JSONObject json = new JSONObject(response); if (json.optInt("result") == 1) { return new StatusSetResponseBean(response); } else { String errorMsg = "Cannot parse the response."; throw new RenrenException( RenrenError.ERROR_CODE_UNABLE_PARSE_RESPONSE, errorMsg, errorMsg); } } catch (JSONException je) { Util.logger(je.getMessage()); throw new RenrenException( RenrenError.ERROR_CODE_UNABLE_PARSE_RESPONSE, je.getMessage(), je.getMessage()); } } } // end of public Status publish(Activity activity, Status status,
@Override public void onHttpError(int errorCode, String description, String failingUrl) { super.onHttpError(errorCode, description, failingUrl); Util.showAlert( example, "Feed HttpError 提示", "HttpError errorCode: " + errorCode + " errorMsg:" + description + " failurl:" + failingUrl); }
@Override public void onCreate(Bundle savedInstanceState) { // 隐藏标题栏 requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(savedInstanceState); // 使用父类的renren对象 if (renren == null) { // renren对象获取失败,无法执行创建相册的操作,直接退出本Activity Util.logger("renren object is null, can't create album!"); showTip("无法创建相册,请稍后重试!"); finish(); } renren.init(this); // 权限验证,如果用户已经登录并且权限满足,则初始化界面,否则结束Activity AuthorizationHelper.check( renren, CreateAlbumActivity.this, new String[] {PhotoHelper.CREATE_ALBUM_PERMISSION}, new RenrenAuthListener() { @Override public void onRenrenAuthError(RenrenAuthError renrenAuthError) { finish(); } @Override public void onComplete(Bundle values) { initComponents(); } @Override public void onCancelLogin() { finish(); } @Override public void onCancelAuth(Bundle values) { finish(); } }); }
@Override public void onRenrenError(RenrenError renrenError) { super.onRenrenError(renrenError); Util.showAlert(example, "Feed RenrenError 提示", "RenrenError:" + renrenError); }
@Override public void onCancel(Bundle values) { super.onCancel(values); Util.showAlert(example, "Feed Cancel 提示", "用户放弃发新鲜事"); }
@Override public void onComplete(Bundle values) { super.onComplete(values); Util.showAlert(example, "Feed Complete 提示", "发新鲜事完成"); }