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;
}
}
});
}
Aggregations