com.github.ivbaranov.mfb.MaterialFavoriteButton Java Examples

The following examples show how to use com.github.ivbaranov.mfb.MaterialFavoriteButton. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PostPhotosAdapter.java    From Hify with MIT License 5 votes vote down vote up
public PostPhotosAdapter(Context context, Activity activity, ArrayList<MultipleImage> IMAGES, boolean local, String postId, MaterialFavoriteButton like_btn,String adminId) {
    this.context = context;
    this.IMAGES =IMAGES;
    this.local=local;
    this.activity=activity;
    inflater = LayoutInflater.from(context);
    this.postId=postId;
    this.like_btn=like_btn;
    this.adminId=adminId;
}
 
Example #2
Source File: MainActivity.java    From IdeaTrackerPlus with MIT License 5 votes vote down vote up
@Override
public void onFavoriteChanged(MaterialFavoriteButton buttonView, boolean favorite) {
    if (favorite) {
        mTinyDB.putInt(getString(R.string.favorite_project), getProjectId());
    } else if (mTinyDB.getInt(getString(R.string.favorite_project)) == mSelectedProfileIndex) {
        mTinyDB.putInt(getString(R.string.favorite_project), -1); //no favorite
    }
}
 
Example #3
Source File: MachineArrayFullAdapter.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    // Get the data item for this position
    Machine machine = getItem(position);
    if (machine == null) return convertView;

    // Check if an existing view is being reused, otherwise inflate the view
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.machinelist_row, parent, false);
    }
    TextView t0 = convertView.findViewById(R.id.LIST_MACHINE_ID);
    t0.setText(String.valueOf(machine.getId()));

    TextView t1 = convertView.findViewById(R.id.LIST_MACHINE_NAME);
    t1.setText(machine.getName());

    TextView t2 = convertView.findViewById(R.id.LIST_MACHINE_SHORT_DESCRIPTION);
    t2.setText(machine.getDescription());

    ImageView i0 = convertView.findViewById(R.id.LIST_MACHINE_PHOTO);
    String lPath = machine.getPicture();
    if (lPath != null && !lPath.isEmpty()) {
        try {
            ImageUtil imgUtil = new ImageUtil();
            String lThumbPath = imgUtil.getThumbPath(lPath);
            ImageUtil.setThumb(i0, lThumbPath);
        } catch (Exception e) {
            i0.setImageResource(R.drawable.ic_gym_bench_50dp);
            i0.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
            e.printStackTrace();
        }
    } else {
        i0.setImageResource(R.drawable.ic_gym_bench_50dp);
        i0.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    }

    MaterialFavoriteButton iFav = convertView.findViewById(R.id.LIST_MACHINE_FAVORITE);
    iFav.setFavorite(machine.getFavorite());
    return convertView;
}
 
Example #4
Source File: MachineCursorAdapter.java    From fastnfitness with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void bindView(View view, Context context, Cursor cursor) {

    TextView t0 = view.findViewById(R.id.LIST_MACHINE_ID);
    t0.setText(cursor.getString(cursor.getColumnIndex(DAOMachine.KEY)));

    TextView t1 = view.findViewById(R.id.LIST_MACHINE_NAME);
    t1.setText(cursor.getString(cursor.getColumnIndex(DAOMachine.NAME)));

    TextView t2 = view.findViewById(R.id.LIST_MACHINE_SHORT_DESCRIPTION);
    t2.setText(cursor.getString(cursor.getColumnIndex(DAOMachine.DESCRIPTION)));

    ImageView i0 = view.findViewById(R.id.LIST_MACHINE_PHOTO);
    String lPath = cursor.getString(cursor.getColumnIndex(DAOMachine.PICTURE));

    ExerciseType lType = ExerciseType.fromInteger(cursor.getInt(cursor.getColumnIndex(DAOMachine.TYPE)));

    if (lPath != null && !lPath.isEmpty()) {
        try {
            ImageUtil imgUtil = new ImageUtil();
            String lThumbPath = imgUtil.getThumbPath(lPath);
            ImageUtil.setThumb(i0, lThumbPath);
        } catch (Exception e) {
            if (lType == ExerciseType.STRENGTH ) {
                i0.setImageResource(R.drawable.ic_gym_bench_50dp); }
            else if (lType == ExerciseType.ISOMETRIC ) {
                i0.setImageResource(R.drawable.ic_static);
            }
            else {
                i0.setImageResource(R.drawable.ic_training_white_50dp);
            i0.setScaleType(ImageView.ScaleType.CENTER_INSIDE); }
            e.printStackTrace();
        }
    } else {
        if (lType == ExerciseType.STRENGTH) {
            i0.setImageResource(R.drawable.ic_gym_bench_50dp); }
        else if (lType == ExerciseType.ISOMETRIC ) {
            i0.setImageResource(R.drawable.ic_static);
        }
        else {
            i0.setImageResource(R.drawable.ic_training_white_50dp); }

        i0.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
    }

    iFav = view.findViewById(R.id.LIST_MACHINE_FAVORITE);
    boolean bFav = cursor.getInt(6) == 1;
    iFav.setFavorite(bFav);
    iFav.setRotationDuration(500);
    iFav.setAnimateFavorite(true);
    iFav.setTag(cursor.getLong(0));

    iFav.setOnClickListener(v -> {
        MaterialFavoriteButton mFav = (MaterialFavoriteButton) v;
        boolean t = mFav.isFavorite();
        mFav.setFavoriteAnimated(!t);
        if (mDbMachine != null) {
            Machine m = mDbMachine.getMachine((long) mFav.getTag());
            m.setFavorite(!t);
            mDbMachine.updateMachine(m);
        }
    });
}