Search in sources :

Example 1 with AboutListEntity

use of com.github.obsessive.simplifyreader.bean.AboutListEntity in project SimplifyReader by chentao0707.

the class AboutUsActivity method initViewsAndEvents.

@Override
protected void initViewsAndEvents() {
    mAboutArray = getResources().getStringArray(R.array.about_list);
    mListViewDataAdapter = new ListViewDataAdapter<>(new ViewHolderCreator<AboutListEntity>() {

        @Override
        public ViewHolderBase<AboutListEntity> createViewHolder(int position) {
            return new ViewHolderBase<AboutListEntity>() {

                TextView mTitle;

                TextView mSubTitle;

                @Override
                public View createView(LayoutInflater layoutInflater) {
                    View convertView = layoutInflater.inflate(R.layout.list_item_about, null);
                    mTitle = ButterKnife.findById(convertView, R.id.list_item_about_title);
                    mSubTitle = ButterKnife.findById(convertView, R.id.list_item_about_sub_title);
                    return convertView;
                }

                @Override
                public void showData(int position, AboutListEntity itemData) {
                    if (null != itemData) {
                        if (!CommonUtils.isEmpty(itemData.getTitle())) {
                            mTitle.setText(itemData.getTitle());
                        }
                        if (!CommonUtils.isEmpty(itemData.getSubTitle())) {
                            mSubTitle.setText(itemData.getSubTitle());
                        }
                    }
                }
            };
        }
    });
    mListView.setAdapter(mListViewDataAdapter);
    mItemData = new AboutListEntity();
    mItemData.setTitle(mAboutArray[0]);
    try {
        PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_ACTIVITIES);
        String version = String.format(getResources().getString(R.string.splash_version), packageInfo.versionName);
        if (!CommonUtils.isEmpty(version)) {
            mItemData.setSubTitle(version);
        }
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    mListViewDataAdapter.getDataList().add(mItemData);
    mItemData = new AboutListEntity();
    mItemData.setTitle(mAboutArray[1]);
    mItemData.setSubTitle("https://github.com/SkillCollege");
    mListViewDataAdapter.getDataList().add(mItemData);
    mItemData = new AboutListEntity();
    mItemData.setTitle(mAboutArray[2]);
    mItemData.setSubTitle("https://github.com/SkillCollege/SimplifyReader");
    mListViewDataAdapter.getDataList().add(mItemData);
    mItemData = new AboutListEntity();
    mItemData.setTitle(mAboutArray[3]);
    mListViewDataAdapter.getDataList().add(mItemData);
    mItemData = new AboutListEntity();
    mItemData.setTitle(mAboutArray[4]);
    mListViewDataAdapter.getDataList().add(mItemData);
    mListViewDataAdapter.notifyDataSetChanged();
    mPayCode.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            DecodeUtils decodeUtils = new DecodeUtils(DecodeUtils.DECODE_DATA_MODE_ALL);
            String url = decodeUtils.decodeWithZxing(BitmapFactory.decodeResource(getResources(), R.drawable.pay_qrcode));
            if (!CommonUtils.isEmpty(url)) {
                TLog.d(TAG_LOG, url);
                intent.setData(Uri.parse(url));
            }
            startActivity(intent);
        }
    });
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Bundle extras = new Bundle();
            switch(position) {
                case 0:
                    // version
                    break;
                case 1:
                    // author
                    extras.putString(BaseWebActivity.BUNDLE_KEY_TITLE, mAboutArray[1]);
                    extras.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, true);
                    extras.putString(BaseWebActivity.BUNDLE_KEY_URL, "https://github.com/SkillCollege");
                    readyGo(BaseWebActivity.class, extras);
                    break;
                case 2:
                    // project index
                    extras.putString(BaseWebActivity.BUNDLE_KEY_TITLE, mAboutArray[2]);
                    extras.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, true);
                    extras.putString(BaseWebActivity.BUNDLE_KEY_URL, "https://github.com/SkillCollege/SimplifyReader");
                    readyGo(BaseWebActivity.class, extras);
                    break;
                case 3:
                    // project description
                    extras.putString(BaseWebActivity.BUNDLE_KEY_TITLE, mAboutArray[3]);
                    extras.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, false);
                    extras.putString(BaseWebActivity.BUNDLE_KEY_URL, "file:///android_asset/project_description.html");
                    readyGo(BaseWebActivity.class, extras);
                    break;
                case 4:
                    // open source description
                    extras.putString(BaseWebActivity.BUNDLE_KEY_TITLE, mAboutArray[4]);
                    extras.putBoolean(BaseWebActivity.BUNDLE_KEY_SHOW_BOTTOM_BAR, false);
                    extras.putString(BaseWebActivity.BUNDLE_KEY_URL, "file:///android_asset/open_source.html");
                    readyGo(BaseWebActivity.class, extras);
                    break;
            }
        }
    });
}
Also used : ViewHolderBase(com.github.obsessive.library.adapter.ViewHolderBase) PackageInfo(android.content.pm.PackageInfo) Bundle(android.os.Bundle) Intent(android.content.Intent) BaseWebActivity(com.github.obsessive.library.base.BaseWebActivity) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AboutListEntity(com.github.obsessive.simplifyreader.bean.AboutListEntity) PackageManager(android.content.pm.PackageManager) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) AdapterView(android.widget.AdapterView) ViewHolderCreator(com.github.obsessive.library.adapter.ViewHolderCreator) DecodeUtils(com.github.obsessive.simplifyreader.ui.activity.qrcode.decode.DecodeUtils)

Aggregations

Intent (android.content.Intent)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 Bundle (android.os.Bundle)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 InjectView (butterknife.InjectView)1 ViewHolderBase (com.github.obsessive.library.adapter.ViewHolderBase)1 ViewHolderCreator (com.github.obsessive.library.adapter.ViewHolderCreator)1 BaseWebActivity (com.github.obsessive.library.base.BaseWebActivity)1 AboutListEntity (com.github.obsessive.simplifyreader.bean.AboutListEntity)1 DecodeUtils (com.github.obsessive.simplifyreader.ui.activity.qrcode.decode.DecodeUtils)1