package com.joe.print.mvp.print;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gingersoft.gsa.cloud.base.utils.time.TimeUtils;
import com.joe.print.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 測試頁打印
 */
public class PrintTest extends PrinterRoot {


    @Override
    public Map<String, List<Bitmap>> getPrintBitmap(Context mContext) {
        Map<String, List<Bitmap>> bitmapMaps = new HashMap<>();
        List<Bitmap> bitmaps = new ArrayList<>();
        bitmaps.add(getTestPrintBitmap(mContext));
        bitmapMaps.put("", bitmaps);
        return bitmapMaps;
    }

    @Override
    public int getPrintCount(Context context) {
        return 1;
    }


    /**
     * 獲取測試打印bitmap
     *
     * @param context
     * @return
     */
    private Bitmap getTestPrintBitmap(Context context) {
        View view = LinearLayout.inflate(context, R.layout.print_test, null);
        TextView tvTime = view.findViewById(R.id.tv_test_print_now_time);
        tvTime.setText("時間：" + TimeUtils.getCurrentDate(TimeUtils.DEFAULT_DATE_FORMAT));
        return viewToBitmap(context, view);
    }

}
