List of usage examples for android.widget LinearLayout getTag
@ViewDebug.ExportedProperty
public Object getTag()
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java
/** * Removes record both from sqlite and backend * /*from w ww . j av a 2s .c om*/ * @param v */ public void onClickDeleteActivity(View v) { LinearLayout llCheckItemRow = (LinearLayout) v.getParent(); LinearLayout llCheckItemWrapper = (LinearLayout) llCheckItemRow.getParent(); int iNumItemsHistory = 0; int iTag = 0; int iClicked = 0; try { llHistory = (LinearLayout) llCheckItemWrapper.getParent(); llListFragment = (LinearLayout) llHistory.getParent(); iNumItemsHistory = ((llHistory.getChildCount() - 1) / 2) - 1; iTag = new Integer(llCheckItemWrapper.getTag().toString()); iClicked = (iTag - iNumItemsHistory) * (-1); iToRemove = (iClicked + 1) * 2; } catch (Exception e) { e.printStackTrace(); } TextView myText = (TextView) llCheckItemRow.findViewById(R.id.textViewTimeStamp); lCheckInToDelete = (Long) myText.getTag(); String sCheckIn = (String) myText.getText(); TextView tvDur = (TextView) llCheckItemRow.findViewById(R.id.textViewDuration); sIdSbuject = (String) tvDur.getTag(); new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert).setTitle("Remove activity?") .setMessage("Are you sure to remove activity started at " + sCheckIn + " ?") .setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Toast.makeText(getApplicationContext(), "About to delete activity "+sCheckIn+" ... ", Toast.LENGTH_SHORT).show(); Log.d(CLASSNAME, "About to delte activity mills[" + lCheckInToDelete + "]"); // Delete this transactional // Issue 16 // https://code.google.com/p/lifelong-learning-hub/issues/detail?id=16 deleteActivityBackend(lCheckInToDelete, Session.getSingleInstance().getUserName()); Session.getSingleInstance().getDatabaseHandler().deleteActivity(lCheckInToDelete); DateUtils du = new DateUtils(); TextView tvDuration = (TextView) llListFragment.findViewById(R.id.tvDuration); tvDuration.setText(du.duration( Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sIdSbuject))); llHistory.getChildAt(iToRemove).setVisibility(View.GONE); //Stop the activity //TimeLineActivity.this.finish(); } }).setNegativeButton("No", null).show(); }
From source file:uk.org.downiesoft.slideshow.BrowserAdapter.java
/** * {@inheritDoc}/* w ww. j av a 2 s . co m*/ */ @Override public View getView(int position, View convertView, ViewGroup parent) { LinearLayout browserItemView; Holder holder; if (convertView == null) { browserItemView = new LinearLayout(mContext); mInflater.inflate(mResource, browserItemView, true); holder = new Holder(); holder.image = (ImageView) browserItemView.findViewById(R.id.rowImage); holder.name = (TextView) browserItemView.findViewById(R.id.rowFilename); holder.count = (TextView) browserItemView.findViewById(R.id.rowCount); browserItemView.setTag(holder); } else { browserItemView = (LinearLayout) convertView; holder = (Holder) browserItemView.getTag(); } final ImageView imageView = holder.image; final TextView textView = holder.name; final TextView countView = holder.count; ZFile item = getItem(position); String name = item.getName(); if (item.isDirectory() && item.getSubPath().length() == 0) { if (mThumbBitmaps.get(position) != null) imageView.setImageBitmap(mThumbBitmaps.get(position)); else imageView.setImageResource(R.drawable.folder); textView.setText(name.substring(0, name.length())); if (mCountsCache.get(position) != null) { countView.setText(String.format("%d", mCountsCache.get(position))); } else { countView.setText("\u2026"); } } else if (item.getSubPath().equals(mContext.getString(R.string.text_images_placeholder))) { imageView.setImageBitmap(mThumbBitmaps.get(position)); textView.setText(name.substring(0, name.length())); if (mCountsCache.get(position) != null) { countView.setText(String.format("%d", mCountsCache.get(position))); } else { countView.setText(""); } } else { if (mThumbBitmaps.get(position) != null) imageView.setImageBitmap(mThumbBitmaps.get(position)); else imageView.setImageResource(R.drawable.ic_launcher); if (mCountsCache.get(position) != null) { countView.setText(String.format("%d", mCountsCache.get(position))); } else { countView.setText("\u2026"); } textView.setText(name); } return browserItemView; }
From source file:com.example.zf_android.trade.ApplyDetailActivity.java
@Override protected void onActivityResult(final int requestCode, int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != RESULT_OK) return;//from w w w .ja v a 2s. c o m switch (requestCode) { case REQUEST_CHOOSE_MERCHANT: { mAgentId = mMerchantId = data.getIntExtra(AGENT_ID, 0); mAgentName = data.getStringExtra(AGENT_NAME); setItemValue(mMerchantKeys[0], mAgentName); getAgentInfo(); break; } case REQUEST_CHOOSE_BANK: { mBankName = data.getStringExtra("bank_name"); mBankNo = data.getStringExtra("bank_no"); setItemValue(customTag, mBankName); setItemValue(mBankKeys[0], mBankName); //FIXME no // setItemValue(mBankKeys[1], mBankNo); break; } case REQUEST_CHOOSE_CITY: { mMerchantProvince = (Province) data.getSerializableExtra(SELECTED_PROVINCE); mMerchantCity = (City) data.getSerializableExtra(SELECTED_CITY); mCityId = mMerchantCity.getId(); setItemValue(mMerchantKeys[8], mMerchantCity.getName()); break; } case REQUEST_CHOOSE_CHANNEL: { mChannelId = data.getIntExtra("channelId", 0); mBillingId = data.getIntExtra("billId", 0); String channelName = data.getStringExtra("channelName"); String billName = data.getStringExtra("billName"); setItemValue(getString(R.string.apply_detail_channel), channelName + " " + billName); break; } case REQUEST_UPLOAD_IMAGE: case REQUEST_TAKE_PHOTO: { final Handler handler = new Handler() { @Override public void handleMessage(Message msg) { if (msg.what == 1) { // CommonUtil.toastShort(ApplyDetailActivity.this, (String) msg.obj); if (null != uploadingTextView) { final String url = (String) msg.obj; LinearLayout item = (LinearLayout) uploadingTextView.getParent().getParent(); updateCustomerDetails(item.getTag(), url); uploadingTextView.setVisibility(View.GONE); ImageView iv_view = (ImageView) item.findViewById(R.id.apply_detail_view); iv_view.setVisibility(View.VISIBLE); iv_view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(ApplyDetailActivity.this, ImageViewer.class); i.putExtra("url", url); i.putExtra("justviewer", true); startActivity(i); } }); } } else { CommonUtil.toastShort(ApplyDetailActivity.this, getString(R.string.toast_upload_failed)); if (null != uploadingTextView) { uploadingTextView.setText(getString(R.string.apply_upload_again)); uploadingTextView.setClickable(true); } } } }; if (null != uploadingTextView) { uploadingTextView.setText(getString(R.string.apply_uploading)); uploadingTextView.setClickable(false); } new Thread() { @Override public void run() { String realPath = ""; if (requestCode == REQUEST_TAKE_PHOTO) { realPath = photoPath; } else { Uri uri = data.getData(); if (uri != null) { realPath = getRealPathFromURI(uri); } } if (TextUtils.isEmpty(realPath)) { handler.sendEmptyMessage(0); return; } CommonUtil.uploadFile(realPath, "img", new CommonUtil.OnUploadListener() { @Override public void onSuccess(String result) { try { JSONObject jo = new JSONObject(result); String url = jo.getString("result"); Message msg = new Message(); msg.what = 1; msg.obj = url; handler.sendMessage(msg); } catch (JSONException e) { handler.sendEmptyMessage(0); } } @Override public void onFailed(String message) { handler.sendEmptyMessage(0); } }); } }.start(); break; } } }
From source file:com.krayzk9s.imgurholo.ui.SingleImageFragment.java
private void setDescendantsHidden(View view) { LinearLayout convertView = (LinearLayout) view; ViewHolder holder = (ViewHolder) convertView.getTag(); int position = holder.position; JSONObject viewData = commentAdapter.getItem(position).getJSONObject(); try {//from w w w . java 2 s . com if (!viewData.has("hidden")) viewData.put("hidden", ViewHolder.VIEW_VISIBLE); boolean hiding; int indentLevel = viewData.getInt("indent"); if (viewData.getInt("hidden") != ViewHolder.VIEW_HIDDEN) { viewData.put("hidden", ViewHolder.VIEW_HIDDEN); hiding = true; } else { viewData.put("hidden", ViewHolder.VIEW_VISIBLE); hiding = false; } for (int i = position + 1; i < commentAdapter.getCount(); i++) { JSONObject childViewData = commentAdapter.getItem(i).getJSONObject(); if (childViewData.getInt("indent") > indentLevel) { if (hiding) { childViewData.put("hidden", ViewHolder.VIEW_DESCENDANT); commentAdapter.addHiddenItem(i); } else { childViewData.put("hidden", ViewHolder.VIEW_VISIBLE); commentAdapter.removeHiddenItem(i); } } else break; } } catch (JSONException e) { Log.e("Converting to Hidden Error!", e.toString()); } commentAdapter.notifyDataSetChanged(); }
From source file:org.gots.allotment.adapter.ListAllotmentAdapter.java
@SuppressWarnings("deprecation") @Override/* ww w . ja v a 2s .co m*/ public View getView(final int position, View convertView, ViewGroup parent) { LinearLayout ll = (LinearLayout) convertView; Holder holder; if (ll == null) { holder = new Holder(); ll = (LinearLayout) LayoutInflater.from(mContext).inflate(R.layout.list_allotments, parent, false); if (GotsPreferences.DEBUG) { TextView textView = new TextView(mContext); textView.setText("(" + getItem(position).getId() + ")" + getItem(position).getUUID()); ll.addView(textView); } holder.listSeeds = (GridView) ll.findViewById(R.id.IdGrowingSeedList); holder.titlebar = (LinearLayout) ll.findViewById(R.id.idAllotmentTitlebar); holder.allotmentName = (TextView) ll.findViewById(R.id.textAllotmentName); holder.menu = (LinearLayout) ll.findViewById(R.id.idAllotmentMenu); holder.allotment = getItem(position); ll.setTag(holder); ll.setDescendantFocusability(LinearLayout.FOCUS_BLOCK_DESCENDANTS); // ll.setOnClickListener(this); } else holder = (Holder) ll.getTag(); WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); int width; int sdk = android.os.Build.VERSION.SDK_INT; if (sdk < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) { width = display.getWidth(); } else { Point size = new Point(); display.getSize(size); width = size.x; } int layoutsize = 150; if (width <= 480) layoutsize = 50; int nbcolumn = (width - 200) / layoutsize; if (nbcolumn < 1) nbcolumn = 1; holder.listSeeds.setNumColumns(nbcolumn); listGrowingSeedAdapter = new ListGrowingSeedAdapter(mContext, getItem(position).getSeeds()); holder.listSeeds.setAdapter(listGrowingSeedAdapter); holder.listSeeds.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, layoutsize)); if (listGrowingSeedAdapter.getCount() > 0) { holder.listSeeds.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, (holder.listSeeds.getCount() / nbcolumn + 1) * layoutsize + layoutsize)); // holder.listSeeds.setLayoutParams(new // LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, // LayoutParams.WRAP_CONTENT)); } // else // holder.listSeeds.setLayoutParams(new // LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, // ((holder.listSeeds.getCount() / nbcolumn) + 1) * layoutsize)); holder.allotmentName.setText(getItem(position).getName()); // holder.titlebar.removeAllViews(); holder.menu.setTag(holder); holder.menu.setOnClickListener(this); // SowingAction sow = new SowingAction(mContext); // ActionWidget widget = new ActionWidget(mContext, sow); // widget.setTag(position); if (isSelectable) { holder.menu.setBackgroundResource(R.anim.rotate_alerte); // Animation myFadeInAnimation = // AnimationUtils.loadAnimation(mContext, R.anim.rotate_alerte); // menu.startAnimation(myFadeInAnimation); AnimationDrawable frameAnimation = (AnimationDrawable) holder.menu.getBackground(); frameAnimation.start(); holder.menu.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new AsyncTask<Void, Integer, GrowingSeedInterface>() { @Override protected GrowingSeedInterface doInBackground(Void... params) { GotsGrowingSeedManager growingSeedManager = GotsGrowingSeedManager.getInstance() .initIfNew(mContext); GotsSeedManager seedManager = GotsSeedManager.getInstance().initIfNew(mContext); // NuxeoGrowingSeedProvider provider = new // NuxeoGrowingSeedProvider(mContext); GrowingSeedInterface growingSeed = (GrowingSeedInterface) seedManager .getSeedById(currentSeedId); growingSeed.setDateSowing(Calendar.getInstance().getTime()); return growingSeedManager.plantingSeed(growingSeed, getItem(position)); } @Override protected void onPostExecute(GrowingSeedInterface seed) { // notifyDataSetChanged(); Toast.makeText(mContext, "Sowing" + " " + SeedUtil.translateSpecie(mContext, seed), Toast.LENGTH_LONG).show(); mContext.sendBroadcast(new Intent(BroadCastMessages.SEED_DISPLAYLIST)); ((Activity) mContext).finish(); } }.execute(); } }); } // widget.setPadding(4, 4, 4, 8); // holder.menu.addView(widget); // // SowingAction sow = new SowingAction(mContext); // ImageView widgetSensor = new ImageView(mContext); // widgetSensor.setImageDrawable(mContext.getResources().getDrawable(R.drawable.ic_sensor)); // widgetSensor.setBackgroundDrawable(mContext.getResources().getDrawable(R.drawable.action_selector)); // widgetSensor.setTag(position); // widgetSensor.setOnClickListener(new View.OnClickListener() { // // @Override // public void onClick(View v) { // // GotsPurchaseItem purchaseItem = new GotsPurchaseItem(mContext); // // // if (!purchaseItem.getFeatureParrot() ? true : // purchaseItem.isPremium()) { // if (!purchaseItem.getFeatureParrot() || purchaseItem.isPremium()) { // FragmentManager fm = mContext.getSupportFragmentManager(); // GotsBillingDialog editNameDialog = new // GotsBillingDialog(GotsPurchaseItem.SKU_FEATURE_PARROT); // editNameDialog.setStyle(DialogFragment.STYLE_NORMAL, // R.style.CustomDialog); // editNameDialog.show(fm, "fragment_edit_name"); // } else { // Intent sensorIntent = new Intent(mContext, SensorActivity.class); // mContext.startActivity(sensorIntent); // }// new AsyncTask<Void, Void, List<ParrotLocation>>() { // // private LocationListAdapter sensorListAdapter; // // // // List<ParrotSampleFertilizer> samplesFertilizer = null; // // // // List<ParrotSampleTemperature> samplesTemp = null; // // // // @Override // // protected List<ParrotLocation> doInBackground(Void... params) { // // ParrotSensorProvider sensorProvider = new // ParrotSensorProvider(mContext); // // List<ParrotLocation> locations = sensorProvider.getLocations(); // // sensorProvider.getStatus(); // // samplesFertilizer = // sensorProvider.getSamples(locations.get(0).getLocation_identifier()); // // samplesTemp = // sensorProvider.getSamples2(locations.get(0).getLocation_identifier()); // // // // return locations; // // } // // // // protected void onPostExecute(List<ParrotLocation> result) { // // // sensorListAdapter = new SensorListAdapter(mContext, result); // // sensorListAdapter = new LocationListAdapter(mContext, result); // // // new AlertDialog.Builder(mContext).setAdapter(sensorListAdapter, // // // new DialogInterface.OnClickListener() { // // // // // // @Override // // // public void onClick(DialogInterface dialog, int which) { // // // Toast.makeText(mContext, // sensorListAdapter.getItem(which).getSensor_serial(), // // // Toast.LENGTH_SHORT).show(); // // // ; // // // } // // // }).show(); // // // // Intent sensorIntent = new Intent(mContext, SensorActivity.class); // // mContext.startActivity(sensorIntent); // // // // if (samplesFertilizer != null) { // // WebView webView = new WebView(mContext); // // String chd = new String(); // // for (ParrotSampleFertilizer fertilizer : samplesFertilizer) { // // chd = chd.concat(String.valueOf(fertilizer.getFertilizer_level() * // 100)); // // chd = chd.concat(","); // // } // // chd = chd.substring(0, chd.length() - 1); // // String url = // "http://chart.apis.google.com/chart?cht=ls&chs=250x100&chd=t:" + chd; // // webView.loadUrl(url); // // Log.d(ListAllotmentAdapter.class.getName(), url); // // AlertDialog.Builder alert = new AlertDialog.Builder(mContext); // // alert.setView(webView); // // alert.show(); // // } // // if (samplesTemp != null) { // // WebView webView = new WebView(mContext); // // String chd = new String(); // // int i = 0; // // for (ParrotSampleTemperature sampleTemp : samplesTemp) { // // chd = // chd.concat(String.valueOf(sampleTemp.getAir_temperature_celsius())); // // chd = chd.concat(","); // // if (i++ >= 50) // // break; // // } // // chd = chd.substring(0, chd.length() - 1); // // String url = // "http://chart.apis.google.com/chart?cht=ls&chs=250x100&chd=t:" + chd; // // webView.loadUrl(url); // // Log.d(ListAllotmentAdapter.class.getName(), url); // // AlertDialog.Builder alert = new AlertDialog.Builder(mContext); // // alert.setView(webView); // // alert.show(); // // } // // }; // // }.execute(); // } // }); // // widgetSensor.setPadding(4, 4, 4, 8); // holder.menu.addView(widgetSensor); return ll; }