worning.java 1.8 KB
package com.lotus.town.notify;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.lotus.town.R;
import com.lotus.town.utils.NotificationUtils;

/**
 * 内存警告
 */
public abstract class worning extends Activity implements View.OnClickListener {

    protected ImageView mWorningImage = null;
    protected TextView mWoringText = null;
    protected TextView mSelfWork = null;
    protected TextView mAutoWork = null;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        NotificationUtils.clearNotification(this);
        setContentView(R.layout.worning_notify_layout);
        setFinishOnTouchOutside(false);

        initView();
        initInfo();
    }

    private void initView() {
        mWorningImage = findViewById(R.id.worning_icon);
        mWoringText = findViewById(R.id.worning_text);
        mSelfWork = findViewById(R.id.self_work);
        mAutoWork = findViewById(R.id.auto_work);

        mSelfWork.setOnClickListener(this);
        mAutoWork.setOnClickListener(this);
    }

    protected abstract void initInfo();



    @Override
    public void onBackPressed() {
        gotoWork();
    }

    @Override
    public void onClick(View v) {
        gotoWork();
    }

    private void gotoWork(){
        Intent i = new Intent();
        i.setClass(this,getDestActivity());
        if(!TextUtils.isEmpty(deliver())){
            i.putExtra("deliver",deliver());
        }
        startActivity(i);
        finish();
    }

    public abstract Class getDestActivity();
    public String deliver(){
        return "";
    };
}