use of ca.etsmtl.applets.etsmobile.model.Nouvelle in project ETSMobile-Android2 by ApplETS.
the class NewsAdapter method getView.
@SuppressLint("DefaultLocale")
@Override
public View getView(int position, View view, ViewGroup parent) {
ViewHolder holder;
if (view != null) {
holder = (ViewHolder) view.getTag();
} else {
view = inflater.inflate(R.layout.row_news, parent, false);
holder = new ViewHolder();
holder.tvTitre = (TextView) view.findViewById(R.id.tv_row_news_titre);
holder.tvDate = (TextView) view.findViewById(R.id.tv_row_news_date);
holder.imageSource = (ImageView) view.findViewById(R.id.iv_news_image);
view.setTag(holder);
}
Nouvelle item = getItem(position);
String image = item.getUrlPicture();
DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd");
DateTime date = dateTimeFormatter.parseDateTime(item.getDate());
holder.tvDate.setText(date.toString("dd MMM yyyy", Locale.CANADA_FRENCH));
if (!image.equals("")) {
Picasso.with(context).load(image).placeholder(R.drawable.loading_spinner).resize(300, 300).into(holder.imageSource);
}
holder.tvTitre.setText(item.getTitre());
return view;
}
use of ca.etsmtl.applets.etsmobile.model.Nouvelle in project ETSMobile-Android2 by ApplETS.
the class NewsDetailsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_news_details);
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(name);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (savedInstanceState == null) {
Bundle extras = getIntent().getExtras();
if (extras == null) {
return;
}
key = extras.getString("key");
name = extras.getString("name");
type = extras.getString("type");
urlImage = extras.getString("urlImage");
value = extras.getString("value");
toolbar.setTitle(name);
}
listView = (ListView) findViewById(R.id.list_news_details);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Nouvelle item = (Nouvelle) parent.getItemAtPosition(position);
String url = item.getLink();
if (URLUtil.isValidUrl(url)) {
Intent internetIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(internetIntent);
} else {
Toast.makeText(NewsDetailsActivity.this, getString(R.string.erreur_lien), Toast.LENGTH_SHORT).show();
}
}
});
}
Aggregations