导航菜单

页面标题

页面副标题

EFFICIENT POS v1.5.7 - SalesReportViewActivity.java 源代码

正在查看: EFFICIENT POS v1.5.7 应用的 SalesReportViewActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package dev.gtr.pos.activity;

import android.app.DownloadManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.print.PrintAttributes;
import android.print.PrintManager;
import android.util.Log;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.FileProvider;
import com.github.barteksc.pdfviewer.PDFView;
import com.github.barteksc.pdfviewer.scroll.ScrollHandle;
import com.github.barteksc.pdfviewer.util.FitPolicy;
import dev.gtr.pos.R;
import dev.gtr.pos.adapter.PdfPrintAdapter;
import dev.gtr.pos.api.ApiClient;
import dev.gtr.pos.config.Constant;
import es.dmoral.toasty.Toasty;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.util.Calendar;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class SalesReportViewActivity extends AppCompatActivity implements View.OnClickListener {
    String FromAttendance;
    String FromStock;
    String accId;
    String accType;
    byte[] bytes;
    int categoryId;
    String cookie;
    String custId;
    String custType;
    int empId;
    File file;
    String fromDate;
    ImageView imageViewBack;
    ImageView imageViewPrint;
    ImageView imageViewSave;
    ImageView imageViewShare;
    boolean isLoaded = false;
    String isLoc;
    String notificationID;
    String onlineSale;
    String orderId;
    PDFView pdfView;
    ProgressBar progressBar;
    String purchaseId;
    String saleId;
    SharedPreferences sharedPreferences;
    String supplyId;
    String toDate;
    String transId;
    String transType;
    Uri uri;
    int warehouseId;
    WebView webView;
    WebViewClient wvc;

    protected void onCreate(Bundle bundle) {
        String str;
        String str2;
        super.onCreate(bundle);
        setContentView(R.layout.activity_sales_report_view);
        this.webView = (WebView) findViewById(R.id.webView);
        this.pdfView = findViewById(R.id.pdfView);
        this.imageViewBack = (ImageView) findViewById(R.id.imageView_back);
        this.imageViewShare = (ImageView) findViewById(R.id.imageview_share);
        this.imageViewPrint = (ImageView) findViewById(R.id.imageview_print);
        this.imageViewSave = (ImageView) findViewById(R.id.imageview_download);
        this.progressBar = (ProgressBar) findViewById(R.id.progressBar_report);
        this.imageViewSave.setOnClickListener(this);
        this.imageViewPrint.setOnClickListener(this);
        this.imageViewShare.setOnClickListener(this);
        this.imageViewBack.setOnClickListener(this);
        SharedPreferences sharedPreferences = getSharedPreferences("LOGIN", 0);
        this.sharedPreferences = sharedPreferences;
        Constant.Token = sharedPreferences.getString("TOKEN", null);
        Constant.ComId = this.sharedPreferences.getString("COMID", null);
        Constant.uId = this.sharedPreferences.getString("UID", null);
        Intent intent = getIntent();
        this.saleId = intent.getStringExtra(Constant.SalesId);
        this.accId = intent.getStringExtra(Constant.ACC_ID);
        this.transId = intent.getStringExtra(Constant.TRANS_ID);
        this.onlineSale = intent.getStringExtra(Constant.OnlineSale);
        this.purchaseId = intent.getStringExtra(Constant.PurchaseId);
        this.notificationID = intent.getStringExtra(Constant.NOTIFICATION_ID);
        this.cookie = intent.getStringExtra(Constant.COOKIE);
        this.FromStock = intent.getStringExtra(Constant.FromStock);
        this.FromAttendance = intent.getStringExtra(Constant.FromAttendance);
        this.custId = intent.getStringExtra(Constant.CUST_ID);
        this.supplyId = intent.getStringExtra(Constant.SUPP_ID);
        this.empId = intent.getIntExtra(Constant.EMPID, 0);
        this.custType = intent.getStringExtra(Constant.CUST_TYPE);
        this.accType = intent.getStringExtra(Constant.ACC_TYPE);
        this.transType = intent.getStringExtra(Constant.TRANS_TYPE);
        this.categoryId = intent.getIntExtra(Constant.CATEGORY_ID, 0);
        this.warehouseId = intent.getIntExtra(Constant.WAREHOUSE_ID, 0);
        this.warehouseId = intent.getIntExtra(Constant.WAREHOUSE_ID, 0);
        this.isLoc = intent.getStringExtra(Constant.ISLOC);
        this.orderId = intent.getStringExtra(Constant.ORDER_ID);
        this.fromDate = intent.getStringExtra(Constant.FROM);
        this.toDate = intent.getStringExtra(Constant.TO);
        String str3 = this.saleId;
        if (str3 != null) {
            getSalesReport(str3);
        }
        if (this.onlineSale != null) {
            getOnlineReport();
        }
        String str4 = this.purchaseId;
        if (str4 != null) {
            getPurchaseReport(str4);
        }
        String str5 = this.orderId;
        if (str5 != null) {
            getOrderReport(str5);
        }
        if (this.FromAttendance != null && this.isLoc != null) {
            getAttendanceReport(this.cookie, String.valueOf(this.empId), this.fromDate, this.toDate, this.isLoc);
        }
        String str6 = this.accId;
        if (str6 != null) {
            getAccReport(str6, this.accType, this.fromDate, this.toDate, this.cookie);
        }
        String str7 = this.transId;
        if (str7 != null) {
            getTransactionReport(str7, this.transType, this.fromDate, this.toDate, this.cookie);
        }
        if (this.FromStock != null) {
            if (this.categoryId != 0 && this.warehouseId != 0) {
                getStockReport(this.cookie, "" + this.warehouseId, "" + this.categoryId, this.fromDate, this.toDate);
            } else {
                getStockReport(this.cookie, null, null, this.fromDate, this.toDate);
            }
        }
        if (this.saleId != null && (str2 = this.notificationID) != null) {
            getSeenNotification(str2, getApplicationContext());
            return;
        }
        String str8 = this.custId;
        if (str8 != null) {
            getCustomerReport(str8, this.custType, this.fromDate, this.toDate, this.cookie);
            return;
        }
        String str9 = this.supplyId;
        if (str9 == null || (str = this.custType) == null) {
            return;
        }
        getCustomerReport(str9, str, this.fromDate, this.toDate, this.cookie);
    }

    private void getPurchaseReport(String str) {
        Log.e("PDF", "in");
        if (str != null) {
            ApiClient.getInstance(this).getApi().getPurchaseReport(this.cookie, "Bearer " + Constant.Token, str, "PDF", "0").enqueue(new Callback<ResponseBody>() {
                @Override
                public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                    if (response.isSuccessful()) {
                        SalesReportViewActivity.this.progressBar.setVisibility(8);
                        SalesReportViewActivity.this.isLoaded = true;
                        try {
                            SalesReportViewActivity.this.bytes = response.body().bytes();
                            SalesReportViewActivity salesReportViewActivity = SalesReportViewActivity.this;
                            salesReportViewActivity.pdfLoader(salesReportViewActivity.bytes);
                            return;
                        } catch (IOException e) {
                            Log.e("PDF", "" + e.toString());
                            e.printStackTrace();
                            return;
                        }
                    }
                    SalesReportViewActivity.this.progressBar.setVisibility(8);
                    SalesReportViewActivity.this.isLoaded = false;
                    Log.e("PDF", "" + response.code());
                }

                @Override
                public void onFailure(Call<ResponseBody> call, Throwable th) {
                    Log.e("PDF", "" + th.toString());
                    SalesReportViewActivity.this.progressBar.setVisibility(8);
                    SalesReportViewActivity.this.isLoaded = false;
                    if (th instanceof SocketTimeoutException) {
                        SalesReportViewActivity.this.isLoaded = false;
                        Toast.makeText((Context) SalesReportViewActivity.this, (CharSequence) "Please Connect through Internet", 0).show();
                    }
                }
            });
            return;
        }
        this.progressBar.setVisibility(8);
        Toasty.error(getApplicationContext(), "SaleId Required", 0).show();
    }

    private void getSalesReport(String str) {
        Log.e("PDF", "in");
        if (str != null) {
            ApiClient.getInstance(this).getApi().getReport(this.cookie, "Bearer " + Constant.Token, str, "PDF", "0").enqueue(new Callback<ResponseBody>() {
                @Override
                public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                    if (response.isSuccessful()) {
                        SalesReportViewActivity.this.progressBar.setVisibility(8);
                        SalesReportViewActivity.this.isLoaded = true;
                        try {
                            SalesReportViewActivity.this.bytes = response.body().bytes();
                            SalesReportViewActivity salesReportViewActivity = SalesReportViewActivity.this;
                            salesReportViewActivity.pdfLoader(salesReportViewActivity.bytes);
                            return;
                        } catch (IOException e) {
                            Log.e("PDF", "" + e.toString());
                            e.printStackTrace();
                            return;
                        }
                    }
                    SalesReportViewActivity.this.progressBar.setVisibility(8);
                    SalesReportViewActivity.this.isLoaded = false;
                    Log.e("PDF", "" + response.code());
                }

                @Override
                public void onFailure(Call<ResponseBody> call, Throwable th) {
                    Log.e("PDF", "" + th.toString());
                    SalesReportViewActivity.this.progressBar.setVisibility(8);
                    SalesReportViewActivity.this.isLoaded = false;
                    if (th instanceof SocketTimeoutException) {
                        SalesReportViewActivity.this.isLoaded = false;
                        Toast.makeText((Context) SalesReportViewActivity.this, (CharSequence) "Please Connect through Internet", 0).show();
                    }
                }
            });
            return;
        }
        this.progressBar.setVisibility(8);
        Toasty.error(getApplicationContext(), "SaleId Required", 0).show();
    }

    private void getCustomerReport(String str, String str2, String str3, String str4, String str5) {
        ApiClient.getInstance(getApplicationContext()).getApi().getCustomerReport(str5, "Bearer " + Constant.Token, str, str2, str3, str4).enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                if (response.isSuccessful()) {
                    SalesReportViewActivity.this.progressBar.setVisibility(8);
                    SalesReportViewActivity.this.isLoaded = true;
                    try {
                        SalesReportViewActivity.this.bytes = response.body().bytes();
                        SalesReportViewActivity salesReportViewActivity = SalesReportViewActivity.this;
                        salesReportViewActivity.pdfLoader(salesReportViewActivity.bytes);
                        return;
                    } catch (IOException e) {
                        Log.e("PDF", "" + e.toString());
                        e.printStackTrace();
                        return;
                    }
                }
                SalesReportViewActivity.this.progressBar.setVisibility(8);
                SalesReportViewActivity.this.isLoaded = false;
                Log.e("PDF", "" + response.code());
            }

            @Override
            public void onFailure(Call<ResponseBody> call, Throwable th) {
                Log.e("PDF", "" + th.toString());
                SalesReportViewActivity.this.progressBar.setVisibility(8);
                SalesReportViewActivity.this.isLoaded = false;
                if (th instanceof SocketTimeoutException) {
                    SalesReportViewActivity.this.isLoaded = false;
                    Toast.makeText((Context) SalesReportViewActivity.this, (CharSequence) "Please Connect through Internet", 0).show();
                }
            }
        });
    }

    private void getAccReport(String str, String str2, String str3, String str4, String str5) {
        ApiClient.getInstance(getApplicationContext()).getApi().getAccReport(str5, "Bearer " + Constant.Token, str, str2, str3, str4).enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                if (response.isSuccessful()) {
                    SalesReportViewActivity.this.progressBar.setVisibility(8);
                    SalesReportViewActivity.this.isLoaded = true;
                    try {
                        SalesReportViewActivity.this.bytes = response.body().bytes();
                        SalesReportViewActivity salesReportViewActivity = SalesReportViewActivity.this;
                        salesReportViewActivity.pdfLoader(salesReportViewActivity.bytes);
                        return;
                    } catch (IOException e) {
                        Log.e("PDF", "" + e.toString());
                        e.printStackTrace();
                        return;
                    }
                }
                SalesReportViewActivity.this.progressBar.setVisibility(8);
                SalesReportViewActivity.this.isLoaded = false;
                Log.e("PDF", "" + response.code());
            }

            @Override
            public void onFailure(Call<ResponseBody> call, Throwable th) {
                Log.e("PDF", "" + th.toString());
                SalesReportViewActivity.this.progressBar.setVisibility(8);
                SalesReportViewActivity.this.isLoaded = false;
                if (th instanceof SocketTimeoutException) {
                    SalesReportViewActivity.this.isLoaded = false;
                    Toast.makeText((Context) SalesReportViewActivity.this, (CharSequence) "Please Connect through Internet", 0).show();
                }
            }
        });
    }

    private void getTransactionReport(String str, String str2, String str3, String str4, String str5) {
        ApiClient.getInstance(getApplicationContext()).getApi().getTransactionReport(str5, "Bearer " + Constant.Token, str, str2, str3, str4).enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                if (response.isSuccessful()) {
                    SalesReportViewActivity.this.progressBar.setVisibility(8);
                    SalesReportViewActivity.this.isLoaded = true;
                    try {
                        SalesReportViewActivity.this.bytes = response.body().bytes();
                        SalesReportViewActivity salesReportViewActivity = SalesReportViewActivity.this;
                        salesReportViewActivity.pdfLoader(salesReportViewActivity.bytes);
                        return;
                    } catch (IOException e) {
                        Log.e("PDF", "" + e.toString());
                        e.printStackTrace();
                        return;
                    }
                }
                SalesReportViewActivity.this.progressBar.setVisibility(8);
                SalesReportViewActivity.this.isLoaded = false;
                Log.e("PDF", "" + response.code());
            }

            @Override
            public void onFailure(Call<ResponseBody> call, Throwable th) {
                Log.e("PDF", "" + th.toString());
                SalesReportViewActivity.this.progressBar.setVisibility(8);
                SalesReportViewActivity.this.isLoaded = false;
                if (th instanceof SocketTimeoutException) {
                    SalesReportViewActivity.this.isLoaded = false;
                    Toast.makeText((Context) SalesReportViewActivity.this, (CharSequence) "Please Connect through Internet", 0).show();
                }
            }
        });
    }

    private void getOnlineReport() {
        Log.e("DDF", "" + this.onlineSale);
        ApiClient.getInstance(getApplicationContext()).getApi().getOnlineOrderReport("Bearer " + Constant.Token, this.cookie, this.onlineSale, "PDF", "1").enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                if (response.isSuccessful()) {
                    SalesReportViewActivity.this.progressBar.setVisibility(8);
                    SalesReportViewActivity.this.isLoaded = true;
                    try {
                        SalesReportViewActivity.this.bytes = response.body().bytes();
                        SalesReportViewActivity salesReportViewActivity = SalesReportViewActivity.this;
                        salesReportViewActivity.pdfLoader(salesReportViewActivity.bytes);
                        return;
                    } catch (IOException e) {
                        Log.e("PDF", "" + e.toString());
                        e.printStackTrace();
                        return;
                    }
                }
                SalesReportViewActivity.this.progressBar.setVisibility(8);
                SalesReportViewActivity.this.isLoaded = false;
                Log.e("PDF", "" + response.code());
            }

            @Override
            public void onFailure(Call<ResponseBody> call, Throwable th) {
                SalesReportViewActivity.this.progressBar.setVisibility(8);
                SalesReportViewActivity.this.isLoaded = false;
                if (th instanceof SocketTimeoutException) {
                    SalesReportViewActivity.this.isLoaded = false;
                    Toast.makeText((Context) SalesReportViewActivity.this, (CharSequence) "Please Connect through Internet", 0).show();
                }
            }
        });
    }

    public void pdfLoader(byte[] bArr) {
        try {
            this.pdfView.fromBytes(bArr).pages(new int[]{0, 2, 1, 3, 3, 3}).enableSwipe(true).swipeHorizontal(true).enableDoubletap(true).defaultPage(0).enableAnnotationRendering(false).password((String) null).scrollHandle((ScrollHandle) null).enableAntialiasing(true).spacing(0).autoSpacing(false).pageFitPolicy(FitPolicy.HEIGHT).pageFitPolicy(FitPolicy.WIDTH).fitEachPage(true).pageSnap(true).pageFling(false).nightMode(false).load();
        } catch (Exception e) {
            Log.e("pdfError", e.toString());
        }
    }

    @Override
    public void onClick(View view) {
        int checkSelfPermission;
        if (view == this.imageViewBack) {
            finish();
        }
        if (view == this.imageViewShare) {
            if (this.isLoaded) {
                savingThePDF(true, false);
            } else {
                Toasty.warning(getApplicationContext(), "Please Wait a minute!", 0).show();
            }
        }
        if (view == this.imageViewSave) {
            if (this.isLoaded) {
                checkSelfPermission = checkSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE");
                if (checkSelfPermission == 0) {
                    savingThePDF(false, false);
                } else {
                    Toasty.warning(getApplicationContext(), "Please Give Permission", 0).show();
                    ActivityCompat.requestPermissions(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 1);
                }
            } else {
                Toasty.warning(getApplicationContext(), "Please Wait a minute!", 0).show();
            }
        }
        if (view == this.imageViewPrint) {
            if (this.isLoaded) {
                savingThePDF(null, true);
            } else {
                Toasty.warning(getApplicationContext(), "Please Wait a minute!", 0).show();
            }
        }
    }

    public void savingThePDF(Boolean bool, boolean z) {
        int checkSelfPermission;
        if (!this.isLoaded || this.bytes.length <= 0) {
            Toasty.warning(getApplicationContext(), "Please Wait a minute!", 0).show();
            return;
        }
        Calendar calendar = Calendar.getInstance();
        int i = calendar.get(5);
        int i2 = calendar.get(2);
        String str = "_" + i + "_" + (i2 + 1) + "_" + calendar.get(1) + "_" + calendar.get(10) + "_" + calendar.get(12) + "_" + calendar.get(13);
        if (this.saleId != null) {
            this.file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "Efficient_POS_SaleId_" + this.saleId + str + ".pdf");
        } else if (this.FromStock != null) {
            this.file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "Efficient_POS_Stock_" + str + ".pdf");
        } else if (this.custId != null) {
            this.file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "Efficient_POS_CustomerId_" + this.custId + str + ".pdf");
        } else if (this.orderId != null) {
            this.file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "E-commerce_OrderId_" + this.orderId + str + ".pdf");
        } else if (this.purchaseId != null) {
            this.file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "E-commerce_PurchaseId_" + this.purchaseId + str + ".pdf");
        } else if (this.FromAttendance != null) {
            this.file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "Attendance Report_" + this.empId + str + ".pdf");
        } else if (this.onlineSale != null) {
            this.file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "Online Order_" + this.onlineSale + str + ".pdf");
        } else if (this.accId != null) {
            this.file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "Efficient_POS_AccId_" + this.accId + str + ".pdf");
        } else if (this.transId != null) {
            this.file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "Efficient_POS_TransId_" + this.transId + str + ".pdf");
        }
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(this.file);
            fileOutputStream.write(this.bytes);
            fileOutputStream.close();
            if (bool != null && !bool.booleanValue()) {
                Toasty.success(getApplicationContext(), "File Downloaded Successfully", 0).show();
                ((DownloadManager) getSystemService("download")).addCompletedDownload(this.file.getName(), this.file.getName(), true, "application/pdf", this.file.getAbsolutePath(), this.file.length(), true);
            }
            if (bool != null && bool.booleanValue()) {
                Intent intent = new Intent("android.intent.action.SEND");
                intent.setType("Application/pdf");
                Uri uriForFile = FileProvider.getUriForFile(this, "dev.gtr.pos.provider", this.file);
                this.uri = uriForFile;
                intent.putExtra("android.intent.extra.STREAM", uriForFile);
                if (this.saleId != null) {
                    intent.putExtra("android.intent.extra.SUBJECT", "Share EFFICIENT POS SALE ID" + this.saleId);
                    intent.putExtra("android.intent.extra.TEXT", "Share EFFICIENT POS SALE ID" + this.saleId);
                    startActivityForResult(Intent.createChooser(intent, "Share EFFICIENT POS SALE ID" + this.saleId), 5);
                } else if (this.FromStock != null) {
                    intent.putExtra("android.intent.extra.SUBJECT", "Share EFFICIENT POS Stock List");
                    intent.putExtra("android.intent.extra.TEXT", "Share EFFICIENT POS Stock List");
                    startActivityForResult(Intent.createChooser(intent, "Share EFFICIENT POS Stock List"), 5);
                } else if (this.custId != null) {
                    intent.putExtra("android.intent.extra.SUBJECT", "Share EFFICIENT POS Customer ID" + this.custId);
                    intent.putExtra("android.intent.extra.TEXT", "Share EFFICIENT POS Customer ID" + this.custId);
                    startActivityForResult(Intent.createChooser(intent, "Share EFFICIENT POS Customer ID" + this.custId), 5);
                } else if (this.orderId != null) {
                    intent.putExtra("android.intent.extra.SUBJECT", "Share E-commerce Order ID" + this.orderId);
                    intent.putExtra("android.intent.extra.TEXT", "Share E-commerce Order ID" + this.orderId);
                    startActivityForResult(Intent.createChooser(intent, "Share E-commerce Order ID" + this.orderId), 5);
                } else if (this.purchaseId != null) {
                    intent.putExtra("android.intent.extra.SUBJECT", "Share Purchase ID" + this.orderId);
                    intent.putExtra("android.intent.extra.TEXT", "Share Purchase ID" + this.orderId);
                    startActivityForResult(Intent.createChooser(intent, "Share Purchase ID" + this.orderId), 5);
                } else if (this.FromAttendance != null) {
                    intent.putExtra("android.intent.extra.SUBJECT", "Share Attendance" + this.empId);
                    intent.putExtra("android.intent.extra.TEXT", "Share Attendance" + this.empId);
                    startActivityForResult(Intent.createChooser(intent, "Share Attendance" + this.empId), 5);
                } else if (this.onlineSale != null) {
                    intent.putExtra("android.intent.extra.SUBJECT", "Share online order" + this.onlineSale);
                    intent.putExtra("android.intent.extra.TEXT", "Share online order" + this.onlineSale);
                    startActivityForResult(Intent.createChooser(intent, "Share online order" + this.onlineSale), 5);
                } else if (this.accId != null) {
                    intent.putExtra("android.intent.extra.SUBJECT", "Share EFFICIENT POS Acc ID" + this.accId);
                    intent.putExtra("android.intent.extra.TEXT", "Share EFFICIENT POS Acc ID" + this.accId);
                    startActivityForResult(Intent.createChooser(intent, "Share EFFICIENT POS Acc ID" + this.accId), 5);
                } else if (this.transId != null) {
                    intent.putExtra("android.intent.extra.SUBJECT", "Share EFFICIENT POS Trans ID" + this.transId);
                    intent.putExtra("android.intent.extra.TEXT", "Share EFFICIENT POS Trans ID" + this.transId);
                    startActivityForResult(Intent.createChooser(intent, "Share EFFICIENT POS Trans ID" + this.transId), 5);
                }
            }
            if (z) {
                if (!this.isLoaded) {
                    Toasty.warning(getApplicationContext(), "Please Wait a minute!", 0).show();
                    return;
                }
                checkSelfPermission = checkSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE");
                if (checkSelfPermission == 0) {
                    print();
                } else {
                    Toasty.warning(getApplicationContext(), "Please Give Permission", 0).show();
                    ActivityCompat.requestPermissions(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, 1);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private void print() {
        this.uri = FileProvider.getUriForFile(this, "dev.gtr.pos.provider", this.file);
        try {
            ((PrintManager) getSystemService("print")).print("Pdf", new PdfPrintAdapter(getApplicationContext(), this.file, this.bytes, this.uri), new PrintAttributes.Builder().build());
        } catch (Exception e) {
            Log.e("Print", e.toString());
        }
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i == 5) {
            getContentResolver().delete(this.uri, null, null);
        }
    }

    private void getSeenNotification(String str, Context context) {
        ApiClient.getInstance(context).getApi().notifySeenNotification("Bearer " + Constant.Token, str, Constant.uId).enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                if (response.isSuccessful()) {
                    Log.e("Notifry", "Success" + response.code());
                } else {
                    Log.e("Notifry", "" + response.code());
                }
            }

            @Override
            public void onFailure(Call<ResponseBody> call, Throwable th) {
                Log.e("Notifry", "" + th.toString());
            }
        });
    }

    private void getOrderReport(String str) {
        ApiClient.getInstance(getApplicationContext()).getApi().getOrderReport(str, this.cookie, "PDF", "0").enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                if (response.isSuccessful()) {
                    SalesReportViewActivity.this.progressBar.setVisibility(8);
                    SalesReportViewActivity.this.isLoaded = true;
                    try {
                        SalesReportViewActivity.this.bytes = response.body().bytes();
                        SalesReportViewActivity salesReportViewActivity = SalesReportViewActivity.this;
                        salesReportViewActivity.pdfLoader(salesReportViewActivity.bytes);
                        SalesReportViewActivity.this.savingThePDF(false, false);
                        return;
                    } catch (IOException e) {
                        Log.e("stock", "" + e.toString());
                        e.printStackTrace();
                        return;
                    }
                }
                SalesReportViewActivity.this.progressBar.setVisibility(8);
                SalesReportViewActivity.this.isLoaded = false;
                Log.e("stock", "" + response.code());
            }

            @Override
            public void onFailure(Call<ResponseBody> call, Throwable th) {
                SalesReportViewActivity.this.progressBar.setVisibility(8);
            }
        });
    }

    private void getAttendanceReport(String str, String str2, String str3, String str4, String str5) {
        ApiClient.getInstance(getApplicationContext()).getApi().getEmployeeAttendanceReport(str, "Bearer " + Constant.Token, str2, str3, str4, str5).enqueue(new Callback<ResponseBody>() {
            @Override
            public void onFailure(Call<ResponseBody> call, Throwable th) {
            }

            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                if (response.isSuccessful()) {
                    SalesReportViewActivity.this.progressBar.setVisibility(8);
                    SalesReportViewActivity.this.isLoaded = true;
                    try {
                        SalesReportViewActivity.this.bytes = response.body().bytes();
                        SalesReportViewActivity salesReportViewActivity = SalesReportViewActivity.this;
                        salesReportViewActivity.pdfLoader(salesReportViewActivity.bytes);
                        return;
                    } catch (IOException e) {
                        Log.e("stock", "" + e.toString());
                        e.printStackTrace();
                        return;
                    }
                }
                SalesReportViewActivity.this.progressBar.setVisibility(8);
                SalesReportViewActivity.this.isLoaded = false;
                Log.e("stock", "" + response.code());
            }
        });
    }

    private void getStockReport(String str, String str2, String str3, String str4, String str5) {
        ApiClient.getInstance(getApplicationContext()).getApi().getStockReport(str, "Bearer " + Constant.Token, str3, str2, str4, str5, "PDF", "0").enqueue(new Callback<ResponseBody>() {
            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                if (response.isSuccessful()) {
                    SalesReportViewActivity.this.progressBar.setVisibility(8);
                    SalesReportViewActivity.this.isLoaded = true;
                    try {
                        SalesReportViewActivity.this.bytes = response.body().bytes();
                        SalesReportViewActivity salesReportViewActivity = SalesReportViewActivity.this;
                        salesReportViewActivity.pdfLoader(salesReportViewActivity.bytes);
                        return;
                    } catch (IOException e) {
                        Log.e("stock", "" + e.toString());
                        e.printStackTrace();
                        return;
                    }
                }
                SalesReportViewActivity.this.progressBar.setVisibility(8);
                SalesReportViewActivity.this.isLoaded = false;
                Log.e("stock", "" + response.code());
            }

            @Override
            public void onFailure(Call<ResponseBody> call, Throwable th) {
                SalesReportViewActivity.this.progressBar.setVisibility(8);
                Log.e("stock", "" + th.toString());
            }
        });
    }
}