public EditNoteActivity(Fragment fragment, View parent, long t) { super(fragment.getActivity()); DependencyInjectionService.getInstance().inject(this); imageCache = AsyncImageView.getImageCache(); this.fragment = fragment; this.activity = (AstridActivity) fragment.getActivity(); this.resources = fragment.getResources(); TypedValue tv = new TypedValue(); fragment.getActivity().getTheme().resolveAttribute(R.attr.asTextColor, tv, false); color = tv.data; fragment.getActivity().getTheme().resolveAttribute(R.attr.asDueDateColor, tv, false); grayColor = tv.data; linkColor = UpdateAdapter.getLinkColor(fragment); cameraButton = getDefaultCameraButton(); setOrientation(VERTICAL); commentsBar = parent.findViewById(R.id.updatesFooter); loadViewForTaskID(t); }
@Override public void bindView(View view, final Context context, Cursor cursor) { boolean needSeparator = false; final int position = cursor.getPosition(); final long itemId = cursor.getLong(cursor.getColumnIndex(Contract._ID)); // Set separator int thisItemCategory = cursor.getInt(cursor.getColumnIndex(Contract.COL_CATEGORY)); if (mCellStates != null) { switch (mCellStates[position]) { case STATE_SECTIONED: needSeparator = true; break; case STATE_REGULAR: needSeparator = false; break; case STATE_UNKNOWN: default: // A separator is needed if it's the first itemview of the // ListView or if the group of the current cell is different // from the previous itemview. if (position == 0) { needSeparator = true; } else { cursor.moveToPosition(position - 1); int prevItemCategory = cursor.getInt(cursor.getColumnIndex(Contract.COL_CATEGORY)); if (thisItemCategory - prevItemCategory != 0) { needSeparator = true; } cursor.moveToPosition(position); } // Cache the result mCellStates[position] = needSeparator ? STATE_SECTIONED : STATE_REGULAR; break; } TextView separator = (TextView) view.findViewById(R.id.section); if (needSeparator) { separator.setText(Utilities.getCategoryString(mFragment.getResources(), thisItemCategory)); separator.setVisibility(View.VISIBLE); } else { separator.setVisibility(View.GONE); } } // Set text fields String itemName = cursor.getString(cursor.getColumnIndex(Contract.COL_ITEM_NAME)); TextView nameView = (TextView) view.findViewById(R.id.item_name); nameView.setText(itemName); Long date = cursor.getLong(cursor.getColumnIndex(Contract.COL_DATE)); String itemDate = Utilities.formatDate(date); TextView dateView = (TextView) view.findViewById(R.id.item_date); dateView.setText(itemDate); String itemImage = cursor.getString(cursor.getColumnIndex(Contract.COL_IMAGE)); ImageView imageView = (ImageView) view.findViewById(R.id.item_image); File imageFile = new File(context.getExternalFilesDir(Environment.DIRECTORY_PICTURES), itemImage); if (imageFile.exists()) { Glide.with(context) .load(imageFile) .centerCrop() .bitmapTransform(new CropCircleTransformation(context)) .into(imageView); } else { int id = mFragment.getResources().getIdentifier(itemImage, "drawable", context.getPackageName()); if (id != 0) { Glide.with(context) .load(id) .centerCrop() .bitmapTransform(new CropCircleTransformation(context)) .into(imageView); } else { Glide.with(context) .load(R.drawable.placeholder) .centerCrop() .bitmapTransform(new CropCircleTransformation(context)) .into(imageView); } } String itemQantity = Utilities.quantityToShortString( cursor.getInt(cursor.getColumnIndex(Contract.COL_QUANTITY))); TextView quantityView = (TextView) view.findViewById(R.id.item_quantity_text); quantityView.setText(itemQantity); LinearLayout quantityViewButton = (LinearLayout) view.findViewById(R.id.item_quantity_button); quantityViewButton.setOnClickListener( new DecrementListener(context, mFragment.getFragmentManager(), itemId)); int itemCategory = cursor.getInt(cursor.getColumnIndex(Contract.COL_CATEGORY)); View categoryView = view.findViewById(R.id.item_category); switch (itemCategory) { case Contract.CATEGORY_DEFAULT: categoryView.setBackgroundColor(Color.BLUE); break; case Contract.CATEGORY_MEAL: categoryView.setBackgroundColor(Color.RED); break; case Contract.CATEGORY_INGREDIENT: categoryView.setBackgroundColor(Color.GREEN); break; case Contract.CATEGORY_SIDE: categoryView.setBackgroundColor(Color.MAGENTA); break; case Contract.CATEGORY_SWEET: categoryView.setBackgroundColor(Color.CYAN); break; case Contract.CATEGORY_OTHER: categoryView.setBackgroundColor(Color.GRAY); break; default: Log.e(TAG, "Unrecognised category"); break; } }
public zzd zzrq() { return zze.zzx(zzadh.getResources()); }