框架整理系列七(StartActivity)

StartActivity.java

import android.content.Context;
import android.content.Intent;

/**
 * 作者:周洲 on 2017/3/22 11:23
 * 

* 邮箱:[email protected] */ public class StartActivity { private Context context; private Class cls; private Intent intent; public StartActivity(Builder builder){ this.context = builder.context; this.cls = builder.cls; this.intent =builder.intent; context.startActivity(intent); } public static class Builder{ private Context context; private Class cls; private Intent intent; public Builder(Context cxt,Class cls){ this.context = cxt; this.cls = cls; intent = new Intent(this.context,this.cls); } public Builder addValue(String key,String value){ intent.putExtra(key,value); return this; } public Builder addValue(String key,int value){ intent.putExtra(key,value); return this; } public Builder setFlags(int flags){ intent.setFlags(flags); return this; } public StartActivity build(){ return new StartActivity(this); } } }

你可能感兴趣的:(框架整理系列七(StartActivity))