List of usage examples for android.view View setTag
public void setTag(final Object tag)
From source file:com.limewoodmedia.nsdroid.fragments.OfficersFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { root = inflater.inflate(R.layout.officers, null, false); list = (ListView) root.findViewById(R.id.officers_list); officers = new ArrayList<Officer>(); officersComparator = new OfficersComparator(); listAdapter = new ArrayAdapter<Officer>(context, 0, officers) { @Override/* w ww . ja va2 s . c o m*/ public View getView(int position, View convertView, ViewGroup parent) { View view; TextView name, office, authority; Officer officer; if (convertView == null) { view = inflater.inflate(R.layout.officer, null); } else { view = convertView; } name = (TextView) view.findViewById(R.id.officer_name); name.setMovementMethod(LinkMovementMethod.getInstance()); office = (TextView) view.findViewById(R.id.officer_office); authority = (TextView) view.findViewById(R.id.officer_authority); officer = getItem(position); // Name String oName = TagParser.idToName(officer.nation); name.setText(Html.fromHtml(oName)); // Office office.setText(officer.office); // Authority StringBuilder sb = new StringBuilder(); int i = 0; for (Officer.Authority auth : officer.authority) { sb.append(auth.name); if (i + 1 < officer.authority.size()) { sb.append(", "); } i++; } authority.setText(sb.toString()); view.setTag(officer); view.setOnClickListener(OfficersFragment.this); name.setOnClickListener(OfficersFragment.this); office.setOnClickListener(OfficersFragment.this); return view; } }; list.setAdapter(listAdapter); return root; }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageAdapter.java
@Override public View newView(Context context, Cursor cursor, ViewGroup parent) { System.out.println("MessageAdapter.java in newView() "); View view = super.newView(context, cursor, parent); MessageListItemViews tagView = new MessageListItemViews(); tagView.containterBlock = (LinearLayout) view.findViewById(R.id.message_block); tagView.imagefile = (ImageView) view.findViewById(R.id.iv_recievedfile); tagView.contentView = (TextView) view.findViewById(R.id.text_view); tagView.errorView = (TextView) view.findViewById(R.id.error_view); tagView.dateView = (TextView) view.findViewById(R.id.date_view); tagView.quickContactView = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo); tagView.deliveredIndicator = (ImageView) view.findViewById(R.id.delivered_indicator); view.setTag(tagView); return view;//from ww w. j av a 2 s . c o m }
From source file:com.sentaroh.android.TaskAutomation.ActivityTaskStatus.java
@Override final public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder;/*from www . ja v a 2 s . com*/ View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(id, null); holder = new ViewHolder(); holder.tv_active_state = (TextView) v.findViewById(R.id.task_status_list_item_active_state); holder.tv_grp = (TextView) v.findViewById(R.id.task_status_list_item_grp); holder.tv_task = (TextView) v.findViewById(R.id.task_status_list_item_task); holder.btn_cancel = (Button) v.findViewById(R.id.task_status_list_item_cancel_btn); holder.config = v.getResources().getConfiguration(); v.setTag(holder); } else { holder = (ViewHolder) v.getTag(); } final TaskStatusActiveTaskListItem o = getItem(position); if (o != null) { if (o.task_name.startsWith("No")) { holder.tv_task.setText("No active tasks"); holder.tv_active_state.setVisibility(TextView.GONE); holder.tv_grp.setVisibility(TextView.GONE); holder.btn_cancel.setVisibility(Button.GONE); } else { holder.tv_active_state.setText(o.task_active_state.substring(0, 1)); holder.tv_active_state.setVisibility(TextView.VISIBLE); holder.tv_grp.setText(o.profile_grp); holder.tv_task.setText(o.task_name); holder.tv_grp.setVisibility(TextView.VISIBLE); holder.btn_cancel.setVisibility(Button.VISIBLE); } final int p = position; holder.btn_cancel.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (ntfy_listener != null) ntfy_listener.notifyToListener(true, new Object[] { o.profile_grp, o.task_name }); remove(p); if (items.size() == 0) { TaskStatusActiveTaskListItem atl = new TaskStatusActiveTaskListItem(); atl.task_name = "No tasks"; items.add(atl); } notifyDataSetChanged(); } }); } return v; }
From source file:com.charon.video.view.ScrollingTabs.java
/** * Add tab view./* www . j av a2 s. c om*/ */ private void initTabView() { int totalWidth = 0; if (mViewPager != null && mTabAdapter != null) { mContainer.removeAllViews(); if (mEqualWidth) { for (int i = 0; i < mViewPager.getAdapter().getCount(); i++) { View tab = mTabAdapter.getView(i); totalWidth += tab.getWidth(); if (tab.getLayoutParams() != null) { // int width = tab.getLayoutParams().width; // int height = tab.getLayoutParams().height; } else { tab.setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 100f)); } if (mTabAdapter.getSeparator() != null && i != mViewPager.getAdapter().getCount() - 1) { isUseSeperator = true; totalWidth += mTabAdapter.getSeparator().getWidth(); } } if (totalWidth < mWindowWidth) { int count = mViewPager.getAdapter().getCount(); if (isUseSeperator) { tabWidth = (mWindowWidth - (count - 1) * mTabAdapter.getSeparator().getWidth()) / count; } else { tabWidth = mWindowWidth / count; } } } for (int i = 0; i < mViewPager.getAdapter().getCount(); i++) { final View tab = mTabAdapter.getView(i); tab.setTag(i); if (tabWidth != 0) { mContainer.addView(tab, new LinearLayout.LayoutParams(tabWidth, android.widget.LinearLayout.LayoutParams.MATCH_PARENT)); } else { mContainer.addView(tab, new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 100f)); } // Segmentation view if (mTabAdapter.getSeparator() != null && i != mViewPager.getAdapter().getCount() - 1) { isUseSeperator = true; mContainer.addView(mTabAdapter.getSeparator()); } // Set click listener on tab. tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { int index = (Integer) tab.getTag(); if (mTabClickListener != null) { mTabClickListener.onClick(index); } else { if (mViewPager.getCurrentItem() == index) { selectTab(index); } else { // If ViewPager change the page, the listener // will call selectTab method mViewPager.setCurrentItem(index, true); } } } }); } // Set the current selected tab when first coming. selectTab(mViewPager.getCurrentItem()); } }
From source file:io.coldstart.android.TrapDetailListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { Trap trap = listOfTraps.get(position); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.trap_detail_list_item, null); String TrapDetails = ""; /*try/* w w w . ja v a 2 s .c o m*/ { JSONArray TrapJSON = new JSONArray(trap.trap); int trapsCount = TrapJSON.length(); for(int i = 0; i < trapsCount; i++) { String tmpPayload = TrapJSON.getString(i); if(!tmpPayload.equals("")) { TrapDetails += tmpPayload + "\n\n"; } } } catch (JSONException e) { TrapDetails = "Trap details failed to parse"; } ((TextView) convertView.findViewById(R.id.TrapDetail)).setText(TrapDetails);*/ String trapDescription = ""; try { trapDescription = trap.getPayloadAsString(); } catch (Exception e) { trapDescription = "Unable to decode trap"; } ((TextView) convertView.findViewById(R.id.TrapDetail)).setText(trapDescription); ((TextView) convertView.findViewById(R.id.TrapDate)) .setTypeface(Typeface.createFromAsset((context).getAssets(), "fonts/MavenPro-Regular.ttf")); ((TextView) convertView.findViewById(R.id.TrapDate)).setText(trap.date); if (trapOnClick != null) { convertView.setTag(position); convertView.setOnClickListener((OnClickListener) trapOnClick); } return convertView; }
From source file:cm.aptoide.ptdev.ScheduledDownloadsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { Aptoide.getThemePicker().setAptoideTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.page_sch_downloads); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(true); getSupportActionBar().setTitle(getString(R.string.setting_schdwntitle)); lv = (ListView) findViewById(android.R.id.list); lv.setDivider(null);//from w w w . j a va 2 s . c o m db = new Database(Aptoide.getDb()); bindService(new Intent(this, DownloadService.class), conn, Context.BIND_AUTO_CREATE); adapter = new CursorAdapter(this, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER) { @Override public View newView(Context context, Cursor arg1, ViewGroup arg2) { return LayoutInflater.from(context).inflate(R.layout.row_sch_download, null); } @Override public void bindView(View convertView, Context arg1, Cursor c) { // Planet to display ScheduledDownload scheduledDownload = scheduledDownloadsHashMap .get(c.getLong(c.getColumnIndex("_id"))); // The child views in each row. CheckBox checkBoxScheduled; TextView textViewName; TextView textViewVersion; ImageView imageViewIcon; // Create a new row view if (convertView.getTag() == null) { // Find the child views. textViewName = (TextView) convertView.findViewById(R.id.name); textViewVersion = (TextView) convertView.findViewById(R.id.appversion); checkBoxScheduled = (CheckBox) convertView.findViewById(R.id.schDwnChkBox); imageViewIcon = (ImageView) convertView.findViewById(R.id.appicon); // Optimization: Tag the row with it's child views, so we don't have to // call findViewById() later when we reuse the row. convertView.setTag(new Holder(textViewName, textViewVersion, checkBoxScheduled, imageViewIcon)); // If CheckBox is toggled, update the planet it is tagged with. checkBoxScheduled.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CheckBox cb = (CheckBox) v; ScheduledDownload schDownload = (ScheduledDownload) cb.getTag(); schDownload.setChecked(cb.isChecked()); } }); } // Reuse existing row view else { // Because we use a ViewHolder, we avoid having to call findViewById(). Holder viewHolder = (Holder) convertView.getTag(); checkBoxScheduled = viewHolder.checkBoxScheduled; textViewVersion = viewHolder.textViewVersion; textViewName = viewHolder.textViewName; imageViewIcon = viewHolder.imageViewIcon; } // Tag the CheckBox with the Planet it is displaying, so that we can // access the planet in onClick() when the CheckBox is toggled. checkBoxScheduled.setTag(scheduledDownload); // Display planet data checkBoxScheduled.setChecked(scheduledDownload.isChecked()); textViewName.setText(scheduledDownload.getName()); textViewVersion.setText(scheduledDownload.getVername()); ImageLoader.getInstance().displayImage(scheduledDownload.getIconPath(), imageViewIcon); } }; getSupportLoaderManager().initLoader(0, null, this); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View item, int arg2, long arg3) { ScheduledDownload scheduledDownload = (ScheduledDownload) ((Holder) item.getTag()).checkBoxScheduled .getTag(); scheduledDownload.toggleChecked(); Holder viewHolder = (Holder) item.getTag(); viewHolder.checkBoxScheduled.setChecked(scheduledDownload.isChecked()); } }); if (getIntent().hasExtra("downloadAll")) { ScheduledDownloadsDialog pd = new ScheduledDownloadsDialog(); pd.show(getSupportFragmentManager(), "installAllScheduled"); } lv.setAdapter(adapter); }
From source file:cm.aptoide.pt.ScheduledDownloads.java
private void continueLoading() { lv = (ListView) findViewById(android.R.id.list); db = Database.getInstance();/*from www . j a va 2s .c om*/ adapter = new CursorAdapter(this, null, CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER) { @Override public View newView(Context context, Cursor arg1, ViewGroup arg2) { return LayoutInflater.from(context).inflate(R.layout.row_sch_download, null); } @Override public void bindView(View convertView, Context arg1, Cursor c) { // Planet to display ScheduledDownload scheduledDownload = scheduledDownloadsHashMap.get(c.getString(0)); // The child views in each row. CheckBox checkBoxScheduled; TextView textViewName; TextView textViewVersion; ImageView imageViewIcon; // Create a new row view if (convertView.getTag() == null) { // Find the child views. textViewName = (TextView) convertView.findViewById(R.id.name); textViewVersion = (TextView) convertView.findViewById(R.id.appversion); checkBoxScheduled = (CheckBox) convertView.findViewById(R.id.schDwnChkBox); imageViewIcon = (ImageView) convertView.findViewById(R.id.appicon); // Optimization: Tag the row with it's child views, so we don't have to // call findViewById() later when we reuse the row. convertView.setTag(new Holder(textViewName, textViewVersion, checkBoxScheduled, imageViewIcon)); // If CheckBox is toggled, update the planet it is tagged with. checkBoxScheduled.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CheckBox cb = (CheckBox) v; ScheduledDownload schDownload = (ScheduledDownload) cb.getTag(); schDownload.setChecked(cb.isChecked()); } }); } // Reuse existing row view else { // Because we use a ViewHolder, we avoid having to call findViewById(). Holder viewHolder = (Holder) convertView.getTag(); checkBoxScheduled = viewHolder.checkBoxScheduled; textViewVersion = viewHolder.textViewVersion; textViewName = viewHolder.textViewName; imageViewIcon = viewHolder.imageViewIcon; } // Tag the CheckBox with the Planet it is displaying, so that we can // access the planet in onClick() when the CheckBox is toggled. checkBoxScheduled.setTag(scheduledDownload); // Display planet data checkBoxScheduled.setChecked(scheduledDownload.isChecked()); textViewName.setText(scheduledDownload.getName()); textViewVersion.setText(scheduledDownload.getVername()); // Tag the CheckBox with the Planet it is displaying, so that we can // access the planet in onClick() when the CheckBox is toggled. checkBoxScheduled.setTag(scheduledDownload); // Display planet data checkBoxScheduled.setChecked(scheduledDownload.isChecked()); textViewName.setText(scheduledDownload.getName()); textViewVersion.setText("" + scheduledDownload.getVername()); ImageLoader.getInstance().displayImage(scheduledDownload.getIconPath(), imageViewIcon); } }; lv.setAdapter(adapter); getSupportLoaderManager().initLoader(0, null, this); lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View item, int arg2, long arg3) { ScheduledDownload scheduledDownload = (ScheduledDownload) ((Holder) item.getTag()).checkBoxScheduled .getTag(); scheduledDownload.toggleChecked(); Holder viewHolder = (Holder) item.getTag(); viewHolder.checkBoxScheduled.setChecked(scheduledDownload.isChecked()); } }); IntentFilter filter = new IntentFilter("pt.caixamagica.aptoide.REDRAW"); registerReceiver(receiver, filter); Button installButton = (Button) findViewById(R.id.sch_down); // installButton.setText(getText(R.string.schDown_installselected)); installButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (isAllChecked()) { for (String scheduledDownload : scheduledDownloadsHashMap.keySet()) { if (scheduledDownloadsHashMap.get(scheduledDownload).checked) { ScheduledDownload schDown = scheduledDownloadsHashMap.get(scheduledDownload); ViewApk apk = new ViewApk(); apk.setApkid(schDown.getApkid()); apk.setName(schDown.getName()); apk.setVercode(schDown.getVercode()); apk.setIconPath(schDown.getIconPath()); apk.setVername(schDown.getVername()); apk.setRepoName(schDown.getRepoName()); serviceDownloadManager .startDownloadWithWebservice(serviceDownloadManager.getDownload(apk), apk); Toast toast = Toast.makeText(ScheduledDownloads.this, R.string.starting_download, Toast.LENGTH_SHORT); toast.show(); } } } else { Toast toast = Toast.makeText(ScheduledDownloads.this, R.string.schDown_nodownloadselect, Toast.LENGTH_SHORT); toast.show(); } } }); if (getIntent().hasExtra("downloadAll")) { Builder dialogBuilder = new AlertDialog.Builder(this); final AlertDialog scheduleDownloadDialog = dialogBuilder.create(); scheduleDownloadDialog.setTitle(getText(R.string.schDwnBtn)); scheduleDownloadDialog.setIcon(android.R.drawable.ic_dialog_alert); scheduleDownloadDialog.setCancelable(false); scheduleDownloadDialog.setMessage(getText(R.string.schDown_install)); scheduleDownloadDialog.setButton(Dialog.BUTTON_POSITIVE, getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { for (String scheduledDownload : scheduledDownloadsHashMap.keySet()) { ScheduledDownload schDown = scheduledDownloadsHashMap.get(scheduledDownload); ViewApk apk = new ViewApk(); apk.setApkid(schDown.getApkid()); apk.setName(schDown.getName()); apk.setVercode(schDown.getVercode()); apk.setIconPath(schDown.getIconPath()); apk.setVername(schDown.getVername()); apk.setRepoName(schDown.getRepoName()); serviceDownloadManager .startDownloadWithWebservice(serviceDownloadManager.getDownload(apk), apk); Toast toast = Toast.makeText(ScheduledDownloads.this, R.string.starting_download, Toast.LENGTH_SHORT); toast.show(); } finish(); } }); scheduleDownloadDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(android.R.string.no), new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { finish(); } }); scheduleDownloadDialog.show(); } }
From source file:com.fastbootmobile.encore.app.adapters.SongsListAdapter.java
/** * {@inheritDoc}/*from w ww . j a v a 2 s . co m*/ */ @Override public View getView(final int position, final View convertView, ViewGroup parent) { final Context ctx = parent.getContext(); assert ctx != null; final ProviderAggregator aggregator = ProviderAggregator.getDefault(); View root = convertView; if (convertView == null) { // Recycle the existing view LayoutInflater inflater = LayoutInflater.from(ctx); root = inflater.inflate(R.layout.item_playlist_view, parent, false); assert root != null; ViewHolder holder = new ViewHolder(); holder.tvTitle = (TextView) root.findViewById(R.id.tvTitle); holder.tvArtist = (TextView) root.findViewById(R.id.tvArtist); holder.tvDuration = (TextView) root.findViewById(R.id.tvDuration); holder.ivOverflow = (ImageView) root.findViewById(R.id.ivOverflow); holder.ivAlbumArt = (AlbumArtImageView) root.findViewById(R.id.ivAlbumArt); holder.ivOffline = (ImageView) root.findViewById(R.id.ivOffline); holder.vCurrentIndicator = root.findViewById(R.id.currentSongIndicator); holder.vRoot = (ViewGroup) root; holder.vRoot.setLayerType(View.LAYER_TYPE_HARDWARE, null); if (mShowAlbumArt) { // Fixup some style stuff holder.ivAlbumArt.setVisibility(View.VISIBLE); } else { holder.ivAlbumArt.setVisibility(View.GONE); } holder.ivOverflow.setOnClickListener(mOverflowClickListener); holder.ivOverflow.setTag(holder); root.setTag(holder); } final Song song = getItem(position); final ViewHolder tag = (ViewHolder) root.getTag(); // Update tag tag.position = position; tag.song = song; root.setTag(tag); // Fill fields if (song != null && song.isLoaded()) { tag.tvTitle.setText(song.getTitle()); tag.tvDuration.setText(Utils.formatTrackLength(song.getDuration())); if (mShowAlbumArt) { tag.ivAlbumArt.loadArtForSong(song); } if (song.getArtist() == null) { tag.tvArtist.setText(null); } else { Artist artist = aggregator.retrieveArtist(song.getArtist(), song.getProvider()); if (artist != null) { tag.tvArtist.setText(artist.getName()); } else { tag.tvArtist.setText("..."); } } } else { tag.tvTitle.setText("..."); tag.tvDuration.setText("..."); tag.tvArtist.setText("..."); if (mShowAlbumArt) { tag.ivAlbumArt.setDefaultArt(); } } // Set current song indicator tag.vCurrentIndicator.setVisibility(View.INVISIBLE); Song currentSong = PlaybackProxy.getCurrentTrack(); if (currentSong != null && currentSong.equals(tag.song)) { tag.vCurrentIndicator.setVisibility(View.VISIBLE); } if (song != null) { // Set alpha based on offline availability and mode if ((aggregator.isOfflineMode() && song.getOfflineStatus() != BoundEntity.OFFLINE_STATUS_READY) || !song.isAvailable()) { Utils.setChildrenAlpha(tag.vRoot, Float.parseFloat(ctx.getResources().getString(R.string.unavailable_track_alpha))); } else { Utils.setChildrenAlpha(tag.vRoot, 1.0f); } // Show offline indicator in any case tag.ivOffline.setVisibility(View.VISIBLE); tag.ivOffline.clearAnimation(); if (song.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_READY) { tag.ivOffline.setImageResource(R.drawable.ic_track_downloaded); } else if (song.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_DOWNLOADING) { tag.ivOffline.setImageResource(R.drawable.ic_sync_in_progress); if (mSyncRotateAnimation == null && tag.ivOffline.getMeasuredWidth() != 0) { mSyncRotateAnimation = new RotateAnimation(0, -360, tag.ivOffline.getMeasuredWidth() / 2.0f, tag.ivOffline.getMeasuredHeight() / 2.0f); mSyncRotateAnimation.setRepeatMode(Animation.INFINITE); mSyncRotateAnimation.setRepeatCount(Animation.INFINITE); mSyncRotateAnimation.setDuration(1000); mSyncRotateAnimation.setInterpolator(new LinearInterpolator()); } if (mSyncRotateAnimation != null) { tag.ivOffline.startAnimation(mSyncRotateAnimation); } } else if (song.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_ERROR) { tag.ivOffline.setImageResource(R.drawable.ic_sync_problem); } else if (song.getOfflineStatus() == BoundEntity.OFFLINE_STATUS_PENDING) { tag.ivOffline.setImageResource(R.drawable.ic_track_download_pending); } else { tag.ivOffline.setVisibility(View.GONE); } } return root; }
From source file:com.mb.kids_mind.Adapter.SimilarListAdapterdetail.java
@Override public View getView(final int position, View cView, ViewGroup parent) { ViewHolder holder = null;//from w ww.ja v a 2 s .c om final SimilarItem contents = list.get(position); final SharedPreferences pref = mContext.getSharedPreferences("pref", mContext.MODE_PRIVATE); final SharedPreferences.Editor editor = pref.edit(); if (cView == null) { //cView=View.inflate(mContext, layout,null); cView = LayoutInflater.from(mContext).inflate(layout, parent, false); holder = new ViewHolder(); holder.image = (ImageView) cView.findViewById(R.id.image); holder.loading = (ImageView) cView.findViewById(R.id.loadingimg); holder.loading.setVisibility(View.GONE); holder.loading.setBackgroundResource(R.anim.progress); holder.loadinglinear = (LinearLayout) cView.findViewById(R.id.loading); holder.loadinglinear.setVisibility(View.GONE); loadingViewAnim = (AnimationDrawable) holder.loading.getBackground(); // holder.question=(TextView)cView.findViewById(R.id.question); // holder.date=(TextView)cView.findViewById(R.id.date); cView.setTag(holder); // Log.v(TAG,"cvew==null"); } else { holder = (ViewHolder) cView.getTag(); // Log.v(TAG,"cvew!=null"); } //holder.image.setImageResource(contents.getRes()); // String DirPath = Environment.getExternalStorageDirectory() // .getAbsolutePath(); // DirPath = DirPath + "/" + "KidsMind2" + "/"; // // File cameraDir = new File(DirPath); // if (!cameraDir.exists()) { // // cameraDir.mkdirs(); // } // File f1 = new File(cameraDir, contents.advice_image); // if (f1.exists()) { // holder.image.setImageURI(Uri.fromFile(f1)); // //mLoader.DisplayImage(f1.getAbsolutePath(), holder.imageView); // // } else { // new DownTask().execute( // (Const.IMAGE_LOAD_URL+"/" + contents.advice_image).trim(),f1,holder.image); // // } requestMyImage(holder.loading, holder.loadinglinear, holder.image, contents.advice_image); // if("Q1".equals(contents.question_id)){ // holder.question.setText(" "); // }else if("Q2".equals(contents.question_id)){ // holder.question.setText(" "); // }else if("Q3".equals(contents.question_id)){ // holder.question.setText(" "); // }else if("Q4".equals(contents.question_id)){ // holder.question.setText(" "); // } // String da=contents.getDate().substring(0, 9); // holder.date.setText(da); return cView; }
From source file:com.snt.bt.recon.adapters.LeDeviceListAdapter.java
@Override public View getView(final int i, View view, final ViewGroup viewGroup) { final ViewHolder viewHolder; // General ListView optimization code. if (view == null) { view = mInflator.inflate(com.snt.bt.recon.R.layout.list_item_device, null); viewHolder = new ViewHolder(); viewHolder.deviceAddress = (TextView) view.findViewById(com.snt.bt.recon.R.id.device_address); viewHolder.deviceName = (TextView) view.findViewById(com.snt.bt.recon.R.id.device_name); viewHolder.deviceRssi = (TextView) view.findViewById(com.snt.bt.recon.R.id.device_rssi); viewHolder.deviceIcon = (ImageView) view.findViewById(com.snt.bt.recon.R.id.device_icon); viewHolder.deviceLastUpdated = (TextView) view.findViewById(com.snt.bt.recon.R.id.device_last_update); viewHolder.ibeaconMajor = (TextView) view.findViewById(com.snt.bt.recon.R.id.ibeacon_major); viewHolder.ibeaconMinor = (TextView) view.findViewById(com.snt.bt.recon.R.id.ibeacon_minor); viewHolder.ibeaconDistance = (TextView) view.findViewById(com.snt.bt.recon.R.id.ibeacon_distance); viewHolder.ibeaconUUID = (TextView) view.findViewById(com.snt.bt.recon.R.id.ibeacon_uuid); viewHolder.ibeaconTxPower = (TextView) view.findViewById(com.snt.bt.recon.R.id.ibeacon_tx_power); viewHolder.ibeaconSection = view.findViewById(com.snt.bt.recon.R.id.ibeacon_section); viewHolder.ibeaconDistanceDescriptor = (TextView) view.findViewById(com.snt.bt.recon.R.id.ibeacon_distance_descriptor); view.setTag(viewHolder); } else {//from w w w .j av a 2s .c o m viewHolder = (ViewHolder) view.getTag(); } final BluetoothLeDevice device = getCursor().getItem(i); final String deviceName = device.getName(); final double rssi = device.getRssi(); if (deviceName != null && deviceName.length() > 0) { viewHolder.deviceName.setText(deviceName); } else { viewHolder.deviceName.setText(com.snt.bt.recon.R.string.unknown_device); } if (BeaconUtils.getBeaconType(device) == BeaconType.IBEACON) { final IBeaconDevice iBeacon = new IBeaconDevice(device); final String accuracy = Constants.DOUBLE_TWO_DIGIT_ACCURACY.format(iBeacon.getAccuracy()); viewHolder.deviceIcon.setImageResource(com.snt.bt.recon.R.drawable.ic_device_ibeacon); viewHolder.ibeaconSection.setVisibility(View.VISIBLE); viewHolder.ibeaconMajor.setText(String.valueOf(iBeacon.getMajor())); viewHolder.ibeaconMinor.setText(String.valueOf(iBeacon.getMinor())); viewHolder.ibeaconTxPower.setText(String.valueOf(iBeacon.getCalibratedTxPower())); viewHolder.ibeaconUUID.setText(iBeacon.getUUID()); viewHolder.ibeaconDistance.setText( mActivity.getString(com.snt.bt.recon.R.string.formatter_meters, accuracy)); viewHolder.ibeaconDistanceDescriptor.setText(iBeacon.getDistanceDescriptor().toString()); } else { viewHolder.deviceIcon.setImageResource(com.snt.bt.recon.R.drawable.ic_bluetooth); viewHolder.ibeaconSection.setVisibility(View.GONE); } final String rssiString = mActivity.getString(com.snt.bt.recon.R.string.formatter_db, String.valueOf(rssi)); final String runningAverageRssiString = mActivity.getString(com.snt.bt.recon.R.string.formatter_db, String.valueOf(device.getRunningAverageRssi())); viewHolder.deviceLastUpdated.setText( android.text.format.DateFormat.format( Constants.TIME_FORMAT, new java.util.Date(device.getTimestamp()))); viewHolder.deviceAddress.setText(device.getAddress()); //viewHolder.deviceRssi.setText(rssiString + " / " + runningAverageRssiString); viewHolder.deviceRssi.setText(rssiString); return view; }