Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.os.Bundle;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static <T extends Serializable> List<T> getArguments(Bundle bundle, String tag, Class<T> clazz) {
        List<T> result = new ArrayList<T>();
        if (bundle != null) {
            T item;
            int i = 0;
            while ((item = getArgument(bundle, String.format("%s%s", tag, i), clazz)) != null) {
                result.add(item);
                i++;
            }
        }
        return result;
    }

    @SuppressWarnings("unchecked")
    public static <T extends Serializable> T getArgument(Bundle bundle, String key, Class<T> clazz) {
        if (bundle != null)
            return (T) bundle.getSerializable(key);
        return null;
    }
}