dxh 5 ans auparavant
Parent
commit
13ffd37a15

+ 29 - 1
app/src/main/java/com/electric/chargingpile/activity/PublishTopicActivity.java

@ -2,17 +2,20 @@ package com.electric.chargingpile.activity;
2 2

3 3
import android.app.Activity;
4 4
import android.content.Context;
5
import android.content.DialogInterface;
5 6
import android.content.Intent;
6 7
import android.graphics.drawable.Drawable;
7 8
import android.net.Uri;
8 9
import android.os.Bundle;
9 10
import android.os.Environment;
10 11
import android.support.annotation.Nullable;
12
import android.support.v7.app.AlertDialog;
11 13
import android.text.Editable;
12 14
import android.text.Html;
13 15
import android.text.TextUtils;
14 16
import android.text.TextWatcher;
15 17
import android.util.Log;
18
import android.view.KeyEvent;
16 19
import android.view.View;
17 20
import android.view.View.OnClickListener;
18 21
import android.widget.EditText;
@ -139,7 +142,8 @@ public class PublishTopicActivity extends Activity implements OnClickListener {
139 142
    public void onClick(View v) {
140 143
        switch (v.getId()) {
141 144
            case R.id.publishtopic_back:
142
                finish();
145
                showDialogToExit();
146
//                finish();
143 147
                break;
144 148
            case R.id.publishtopic_publish:
145 149
                if (media == null) {
@ -381,4 +385,28 @@ public class PublishTopicActivity extends Activity implements OnClickListener {
381 385
        super.onPause();
382 386
        MobclickAgent.onPause(this);
383 387
    }
388

389
    private void showDialogToExit(){
390
        AlertDialog.Builder builder = new AlertDialog.Builder(PublishTopicActivity.this);
391
        builder.setTitle("提示");
392
        builder.setMessage("确认取消发布?");
393
        builder.setCancelable(false);
394
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
395
            @Override
396
            public void onClick(DialogInterface dialog, int which) {
397
                finish();
398
            }
399
        });
400
        builder.setNegativeButton("取消", null);
401
        builder.create().show();
402
    }
403

404
    @Override
405
    public boolean onKeyUp(int keyCode, KeyEvent event) {
406
        if (keyCode == KeyEvent.KEYCODE_BACK) {
407
            showDialogToExit();
408
            return true;
409
        }
410
        return false;
411
    }
384 412
}