All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.androidannotations.api.builder.IntentBuilder Maven / Gradle / Ivy

There is a newer version: 4.8.0
Show newest version
/**
 * Copyright (C) 2010-2016 eBusiness Information, Excilys Group
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed To in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.androidannotations.api.builder;

import java.io.Serializable;
import java.util.ArrayList;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;

@SuppressWarnings("unchecked")
public abstract class IntentBuilder> extends Builder {

	protected final Context context;
	protected final Intent intent;

	public IntentBuilder(Context context, Class clazz) {
		this(context, new Intent(context, clazz));
	}

	public IntentBuilder(Context context, Intent intent) {
		this.context = context;
		this.intent = intent;
	}

	public Context getContext() {
		return context;
	}

	public Intent get() {
		return intent;
	}

	public I flags(int flags) {
		intent.setFlags(flags);
		return (I) this;
	}

	public I action(String action) {
		intent.setAction(action);
		return (I) this;
	}

	public I type(String type) {
		intent.setType(type);
		return (I) this;
	}

	public I category(String category) {
		intent.addCategory(category);
		return (I) this;
	}

	public I data(Uri data) {
		intent.setData(data);
		return (I) this;
	}

	public I extra(String name, boolean value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, byte value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, char value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, short value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, int value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, long value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, float value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, double value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, String value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, CharSequence value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, Parcelable value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, Parcelable[] value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I parcelableArrayListExtra(String name, ArrayList value) {
		intent.putParcelableArrayListExtra(name, value);
		return (I) this;
	}

	public I integerArrayListExtra(String name, ArrayList value) {
		intent.putIntegerArrayListExtra(name, value);
		return (I) this;
	}

	public I stringArrayListExtra(String name, ArrayList value) {
		intent.putStringArrayListExtra(name, value);
		return (I) this;
	}

	public I extra(String name, Serializable value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, boolean[] value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, byte[] value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, short[] value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, char[] value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, int[] value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, long[] value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, float[] value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, double[] value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, String[] value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extra(String name, Bundle value) {
		intent.putExtra(name, value);
		return (I) this;
	}

	public I extras(Intent src) {
		intent.putExtras(src);
		return (I) this;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy