// Path: app/src/main/java/com/liying/ipgw/activity/RecommendActivity.java
// public class RecommendActivity extends BaseActivity {
//     private static WeakReference<RecommendActivity> recommendActivity;
// 
//     // 图标数组
//     private static int[] icons = {R.mipmap.xdp_512x512, R.mipmap.sec_512x512, R.mipmap.circle_512x512};
//     // 软件名称数组
//     private static int[] name = {R.string.recommend_name_xdp, R.string.recommend_name_sec, R.string.recommend_name_circle};
//     // 软件描述数组
//     private static int[] desc = {R.string.recommend_desc_xdp, R.string.recommend_desc_sec, R.string.recommend_desc_circle};
//     // 软件包名
//     public static String[] packageName = {"lxy.liying.hdtvneu", "lxy.liying.secbook", "lxy.liying.circletodo"};
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_recommend);
//         AccountApp.activityList.add(this);
//         TextView tvBack = (TextView) findViewById(R.id.tvBack);
//         tvBack.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 finish();
//             }
//         });
//         ListView lvRecommend = (ListView) findViewById(R.id.lvRecommend);
//         RecommendListAdapter adapter = new RecommendListAdapter(this, icons, name, desc);
//         lvRecommend.setAdapter(adapter);
// 
//         recommendActivity = new WeakReference<RecommendActivity>(this);
//     }
// 
//     /**
//      * 获取本Activity的实例
//      * @return
//      */
//     public static RecommendActivity getInstance() {
//         return recommendActivity.get();
//     }
// 
//     /**
//      * 跳到应用商店的下载页面
//      * @param packageName 应用的包名
//      */
//     public void goToDownload(String packageName) {
//         Uri uri = Uri.parse("market://details?id=" + packageName);
//         Intent intent = new Intent(Intent.ACTION_VIEW, uri);
//         ComponentName componentName = intent.resolveActivity(getPackageManager());
//         if (componentName != null) {
//             startActivity(intent);
//         } else {
//             AppToast.showToast("您没有安装应用市场类软件，无法打开应用详情页面。");
//         }
//     }
// 
//     @Override
//     protected void onDestroy() {
//         super.onDestroy();
//         AccountApp.activityList.remove(this);
//     }
// }


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.liying.ipgw.R;
import com.liying.ipgw.activity.RecommendActivity;


    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ListItemView listItemView = null;
        if (convertView == null){
            listItemView = new ListItemView();
            //获取list_item布局文件的视图
            convertView = listContainer.inflate(R.layout.item_recommend, null);
            listItemView.ivRecommendIcon = (ImageView) convertView.findViewById(R.id.ivRecommendIcon);
            listItemView.tvRecommendName = (TextView) convertView.findViewById(R.id.tvRecommendName);
            listItemView.tvRecommendDesc = (TextView) convertView.findViewById(R.id.tvRecommendDesc);
            listItemView.btnDownload = (Button) convertView.findViewById(R.id.btnDownload);

            //设置控件集到convertView
            convertView.setTag(listItemView);
        } else {
            listItemView = (ListItemView)convertView.getTag();
        }

        listItemView.ivRecommendIcon.setImageResource(icons[position]);
        listItemView.tvRecommendName.setText(name[position]);
        listItemView.tvRecommendDesc.setText(desc[position]);
        listItemView.btnDownload.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

// Path: app/src/main/java/com/liying/ipgw/activity/RecommendActivity.java
// public class RecommendActivity extends BaseActivity {
//     private static WeakReference<RecommendActivity> recommendActivity;
// 
//     // 图标数组
//     private static int[] icons = {R.mipmap.xdp_512x512, R.mipmap.sec_512x512, R.mipmap.circle_512x512};
//     // 软件名称数组
//     private static int[] name = {R.string.recommend_name_xdp, R.string.recommend_name_sec, R.string.recommend_name_circle};
//     // 软件描述数组
//     private static int[] desc = {R.string.recommend_desc_xdp, R.string.recommend_desc_sec, R.string.recommend_desc_circle};
//     // 软件包名
//     public static String[] packageName = {"lxy.liying.hdtvneu", "lxy.liying.secbook", "lxy.liying.circletodo"};
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_recommend);
//         AccountApp.activityList.add(this);
//         TextView tvBack = (TextView) findViewById(R.id.tvBack);
//         tvBack.setOnClickListener(new View.OnClickListener() {
//             @Override
//             public void onClick(View v) {
//                 finish();
//             }
//         });
//         ListView lvRecommend = (ListView) findViewById(R.id.lvRecommend);
//         RecommendListAdapter adapter = new RecommendListAdapter(this, icons, name, desc);
//         lvRecommend.setAdapter(adapter);
// 
//         recommendActivity = new WeakReference<RecommendActivity>(this);
//     }
// 
//     /**
//      * 获取本Activity的实例
//      * @return
//      */
//     public static RecommendActivity getInstance() {
//         return recommendActivity.get();
//     }
// 
//     /**
//      * 跳到应用商店的下载页面
//      * @param packageName 应用的包名
//      */
//     public void goToDownload(String packageName) {
//         Uri uri = Uri.parse("market://details?id=" + packageName);
//         Intent intent = new Intent(Intent.ACTION_VIEW, uri);
//         ComponentName componentName = intent.resolveActivity(getPackageManager());
//         if (componentName != null) {
//             startActivity(intent);
//         } else {
//             AppToast.showToast("您没有安装应用市场类软件，无法打开应用详情页面。");
//         }
//     }
// 
//     @Override
//     protected void onDestroy() {
//         super.onDestroy();
//         AccountApp.activityList.remove(this);
//     }
// }


// Path: app/src/main/java/com/liying/ipgw/adapter/RecommendListAdapter.java
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.liying.ipgw.R;
import com.liying.ipgw.activity.RecommendActivity;


    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ListItemView listItemView = null;
        if (convertView == null){
            listItemView = new ListItemView();
            //获取list_item布局文件的视图
            convertView = listContainer.inflate(R.layout.item_recommend, null);
            listItemView.ivRecommendIcon = (ImageView) convertView.findViewById(R.id.ivRecommendIcon);
            listItemView.tvRecommendName = (TextView) convertView.findViewById(R.id.tvRecommendName);
            listItemView.tvRecommendDesc = (TextView) convertView.findViewById(R.id.tvRecommendDesc);
            listItemView.btnDownload = (Button) convertView.findViewById(R.id.btnDownload);

            //设置控件集到convertView
            convertView.setTag(listItemView);
        } else {
            listItemView = (ListItemView)convertView.getTag();
        }

        listItemView.ivRecommendIcon.setImageResource(icons[position]);
        listItemView.tvRecommendName.setText(name[position]);
        listItemView.tvRecommendDesc.setText(desc[position]);
        listItemView.btnDownload.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                RecommendActivity activity = RecommendActivity.getInstance();
