Exemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_question);
    MobclickAgent.onEvent(this, Mob.Event_Open_Question);
    loadingView = (LoadingView) findViewById(R.id.question_progress_loading);
    loadingView.setReloadListener(this);
    progressBar = (ProgressBar) findViewById(R.id.question_loading);
    Toolbar toolbar = (Toolbar) findViewById(R.id.action_bar);
    setSupportActionBar(toolbar);
    toolbar.setOnClickListener(
        new View.OnClickListener() {

          boolean preparingToScrollToHead = false;

          @Override
          public void onClick(View v) {
            if (preparingToScrollToHead) {
              listView.setSelection(0);
            } else {
              preparingToScrollToHead = true;
              new Handler()
                  .postDelayed(
                      new Runnable() {
                        @Override
                        public void run() {
                          preparingToScrollToHead = false;
                        }
                      },
                      200);
            }
          }
        });
    View headView = findViewById(R.id.head_view);
    question = (Question) getIntent().getSerializableExtra(Consts.Extra_Question);
    notice_id = getIntent().getStringExtra(Consts.Extra_Notice_Id);
    listView = (LListView) findViewById(R.id.list_detail);
    adapter = new QuestionDetailAdapter(this);
    listView.setAdapter(adapter);

    listView.setCanPullToLoadMore(false);
    listView.setOnRefreshListener(this);
    listView.setOnItemClickListener(onItemClickListener);

    floatingActionsMenu = (FloatingActionsMenu) findViewById(R.id.layout_operation);
    FloatingActionButton replyButton = (FloatingActionButton) findViewById(R.id.button_reply);
    FloatingActionButton recomButton = (FloatingActionButton) findViewById(R.id.button_recommend);
    FloatingActionButton favorButton = (FloatingActionButton) findViewById(R.id.button_favor);

    replyButton.setOnClickListener(this);
    recomButton.setOnClickListener(this);
    favorButton.setOnClickListener(this);

    AutoHideUtil.applyListViewAutoHide(
        this,
        listView,
        headView,
        floatingActionsMenu,
        (int) getResources().getDimension(R.dimen.abc_action_bar_default_height_material));
    floatingActionsMenu.setVisibility(View.GONE);
    loadData(-1);
  }
Exemplo n.º 2
0
 private void cancelPotentialTask() {
   if (task != null && task.getStatus() == AAsyncTask.Status.RUNNING) {
     task.cancel(true);
     listView.doneOperation();
   }
 }