Ejemplo n.º 1
0
  protected void buildMultiPic(final GridLayout gridLayout) {
    gridLayout.setVisibility(View.VISIBLE);
    // 获取当前屏幕尺寸
    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    windowManager.getDefaultDisplay().getMetrics(metrics);
    // 设置图片的宽度和高度
    int picWidth = metrics.widthPixels / 3 - 48;

    for (int i = 0; i < 9; i++) {
      // 获取View
      SimpleDraweeView simpleDraweeView = (SimpleDraweeView) gridLayout.getChildAt(i);
      // 设置布局参数
      GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
      layoutParams.width = picWidth;
      layoutParams.height = picWidth;
      layoutParams.setMargins(8, 8, 8, 8);
      simpleDraweeView.setLayoutParams(layoutParams);
      // 设置图片数据源
      simpleDraweeView.setImageURI(Uri.parse(Image.imageThumbUrls[i]));
      // 准备传递数据
      final ImageViewPageMessage imageViewPageMessage =
          new ImageViewPageMessage(Image.imageThumbUrls, i);
      simpleDraweeView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              EventBus.getDefault().postSticky(imageViewPageMessage);
              Intent intent = new Intent(mContext, ImageViewPagerActivity.class);
              mContext.startActivity(intent);
            }
          });
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(com.polarion.starter.R.layout.activity_agenda_details);

    // setup the Toolbar
    mToolbar = (Toolbar) findViewById(com.polarion.starter.R.id.toolbar);
    if (mToolbar != null) {
      mToolbar.setTitle("Session Details");
      setSupportActionBar(mToolbar);
    }
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // get the selected Agenda Item stored in Application
    StarterApplication myApp = (StarterApplication) getApplication();
    mItem = myApp.getSelectedAgendaItem();
    TextView sessionTime = (TextView) findViewById(com.polarion.starter.R.id.sessionTime);
    sessionTime.setText(mItem.getDisplayTime());
    TextView descriptionView =
        (TextView) findViewById(com.polarion.starter.R.id.sessionDescription);
    descriptionView.setText(mItem.getDescription());
    TextView sessionName = (TextView) findViewById(com.polarion.starter.R.id.sessionName);
    sessionName.setText(mItem.getSessionName());
    TextView speakerView = (TextView) findViewById(com.polarion.starter.R.id.presenter);
    speakerView.setText(mItem.getSpeaker());
    final RatingBar contentBar = (RatingBar) findViewById(com.polarion.starter.R.id.contentBarGrid);
    final RatingBar presenterBar =
        (RatingBar) findViewById(com.polarion.starter.R.id.presenterBarGrid);
    mRateButton = (Button) findViewById(com.polarion.starter.R.id.rateButton);
    mRateButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            ParseObject sessionRating = new ParseObject("SessionRating");
            float contentRating = contentBar.getRating(),
                presenterRating = presenterBar.getRating();
            sessionRating.put("contentRating", contentRating);
            sessionRating.put("presenterRating", presenterRating);
            if (ParseUser.getCurrentUser() != null)
              sessionRating.put("user", ParseUser.getCurrentUser());
            sessionRating.put("session", mItem);
            sessionRating.saveEventually();
            finish(); // when done rating close the Agenda Details
          }
        });
    Boolean isRateable = mItem.isRateable();
    if (!isRateable) {
      mRateButton.setVisibility(View.INVISIBLE);
      mRatingLayout = (GridLayout) findViewById(com.polarion.starter.R.id.ratingGridLayout);
      mRatingLayout.setVisibility(View.INVISIBLE);
    }
  }