/*
* Copyright (C) 2013 YIXIA.COM
*
* 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 io.vov.vitamio.demo;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import io.vov.vitamio.Vitamio;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.umeng.analytics.MobclickAgent;
/**
* List
*/
public class VitamioListActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Vitamio.isInitialized(getApplicationContext());
setListAdapter(new SimpleAdapter(this, getData(), android.R.layout.simple_list_item_1, new String[] { "title" }, new int[] { android.R.id.text1 }));
}
protected List<Map<String, Object>> getData() {
List<Map<String, Object>> myData = new ArrayList<Map<String, Object>>();
addItem(myData, "MediaPlayer", new Intent(this, MediaPlayerDemo.class));
addItem(myData, "VideoView", new Intent(this, VideoViewDemo.class));
addItem(myData, "MediaMetadata", new Intent(this, MediaMetadataRetrieverDemo.class));
addItem(myData, "VideoSubtitle", new Intent(this, VideoSubtitleList.class));
addItem(myData, "VideoViewBuffer", new Intent(this, VideoViewBuffer.class));
return myData;
}
protected void addItem(List<Map<String, Object>> data, String name, Intent intent) {
Map<String, Object> temp = new HashMap<String, Object>();
temp.put("title", name);
temp.put("intent", intent);
data.add(temp);
}
@SuppressWarnings("unchecked")
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
Map<String, Object> map = (Map<String, Object>) l.getItemAtPosition(position);
Intent intent = (Intent) map.get("intent");
startActivity(intent);
}
@Override
protected void onResume() {
MobclickAgent.onResume(this);
super.onResume();
}
@Override
protected void onPause() {
MobclickAgent.onPause(this);
super.onPause();
}
}