package com.sdk.example;

import org.json.JSONObject;

import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.text.SpannableString;
import android.text.Spanned;
import android.util.Log;
import android.widget.TextView;

import com.sdk.util.Parser;
import com.wole56.sdk.Video;

/**
 * 获取推荐视频,支持分页
 * 
 * @author susie
 * 
 */
public class GetRecommendVideo extends Activity {

	private static final String TAG = "GetRecommendVideo";
	private TextView resultTxtV;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.video_recommend);

		// init ui
		resultTxtV = (TextView) findViewById(R.id.recommend_result_txt);

		String cid = "1";// 频道
		String num = "5";// 每页数量
		String page = "1";// 第几页

		JSONObject result = Video.getRecommendVideo(getApplicationContext(),
				cid, num, page);
		Log.i(TAG, "recommend result" + result);

		// 数据简单解析与呈现
		String parseStr = Parser.simpleParser(result);

		// 富文本形式展现
		Spanned span = Html.fromHtml(parseStr);
		SpannableString spanStr = new SpannableString(span);
		// show result
		resultTxtV.setText(spanStr);
	}
}
